# Maintainer: Devin Cofer # Maintainer: Niko Cantero <[at]niko:conduit.rs (Matrix)> # Contributor: Kyle De'Vir (QuartzDragon) # Contributor: Jonas Heinrich # Contributor: Maxwell Anselm # Contributor: Jan Alexander Steffens (heftig) # Contributor: Ionut Biru # Contributor: Jakub Schmidtke ## options # three-stage profile-guided optimization : ${_build_pgo:=true} # reuse existing PGO profile : ${_build_pgo_reuse:=true} # package debug symbols for upload : ${_build_symbols:=false} # make latest mozilla-central nightly revision : ${_build_nightly:=false} # target wayland only : ${_build_wayland:=true} # profile with xvfb-run, if possible : ${_build_pgo_xvfb:=false} # modify package name : ${_build_hg:=true} [[ "${_build_nightly::1}" == "t" ]] && _pkgtype+="-nightly" [[ "${_build_wayland::1}" == "t" ]] && _pkgtype+="-wayland" [[ "${_build_hg::1}" == "t" ]] && _pkgtype+="-hg" ## basic info pkgname="firefox${_pkgtype:-}" _pkgname=firefox-nightly pkgver=125.0a1+20240220.1+hef9cbc0f26f8 pkgrel=1 pkgdesc="Standalone web browser from mozilla.org" url="https://www.mozilla.org/firefox/channel/#nightly" license=('MPL-2.0') arch=(x86_64) depends=( dbus ffmpeg gtk3 libevent libjpeg libpulse libvpx libwebp mime-types pipewire ttf-font zlib ) makedepends=( cbindgen clang diffutils dump_syms imake inetutils jack lld llvm mercurial mesa nasm nodejs python rust unzip wasi-compiler-rt wasi-libc wasi-libc++ wasi-libc++abi yasm zip ) optdepends=( 'hunspell-dictionary: Spell checking' 'libnotify: Notification integration' 'networkmanager: Location detection via available WiFi networks' 'speech-dispatcher: Text-to-Speech' 'xdg-desktop-portal: Screensharing with Wayland' ) if [[ "${_build_pgo::1}" == "t" ]] ; then if [[ "${_build_pgo_xvfb::1}" == "t" ]] && [ "${_build_wayland::1}" != "t" ] ; then makedepends+=( xorg-server-xvfb ) else makedepends+=( weston xwayland-run # AUR ) fi fi if [[ "${_build_nightly::1}" == "t" ]] ; then pkgdesc+=" - nightly" else pkgdesc+=" - mozilla-unified hg, nightly branding" fi if [[ "${_build_wayland::1}" == "t" ]] ; then pkgdesc+=", targeting wayland" else pkgdesc+=", targeting wayland and x11" depends+=( libxss libxt ) fi if [[ "${_build_hg::1}" == "t" ]] ; then depends+=( nspr-hg nss-hg ) fi if [[ "$pkgname" != "firefox-nightly" ]] ; then provides=('firefox-nightly') conflicts=('firefox-nightly') fi options=( !debug !emptydirs !lto !makeflags !strip ) if [[ "${_build_nightly::1}" == "t" ]] ; then _get_version_info() { local _info_url="https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central" local _filename=$( curl -Ssf "$_info_url/" | grep linux-x86_64\.txt \ | sed -E 's&^.*href=".*/(firefox-.*\.linux-x86_64\.txt)".*$&\1&' \ | sort -rV | head -1 ) local _response=$(curl -Ssf "$_info_url/$_filename") _version=$(printf '%s' "$_filename" | sed -E 's&^firefox-([0-9]+\.[0-9].*)\.en-US\.linux-x86_64\.txt$&\1&') _date=$(printf '%s' "$_response" | head -1 | sed -E 's&^([0-9]{8})([0-9]*)$&\1.\2&') _revision=$(printf '%s' "$_response" | tail -1 | sed -E 's&^.*/rev/([a-f0-9]+)$&\1&') } _get_version_info _repo="https://hg.mozilla.org/mozilla-central" source+=("hg+$_repo#revision=$_revision") sha256sums+=('SKIP') pkgver() { printf '%s+%s+h%s' "${_version:?}" "${_date::11}" "${_revision::9}" } else _repo="https://hg.mozilla.org/mozilla-unified" source+=("hg+$_repo") sha256sums+=('SKIP') pkgver() { cd "${_repo##*/}" local version=$( # https://blog.mozilla.org/security/2023/05/11/updated-gpg-key-for-signing-firefox-releases/ 14F26682D0916CDD81E37B6D61B7B526D98F0353 ) # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys) # Note: These are for Arch Linux use ONLY. For your own distribution, please # get your own set of keys. Feel free to contact foutrelis@archlinux.org for # more information. _google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM # Mozilla API keys (see https://location.services.mozilla.com/api) # Note: These are for Arch Linux use ONLY. For your own distribution, please # get your own set of keys. Feel free to contact heftig@archlinux.org for # more information. _mozilla_api_key=e05d56db0a694edc8b5aaebda3f2db6a prepare() { mkdir mozbuild cd "${_repo##*/}" # Change install dir from 'firefox' to 'firefox-nightly' patch -Np1 -i ../firefox-install-dir.patch echo -n "$_google_api_key" >google-api-key echo -n "$_mozilla_api_key" >mozilla-api-key cat >../mozconfig <>../mozconfig "ac_add_options --enable-default-toolkit=cairo-gtk3-wayland-only" else echo >>../mozconfig "ac_add_options --enable-default-toolkit=cairo-gtk3-x11-wayland" fi if [[ "${_build_hg::1}" == "t" ]] ; then cat >>../mozconfig <.mozconfig ../mozconfig echo >>.mozconfig "ac_add_options --enable-profile-generate=cross" ./mach build echo "Profiling instrumented browser..." ./mach package if [[ "${_build_pgo_xvfb::1}" == "t" ]] ; then local _headless_run=( xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" ) else local _headless_run=( wlheadless-run -c weston --width=1920 --height=1080 ) fi LLVM_PROFDATA=llvm-profdata JARLOG_FILE=${PWD@Q}/jarlog \ "${_headless_run[@]}" -- ./mach python build/pgo/profileserver.py echo "Removing instrumented browser..." ./mach clobber fi echo "Building optimized browser..." cat >.mozconfig ../mozconfig if [[ -s merged.profdata ]] ; then stat -c "Profile data found (%s bytes)" merged.profdata echo >>.mozconfig "ac_add_options --enable-profile-use=cross" echo >>.mozconfig "ac_add_options --with-pgo-profile-path='${PWD@Q}/merged.profdata'" # save profdata for reuse cp --reflink=auto -f merged.profdata "$_old_profdata" else echo "Profile data not found." fi if [[ -s jarlog ]] ; then stat -c "Jar log found (%s bytes)" jarlog echo >>.mozconfig "ac_add_options --with-pgo-jarlog='${PWD@Q}/jarlog'" # save jarlog for reuse cp --reflink=auto -f jarlog "$_old_jarlog" else echo "Jar log not found." fi ./mach build else echo "Building browser..." cat >.mozconfig ../mozconfig ./mach build fi echo "Building symbol archive..." ./mach buildsymbols } package() { cd "${_repo##*/}" DESTDIR="$pkgdir" ./mach install local vendorjs="$pkgdir/usr/lib/$_pkgname/browser/defaults/preferences/vendor.js" install -Dvm644 /dev/stdin "$vendorjs" <