# Maintainer: Nicola Squartini pkgname=electron12 pkgver=12.2.3 _commit=8492c10291d852071bb599fcf59d57eb2566afd8 _chromiumver=89.0.4389.128 _gcc_patchset=7 pkgrel=4 pkgdesc='Build cross platform desktop apps with web technologies' arch=('x86_64') url='https://electronjs.org/' license=('MIT' 'custom') depends=('c-ares' 'ffmpeg' 'gtk3' 'libevent' 'libxslt' 'minizip' 'nss' 're2' 'snappy') makedepends=('clang' 'git' 'gn-m87' 'gperf' 'harfbuzz-icu' 'http-parser' 'java-runtime-headless' 'jsoncpp' 'libnotify' 'lld' 'llvm' 'ninja' 'npm' 'pciutils' 'pipewire' 'python2' 'python' 'python-httplib2' 'python-pyparsing' 'python-six' 'wget' 'yarn') optdepends=('kde-cli-tools: file deletion support (kioclient5)' 'libappindicator-gtk3: StatusNotifierItem support' 'pipewire: WebRTC desktop sharing under Wayland' 'trash-cli: file deletion support (trash-put)' "xdg-utils: open URLs with desktop's default (xdg-email, xdg-open)") options=('!lto') # Electron adds its own flags for ThinLTO source=('git+https://github.com/electron/electron.git' 'git+https://chromium.googlesource.com/chromium/tools/depot_tools.git#branch=main' "https://github.com/stha09/chromium-patches/releases/download/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}/chromium-${_chromiumver%%.*}-patchset-${_gcc_patchset}.tar.xz" "electron-launcher.sh" "electron.desktop" 'default_app-icon.patch' 'use-system-libraries-in-node.patch' 'add-dependency-on-opus-in-webcodecs.patch' 'breakpad-fix-for-non-constant-SIGSTKSZ.patch' 'chromium-fix-libva-redef.patch' 'chromium-glibc-2.33.patch' 'chromium-harfbuzz-3.0.0.patch' 'sandbox-build-if-glibc-2.34-dynamic-stack-size-is-en.patch' 'skia-harfbuzz-3.0.0.patch' 'sql-make-VirtualCursor-standard-layout-type.patch' 'std-max-fix.patch' 'ffmpeg5.patch' ) sha256sums=('SKIP' 'SKIP' 'f8b1558f6c87b33423da854d42f0f69d47885a96d6bf6ce7f26373e93d47442f' '929e058a3cbcdea24f42716a43f6ab29727d99b0cddd807099b791662f1a100e' '0805ec335447914d8895afa13f07de0496a687f7f6a088c1fe10d72d08d2f42c' 'dd2d248831dd4944d385ebf008426e66efe61d6fdf66f8932c963a12167947b4' 'f16103daf05713dea632b5f01e45db20ff12d1770a6539b4e8d3957a0242dd54' 'b86b11de8db438c47f0a84c7956740f648d21035f4ee46bfbd50c3348d369121' 'b4d28867c1fabde6c50a2cfa3f784730446c4d86e5191e0f0000fbf7b0f91ecf' 'de9eb3612d44616a500c2eccdffac814eb90ad9a868cc1030d17fc6783d544e2' '2fccecdcd4509d4c36af873988ca9dbcba7fdb95122894a9fdf502c33a1d7a4b' '7ce947944a139e66774dfc7249bf7c3069f07f83a0f1b2c1a1b14287a7e15928' 'f910be9370c880de6e1d61cc30383c069e421d7acf406166e4fbfad324fc7d61' 'c9ed1dbadaf4be6097e25bc5577b91751799befc2d0376b143e1bd10def5754e' 'dd317f85e5abfdcfc89c6f23f4c8edbcdebdd5e083dcec770e5da49ee647d150' 'c315dd56b354cf5ad3458e1edf397cc7b492fefe82138135a881206a82b9d9dc' '4f32b815349357ef1f17b36059cee588c994472b9754a194fff41ec21a93826b' ) _system_libs=('ffmpeg' 'flac' 'fontconfig' 'freetype' 'harfbuzz-ng' 'icu' 'libdrm' 'libevent' 'libjpeg' 'libpng' # 'libvpx' 'libwebp' 'libxml' 'libxslt' # 'openh264' 'opus' 're2' 'snappy' 'zlib' ) prepare() { mkdir -p "${srcdir}"/python2-path ln -sf /usr/bin/python2 "${srcdir}/python2-path/python" export PATH="${srcdir}/python2-path:${PATH}:${srcdir}/depot_tools" echo "Fetching chromium..." git clone --branch=${_chromiumver} --depth=1 \ https://chromium.googlesource.com/chromium/src.git echo "solutions = [ { \"name\": \"src/electron\", \"url\": \"file://${srcdir}/electron@${_commit}\", \"deps_file\": \"DEPS\", \"managed\": False, \"custom_deps\": { \"src\": None, }, \"custom_vars\": {}, }, ]" > .gclient python3 "${srcdir}/depot_tools/gclient.py" sync \ --with_branch_heads \ --with_tags \ --nohooks sed -e "s/'am'/'apply'/" -i src/electron/script/lib/git.py echo "Running hooks..." # python2 "${srcdir}/depot_tools/gclient.py" runhooks python2 src/build/landmines.py python2 src/build/util/lastchange.py -o src/build/util/LASTCHANGE python2 src/build/util/lastchange.py -m GPU_LISTS_VERSION \ --revision-id-only --header src/gpu/config/gpu_lists_version.h python2 src/build/util/lastchange.py -m SKIA_COMMIT_HASH \ -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h # Create sysmlink to system clang-format ln -s /usr/bin/clang-format src/buildtools/linux64 # Create sysmlink to system Node.js mkdir -p src/third_party/node/linux/node-linux-x64/bin ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin #python2 src/third_party/depot_tools/download_from_google_storage.py \ # --no_resume --extract --no_auth --bucket chromium-nodejs \ # -s src/third_party/node/node_modules.tar.gz.sha1 cd src/third_party/node npm ci cd ../../.. vpython src/tools/download_optimization_profile.py \ --newest_state=src/chrome/android/profiles/newest.txt \ --local_state=src/chrome/android/profiles/local.txt \ --output_name=src/chrome/android/profiles/afdo.prof \ --gs_url_base=chromeos-prebuilt/afdo-job/llvm #vpython src/tools/update_pgo_profiles.py \ # --target=linux \ # update \ # --gs-url-base=chromium-optimization-profiles/pgo_profiles python2 src/electron/script/apply_all_patches.py \ src/electron/patches/config.json cd src/electron yarn install --frozen-lockfile cd .. echo "Applying local patches..." # Fixes for building with libstdc++ instead of libc++ patch -Np1 -d third_party/breakpad/breakpad < ../breakpad-fix-for-non-constant-SIGSTKSZ.patch patch -Np1 -i ../patches/chromium-89-quiche-dcheck.patch patch -Np1 -i ../patches/chromium-89-AXTreeSerializer-include.patch patch -Np1 -i ../ffmpeg5.patch patch -Np1 -i ../add-dependency-on-opus-in-webcodecs.patch patch -Np1 -i ../chromium-fix-libva-redef.patch patch -Np1 -i ../chromium-glibc-2.33.patch patch -Np1 -i ../chromium-harfbuzz-3.0.0.patch patch -Np1 -i ../sandbox-build-if-glibc-2.34-dynamic-stack-size-is-en.patch patch -Np1 -d third_party/skia <../skia-harfbuzz-3.0.0.patch patch -Np1 -i ../sql-make-VirtualCursor-standard-layout-type.patch patch -Np1 -i ../std-max-fix.patch patch -Np1 -i ../use-system-libraries-in-node.patch patch -Np1 -i ../default_app-icon.patch # Icon from .desktop file echo "Patching Chromium for using system libraries..." sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \ tools/generate_shim_headers/generate_shim_headers.py for lib in $(printf "%s\n" "${_system_libs[@]}" | sed 's/^libjpeg$/&_turbo/'); do third_party_dir="third_party/${lib}" if [ ! -d ${third_party_dir} ]; then third_party_dir="base/${third_party_dir}" fi find ${third_party_dir} -type f \ \! -path "${third_party_dir}/chromium/*" \ \! -path "${third_party_dir}/google/*" \ \! -path 'third_party/harfbuzz-ng/utils/hb_scoped.h' \ \! -regex '.*\.\(gn\|gni\|isolate\)' \ -delete done python2 build/linux/unbundle/replace_gn_files.py \ --system-libraries \ "${_system_libs[@]}" } build() { export CC=clang export CXX=clang++ export AR=ar export NM=nm CFLAGS="${CFLAGS/-fexceptions/}" CXXFLAGS="${CXXFLAGS/-fexceptions/}" # This appears to cause random segfaults when combined with ThinLTO # https://bugs.archlinux.org/task/73518 CFLAGS=${CFLAGS/-fstack-clash-protection} CXXFLAGS=${CXXFLAGS/-fstack-clash-protection} # Do not warn about unknown warning options CFLAGS+=' -Wno-unknown-warning-option' CXXFLAGS+=' -Wno-unknown-warning-option' cd src export CHROMIUM_BUILDTOOLS_PATH="${PWD}/buildtools" GN_EXTRA_ARGS=' blink_symbol_level = 0 chrome_pgo_phase = 0 clang_use_chrome_plugins = false custom_toolchain = "//build/toolchain/linux/unbundle:default" host_toolchain = "//build/toolchain/linux/unbundle:default" icu_use_data_file = false is_component_ffmpeg = false link_pulseaudio = true rtc_pipewire_version = "0.3" rtc_use_pipewire = true treat_warnings_as_errors = false use_custom_libcxx = false use_gnome_keyring = false use_sysroot = false ' gn-m87 gen out/Release \ --args="import(\"//electron/build/args/release.gn\") ${GN_EXTRA_ARGS}" ninja -C out/Release electron # Strip before zip to avoid # zipfile.LargeZipFile: Filesize would require ZIP64 extensions strip -s out/Release/electron ninja -C out/Release electron_dist_zip # ninja -C out/Release third_party/electron_node:headers } package() { install -dm755 "${pkgdir}/usr/lib/${pkgname}" bsdtar -xf src/out/Release/dist.zip -C "${pkgdir}/usr/lib/${pkgname}" chmod u+s "${pkgdir}/usr/lib/${pkgname}/chrome-sandbox" install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}" for l in "${pkgdir}/usr/lib/${pkgname}"/{LICENSE,LICENSES.chromium.html}; do ln -s \ "$(realpath --relative-to="${pkgdir}/usr/share/licenses/${pkgname}" "${l}")" \ "${pkgdir}/usr/share/licenses/${pkgname}" done install -Dm755 "${srcdir}/electron-launcher.sh" \ "${pkgdir}/usr/bin/${pkgname}" # Install .desktop and icon file (see default_app-icon.patch) install -Dm644 "electron.desktop" \ "${pkgdir}/usr/share/applications/${pkgname}.desktop" install -Dm644 src/electron/default_app/icon.png \ "${pkgdir}/usr/share/pixmaps/${pkgname}.png" # hicolor has no 1024x1024 }