PKGBUILD 11 KB

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