packages/firefox/PKGBUILD

326 lines
11 KiB
Bash

# powER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Jakub Schmidtke <sjakub@gmail.com>
pkgname=firefox
pkgver=133.0.3
pkgrel=1
pkgdesc="Fast, Private & Safe Web Browser"
url="https://www.mozilla.org/firefox/"
arch=(x86_64 powerpc64le riscv64)
license=(MPL-2.0)
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
nspr
nss
pango
ttf-font
)
makedepends=(
cbindgen
clang
diffutils
imake
jack
llvm
mesa
nodejs-lts-iron
python311
rust
unzip
wasi-compiler-rt
wasi-libc
wasi-libc++
wasi-libc++abi
xorg-server-xvfb
zip
)
makedepends_x86_64=(
lld
nasm
yasm
)
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'
)
options=(
!emptydirs
!lto
!makeflags
)
source=(
https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
$pkgname-symbolic.svg
$pkgname.desktop
org.mozilla.$pkgname.metainfo.xml
0001-Install-under-remoting-name.patch
firefox-pgo.patch
ffmpeg-cleanup.patch
hotfix-gcc14.patch
hotfix-no-pip-check.patch
hotfix-wgpu-atomicu64.patch
riscv.patch
sandbox-fonts.patch
sandbox-x11.patch
)
validpgpkeys=(
# Mozilla Software Releases <release@mozilla.com>
# https://blog.mozilla.org/security/2023/05/11/updated-gpg-key-for-signing-firefox-releases/
14F26682D0916CDD81E37B6D61B7B526D98F0353
)
sha256sums=('f134a5420200bb03ab460f9d2867507c0edb222ce73faf4064cdbea02a0aca1b'
'SKIP'
'a9b8b4a0a1f4a7b4af77d5fc70c2686d624038909263c795ecc81e0aec7711e9'
'71fe797430198ac8c00b538dce537284cf526e48be0496698cf5a980d70c16da'
'58d78ce57b3ee936bc966458d6b20ab142d02a897bbe924b3f26717af0c5bee1'
'883ca2fa723a7572269d18559d5b82412782ad63e5dd3820eeb0540e3fe34314'
'0af4fc9150fbc7423656af8413fb352a7ae885a7a4bc5a12a9d7e330747f91ef'
'15fdd2e1ffe314eaee6685ae5178c4089477837d4ed49ba7fc6458d8dedc6c08'
'9903247f113d74a7ae0b68739639beaef61300c7611bb6beb1f718b054f34f4d'
'184e929778342487bcdb87d30b37c36cb7dc2eedfc4de415c6d06d1fe0bef0e0'
'226932fe11fcb84058306ca94d264ee9e2de3ec905e42bfad565571fea038a18'
'ee34d6236aed46d629e88a7a254915f330c892e8aeb9063a136d8c712dfd5d24'
'21888aab6b7580cba83c9260108711137e2d3c1a87689fb2ca03375a0c1446d6'
'5078bcaa6e7b5696bf539c753b1da9283571b2d8175b866275fe28a9ab0aad43')
b2sums=('e686408397a886e36ead739851ec190f108db2bda92b7147ec16c12233459dc23ab256ba125fb8902fb2a855ea76d9cb02e6c55ea62e7639f8700dba6bae9acb'
'SKIP'
'63a8dd9d8910f9efb353bed452d8b4b2a2da435857ccee083fc0c557f8c4c1339ca593b463db320f70387a1b63f1a79e709e9d12c69520993e26d85a3d742e34'
'2c7936949ef922307fb593bd0480a13bde2eab8ae24fc89071d809d6659384705f9b7838b1ae8bc46b98a152ba01fcffad606d4c84796ad9bfaaf20166f0a0fd'
'2ce33432f8a73a4f1a412b7a065d3c124e1ca9f6bdf3fad0407e897efc0840f8ef43eeeb1b9bef4a102d9fac0b2c4a2ef205726b817f83fe9c3742d076778b14'
'8a894b01e405b628877483e40e9b018647977cb053b6af02afc901ed24d6e1f767f3db8c321070e33aea4a05ba16f1eb47ae600e5299b5f9caad03d20ba38cf5'
'31dfc620b032b9315c2f6eb876d4b9a418eb9e6e89a212b1b847cfd96f13160f1d170ba7752c7a8caa3835e83232e86e4df923fd80e536c0f93d9f8c7387d8fe'
'fe679b79ec3f7a8368772554a8745eac71114d33c4aefcb315b51fae3633e1b0e0392325b8ef59abddc262ab57aad54eb976d90eebeec7cd7e5c31de578897cc'
'0a831d3cc36c00ed8c8cf027f9b360e510f7fd86efd260dc5ec3d87e0564a45943de9c91e5c4a8fd5820d3dd7998c11a2ad87194f7f92a5468dfc6a0291235c5'
'cedf9057e0e86f25cc6bce5a27baff9e5d090bbb265d584a00e1c7dc17a0fff9c9360c26302ef589b6d96e536db3003b94597035fcac86d71d96f086f2300fb0'
'695ee838eb74727f553e570cc88b0748e4b893b26e12d399912ccc7beaf406935f25ae44f42f2e3f754e3ca537103151afaf154b688bd2b305504d84b458a79a'
'7e7e6df1bb31b3f0122a3efd29b340ed0c7f44e0c3d6c156f1e78cb5614fc4591de1c6c8227550dd2bfe0006bc6ede4f58dde2c21fdbbd4d3a58c4ce70a0025c'
'f542dda6798de78f4144e6dfb0149a218bd4313e6827b40d0e104edbef2a3cac3a4ff00e499ee7c0e90aee9feed7ac83f0c07a423231bce3719b71b76aaf147f'
'3589e5228bd3178c7f6744cf0b2a6bff12cb0622766cba11384cb015c0b824926e5a1d910462add6d26f907ec039c10e9d811824f5ed7014447b51fbe800d85a')
# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Arch POWER use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact alex.bldck@gmail.com for
# more information.
_google_api_key=AIzaSyDgkw4O3LM0Jnr2N7Wq2NG7iUVzRU5sBaA
prepare() {
mkdir mozbuild
cd firefox-$pkgver
# Make different channels installable in parallel
patch -Np1 -i ../0001-Install-under-remoting-name.patch
# Classilla's PGO patch
patch -Np1 -i ${srcdir}/firefox-pgo.patch
# Lovely T2 touches
patch -Np1 -i ${srcdir}/ffmpeg-cleanup.patch
patch -Np1 -i ${srcdir}/hotfix-gcc14.patch
patch -Np1 -i ${srcdir}/hotfix-no-pip-check.patch
patch -Np1 -i ${srcdir}/hotfix-wgpu-atomicu64.patch
patch -Np1 -i ${srcdir}/riscv.patch
patch -Np1 -i ${srcdir}/sandbox-fonts.patch
patch -Np1 -i ${srcdir}/sandbox-x11.patch
sed -i 's/\("files":{[^,]*\),[^}]*}/\1}/' third_party/rust/*/.cargo-checksum.json
echo -n "$_google_api_key" >google-api-key
cat >../mozconfig <<END
ac_add_options --enable-application=browser
mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
ac_add_options --prefix=/usr
ac_add_options --enable-release
ac_add_options --enable-hardening
ac_add_options --enable-optimize
ac_add_options --enable-rust-simd
ac_add_options --enable-linker=bfd
ac_add_options --disable-install-strip
ac_add_options --disable-bootstrap
# Branding
ac_add_options --enable-official-branding
ac_add_options --enable-update-channel=release
ac_add_options --with-distribution-id=org.archlinuxpower
ac_add_options --with-unsigned-addon-scopes=app,system
ac_add_options --allow-addon-sideload
export MOZILLA_OFFICIAL=1
export MOZ_APP_REMOTINGNAME=$pkgname
# 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
# System libraries
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
# Features
ac_add_options --enable-alsa
ac_add_options --enable-jack
ac_add_options --disable-updater
ac_add_options --disable-tests
END
case "${CARCH}" in
x86_64)
echo "ac_add_options --disable-elf-hack" >> ../mozconfig
echo "ac_add_options --enable-crashreporter" >> ../mozconfig
echo "ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot" >> ../mozconfig
echo "export CC=clang" >> ../mozconfig
echo "export CXX=clang++" >> ../mozconfig
;;
riscv64)
echo "ac_add_options --disable-crashreporter" >> ../mozconfig
echo "ac_add_options --without-wasm-sandboxed-libraries" >> ../mozconfig
echo "export CC=clang" >> ../mozconfig
echo "export CXX=clang++" >> ../mozconfig
;;
*)
echo "export RUSTC_OPT_LEVEL=2" >> ../mozconfig
echo "ac_add_options --enable-lto=full" >> ../mozconfig
echo "ac_add_options MOZ_PGO=1" >> ../mozconfig
echo "ac_add_options --disable-crashreporter" >> ../mozconfig
echo "ac_add_options --without-wasm-sandboxed-libraries" >> ../mozconfig
echo "export CC=${CHOST}-gcc" >> ../mozconfig
echo "export CXX=${CHOST}-g++" >> ../mozconfig
echo "export CFLAGS='${CFLAGS/ -fexceptions/}'" >> ../mozconfig
echo "export CXXFLAGS='${CXXFLAGS/ -fexceptions/}'" >> ../mozconfig
;;
esac
}
build() {
cd firefox-$pkgver
cat ${srcdir}/mozconfig | tee .mozconfig
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=pip
export MOZBUILD_STATE_PATH="$srcdir/mozbuild"
export MOZ_BUILD_DATE="$(date -u${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH} +%Y%m%d%H%M%S)"
export MOZ_NOSPAM=1
# 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
xvfb-run -s "-screen 0 1920x1080x24 -nolisten local" \
python3.11 ./mach build --priority normal
}
package() {
cd firefox-$pkgver
DESTDIR="$pkgdir" python3.11 ./mach install
local vendorjs="$pkgdir/usr/lib/$pkgname/browser/defaults/preferences/vendor.js"
install -Dvm644 /dev/stdin "$vendorjs" <<END
// Use LANG environment variable to choose locale
pref("intl.locale.requested", "");
// Use system-provided dictionaries
pref("spellchecker.dictionary_path", "/usr/share/hunspell");
// Disable default browser checking.
pref("browser.shell.checkDefaultBrowser", false);
// Don't disable extensions in the application directory
pref("extensions.autoDisableScopes", 11);
// Enable GNOME Shell search provider
pref("browser.gnome-search-provider.enabled", true);
END
local distini="$pkgdir/usr/lib/$pkgname/distribution/distribution.ini"
install -Dvm644 /dev/stdin "$distini" <<END
[Global]
id=archpower
version=1.0
about=Mozilla Firefox for Arch POWER
[Preferences]
app.distributor=archpower
app.distributor.channel=$pkgname
app.partner.archpower=archpower
END
local i theme=official
for i in 16 22 24 32 48 64 128 256; do
install -Dvm644 browser/branding/$theme/default$i.png \
"$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
done
install -Dvm644 browser/branding/$theme/content/about-logo.png \
"$pkgdir/usr/share/icons/hicolor/192x192/apps/$pkgname.png"
install -Dvm644 browser/branding/$theme/content/about-logo@2x.png \
"$pkgdir/usr/share/icons/hicolor/384x384/apps/$pkgname.png"
install -Dvm644 browser/branding/$theme/content/about-logo.svg \
"$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
install -Dvm644 ../$pkgname-symbolic.svg -t "$pkgdir/usr/share/icons/hicolor/symbolic/apps"
install -Dvm644 ../$pkgname.desktop -t "$pkgdir/usr/share/applications"
install -Dvm644 ../org.mozilla.$pkgname.metainfo.xml -t "$pkgdir/usr/share/metainfo"
# 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
local sprovider="$pkgdir/usr/share/gnome-shell/search-providers/$pkgname.search-provider.ini"
install -Dvm644 /dev/stdin "$sprovider" <<END
[Shell Search Provider]
DesktopId=$pkgname.desktop
BusName=org.mozilla.${pkgname//-/_}.SearchProvider
ObjectPath=/org/mozilla/${pkgname//-/_}/SearchProvider
Version=2
END
}
# vim:set sw=2 sts=-1 et: