PKGBUILD 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. # Maintainer: Noah Vogt (noahvogt) <noah@noahvogt.com>
  2. # Maintainer: Bruno Pagani <archange@archlinux.org>
  3. # Remember to handle https://bugs.archlinux.org/task/74324 on major upgrades
  4. _use_suffix=0
  5. pkgver=20.3.8
  6. _commit=9fa958cb5fa02fbca258f8b6894d5371bf6e4415
  7. _chromiumver=104.0.5112.81
  8. _gcc_patchset=2
  9. # shellcheck disable=SC2034
  10. pkgrel=1
  11. _major_ver=${pkgver%%.*}
  12. if [[ ${_use_suffix} != 0 ]]; then
  13. pkgname="electron${_major_ver}-xdg"
  14. else
  15. pkgname=electron-xdg
  16. fi
  17. # shellcheck disable=SC2034
  18. pkgdesc='Build cross platform desktop apps with web technologies - without creating a useless ~/.pki directory'
  19. # shellcheck disable=SC2034
  20. arch=('x86_64')
  21. # shellcheck disable=SC2034
  22. url='https://electronjs.org/'
  23. # shellcheck disable=SC2034
  24. license=('MIT' 'custom')
  25. # shellcheck disable=SC2034
  26. depends=('c-ares' 'ffmpeg' 'gtk3' 'libevent' 'libxslt' 'minizip' 'nss' 're2'
  27. 'snappy')
  28. # shellcheck disable=SC2034
  29. makedepends=('clang' 'git' 'gn' 'gperf' 'harfbuzz-icu' 'http-parser'
  30. 'java-runtime-headless' 'jsoncpp' 'libnotify' 'lld' 'llvm' 'ninja'
  31. 'npm' 'pciutils' 'pipewire' 'python' 'python-httplib2'
  32. 'python-pyparsing' 'python-six' 'wget' 'yarn')
  33. # shellcheck disable=SC2034
  34. optdepends=('kde-cli-tools: file deletion support (kioclient5)'
  35. 'libappindicator-gtk3: StatusNotifierItem support'
  36. 'pipewire: WebRTC desktop sharing under Wayland'
  37. 'trash-cli: file deletion support (trash-put)'
  38. 'xdg-utils: open URLs with desktop’s default (xdg-email, xdg-open)')
  39. if [[ ${_use_suffix} == 0 ]]; then
  40. # shellcheck disable=SC2034
  41. conflicts=("electron${_major_ver}" "electron")
  42. # shellcheck disable=SC2034
  43. provides=("electron${_major_ver}" "electron")
  44. else
  45. provides=("electron")
  46. conflicts=("electron")
  47. fi
  48. # shellcheck disable=SC2034
  49. options=('!lto') # Electron adds its own flags for ThinLTO
  50. # shellcheck disable=SC2034
  51. source=('git+https://github.com/electron/electron.git'
  52. 'git+https://chromium.googlesource.com/chromium/tools/depot_tools.git#branch=main'
  53. "https://github.com/stha09/chromium-patches/releases/download/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}.tar.xz"
  54. "electron-launcher.sh"
  55. "electron.desktop"
  56. 'default_app-icon.patch'
  57. 'jinja-python-3.10.patch'
  58. 'use-system-libraries-in-node.patch'
  59. 'std-vector-non-const.patch'
  60. 'x11-ozone-fix-X11-screensaver-suspension.patch'
  61. 'roll-src-third_party-ffmpeg.patch'
  62. 'chromium-tflite-system-zlib.patch'
  63. 'remove-no-opaque-pointers-flag.patch'
  64. )
  65. # shellcheck disable=SC2034
  66. sha256sums=('SKIP'
  67. 'SKIP'
  68. 'ce702099849465927cf47f7bc3a4a27045d0e35e16b17481ebf35e14506bafa7'
  69. '77817939c9833f8dda74a8c75620c15747170551ffa6f14f7c5b4071599e8831'
  70. '4484200d90b76830b69eea3a471c103999a3ce86bb2c29e6c14c945bf4102bae'
  71. 'dd2d248831dd4944d385ebf008426e66efe61d6fdf66f8932c963a12167947b4'
  72. '55dbe71dbc1f3ab60bf1fa79f7aea7ef1fe76436b1d7df48728a1f8227d2134e'
  73. 'c70652a8b24c237bcfd27469de32797a2cb46d9f0d63d897bb6418314a25644c'
  74. '76b969e1534e8c355b8b524a686cbf3b24136eaa6bd40b0c09fdd9866049f159'
  75. '9956a843bc8a765c130080616ccd3ebc46ea95c3a2324c4b403bc293a8705eb2'
  76. '30df59a9e2d95dcb720357ec4a83d9be51e59cc5551365da4c0073e68ccdec44'
  77. '588c166bf748793758a7df438cfa665b32e09ca8fbd6380be28bc5984a33523c'
  78. 'ab46b2c26a4dfe86486fd7e31bfc7211c515994a61a8c0cbd742f9c9e3c91873')
  79. _system_libs=('ffmpeg'
  80. 'flac'
  81. 'fontconfig'
  82. 'freetype'
  83. 'harfbuzz-ng'
  84. 'icu'
  85. 'libdrm'
  86. 'libevent'
  87. 'libjpeg'
  88. 'libpng'
  89. # 'libvpx'
  90. 'libwebp'
  91. 'libxml'
  92. 'libxslt'
  93. # 'openh264'
  94. 'opus'
  95. 're2'
  96. 'snappy'
  97. 'zlib'
  98. )
  99. # add custom patches by extending the bash array, as this is both cleaner
  100. # and easier to maintain
  101. source=(${source[@]}
  102. xdg-basedir.patch)
  103. sha256sums=(${sha256sums[@]}
  104. 'cd844867b5b2197ad097662fee32579a7091dfba1d46cb438c4c7e696690440a')
  105. prepare() {
  106. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron-launcher.sh
  107. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron.desktop
  108. if [[ ${_use_suffix} != 0 ]]; then
  109. sed -i "s|@ELECTRON_NAME@|Electron ${_major_ver}|" electron.desktop
  110. else
  111. sed -i "s|@ELECTRON_NAME@|Electron|" electron.desktop
  112. fi
  113. export PATH="${PATH}:${srcdir:?}/depot_tools"
  114. echo "Fetching chromium..."
  115. git clone --branch=${_chromiumver} --depth=1 \
  116. https://chromium.googlesource.com/chromium/src.git
  117. echo "solutions = [
  118. {
  119. \"name\": \"src/electron\",
  120. \"url\": \"file://${srcdir}/electron@${_commit}\",
  121. \"deps_file\": \"DEPS\",
  122. \"managed\": False,
  123. \"custom_deps\": {
  124. \"src\": None,
  125. },
  126. \"custom_vars\": {},
  127. },
  128. ]" > .gclient
  129. python "${srcdir}/depot_tools/gclient.py" sync \
  130. --with_branch_heads \
  131. --with_tags \
  132. --nohooks
  133. (
  134. cd src/electron || exit
  135. patch -Np1 -i ../../std-vector-non-const.patch
  136. )
  137. echo "Running hooks..."
  138. # python "${srcdir}/depot_tools/gclient.py" runhooks
  139. src/build/landmines.py
  140. src/build/util/lastchange.py -o src/build/util/LASTCHANGE
  141. src/build/util/lastchange.py -m GPU_LISTS_VERSION \
  142. --revision-id-only --header src/gpu/config/gpu_lists_version.h
  143. src/build/util/lastchange.py -m SKIA_COMMIT_HASH \
  144. -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h
  145. # Create sysmlink to system clang-format
  146. ln -s /usr/bin/clang-format src/buildtools/linux64
  147. # Create sysmlink to system Node.js
  148. mkdir -p src/third_party/node/linux/node-linux-x64/bin
  149. ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin
  150. src/third_party/depot_tools/download_from_google_storage.py \
  151. --no_resume --extract --no_auth --bucket chromium-nodejs \
  152. -s src/third_party/node/node_modules.tar.gz.sha1
  153. python src/tools/download_optimization_profile.py \
  154. --newest_state=src/chrome/android/profiles/newest.txt \
  155. --local_state=src/chrome/android/profiles/local.txt \
  156. --output_name=src/chrome/android/profiles/afdo.prof \
  157. --gs_url_base=chromeos-prebuilt/afdo-job/llvm
  158. #vpython src/tools/update_pgo_profiles.py \
  159. # --target=linux \
  160. # update \
  161. # --gs-url-base=chromium-optimization-profiles/pgo_profiles
  162. src/electron/script/apply_all_patches.py \
  163. src/electron/patches/config.json
  164. cd src/electron || exit
  165. yarn install --frozen-lockfile
  166. cd ..
  167. echo "Applying local patches..."
  168. # move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki
  169. patch -p1 -i ../xdg-basedir.patch
  170. # Remove '-Xclang -no-opaque-pointers' flag not supported by our clang
  171. patch -Np1 -i ../remove-no-opaque-pointers-flag.patch
  172. # Fix build with unbundled zlip (patch from Gentoo)
  173. patch -Np1 -i ../chromium-tflite-system-zlib.patch
  174. # Upstream fixes
  175. patch -Np1 -i ../x11-ozone-fix-X11-screensaver-suspension.patch
  176. # Revert ffmpeg roll requiring new channel layout API support
  177. # https://crbug.com/1325301
  178. patch -Rp1 -i ../roll-src-third_party-ffmpeg.patch
  179. # Fixes for building with libstdc++ instead of libc++
  180. patch -Np1 -i ../patches/chromium-103-VirtualCursor-std-layout.patch
  181. # Electron specific fixes
  182. patch -d third_party/electron_node/tools/inspector_protocol/jinja2 \
  183. -Np1 -i ../../../../../../jinja-python-3.10.patch
  184. patch -Np1 -i ../use-system-libraries-in-node.patch
  185. patch -Np1 -i ../default_app-icon.patch # Icon from .desktop file
  186. echo "Patching Chromium for using system libraries..."
  187. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  188. tools/generate_shim_headers/generate_shim_headers.py
  189. for lib in $(printf "%s\n" "${_system_libs[@]}" | sed 's/^libjpeg$/&_turbo/'); do
  190. third_party_dir="third_party/${lib}"
  191. if [ ! -d "${third_party_dir}" ]; then
  192. third_party_dir="base/${third_party_dir}"
  193. fi
  194. find "${third_party_dir}" -type f \
  195. \! -path "${third_party_dir}/chromium/*" \
  196. \! -path "${third_party_dir}/google/*" \
  197. \! -path 'third_party/harfbuzz-ng/utils/hb_scoped.h' \
  198. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  199. -delete
  200. done
  201. build/linux/unbundle/replace_gn_files.py \
  202. --system-libraries \
  203. "${_system_libs[@]}"
  204. }
  205. build() {
  206. export CC=clang
  207. export CXX=clang++
  208. export AR=ar
  209. export NM=nm
  210. # https://github.com/webpack/webpack/issues/14532
  211. export NODE_OPTIONS=--openssl-legacy-provider
  212. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  213. CFLAGS+=' -Wno-builtin-macro-redefined'
  214. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  215. CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
  216. # Do not warn about unknown warning options
  217. CFLAGS+=' -Wno-unknown-warning-option'
  218. CXXFLAGS+=' -Wno-unknown-warning-option'
  219. # Let Chromium set its own symbol level
  220. CFLAGS=${CFLAGS/-g }
  221. CXXFLAGS=${CXXFLAGS/-g }
  222. # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
  223. CFLAGS=${CFLAGS/-fexceptions}
  224. CFLAGS=${CFLAGS/-fcf-protection}
  225. CXXFLAGS=${CXXFLAGS/-fexceptions}
  226. CXXFLAGS=${CXXFLAGS/-fcf-protection}
  227. # This appears to cause random segfaults when combined with ThinLTO
  228. # https://bugs.archlinux.org/task/73518
  229. CFLAGS=${CFLAGS/-fstack-clash-protection}
  230. CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
  231. # https://crbug.com/957519#c122
  232. CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
  233. # Do not warn about unknown warning options
  234. CFLAGS+=' -Wno-unknown-warning-option'
  235. CXXFLAGS+=' -Wno-unknown-warning-option'
  236. cd src || exit
  237. export CHROMIUM_BUILDTOOLS_PATH="${PWD}/buildtools"
  238. GN_EXTRA_ARGS='
  239. custom_toolchain = "//build/toolchain/linux/unbundle:default"
  240. host_toolchain = "//build/toolchain/linux/unbundle:default"
  241. clang_use_chrome_plugins = false
  242. symbol_level = 0
  243. chrome_pgo_phase = 0
  244. treat_warnings_as_errors = false
  245. rtc_use_pipewire = true
  246. link_pulseaudio = true
  247. use_gnome_keyring = false
  248. use_sysroot = false
  249. use_custom_libcxx = false
  250. icu_use_data_file = false
  251. is_component_ffmpeg = false
  252. '
  253. gn gen out/Release \
  254. --args="import(\"//electron/build/args/release.gn\") ${GN_EXTRA_ARGS}"
  255. ninja -C out/Release electron
  256. # Strip before zip to avoid
  257. # zipfile.LargeZipFile: Filesize would require ZIP64 extensions
  258. strip -s out/Release/electron
  259. ninja -C out/Release electron_dist_zip
  260. # ninja -C out/Release third_party/electron_node:headers
  261. }
  262. package() {
  263. install -dm755 "${pkgdir:?}/usr/lib/${pkgname%-*}"
  264. bsdtar -xf src/out/Release/dist.zip -C "${pkgdir}/usr/lib/${pkgname%-*}"
  265. chmod u+s "${pkgdir}/usr/lib/${pkgname%-*}/chrome-sandbox"
  266. install -dm755 "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  267. for l in "${pkgdir}/usr/lib/${pkgname%-*}"/{LICENSE,LICENSES.chromium.html}; do
  268. ln -s \
  269. "$(realpath --relative-to="${pkgdir}/usr/share/licenses/${pkgname%-*}" "${l}")" \
  270. "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  271. done
  272. install -Dm755 "${srcdir}/electron-launcher.sh" \
  273. "${pkgdir}/usr/bin/${pkgname%-*}"
  274. if [[ "${_use_suffix}" == 0 ]]; then
  275. ln -s "/usr/bin/${pkgname%-*}" "${pkgdir}/usr/bin/${pkgname%-*}${_major_ver}"
  276. ln -s "/usr/lib/${pkgname%-*}" "${pkgdir}/usr/lib/${pkgname%-*}${_major_ver}"
  277. fi
  278. # Install .desktop and icon file (see default_app-icon.patch)
  279. install -Dm644 electron.desktop \
  280. "${pkgdir}/usr/share/applications/${pkgname%-*}.desktop"
  281. install -Dm644 src/electron/default_app/icon.png \
  282. "${pkgdir}/usr/share/pixmaps/${pkgname%-*}.png" # hicolor has no 1024x1024
  283. }