Files
BMLFS/build-scripts/firefox.build

160 lines
6.5 KiB
Bash

#! /bin/bash
# FireFox 91.6.0
# Source: https://ftp.mozilla.org/pub/firefox/releases/91.6.0esr/source/firefox-91.6.0esr.source.tar.xz
#
# $BUILD = Directory to temporarily install
# $PKGS = Directory to store built packages
#
# DEPS
# Required: rusrc, Autoconf-2.13, Cbindgen, dbus-glib, both GTK+-3, libnotify, LLVM,
# Required: nodejs, NSS, PulseAudio(or alsa-lib), Python3 with SQlite, startup-notification,
# Required: Unzip, yasm, Zip, pipewire
# Recommended: ICU, libevent, libwebp, NASM
# Optional: cURL, Doxygen, FFmpeg, liboauth, OpenJDK, Valgrind, Wget, Wireless-Tools, libpoxy
#
# Add missing header
cp -v ../files/firefox-alpine/stab.h toolkit/crashreporter/google-breakpad/src/
# Apply patchess from Alpine
patch -Np1 -i ../patches/firefox-alpine/fix-fortify-system-wrappers.patch
patch -Np1 -i ../patches/firefox-alpine/fix-tools.patch
patch -Np1 -i ../patches/firefox-alpine/mallinfo.patch
patch -Np1 -i ../patches/firefox-alpine/disable-moz-stackwalk.patch
patch -Np1 -i ../patches/firefox-alpine/fix-rust-target.patch
patch -Np1 -i ../patches/firefox-alpine/fix-webrtc-glibcisms.patch
patch -Np1 -i ../patches/firefox-alpine/allow-custom-rust-vendor.patch
patch -Np1 -i ../patches/firefox-alpine/disable-neon-in-aom.patch
patch -Np1 -i ../patches/firefox-alpine/sandbox-fork.patch
patch -Np1 -i ../patches/firefox-alpine/sandbox-sched_setscheduler.patch
patch -Np1 -i ../patches/firefox-alpine/sandbox-largefile.patch
patch -Np1 -i ../patches/firefox-alpine/avoid-redefinition.patch
# 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
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/audio_thread_priority/.cargo-checksum.json
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/target-lexicon-0.9.0/.cargo-checksum.json
mkdir -pv objdir && cd objdir && \
# Setup Environment:
export SHELL=/bin/sh BUILD_OFFICIAL=1 MOZILLA_OFFICIAL=1 USE_SHORT_LIBNAME=1
export MACH_USE_SYSTEM_PYTHON=1
export RUST_TARGET="x86_64-unknown-linux-musl"
# Build with Clang, takes less RAM
export CC="clang" CXX="clang++"
# set rpath so linker finds the libs
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/firefox"
# For ARM & x86:
# .. disable-elf-hack: exists only on arm, x86, x86_64
export CXARGS="--disable-elf-hack "
# FireFox doesn't have SIMD available on these arches.
# armhf|armv7 = export CXARGS+="--disable-rust-simd --disable-debug-symbols --disable-debug "
# export RUSTFLAGS="$RUSTFLAGS -C debuginfo=0"
# x86 = export CXARGS+="--disable-debug-symbols --disable-debug "
# export RUSTFLAGS="$RUSTFLAGS -C debuginfo=0"
export CXARGS+="--enable-rust-simd "
export CARGS="--disable-crashreporter "
export CARGS+="--disable-gold "
export CARGS+="--disable-install-strip "
export CARGS+="--disable-jemalloc "
export CARGS+="--disable-profiling "
export CARGS+="--disable-strip "
export CARGS+="--disable-tests "
export CARGS+="--disable-updater "
export CARGS+="--enable-alsa "
export CARGS+="--enable-dbus "
export CARGS+="--enable-default-toolkit=cairo-gtk3-wayland "
export CARGS+="--enable-ffmpeg "
export CARGS+="--enable-hardening "
export CARGS+="--enable-official-branding "
export CARGS+="--enable-necko-wifi "
export CARGS+="--enable-pulseaudio "
export CARGS+="--disable-smoosh "
export CARGS+="--enable-system-ffi "
export CARGS+="--enable-system-pixman "
export CARGS+="--with-system-ffi "
export CARGS+="--with-system-icu "
export CARGS+="--with-system-jpeg "
export CARGS+="--with-system-libevent "
export CARGS+="--with-system-libvpx "
export CARGS+="--with-system-nspr "
export CARGS+="--with-system-nss "
export CARGS+="--with-system-png "
export CARGS+="--with-system-pixman "
export CARGS+="--with-system-webp "
export CARGS+="--with-system-zlib "
export CARGS+="--with-clang-path=/usr/bin/clang "
export CARGS+="--with-libclang-path=/usr/lib "
# Configure source
../mach configure --prefix=/usr $CARGS $CXARGS --enable-optimize="$CFLAGS -O2"
# Build!
../mach build
# Install!
sudo -E DESTDIR=$BUILD ../mach install
sudo install -m755 -dv $BUILD/usr/share/applications
sudo install -m755 -dv $BUILD/usr/share/pixmaps
# Install the icons
for i in ../browser/branding/official/default*.png; do
export p=${i%.png}
p=${p##*/default}
sudo install -D -m644 $i $BUILD/usr/share/icons/hicolor/"$p"x"$p"/apps/firefox.png
done
sudo install -m644 ../browser/branding/official/default48.png \
$BUILD/usr/share/pixmaps/firefox.png
sudo install -m644 ../..files/firefox-alpine/firefox.desktop $BUILD/usr/share/applications/org.mozilla.firefox.desktop
sudo install -m644 ../..files/firefox-alpine/firefox-safe.desktop $BUILD/usr/share/applications/org.mozilla.firefox-safe.desktop
# install vendor prefs
sudo install -dv $BUILD/usr/lib/firefox/browser/defaults/preferences
cat >> /tmp/firefox-branding.js << "EOF"
// Use LANG environment variable to choose locale
pref("intl.locale.requested", "");
// Disable default browser checking.
pref("browser.shell.checkDefaultBrowser", false);
// Don't disable our bundled extensions in the application directory
pref("extensions.autoDisableScopes", 11);
pref("extensions.shownSelectionUI", true);
EOF
sudo mv /tmp/firefox-branding.js $BUILD/usr/lib/firefox/browser/defaults/preferences/firefox-branding.js
cd $BUILD && sudo -S mkdir -v ${BUILD}/install &&
cat > /tmp/slack-desc << "EOF"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
mozilla-firefox: mozilla-firefox (Mozilla Firefox Web browser)
mozilla-firefox:
mozilla-firefox: This project is a redesign of the Mozilla browser component written
mozilla-firefox: using the XUL user interface language. Firefox empowers you to
mozilla-firefox: browse faster, more safely and more efficiently than with any other
mozilla-firefox: browser.
mozilla-firefox:
mozilla-firefox: Visit the Mozilla Firefox project online:
mozilla-firefox: http://www.mozilla.org/projects/firefox/
mozilla-firefox:
mozilla-firefox:
EOF
sudo -S mv -v /tmp/slack-desc install/ &&
sudo -S makepkg -l y -c n $PKGS/mozilla-firefox-91.1.6-$(uname -m)-mlfs.txz &&
sudo -S rm -rf ${BUILD}/*