File PKGBUILD of Package firefox-kde
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Jakub Schmidtke <sjakub@gmail.com>
# Contributor: Serhii Starovoitov <drommer.94@gmail.com>
_pkgname=firefox
pkgname=firefox-kde
pkgver=144.0.2
pkgrel=1
pkgdesc="Standalone web browser, designed for standards compliance and performance."
arch=('x86_64')
license=('MPL-2.0')
url="https://www.mozilla.org/firefox/"
depends=('alsa-lib' 'at-spi2-core' 'bash' 'cairo' 'dbus' 'ffmpeg' 'fontconfig' 'freetype2' 'gcc-libs' 'gdk-pixbuf2' 'glib2' 'glibc'
'gtk3' 'hicolor-icon-theme' 'libpulse' 'libx11' 'libxcb' 'libxcomposite' 'libxdamage' 'libxext' 'libxfixes' 'libxrandr'
'libxss' 'libxt' 'mime-types' 'pango' 'plasma-browser-integration' 'ttf-font' 'xdg-desktop-portal-kde')
makedepends=('cbindgen' 'clang' 'diffutils' 'imake' 'inetutils' 'jack' 'libfdk-aac' 'lld' 'llvm' 'mesa' 'nasm' 'nodejs'
'python' 'python-psutil' 'python-typing_extensions' 'python-zstandard' 'rust' 'unzip' 'wasi-compiler-rt'
'wasi-libc' 'wasi-libc++' 'wasi-libc++abi' 'weston' 'wlheadless-run' 'yasm' 'zip')
optdepends=('hunspell-en_US: Spell checking, American English'
'libnotify: Notification integration'
'networkmanager: Location detection via available WiFi networks'
'speech-dispatcher: Text-to-Speech'
'xdg-desktop-portal: Screensharing with Wayland')
provides=("firefox=${pkgver}")
conflicts=('firefox')
options=(!emptydirs !lto !makeflags)
source=("https://archive.mozilla.org/pub/$_pkgname/releases/$pkgver/source/$_pkgname-$pkgver.source.tar.xz"
"$_pkgname.desktop"
"identity-icons-brand.svg"
"firefox-branded-icons.patch"
"install-under-remoting-name.patch"
"set-gdk-focus-change-mask-1196777.patch"
"system-fdk-aac-1667096.patch"
"disable-nvidia-blocklist.patch"
)
sha256sums=('eac4722ed259008d73006c4894c18d2871702c661d14e27505812351df62806b'
'71fe797430198ac8c00b538dce537284cf526e48be0496698cf5a980d70c16da'
'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9'
'820ece0f1d425b24b837967d93eab2775722dcebcc7c1713907f48a213e403a8'
'ef63a12975f108f30b00bb3290d9ca76f311d8af9c1d5dfc0d8335ad57e8f77c'
'6f17c64f11d2008b2ca6be07f383461c820f0a886ee61a702bae5b5b1f12d39d'
'097b700fb0cbb9288fe8fb6bd7937d4fafb5513819437db80a98f04efd1534d0'
'06e30b49678a48f4b6d5eb74de91f743734c7d21efd442777c77aee8cf5dad85'
)
validpgpkeys=(14F26682D0916CDD81E37B6D61B7B526D98F0353)
shopt -s extglob
# 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() {
cd $_pkgname-$pkgver
sed -i -e 's|psutil>=5.4.2,<=5.9.4|psutil>=5.4.2,<=7.1.1|' \
-e 's|zstandard>=0.11.1,<=0.24.0|zstandard>=0.11.1,<=0.25.0|' \
-e 's|pypi-optional:glean-sdk|# pypi-optional:glean-sdk|' \
-e 's|vendored:third_party/python/typing_extensions|# vendored:third_party/python/typing_extensions|' \
python/sites/mach.txt
# Patches
patch -Np1 -i "$srcdir/firefox-branded-icons.patch"
patch -Np1 -i "$srcdir/install-under-remoting-name.patch"
patch -Np1 -i "$srcdir/set-gdk-focus-change-mask-1196777.patch"
patch -Np1 -i "$srcdir/system-fdk-aac-1667096.patch"
patch -Np1 -i "$srcdir/disable-nvidia-blocklist.patch"
echo -n "$_google_api_key" >google-api-key
echo -n "$_mozilla_api_key" >mozilla-api-key
cat >../mozconfig <<END
mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
ac_add_options --enable-application=browser
ac_add_options --disable-bootstrap
ac_add_options --disable-elf-hack
ac_add_options --disable-install-strip
ac_add_options --enable-hardening
ac_add_options --enable-linker=lld
ac_add_options --enable-optimize
ac_add_options --enable-release
ac_add_options --enable-rust-simd
ac_add_options --prefix=/usr
ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
# Branding
ac_add_options --allow-addon-sideload
ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=release
ac_add_options --with-distribution-id=org.archlinux
ac_add_options --with-unsigned-addon-scopes=app,system
# Keys
ac_add_options --with-google-location-service-api-keyfile=${PWD@Q}/google-api-key
ac_add_options --with-google-safebrowsing-api-keyfile=${PWD@Q}/google-api-key
ac_add_options --with-mozilla-api-keyfile=${PWD@Q}/mozilla-api-key
# Features
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --enable-alsa
ac_add_options --enable-crashreporter
ac_add_options --enable-jack
ac_add_options --with-system-fdk-aac
END
}
build() {
cd $_pkgname-$pkgver
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
export MOZ_BUILD_DATE="$(date -u${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH} +%Y%m%d%H%M%S)"
export MOZ_ENABLE_VAAPI=1
export MOZ_GLX_IGNORE_BLACKLIST=1
export MOZ_NOSPAM=1
export MOZ_WAYLAND_PROXY=1
export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
export MOZILLA_OFFICIAL=1
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$srcdir/xdg-runtime}"
[ ! -d "$XDG_RUNTIME_DIR" ] && install -dm700 "${XDG_RUNTIME_DIR:?}"
# malloc_usable_size is used in various parts of the codebase
CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
# Breaks compilation since https://bugzilla.mozilla.org/show_bug.cgi?id=1896066
CFLAGS="${CFLAGS/-fexceptions/}"
CXXFLAGS="${CXXFLAGS/-fexceptions/}"
# LTO needs more open files
ulimit -n 4096
# Do 3-tier PGO
echo "Building instrumented browser..."
cat >.mozconfig ../mozconfig - <<END
ac_add_options --enable-profile-generate=cross
END
./mach build --priority normal
echo "Profiling instrumented browser..."
./mach package
LLVM_PROFDATA=llvm-profdata \
JARLOG_FILE="$PWD/jarlog" \
dbus-run-session \
wlheadless-run -c weston --width=1920 --height=1080 -- \
./mach python build/pgo/profileserver.py
stat -c "Profile data found (%s bytes)" merged.profdata
test -s merged.profdata
stat -c "Jar log found (%s bytes)" jarlog
test -s jarlog
echo "Removing instrumented browser..."
./mach clobber objdir
echo "Building optimized browser..."
cat >.mozconfig ../mozconfig - <<END
ac_add_options --enable-lto=cross
ac_add_options --enable-profile-use=cross
ac_add_options --with-pgo-profile-path=${PWD@Q}/merged.profdata
ac_add_options --with-pgo-jarlog=${PWD@Q}/jarlog
END
./mach build --priority normal
}
package() {
cd $_pkgname-$pkgver
DESTDIR="$pkgdir" ./mach install
install -Dvm644 /dev/stdin "$pkgdir/usr/lib/$_pkgname/browser/defaults/preferences/vendor.js" <<END
// Custom zoom scaling
pref("toolkit.zoomManager.zoomValues", ".25,.5,.65,.75,.8,.85,.9,.95,1,1.05,1.1,1.15,1.2,1.25,1.35,1.5,1.75,2,2.5,3,5");
// Disable built-in translator (beta)
pref("browser.translations.automaticallyPopup", false);
pref("browser.translations.enable", false);
pref("browser.translations.panelShown", false);
// Disable close window with last tab
pref("browser.tabs.closeWindowWithLastTab", false);
// Don't disable extensions in the application directory
pref("extensions.autoDisableScopes", 11);
// Enable DNS over HTTPS
pref("network.trr.mode", 2);
pref("network.trr.uri", "https://mozilla.cloudflare-dns.com/dns-query");
// Enable Experimental Features
pref("browser.preferences.experimental", true);
// Enable Multi-Account Containers
pref("privacy.userContext.enabled", true);
pref("privacy.userContext.ui.enabled", true);
// Enable Mute Button on Picture-in-Picture Window
pref("media.videocontrols.picture-in-picture.audio-toggle.enabled", true);
// Enable VA-API
pref("gfx.webrender.all", true);
pref("media.ffmpeg.vaapi.enabled", true);
// Enable XDG Desktop Portal
pref("widget.use-xdg-desktop-portal.file-picker", 1);
pref("widget.use-xdg-desktop-portal.location", 1);
pref("widget.use-xdg-desktop-portal.mime-handler", 1);
pref("widget.use-xdg-desktop-portal.open-uri", 1);
pref("widget.use-xdg-desktop-portal.settings", 1);
// Some KDE integration tweaks
pref("browser.shell.checkDefaultBrowser", false);
pref("media.hardwaremediakeys.enabled", false);
// Use LANG environment variable to choose locale
pref("intl.locale.requested", "");
// Use system-provided dictionaries
pref("spellchecker.dictionary_path", "/usr/share/hunspell");
END
install -Dvm644 /dev/stdin "$pkgdir/usr/lib/$_pkgname/distribution/distribution.ini" <<END
[Global]
id=archlinux
version=1.0
about=Mozilla Firefox for Arch Linux
[Preferences]
app.distributor=archlinux
app.distributor.channel=$_pkgname
app.partner.archlinux=archlinux
END
for i in 16 22 24 32 48 64 128 256; do
install -Dvm644 browser/branding/official/default$i.png \
"$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$_pkgname.png"
done
install -Dvm644 browser/branding/official/content/about-logo.png \
"$pkgdir/usr/share/icons/hicolor/192x192/apps/$_pkgname.png"
install -Dvm644 browser/branding/official/content/about-logo@2x.png \
"$pkgdir/usr/share/icons/hicolor/384x384/apps/$_pkgname.png"
install -Dvm644 browser/branding/official/content/about-logo.svg \
"$pkgdir/usr/share/icons/hicolor/scalable/apps/$_pkgname.svg"
install -Dvm644 ../identity-icons-brand.svg \
"$pkgdir/usr/share/icons/hicolor/symbolic/apps/$_pkgname-symbolic.svg"
install -Dvm644 ../$_pkgname.desktop \
"$pkgdir/usr/share/applications/$_pkgname.desktop"
# Install a wrapper to avoid confusion about binary path
install -Dvm755 /dev/stdin "$pkgdir/usr/bin/$_pkgname" <<END
#!/bin/sh
exec /usr/lib/$_pkgname/firefox "\$@"
END
# Replace duplicate binary with wrapper
# https://bugzilla.mozilla.org/show_bug.cgi?id=658850
ln -srfv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/lib/$_pkgname/firefox-bin"
# Use system certificates
local nssckbi="$pkgdir/usr/lib/$_pkgname/libnssckbi.so"
if [[ -e $nssckbi ]]; then
ln -srfv "$pkgdir/usr/lib/libnssckbi.so" "$nssckbi"
fi
}