277 lines
9.6 KiB
Plaintext

# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=firefox-developer-edition
pkgver=120.0_beta9
_pkgver=${pkgver/_beta/b}
_releasedate=2023-10-11
pkgrel=0
pkgdesc="Firefox web browser"
url="https://www.firefox.com/"
# s390x and riscv64 blocked by rust and cargo
# armhf: https://bugzilla.mozilla.org/show_bug.cgi?id=1680495
# ppc64le: ld.lld: error: undefined hidden symbol: something about video
# x86/armv7: who is using this there?
arch="x86_64 aarch64"
license="GPL-3.0-only AND LGPL-2.1-only AND LGPL-3.0-only AND MPL-2.0"
depends="
ffmpeg-libavcodec
"
makedepends="
alsa-lib-dev
automake
bsd-compat-headers
cargo
cbindgen
clang
clang-libclang
dbus-glib-dev
gettext
gtk+3.0-dev
hunspell-dev
icu-dev
libevent-dev
libffi-dev
libjpeg-turbo-dev
libnotify-dev
libogg-dev
libtheora-dev
libtool
libvorbis-dev
libvpx-dev
libwebp-dev
libxcomposite-dev
libxt-dev
lld
llvm-dev
m4
mesa-dev
nasm
nodejs
nspr-dev
nss-dev
pipewire-dev
pulseaudio-dev
python3
sed
wasi-sdk
wireless-tools-dev
zip
"
source="https://ftp.mozilla.org/pub/firefox/releases/$_pkgver/source/firefox-$_pkgver.source.tar.xz
audio-lfs64.patch
disable-moz-stackwalk.patch
fix-fortify-system-wrappers.patch
fix-rust-target.patch
fix-webrtc-glibcisms.patch
install-dir.patch
lfs64.patch
no-ccache-stats.patch
python-deps.patch
rust-lto-thin.patch
sandbox-fork.patch
sandbox-largefile.patch
sandbox-sched_setscheduler.patch
icu74.patch
stab.h
firefox-developer-edition.desktop
distribution.ini
vendor-prefs.js
"
options="!check" # no tests
builddir="$srcdir/firefox-${pkgver/_*/}"
_mozappdir=/usr/lib/firefox-developer-edition
# help our shared-object scanner to find the libs
ldpath="$_mozappdir"
sonameprefix="$pkgname:"
# we need this because cargo verifies checksums of all files in vendor
# crates when it builds and gives us no way to override or update the
# file sanely... so just clear out the file list
_clear_vendor_checksums() {
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
}
export CFLAGS="${CFLAGS/-fstack-clash-protection/} -g0 -O2"
export CXXFLAGS="${CXXFLAGS/-fstack-clash-protection/} -g0 -O2 -Wno-deprecated-builtins -Wno-deprecated-declarations"
prepare() {
default_prepare
cp "$srcdir"/stab.h toolkit/crashreporter/google-breakpad/src/
_clear_vendor_checksums audio_thread_priority
cat > base-mozconfig <<-EOF
# disable unwanted things
ac_add_options --disable-bootstrap
ac_add_options --disable-cargo-incremental
ac_add_options --disable-crashreporter
ac_add_options --disable-elf-hack
ac_add_options --disable-install-strip
ac_add_options --disable-jemalloc
ac_add_options --disable-strip
ac_add_options --disable-tests
ac_add_options --disable-updater
# features
ac_add_options --enable-alsa
ac_add_options --enable-dbus
ac_add_options --enable-default-toolkit=cairo-gtk3-wayland
ac_add_options --enable-ffmpeg
ac_add_options --enable-hardening
ac_add_options --enable-linker=lld
ac_add_options --enable-lto=cross
ac_add_options --enable-necko-wifi
ac_add_options --enable-official-branding
ac_add_options --enable-optimize="$CFLAGS"
ac_add_options --enable-pulseaudio
ac_add_options --enable-release
ac_add_options --enable-sandbox
ac_add_options --enable-update-channel=aurora
# system libs
ac_add_options --enable-system-pixman
ac_add_options --with-system-ffi
ac_add_options --with-system-icu
ac_add_options --with-system-jpeg
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-png
ac_add_options --with-system-webp
ac_add_options --with-system-zlib
# misc
ac_add_options --prefix=/usr
ac_add_options --allow-addon-sideload
ac_add_options --with-distribution-id=org.alpinelinux
ac_add_options --with-libclang-path=/usr/lib
ac_add_options --with-unsigned-addon-scopes=app,system
ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
ac_add_options --with-branding=browser/branding/aurora
ac_add_options --host=$CHOST
ac_add_options --target=$CTARGET
mk_add_options RUSTFLAGS="$RUSTFLAGS"
# objdir
mk_add_options MOZ_OBJDIR="$builddir/obj"
EOF
}
build() {
# for lto
ulimit -n 4096
# can't be set here and fail
unset RUSTFLAGS
local thinlto_jobs=${JOBS:-1}
case "$CARCH" in
# on this platform, lld seems to not utilise >1 threads for thinlto for some reason.
# at the same time, having more than 8 also crashes lld for firefox buildsystems (why?).
aarch64)
if [ $thinlto_jobs -gt 8 ]; then
thinlto_jobs=8
fi
esac
export LDFLAGS="$LDFLAGS -Wl,--thinlto-jobs=$thinlto_jobs"
export CC="clang"
export CXX="clang++"
export SHELL=/bin/sh
export BUILD_OFFICIAL=1
export MOZILLA_OFFICIAL=1
export USE_SHORT_LIBNAME=1
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
export MOZ_APP_REMOTINGNAME=firefoxdeveloperedition
export MOZBUILD_STATE_PATH="$srcdir"/mozbuild
# allow unsigned addons for dev-edition
export MOZ_REQUIRE_SIGNING=
# disable desktop notifications
export MOZ_NOSPAM=1
# Find our triplet JSON
export RUST_TARGET="$CTARGET"
# set rpath so linker finds the libs
export LDFLAGS="$LDFLAGS -Wl,-rpath,$_mozappdir"
# let firefox do this itself.
unset CARGO_PROFILE_RELEASE_OPT_LEVEL
unset CARGO_PROFILE_RELEASE_CODEGEN_UNITS
unset CARGO_PROFILE_RELEASE_PANIC
unset CARGO_PROFILE_RELEASE_LTO
export MOZ_BUILD_DATE="$(date ${SOURCE_DATE_EPOCH:+ -d@${SOURCE_DATE_EPOCH}} "+%Y%m%d%H%M%S")"
cat > .mozconfig base-mozconfig
./mach build
}
package() {
DESTDIR="$pkgdir" ./mach install
local _png
for _png in ./browser/branding/aurora/default*.png; do
local i=${_png%.png}
i=${i##*/default}
install -Dm644 "$_png" \
"$pkgdir"/usr/share/icons/hicolor/"$i"x"$i"/apps/$pkgname.png
done
install -Dm644 browser/branding/aurora/content/about-logo.png \
"$pkgdir"/usr/share/icons/hicolor/192x192/apps/$pkgname.png
install -Dm644 browser/branding/aurora/content/about-logo@2x.png \
"$pkgdir"/usr/share/icons/hicolor/384x384/apps/$pkgname.png
install -Dm644 browser/branding/aurora/content/about-logo.svg \
"$pkgdir"/usr/share/icons/hicolor/scalable/apps/$pkgname.svg
install -Dm644 "$srcdir"/firefox-developer-edition.desktop \
"$pkgdir"/usr/share/applications/firefox-developer-edition.desktop
install -Dm644 "$srcdir"/distribution.ini \
"$pkgdir"/$_mozappdir/distribution/distribution.ini
# install our vendor prefs
install -Dm644 "$srcdir"/vendor-prefs.js \
"$pkgdir"/$_mozappdir/browser/defaults/preferences/vendor.js
# Replace duplicate binary with wrapper
# https://bugzilla.mozilla.org/show_bug.cgi?id=658850
install -Dm755 /dev/stdin "$pkgdir"/usr/bin/firefox-developer-edition <<- EOF
#!/bin/sh
exec $_mozappdir/firefox "\$@"
EOF
rm "$pkgdir"/$_mozappdir/firefox-bin
ln -sfv /usr/bin/firefox-developer-edition "$pkgdir"/$_mozappdir/firefox-bin
}
sha512sums="
7ac5562ce393ea84663eac5c6ee1a0ca527ff4a8a9ec6aaaef37213ff071076846949e80af21d95ec8e32d3cbc740b772a9d7cc54965b7bbc8e015da22ae927f firefox-120.0b9.source.tar.xz
3e0501ae7a650346c667dfdc0ae0ca286084f22e89ab2ac671cc0d7315673dc5b6dcb9f9882f6f39d26e9a31e57f7a0fd53d6b805e520224e22b8976850e2eb8 audio-lfs64.patch
454ea3263cabce099accbdc47aaf83be26a19f8b5a4568c01a7ef0384601cf8315efd86cd917f9c8bf419c2c845db89a905f3ff9a8eb0c8e41042e93aa96a85c disable-moz-stackwalk.patch
2f4f15974d52de4bb273b62a332d13620945d284bbc6fe6bd0a1f58ff7388443bc1d3bf9c82cc31a8527aad92b0cd3a1bc41d0af5e1800e0dcbd7033e58ffd71 fix-fortify-system-wrappers.patch
cd68b89e29e5f6379fbd5679db27b9a5ef70ea65e51c0d0a8137e1f1fd210e35a8cfb047798e9549bc7275606d7ec5c8d8af1335d29da4699db7acd8bc7ff556 fix-rust-target.patch
305c874fdea3096e9c4c6aa6520ac64bb1c347c4b59db8360096646593fe684c3b5377874d91cecd33d56d1410b4714fbdea2b514923723ecbeff79d51265d9b fix-webrtc-glibcisms.patch
ff471e5160e313a9657bcbb767a6a581bab9da053cced02bde38d1ef03349472ad3602dba026c10d676d55c1712af772dd2b7bdbfa72b5db498c9ce8a2133423 install-dir.patch
5fa9382c692e4bd6a2634308f24a6526fd12a60a2563d2090056d43a60505df3ec9881bbf54562e69394467529b3b0dc45955afca46ed329af03cea074fff070 lfs64.patch
64b6458099baa225b346b40e3080cea3a5c73a834e39fa4a438af77701e6ded84e2fb0d6fffff8c2533cc43b898fe9f411be023e875acebec452aa2379861f04 no-ccache-stats.patch
ff3618223bba2d7b877a16451256e67d973c5f4e24027cb5a7da4c0a6f6a028a1eb51d3cbcddae71bca584a4c13cb485950b86022ea26d4e25ae3fdf3ce5d910 python-deps.patch
1c6918dd6655d3a1251bfd4af2e1c561cbb00d540a883b4c1ebf7f5de530d754d9ac07b4b5f56cdab6c511d25c8910ec94043f5733e97501a67abffe1bafaeb1 rust-lto-thin.patch
2518f2fc75b5db30058e0735f47d60fdf1e7adfaeee4b33fb2afb1bd9a616ce943fd88f4404d0802d4083703f4acf1d5ad42377218d025bc768807fbaf7e1609 sandbox-fork.patch
b7d0a6126bdf6c0569f80aabf5b37ed2c7a35712eb8a0404a2d85381552f5555d4f97d213ea26cec6a45dc2785f22439376ed5f8e78b4fd664ef0223307b333e sandbox-largefile.patch
94433c5ffdbe579c456d95c5f053f61fcbab2f652fa90bc69dcc27d9a1507a8e5c677adeadae9a7a75cc9a55184c1040737f4dfd10b279c088ef016561e6f135 sandbox-sched_setscheduler.patch
afabea91b328c5a68eaa20f9099ac7b2d0e7f2423e816b05ed168bdd326a5684fa02de08bf05c6033e9b888f02775d1b0443a00329b7a632ee399122a391c13a icu74.patch
0b3f1e4b9fdc868e4738b5c81fd6c6128ce8885b260affcb9a65ff9d164d7232626ce1291aaea70132b3e3124f5e13fef4d39326b8e7173e362a823722a85127 stab.h
2ff0cb8e2eb94cee306b488adf6d7f4debbaff6155be3ed3eeee814cdb356e2e60fe38cc29d6c8d10079937fd2c930cfddf283977cf645395d31eaf76c7f0ac2 firefox-developer-edition.desktop
4fd66382983d406ce0cd3586239fb1110224aeb2f9eee6fc931d980a31d18739d001d1f152208a7f1ccaae80867c40bd3d2ac674484617532a8f38049dc745bd distribution.ini
fc45bc3ffb9404e5338ea26a9f04807b40f6f516324972cddd48bedb91b8bd7c6b8d4e03a0209020f5e67b703bc4ff89389985791b9bd544a0fc3951e2dc338e vendor-prefs.js
"