PKGBUILD 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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=22.3.2
  6. _commit=5d3eea593437830ea16e4901f0410feadb0718d4
  7. _chromiumver=108.0.5359.215
  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. 'qt5-base: enable Qt5 with --enable-features=AllowQt'
  38. 'trash-cli: file deletion support (trash-put)'
  39. 'xdg-utils: open URLs with desktop’s default (xdg-email, xdg-open)')
  40. if [[ ${_use_suffix} == 0 ]]; then
  41. # shellcheck disable=SC2034
  42. conflicts=("electron${_major_ver}" "electron")
  43. # shellcheck disable=SC2034
  44. provides=("electron${_major_ver}" "electron")
  45. else
  46. provides=("electron")
  47. conflicts=("electron")
  48. fi
  49. # shellcheck disable=SC2034
  50. options=('!lto') # Electron adds its own flags for ThinLTO
  51. # shellcheck disable=SC2034
  52. source=('git+https://github.com/electron/electron.git'
  53. 'git+https://chromium.googlesource.com/chromium/tools/depot_tools.git#branch=main'
  54. "https://github.com/stha09/chromium-patches/releases/download/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}.tar.xz"
  55. "electron-launcher.sh"
  56. "electron.desktop"
  57. 'default_app-icon.patch'
  58. 'jinja-python-3.10.patch'
  59. 'use-system-libraries-in-node.patch'
  60. 'std-vector-non-const.patch'
  61. 're-fix-TFLite-build-error-on-linux-with-system-zlib.patch'
  62. 'chromium-icu72.patch'
  63. 'v8-enhance-Date-parser-to-take-Unicode-SPACE.patch'
  64. 'REVERT-roll-src-third_party-ffmpeg-m102.patch'
  65. 'REVERT-roll-src-third_party-ffmpeg-m106.patch'
  66. 'angle-wayland-include-protocol.patch'
  67. )
  68. # shellcheck disable=SC2034
  69. sha256sums=('SKIP'
  70. 'SKIP'
  71. '40ef8af65e78901bb8554eddbbb5ebc55c0b8e7927f6ca51b2a353d1c7c50652'
  72. '77817939c9833f8dda74a8c75620c15747170551ffa6f14f7c5b4071599e8831'
  73. '4484200d90b76830b69eea3a471c103999a3ce86bb2c29e6c14c945bf4102bae'
  74. 'dd2d248831dd4944d385ebf008426e66efe61d6fdf66f8932c963a12167947b4'
  75. '55dbe71dbc1f3ab60bf1fa79f7aea7ef1fe76436b1d7df48728a1f8227d2134e'
  76. 'ff588a8a4fd2f79eb8a4f11cf1aa151298ffb895be566c57cc355d47f161f53f'
  77. '893bc04c7fceba2f0a7195ed48551d55f066bbc530ec934c89c55768e6f3949c'
  78. '9015b9d6d5b4c1e7248d6477a4b4b6bd6a3ebdc57225d2d8efcd79fc61790716'
  79. 'dabb5ab204b63be73d3c5c8b7c1fa74053105a285852ba3bbc4fb77646608572'
  80. 'b83406a881d66627757d9cbc05e345cbb2bd395a48b6d4c970e5e1cb3f6ed454'
  81. '30df59a9e2d95dcb720357ec4a83d9be51e59cc5551365da4c0073e68ccdec44'
  82. '4c12d31d020799d31355faa7d1fe2a5a807f7458e7f0c374adf55edb37032152'
  83. 'cd0d9d2a1d6a522d47c3c0891dabe4ad72eabbebc0fe5642b9e22efa3d5ee572')
  84. # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py
  85. # Keys are the names in the above script; values are the dependencies in Arch
  86. declare -gA _system_libs=(
  87. [brotli]=brotli
  88. [dav1d]=dav1d
  89. [ffmpeg]=ffmpeg
  90. [flac]=flac
  91. [fontconfig]=fontconfig
  92. [freetype]=freetype2
  93. [harfbuzz-ng]=harfbuzz
  94. [icu]=icu
  95. [jsoncpp]=jsoncpp
  96. [libaom]=aom
  97. [libavif]=libavif
  98. [libdrm]=
  99. [libjpeg]=libjpeg
  100. [libpng]=libpng
  101. #[libvpx]=libvpx
  102. [libwebp]=libwebp
  103. [libxml]=libxml2
  104. [libxslt]=libxslt
  105. [opus]=opus
  106. [re2]=re2
  107. [snappy]=snappy
  108. [woff2]=woff2
  109. [zlib]=minizip
  110. )
  111. _unwanted_bundled_libs=(
  112. $(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')
  113. )
  114. depends+=(${_system_libs[@]})
  115. # add custom patches by extending the bash array, as this is both cleaner
  116. # and easier to maintain
  117. source=(${source[@]}
  118. xdg-basedir.patch)
  119. sha256sums=(${sha256sums[@]}
  120. 'cd844867b5b2197ad097662fee32579a7091dfba1d46cb438c4c7e696690440a')
  121. prepare() {
  122. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron-launcher.sh
  123. sed -i "s|@ELECTRON@|${pkgname%-*}|" electron.desktop
  124. if [[ ${_use_suffix} != 0 ]]; then
  125. sed -i "s|@ELECTRON_NAME@|Electron ${_major_ver}|" electron.desktop
  126. else
  127. sed -i "s|@ELECTRON_NAME@|Electron|" electron.desktop
  128. fi
  129. export PATH="${PATH}:${srcdir:?}/depot_tools"
  130. echo "Fetching chromium..."
  131. git clone --branch=${_chromiumver} --depth=1 \
  132. https://chromium.googlesource.com/chromium/src.git
  133. cat >.gclient <<EOF
  134. solutions = [
  135. {
  136. "name": "src/electron",
  137. "url": "file://${srcdir}/electron@${_commit}",
  138. "deps_file": "DEPS",
  139. "managed": False,
  140. "custom_deps": {
  141. "src": None,
  142. },
  143. "custom_vars": {},
  144. },
  145. ]
  146. EOF
  147. export PATH+=":$PWD/depot_tools" DEPOT_TOOLS_UPDATE=0
  148. export VPYTHON_BYPASS='manually managed python not supported by chrome operations'
  149. echo "Fetching chromium..."
  150. git clone -b ${_chromiumver} --depth=2 https://chromium.googlesource.com/chromium/src
  151. depot_tools/gclient.py sync -D \
  152. --nohooks \
  153. --with_branch_heads \
  154. --with_tags
  155. (
  156. cd src/electron || exit
  157. patch -Np1 -i ../../std-vector-non-const.patch
  158. )
  159. echo "Running hooks..."
  160. # python "${srcdir}/depot_tools/gclient.py" runhooks
  161. src/build/landmines.py
  162. src/build/util/lastchange.py -o src/build/util/LASTCHANGE
  163. src/build/util/lastchange.py -m GPU_LISTS_VERSION \
  164. --revision-id-only --header src/gpu/config/gpu_lists_version.h
  165. src/build/util/lastchange.py -m SKIA_COMMIT_HASH \
  166. -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h
  167. src/build/util/lastchange.py \
  168. -s src/third_party/dawn --revision src/gpu/webgpu/DAWN_VERSION
  169. src/tools/update_pgo_profiles.py --target=linux update \
  170. --gs-url-base=chromium-optimization-profiles/pgo_profiles
  171. depot_tools/download_from_google_storage.py --no_resume --extract --no_auth \
  172. --bucket chromium-nodejs -s src/third_party/node/node_modules.tar.gz.sha1
  173. # Create sysmlink to system clang-format
  174. ln -s /usr/bin/clang-format src/buildtools/linux64
  175. # Create sysmlink to system Node.js
  176. mkdir -p src/third_party/node/linux/node-linux-x64/bin
  177. ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin
  178. src/electron/script/apply_all_patches.py \
  179. src/electron/patches/config.json
  180. cd src/electron || exit
  181. yarn install --frozen-lockfile
  182. cd ..
  183. echo "Applying local patches..."
  184. # move ~/.pki directory to ${XDG_DATA_HOME:-$HOME/.local}/share/pki
  185. patch -p1 -i ../xdg-basedir.patch
  186. # Upstream fixes
  187. patch -Np1 -i ../re-fix-TFLite-build-error-on-linux-with-system-zlib.patch
  188. patch -Np1 -i ../chromium-icu72.patch
  189. patch -Np1 -d v8 <../v8-enhance-Date-parser-to-take-Unicode-SPACE.patch
  190. # Revert ffmpeg roll requiring new channel layout API support
  191. # https://crbug.com/1325301
  192. patch -Rp1 -i ../REVERT-roll-src-third_party-ffmpeg-m102.patch
  193. # Revert switch from AVFrame::pkt_duration to AVFrame::duration
  194. patch -Rp1 -i ../REVERT-roll-src-third_party-ffmpeg-m106.patch
  195. # https://crbug.com/angleproject/7582
  196. patch -Np0 -i ../angle-wayland-include-protocol.patch
  197. # Fixes for building with libstdc++ instead of libc++
  198. patch -Np1 -i ../patches/chromium-103-VirtualCursor-std-layout.patch
  199. # Electron specific fixes
  200. patch -d third_party/electron_node/tools/inspector_protocol/jinja2 \
  201. -Np1 -i ../../../../../../jinja-python-3.10.patch
  202. patch -Np1 -i ../use-system-libraries-in-node.patch
  203. patch -Np1 -i ../default_app-icon.patch # Icon from .desktop file
  204. # Allow building against system libraries in official builds
  205. echo "Patching Chromium for using system libraries..."
  206. sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
  207. tools/generate_shim_headers/generate_shim_headers.py
  208. # Remove bundled libraries for which we will use the system copies; this
  209. # *should* do what the remove_bundled_libraries.py script does, with the
  210. # added benefit of not having to list all the remaining libraries
  211. local _lib
  212. for _lib in ${_unwanted_bundled_libs[@]}; do
  213. third_party_dir="third_party/$_lib"
  214. if [ ! -d "${third_party_dir}" ]; then
  215. third_party_dir="base/${third_party_dir}"
  216. fi
  217. find "${third_party_dir}" -type f \
  218. \! -path "${third_party_dir}/chromium/*" \
  219. \! -path "${third_party_dir}/google/*" \
  220. \! -path 'third_party/harfbuzz-ng/utils/hb_scoped.h' \
  221. \! -regex '.*\.\(gn\|gni\|isolate\)' \
  222. -delete
  223. done
  224. ./build/linux/unbundle/replace_gn_files.py \
  225. --system-libraries "${!_system_libs[@]}"
  226. }
  227. build() {
  228. export CC=clang
  229. export CXX=clang++
  230. export AR=ar
  231. export NM=nm
  232. # https://github.com/webpack/webpack/issues/14532
  233. export NODE_OPTIONS=--openssl-legacy-provider
  234. # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn)
  235. CFLAGS+=' -Wno-builtin-macro-redefined'
  236. CXXFLAGS+=' -Wno-builtin-macro-redefined'
  237. CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__='
  238. # Do not warn about unknown warning options
  239. CFLAGS+=' -Wno-unknown-warning-option'
  240. CXXFLAGS+=' -Wno-unknown-warning-option'
  241. # Let Chromium set its own symbol level
  242. CFLAGS=${CFLAGS/-g }
  243. CXXFLAGS=${CXXFLAGS/-g }
  244. # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123
  245. CFLAGS=${CFLAGS/-fexceptions}
  246. CFLAGS=${CFLAGS/-fcf-protection}
  247. CXXFLAGS=${CXXFLAGS/-fexceptions}
  248. CXXFLAGS=${CXXFLAGS/-fcf-protection}
  249. # This appears to cause random segfaults when combined with ThinLTO
  250. # https://bugs.archlinux.org/task/73518
  251. CFLAGS=${CFLAGS/-fstack-clash-protection}
  252. CXXFLAGS=${CXXFLAGS/-fstack-clash-protection}
  253. # https://crbug.com/957519#c122
  254. CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS}
  255. # Do not warn about unknown warning options
  256. CFLAGS+=' -Wno-unknown-warning-option'
  257. CXXFLAGS+=' -Wno-unknown-warning-option'
  258. cd src || exit
  259. export CHROMIUM_BUILDTOOLS_PATH="${PWD}/buildtools"
  260. GN_EXTRA_ARGS='
  261. custom_toolchain = "//build/toolchain/linux/unbundle:default"
  262. host_toolchain = "//build/toolchain/linux/unbundle:default"
  263. clang_base_path = "/usr"
  264. clang_use_chrome_plugins = false
  265. symbol_level = 0 # sufficient for backtraces on x86(_64)
  266. chrome_pgo_phase = 2
  267. treat_warnings_as_errors = false
  268. disable_fieldtrial_testing_config = true
  269. blink_enable_generated_code_formatting = false
  270. ffmpeg_branding = "Chrome"
  271. rtc_use_pipewire = true
  272. link_pulseaudio = true
  273. use_custom_libcxx = false
  274. use_gnome_keyring = false
  275. use_sysroot = false
  276. use_system_libwayland = true
  277. use_system_wayland_scanner = true
  278. icu_use_data_file = false
  279. is_component_ffmpeg = false
  280. '
  281. gn gen out/Release \
  282. --args="import(\"//electron/build/args/release.gn\") ${GN_EXTRA_ARGS}"
  283. ninja -C out/Release electron
  284. ninja -C out/Release electron_dist_zip
  285. # ninja -C out/Release third_party/electron_node:headers
  286. }
  287. package() {
  288. install -dm755 "${pkgdir:?}/usr/lib/${pkgname%-*}"
  289. bsdtar -xf src/out/Release/dist.zip -C "${pkgdir}/usr/lib/${pkgname%-*}"
  290. chmod u+s "${pkgdir}/usr/lib/${pkgname%-*}/chrome-sandbox"
  291. install -dm755 "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  292. for l in "${pkgdir}/usr/lib/${pkgname%-*}"/{LICENSE,LICENSES.chromium.html}; do
  293. ln -s \
  294. "$(realpath --relative-to="${pkgdir}/usr/share/licenses/${pkgname%-*}" "${l}")" \
  295. "${pkgdir}/usr/share/licenses/${pkgname%-*}"
  296. done
  297. install -Dm755 "${srcdir}/electron-launcher.sh" \
  298. "${pkgdir}/usr/bin/${pkgname%-*}"
  299. if [[ "${_use_suffix}" == 0 ]]; then
  300. ln -s "/usr/bin/${pkgname%-*}" "${pkgdir}/usr/bin/${pkgname%-*}${_major_ver}"
  301. ln -s "/usr/lib/${pkgname%-*}" "${pkgdir}/usr/lib/${pkgname%-*}${_major_ver}"
  302. fi
  303. # Install .desktop and icon file (see default_app-icon.patch)
  304. install -Dm644 electron.desktop \
  305. "${pkgdir}/usr/share/applications/${pkgname%-*}.desktop"
  306. install -Dm644 src/electron/default_app/icon.png \
  307. "${pkgdir}/usr/share/pixmaps/${pkgname%-*}.png" # hicolor has no 1024x1024
  308. }