PKGBUILD 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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=1
  5. pkgver=25.6.0
  6. _chromiumver=
  7. # shellcheck disable=SC2034
  8. pkgrel=1
  9. _major_ver=${pkgver%%.*}
  10. if [[ ${_use_suffix} != 0 ]]; then
  11. pkgname="electron${_major_ver}-xdg"
  12. else
  13. pkgname=electron-xdg
  14. fi
  15. # shellcheck disable=SC2034
  16. pkgdesc='Build cross platform desktop apps with web technologies - without creating a useless ~/.pki directory'
  17. # shellcheck disable=SC2034
  18. arch=('x86_64')
  19. # shellcheck disable=SC2034
  20. url='https://electronjs.org/'
  21. # shellcheck disable=SC2034
  22. license=('MIT' 'custom')
  23. # shellcheck disable=SC2034
  24. depends=('c-ares' 'gtk3' 'libevent' 'nss' 'libffi')
  25. # shellcheck disable=SC2034
  26. makedepends=('clang' 'git' 'gn' 'gperf' 'harfbuzz-icu' 'http-parser'
  27. 'qt5-base' 'java-runtime-headless' 'libnotify' 'lld' 'llvm'
  28. 'ninja' 'npm' 'pciutils' 'pipewire' 'python' 'python-httplib2'
  29. 'python-requests' 'python-pyparsing' 'python-six' 'wget' 'yarn')
  30. # shellcheck disable=SC2034
  31. optdepends=('kde-cli-tools: file deletion support (kioclient5)'
  32. 'pipewire: WebRTC desktop sharing under Wayland'
  33. 'qt5-base: enable Qt5 with --enable-features=AllowQt'
  34. 'trash-cli: file deletion support (trash-put)'
  35. 'xdg-utils: open URLs with desktop’s default (xdg-email, xdg-open)')
  36. if [[ ${_use_suffix} == 0 ]]; then
  37. # shellcheck disable=SC2034
  38. conflicts=("electron${_major_ver}")
  39. # shellcheck disable=SC2034
  40. provides=("electron${_major_ver}")
  41. replaces=("electron${_major_ver}")
  42. fi
  43. # shellcheck disable=SC2034
  44. options=('!lto') # Electron adds its own flags for ThinLTO
  45. # shellcheck disable=SC2034
  46. source=("git+https://github.com/electron/electron.git#tag=v$pkgver"
  47. 'git+https://chromium.googlesource.com/chromium/tools/depot_tools.git#branch=main'
  48. "chromium-mirror::git+https://github.com/chromium/chromium.git#tag=$_chromiumver"
  49. "electron-launcher.sh"
  50. "electron.desktop"
  51. 'default_app-icon.patch'
  52. 'jinja-python-3.10.patch'
  53. 'use-system-libraries-in-node.patch'
  54. 'std-vector-non-const.patch'
  55. 'add-some-typename-s-that-are-required-in-C-17.patch'
  56. 'REVERT-disable-autoupgrading-debug-info.patch'
  57. 'random-fixes-for-gcc13.patch'
  58. )
  59. # shellcheck disable=SC2034
  60. sha256sums=('SKIP'
  61. 'SKIP'
  62. 'SKIP'
  63. 'b0ac3422a6ab04859b40d4d7c0fd5f703c893c9ec145c9894c468fbc0a4d457c'
  64. '4484200d90b76830b69eea3a471c103999a3ce86bb2c29e6c14c945bf4102bae'
  65. 'dd2d248831dd4944d385ebf008426e66efe61d6fdf66f8932c963a12167947b4'
  66. '55dbe71dbc1f3ab60bf1fa79f7aea7ef1fe76436b1d7df48728a1f8227d2134e'
  67. 'ff588a8a4fd2f79eb8a4f11cf1aa151298ffb895be566c57cc355d47f161f53f'
  68. '893bc04c7fceba2f0a7195ed48551d55f066bbc530ec934c89c55768e6f3949c'
  69. '621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11'
  70. '1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69'
  71. 'ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0')
  72. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  73. # Keys are the names in the above script; values are the dependencies in Arch
  74. declare -gA _system_libs=(
  75. [brotli]=brotli
  76. [dav1d]=dav1d
  77. [ffmpeg]=ffmpeg
  78. [flac]=flac
  79. [fontconfig]=fontconfig
  80. [freetype]=freetype2
  81. [harfbuzz-ng]=harfbuzz
  82. [icu]=icu
  83. [jsoncpp]=jsoncpp
  84. # [libaom]=aom
  85. #[libavif]=libavif # https://github.com/AOMediaCodec/libavif/commit/4d2776a3
  86. [libdrm]=
  87. [libjpeg]=libjpeg
  88. [libpng]=libpng
  89. #[libvpx]=libvpx
  90. [libwebp]=libwebp
  91. [libxml]=libxml2
  92. [libxslt]=libxslt
  93. [opus]=opus
  94. #[re2]=re2
  95. [snappy]=snappy
  96. [woff2]=woff2
  97. [zlib]=minizip
  98. )
  99. _unwanted_bundled_libs=(
  100. $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
  101. )
  102. depends+=(${_system_libs[@]})
  103. # add custom patches by extending the bash array, as this is both cleaner
  104. # and easier to maintain
  105. source=(${source[@]}
  106. xdg-basedir.patch)
  107. sha256sums=(${sha256sums[@]}
  108. 'cd844867b5b2197ad097662fee32579a7091dfba1d46cb438c4c7e696690440a')
  109. prepare() {
  110. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron-launcher.sh
  111. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron.desktop
  112. if [[ ${_use_suffix} != 0 ]]; then
  113. sed -i "s|@ELECTRON_NAME@|Electron ${_major_ver}|" electron.desktop
  114. else
  115. sed -i "s|@ELECTRON_NAME@|Electron|" electron.desktop
  116. fi
  117. sed --in-place "/'chromium_version':/{n;s/'[0-9.]\+',/'${_chromiumver}',/}" "${srcdir}/electron/DEPS"
  118. cat >.gclient <<EOF
  119. solutions = [
  120. {
  121. "name": "src/electron",
  122. "url": "file://${srcdir}/electron@${_commit}",
  123. "deps_file": "DEPS",
  124. "managed": False,
  125. "custom_deps": {
  126. "src": None,
  127. },
  128. "custom_vars": {},
  129. },
  130. ]
  131. EOF
  132. export PATH+=":$PWD/depot_tools" DEPOT_TOOLS_UPDATE=0
  133. export VPYTHON_BYPASS='manually managed python not supported by chrome operations'
  134. echo "Linking chromium from sources..."
  135. ln -s chromium-mirror src
  136. depot_tools/gclient.py sync -D \
  137. --nohooks \
  138. --with_branch_heads \
  139. --with_tags
  140. (
  141. cd src/electron || exit
  142. patch -Np1 -i ../../std-vector-non-const.patch
  143. )
  144. echo "Running hooks..."
  145. # python "${srcdir}/depot_tools/gclient.py" runhooks
  146. src/build/landmines.py
  147. src/build/util/lastchange.py -o src/build/util/LASTCHANGE
  148. src/build/util/lastchange.py -m GPU_LISTS_VERSION \
  149. --revision-id-only --header src/gpu/config/gpu_lists_version.h
  150. src/build/util/lastchange.py -m SKIA_COMMIT_HASH \
  151. -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h
  152. src/build/util/lastchange.py \
  153. -s src/third_party/dawn --revision src/gpu/webgpu/DAWN_VERSION
  154. src/tools/update_pgo_profiles.py --target=linux update \
  155. --gs-url-base=chromium-optimization-profiles/pgo_profiles
  156. depot_tools/download_from_google_storage.py --no_resume --extract --no_auth \
  157. --bucket chromium-nodejs -s src/third_party/node/node_modules.tar.gz.sha1
  158. # Create sysmlink to system clang-format
  159. ln -s /usr/bin/clang-format src/buildtools/linux64
  160. # Create sysmlink to system Node.js
  161. mkdir -p src/third_party/node/linux/node-linux-x64/bin
  162. ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin
  163. src/electron/script/apply_all_patches.py \
  164. src/electron/patches/config.json
  165. cd src/electron || exit
  166. yarn install --frozen-lockfile
  167. cd ..
  168. echo "Applying local patches..."
  169. # move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki
  170. patch -p1 -i ../xdg-basedir.patch
  171. # Upstream fixes
  172. patch -Np1 -i "${srcdir}/add-some-typename-s-that-are-required-in-C-17.patch"
  173. # Revert addition of compiler flag that needs newer clang
  174. patch -Rp1 -i "${srcdir}/REVERT-disable-autoupgrading-debug-info.patch"
  175. # GCC13 patches for chromium (https://github.com/archlinux/svntogit-packages/commit/470e5cbc7b58b4955664cdae386161d22c17d980)
  176. patch -Np1 -i "${srcdir}/random-fixes-for-gcc13.patch"
  177. # Electron specific fixes
  178. patch -Np1 -i "${srcdir}/jinja-python-3.10.patch" -d "third_party/electron_node/tools/inspector_protocol/jinja2"
  179. patch -Np1 -i "${srcdir}/use-system-libraries-in-node.patch"
  180. patch -Np1 -i "${srcdir}/default_app-icon.patch" # Icon from .desktop file
  181. # Allow building against system libraries in official builds
  182. echo "Patching Chromium for using system libraries..."
  183. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  184. tools/generate_shim_headers/generate_shim_headers.py
  185. # Remove bundled libraries for which we will use the system copies; this
  186. # *should* do what the remove_bundled_libraries.py script does, with the
  187. # added benefit of not having to list all the remaining libraries
  188. local _lib
  189. for _lib in ${_unwanted_bundled_libs[@]}; 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 "${!_system_libs[@]}"
  203. }
  204. build() {
  205. export CC=clang
  206. export CXX=clang++
  207. export AR=ar
  208. export NM=nm
  209. # https://github.com/webpack/webpack/issues/14532
  210. export NODE_OPTIONS=--openssl-legacy-provider
  211. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  212. CFLAGS+=' -Wno-builtin-macro-redefined'
  213. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  214. CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
  215. # Do not warn about unknown warning options
  216. CFLAGS+=' -Wno-unknown-warning-option'
  217. CXXFLAGS+=' -Wno-unknown-warning-option'
  218. # Let Chromium set its own symbol level
  219. CFLAGS=${CFLAGS/-g }
  220. CXXFLAGS=${CXXFLAGS/-g }
  221. # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
  222. CFLAGS=${CFLAGS/-fexceptions}
  223. CFLAGS=${CFLAGS/-fcf-protection}
  224. CXXFLAGS=${CXXFLAGS/-fexceptions}
  225. CXXFLAGS=${CXXFLAGS/-fcf-protection}
  226. # This appears to cause random segfaults when combined with ThinLTO
  227. # https://bugs.archlinux.org/task/73518
  228. CFLAGS=${CFLAGS/-fstack-clash-protection}
  229. CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
  230. # https://crbug.com/957519#c122
  231. CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
  232. # Do not warn about unknown warning options
  233. CFLAGS+=' -Wno-unknown-warning-option'
  234. CXXFLAGS+=' -Wno-unknown-warning-option'
  235. cd src || exit
  236. export CHROMIUM_BUILDTOOLS_PATH="${PWD}/buildtools"
  237. GN_EXTRA_ARGS='
  238. custom_toolchain = "//build/toolchain/linux/unbundle:default"
  239. host_toolchain = "//build/toolchain/linux/unbundle:default"
  240. clang_base_path = "/usr"
  241. clang_use_chrome_plugins = false
  242. symbol_level = 0 # sufficient for backtraces on x86(_64)
  243. chrome_pgo_phase = 0
  244. treat_warnings_as_errors = false
  245. disable_fieldtrial_testing_config = true
  246. blink_enable_generated_code_formatting = false
  247. ffmpeg_branding = "Chrome"
  248. rtc_use_pipewire = true
  249. link_pulseaudio = true
  250. use_custom_libcxx = false
  251. use_gnome_keyring = false
  252. use_sysroot = false
  253. use_system_libffi = true
  254. icu_use_data_file = false
  255. is_component_ffmpeg = false
  256. '
  257. gn gen out/Release \
  258. --args="import(\"//electron/build/args/release.gn\") ${GN_EXTRA_ARGS}"
  259. ninja -C out/Release electron
  260. ninja -C out/Release electron_dist_zip
  261. # ninja -C out/Release third_party/electron_node:headers
  262. }
  263. package() {
  264. install -dm755 "${pkgdir:?}/usr/lib/${pkgname%-*}"
  265. bsdtar -xf src/out/Release/dist.zip -C "${pkgdir}/usr/lib/${pkgname%-*}"
  266. chmod u+s "${pkgdir}/usr/lib/${pkgname%-*}/chrome-sandbox"
  267. install -dm755 "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  268. for l in "${pkgdir}/usr/lib/${pkgname%-*}"/{LICENSE,LICENSES.chromium.html}; do
  269. ln -s \
  270. "$(realpath --relative-to="${pkgdir}/usr/share/licenses/${pkgname%-*}" "${l}")" \
  271. "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  272. done
  273. install -Dm755 "${srcdir}/electron-launcher.sh" \
  274. "${pkgdir}/usr/bin/${pkgname%-*}"
  275. if [[ "${_use_suffix}" == 0 ]]; then
  276. ln -s "/usr/bin/${pkgname%-*}" "${pkgdir}/usr/bin/${pkgname%-*}${_major_ver}"
  277. ln -s "/usr/lib/${pkgname%-*}" "${pkgdir}/usr/lib/${pkgname%-*}${_major_ver}"
  278. fi
  279. # Install .desktop and icon file (see default_app-icon.patch)
  280. install -Dm644 electron.desktop \
  281. "${pkgdir}/usr/share/applications/${pkgname%-*}.desktop"
  282. install -Dm644 src/electron/default_app/icon.png \
  283. "${pkgdir}/usr/share/pixmaps/${pkgname%-*}.png" # hicolor has no 1024x1024
  284. }