mirror of
https://github.com/dslm4515/BMLFS.git
synced 2026-01-31 07:27:41 +00:00
209 lines
8.0 KiB
Bash
209 lines
8.0 KiB
Bash
#! /bin/bash
|
|
|
|
# FireFox
|
|
# Source: https://ftp.mozilla.org/pub/firefox/releases/140.0.1/source/firefox-140.0.1.source.tar.xz
|
|
#
|
|
# $BUILD = Directory to temporarily install
|
|
# $PKGS = Directory to store built packages
|
|
#
|
|
# DEPS
|
|
# Required: Cbindgen dbus-glib GTK+3 libnotify LLVM Unzip nodejs
|
|
# Required: libarchive, PulseAudio(or alsa-lib), Python3 with SQlite,
|
|
# Recommended: ICU, libevent, libwebp, NASM
|
|
# Optional: cURL, Doxygen, FFmpeg, liboauth, OpenJDK, Valgrind, Wget
|
|
# Optional: startup-notification libpoxy Wireless-Tools
|
|
#
|
|
|
|
# NOTE: This version of Firefox can now be built without build system
|
|
# expecting Xorg support.
|
|
|
|
# TO DO:
|
|
# [ ] Update build for other architechtures
|
|
# [x] Update build with choice of simple build or optimized build -- compiles
|
|
# but produced binary segfaults
|
|
|
|
export PVER="140.0.1"
|
|
|
|
# Add missing header:
|
|
cp -v ../files/firefox140.0.1-alpine/stab.h \
|
|
toolkit/crashreporter/google-breakpad/src/
|
|
|
|
# Clear vendor checksums
|
|
for d in audio_thread_priority libc
|
|
do
|
|
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$d/.cargo-checksum.json
|
|
done
|
|
|
|
# Apply patches
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/abseil-cpp.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/bmo-1952657-no-execinfo.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/fix-fortify-system-wrappers.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/fix-rust-target.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/fix-webrtc-glibcisms.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/lfs64.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/loong0001-Enable-WebRTC-for-loongarch64.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/loong0003-Define-HWCAP_LOONGARCH_LSX_and_LASX.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/loong0004-Fix-ycbcr-chromium_types-warning.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/no-ccache-stats.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/rust-lto-thin.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/sandbox-sched_setscheduler.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/sqlite-ppc.patch
|
|
patch -Np1 -i ../patches/firefox140.0.1-alpine/widevine.patch
|
|
|
|
# Set compiler & linker flags
|
|
export CFLAGS="-fstack-clash-protection -g0 -O2 "
|
|
export CXXFLAGS="-fstack-clash-protection -g0 -O2 "
|
|
export CXXFLAGS+="-Wno-deprecated-builtins -Wno-deprecated-declarations "
|
|
export LDFLAGS="-Wl,--thinlto-jobs=2 -Wl,--threads=3 "
|
|
|
|
# Remove any rustflags set in the environment:
|
|
unset RUSTFLAGS
|
|
|
|
export MOZ_BUILD_DATE="$(date ${SOURCE_DATE_EPOCH:+ -d@${SOURCE_DATE_EPOCH}} "+%Y%m%d%H%M%S")"
|
|
|
|
# Per Alpine, set limit for LTO
|
|
ulimit -n 4096
|
|
|
|
# Setup Environment:
|
|
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=firefox
|
|
export MOZBUILD_STATE_PATH=${PWD}/mozbuild
|
|
# Per Alpine Linux, disable desktop notifications
|
|
export MOZ_NOSPAM=1
|
|
|
|
# If rust was installed:
|
|
export RUST_TARGET="x86_64-unknown-linux-musl"
|
|
# If rust was not installed, prebuilt rustc from Chimera can be used:
|
|
export RUST_TARGET="x86_64-chimera-linux-musl"
|
|
|
|
# Use GCC instead of clang, as build will fail prematurely
|
|
# due "missing" wrapped 'new' header
|
|
export CC="gcc"
|
|
export CXX="g++"
|
|
|
|
# Per Alpine Linux, set rpath so linker finds the libs
|
|
export LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib/firefox"
|
|
|
|
# let firefox do this itself.
|
|
unset CARGO_PROFILE_RELEASE_OPT_LEVEL
|
|
unset CARGO_PROFILE_RELEASE_LTO
|
|
|
|
# Per Alpine Linux, default allocator returns
|
|
# oom ( and, in turn, std::bad_alloc in clang )
|
|
# at even ~70% of host memory usage
|
|
#export LD_PRELOAD=/usr/lib/libmimalloc-insecure.so.2
|
|
# Musl built in MLFS now uses mimalloc
|
|
|
|
#mkdir -pv ${PWD}/mozbuild
|
|
#cp -v ../files/firefox140.0.1-alpine/mozconfig base-mozconfig
|
|
# Just use configure script instead for now
|
|
|
|
export CARGS="--disable-bootstrap --disable-cargo-incremental "
|
|
export CARGS+="--disable-crashreporter --disable-debug "
|
|
export CARGS+="--disable-debug-symbols --disable-install-strip "
|
|
export CARGS+="--disable-jemalloc --disable-strip --disable-tests "
|
|
export CARGS+="--disable-updater --without-wasm-sandboxed-libraries "
|
|
|
|
export CARGS+="--enable-alsa --enable-dbus --enable-libproxy "
|
|
export CARGS+="--enable-default-toolkit=cairo-gtk3-wayland "
|
|
export CARGS+="--enable-ffmpeg --enable-hardening --enable-linker=lld "
|
|
export CARGS+="--enable-necko-wifi --enable-official-branding "
|
|
export CARGS+="--enable-packed-relative-relocs --enable-pulseaudio "
|
|
export CARGS+="--enable-release --enable-update-channel=release "
|
|
|
|
export CARGS+="--enable-system-pixman --with-system-ffi --with-system-icu "
|
|
export CARGS+="--with-system-jpeg --with-system-libevent --with-system-libvpx "
|
|
export CARGS+="--with-system-nspr --with-system-nss --with-system-png "
|
|
export CARGS+="--with-system-webp --with-system-zlib "
|
|
|
|
export CARGS+="--allow-addon-sideload --prefix=/usr --libdir=/usr/lib "
|
|
export CARGS+="--with-libclang-path=/usr/lib --with-unsigned-addon-scopes=app,system "
|
|
export CARGS+="--with-distribution-id=org.mlfs "
|
|
|
|
# If rust was built successfuly, set the host & target
|
|
export CARGS+="--host=x86_64-unknown-linux-musl --target=x86_64-unknown-linux-musl "
|
|
|
|
# If rust could not be installed, prebuilt rustc from Chimera can be used:
|
|
export CARGS+="--host=x86_64-chimera-linux-musl --target=x86_64-chimera-linux-musl "
|
|
|
|
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
|
|
./mach configure --enable-optimize="$CFLAGS" $CARGS
|
|
|
|
# Build
|
|
./mach build
|
|
|
|
# Install to stage area
|
|
sudo -E DESTDIR=$BUILD ./mach install
|
|
sudo install -m755 -dv $BUILD/usr/share/applications
|
|
sudo install -m755 -dv $BUILD/usr/share/pixmaps
|
|
|
|
# Fix link
|
|
sudo rm -v $BUILD/usr/bin/firefox
|
|
sudo ln -sv ../../usr/lib/firefox/firefox $BUILD/usr/bin/firefox
|
|
|
|
# Add vendor preferences, per ALine Linux
|
|
sudo install -m755 -dv $BUILD/usr/lib/firefox/browser/defaults/preferences
|
|
sudo cp -va ../files/firefox140.0.1-alpine/vendor-prefs.js \
|
|
$BUILD/usr/lib/firefox/browser/defaults/preferences/
|
|
|
|
# https://bugzilla.mozilla.org/show_bug.cgi?id=658850
|
|
# Remove duplicate binary
|
|
sudo rm -v $BUILD/usr/lib/firefox/firefox-bin
|
|
sudo ln -sv firefox $BUILD/usr/lib/firefox/firefox-bin
|
|
|
|
# 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
|
|
|
|
# Create desktop launch file
|
|
cat > /tmp/org.mozilla.firefox.desktop << EOF
|
|
[Desktop Entry]
|
|
Encoding=UTF-8
|
|
Name=Firefox Web Browser
|
|
Comment=Browse the World Wide Web
|
|
GenericName=Web Browser
|
|
Exec=firefox %u
|
|
Terminal=false
|
|
Type=Application
|
|
Icon=firefox
|
|
Categories=GNOME;GTK;Network;WebBrowser;
|
|
MimeType=$MIMETYPE
|
|
StartupNotify=true
|
|
EOF
|
|
sudo mv /tmp/org.mozilla.firefox.desktop $BUILD/usr/share/applications/
|
|
|
|
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-$PVER-$PSUFFIX &&
|
|
sudo -S rm -rf ${BUILD}/*
|