Skip to content

Instantly share code, notes, and snippets.

@ptrcnull
Last active June 1, 2026 13:11
Show Gist options
  • Select an option

  • Save ptrcnull/30a39be0fb8748d91e07943510aaac47 to your computer and use it in GitHub Desktop.

Select an option

Save ptrcnull/30a39be0fb8748d91e07943510aaac47 to your computer and use it in GitHub Desktop.
Build Firefox with Alpine config/patches in gecko-dev
#!/bin/sh
# for lto
ulimit -n 4096
# can't be set here and fail
unset RUSTFLAGS
_mozappdir=/usr/lib/firefox-nightly
_clear_vendor_checksums() {
sed -i 's/\("files":{\)[^}]*/\1/' third_party/rust/$1/.cargo-checksum.json
if [ -f comm/third_party/rust/$1/.cargo-checksum.json ]; then
sed -i 's/\("files":{\)[^}]*/\1/' comm/third_party/rust/$1/.cargo-checksum.json
fi
}
_clear_vendor_checksums audio_thread_priority
_clear_vendor_checksums libc
_clear_vendor_checksums cc
export LDFLAGS="$LDFLAGS -Wl,--thinlto-jobs=16"
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="$PWD"/.mozbuild
export MOZ_MAKE_FLAGS="-j$(nproc)"
# allow unsigned addons for dev-edition
export MOZ_REQUIRE_SIGNING=
# disable desktop notifications
export MOZ_NOSPAM=1
# Find our triplet JSON
export RUST_TARGET="x86_64-alpine-linux-musl"
# set rpath so linker finds the libs
export LDFLAGS="$LDFLAGS -Wl,-rpath,$_mozappdir"
# awawa
export PATH="/usr/lib/llvm18/bin:$PATH"
# 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")"
export MOZCONFIG=aports-mozconfig
export PATH="/usr/lib/ccache/bin:$PATH"
export RUSTC_WRAPPER=sccache
exec ./mach "$@"
#!/bin/sh
for patch in ~/aports/community/firefox/*.patch; do
patch -p1 < "$patch" && git commit -am "$patch" || { echo "PATCH DID NOT APPLY: $patch" && git reset --hard };
done
ln -vf ~/aports/community/firefox/mozconfig aports-mozconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment