contrib/firefox/Pkgfile

141 lines
5.1 KiB
Plaintext
Raw Normal View History

2018-12-26 11:23:08 +01:00
# Description: The Mozilla Firefox browser with Alsa support
# URL: https://www.mozilla.com/firefox/
2023-03-11 14:23:48 +01:00
# Maintainer: Danny Rawlins, crux at romster dot me
2023-06-26 12:44:35 +02:00
# Depends on: aom autoconf-2.13 brotli cbindgen dav1d dbus-glib ffmpeg graphite2 libevent libnotify libvpx libwebp libxkbcommon nodejs nss pulseaudio unzip xorg-libxcomposite xorg-libxcursor xorg-libxinerama xorg-libxt zip
# Optional: sccache lld wasi-libc++ alsa-lib jack pipewire
2018-12-26 11:23:08 +01:00
name=firefox
2023-06-26 12:44:35 +02:00
version=114.0.2
2021-06-18 15:40:19 +02:00
release=1
2021-02-06 03:49:27 +01:00
source=(https://archive.mozilla.org/pub/firefox/releases/$version/source/$name-$version.source.tar.xz
2022-09-19 14:31:08 +02:00
firefox.desktop
2023-04-30 05:50:25 +02:00
node-stdout-nonblocking-wrapper)
2022-09-19 14:31:08 +02:00
_clear_vendor_checksums() {
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
}
2021-02-15 09:42:41 +01:00
2018-12-26 11:23:08 +01:00
build() {
2021-09-09 12:51:11 +02:00
cd $name-$version
2018-12-26 11:23:08 +01:00
2023-04-30 05:50:25 +02:00
#for p in $SRC/*.patch; do
# patch -p1 -i $p
#done
2023-03-11 14:23:48 +01:00
2023-06-26 12:44:35 +02:00
local clangVer=$(/usr/bin/clang -dumpversion)
local cruxVer=$(/usr/bin/crux | cut -d' ' -f3)
2021-10-26 13:22:39 +02:00
if [ "$(/usr/bin/python3 -c "import sys; print(sys.stdout.encoding)")" != 'utf-8' ]; then
2020-04-10 06:53:10 +02:00
printf "\e[031mError: set an UTF-8 locale to compile this!\033[0m\n"
exit 1
fi
if [ -e '/usr/bin/ccache' ]; then
2023-06-26 12:44:35 +02:00
export OS_CCACHE_COMPILERCHECK="$clangVer $cruxVer"
export CCACHE_COMPILERCHECK="string:$OS_CCACHE_COMPILERCHECK"
2020-04-10 06:53:10 +02:00
PATH=$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')
2021-09-09 12:51:11 +02:00
fi
2021-09-09 12:51:11 +02:00
prt-get isinst sccache && export RUSTC_WRAPPER='/usr/bin/sccache'
2023-06-26 12:44:35 +02:00
mkdir -p "$PKGMK_SOURCE_DIR/rust"
export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
2018-12-26 11:23:08 +01:00
cat <<- EOF > .mozconfig
2022-09-19 14:31:08 +02:00
export NODEJS="$SRC/node-stdout-nonblocking-wrapper"
2018-12-26 11:23:08 +01:00
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/firefox-shared
unset MOZ_TELEMETRY_REPORTING
2018-12-26 11:23:08 +01:00
ac_add_options --prefix=/usr
2019-02-15 09:56:43 +01:00
ac_add_options --enable-application=browser
2022-10-23 20:58:32 +02:00
#ac_add_options --with-system-harfbuzz
2022-09-19 14:31:08 +02:00
#ac_add_options --with-system-graphite2
2022-10-23 20:58:32 +02:00
#ac_add_options --with-system-av1
2018-12-26 11:23:08 +01:00
ac_add_options --with-system-jpeg
ac_add_options --with-system-zlib
ac_add_options --with-system-png
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
2021-09-09 12:51:11 +02:00
ac_add_options --with-system-libevent
ac_add_options --with-system-libvpx
ac_add_options --with-system-webp
ac_add_options --with-wasi-sysroot=/usr/share/wasi-sysroot
ac_add_options --enable-av1
2018-12-26 11:23:08 +01:00
ac_add_options --enable-system-ffi
ac_add_options --enable-system-pixman
2019-02-15 09:56:43 +01:00
ac_add_options --enable-optimize
2020-05-01 15:43:38 +02:00
ac_add_options --enable-release
ac_add_options --enable-rust-simd
2022-09-20 13:25:26 +02:00
ac_add_options --enable-sandbox
2018-12-26 11:23:08 +01:00
ac_add_options --enable-official-branding
ac_add_options --with-distribution-id=nu.crux
2021-09-09 12:51:11 +02:00
ac_add_options --enable-lto=thin
2018-12-26 11:23:08 +01:00
ac_add_options --disable-tests
2022-09-20 13:25:26 +02:00
ac_add_options --disable-debug-symbols
2018-12-26 11:23:08 +01:00
ac_add_options --disable-updater
ac_add_options --disable-crashreporter
ac_add_options --disable-necko-wifi
2022-09-20 13:25:26 +02:00
ac_add_options --disable-parental-controls
2020-08-27 13:47:05 +02:00
ac_add_options --disable-elf-hack
2018-12-26 11:23:08 +01:00
EOF
2021-09-09 12:51:11 +02:00
# audio
2022-09-20 13:25:26 +02:00
prt-get isinst alsa-lib && echo 'ac_add_options --enable-alsa' >> .mozconfig
prt-get isinst jack && echo 'ac_add_options --enable-jack' >> .mozconfig
prt-get isinst pulseaudio && echo 'ac_add_options --enable-pulseaudio' >> .mozconfig
2021-09-09 12:51:11 +02:00
prt-get isinst wayland-protocols && \
echo 'ac_add_options --enable-default-toolkit=cairo-gtk3-wayland' >> .mozconfig || \
echo 'ac_add_options --enable-default-toolkit=cairo-gtk3' >> .mozconfig
2023-06-26 12:44:35 +02:00
# use gold linker, if present
prt-get isinst lld && \
{ echo 'ac_add_options --enable-linker=lld' >> .mozconfig;
export LDFLAGS+=" -Wl,--thinlto-jobs=$((JOBS / 2))"; } || \
echo 'ac_add_options --enable-linker=bfd' >> .mozconfig
# sandboxed web apps
[ -e /usr/lib/clang/${clangVer%%.*}/lib/wasi/libclang_rt.builtins-wasm32.a ] \
|| echo 'ac_add_options --without-wasm-sandboxed-libraries' >> .mozconfig
2020-04-10 06:53:10 +02:00
[[ -e '/usr/bin/ccache' ]] && echo 'ac_add_options --enable-ccache' >> .mozconfig
2022-09-19 14:31:08 +02:00
export CC=clang CXX=clang++ AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib RUSTFLAGS="-C opt-level=2 $RUSTFLAGS"
2023-06-26 12:44:35 +02:00
export MOZ_MAKE_FLAGS="-j ${JOBS-1}"
2022-09-19 14:31:08 +02:00
export MOZBUILD_STATE_PATH="$SRC"/mozbuild
2021-09-09 12:51:11 +02:00
# Disable notification when build system has finished
2020-04-10 06:53:10 +02:00
export MOZ_NOSPAM=1
2021-09-09 12:51:11 +02:00
# Use system's Python environment
2022-09-19 14:31:08 +02:00
export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS=mach
#export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=pip
mkdir $SRC/bin
ln -s /usr/bin/pip3 $SRC/bin/pip
ln -s /usr/bin/python3 $SRC/bin/python
export PATH="$SRC/bin:$PATH"
2022-10-23 20:58:32 +02:00
2021-09-09 12:51:11 +02:00
# Show flags set at the beginning
echo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}"
echo "Current CFLAGS:\t\t${CFLAGS:-no value set}"
echo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}"
echo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}"
echo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}"
# python/mach/mach/mixin/process.py fails to detect SHELL
export SHELL='/usr/bin/bash'
2018-12-26 11:23:08 +01:00
./mach build
2019-02-15 09:56:43 +01:00
#./mach build toolkit/library/rust
2018-12-26 11:23:08 +01:00
DESTDIR=$PKG ./mach install
install -d $PKG/usr/share/pixmaps
2023-06-26 12:44:35 +02:00
ln -s /usr/lib/firefox/browser/chrome/icons/default/default48.png $PKG/usr/share/pixmaps/firefox.png
2018-12-26 11:23:08 +01:00
install -D -m 0644 $SRC/firefox.desktop $PKG/usr/share/applications/firefox.desktop
# Remove crap
rm -r $PKG/usr/lib/firefox/browser/features
rm $PKG/usr/lib/firefox/removed-files
install -d $PKG/etc/revdep.d
echo "/usr/lib/firefox" > $PKG/etc/revdep.d/firefox
}