repo/extra/firefox-esr/build
2020-10-21 16:41:13 +03:00

143 lines
3.9 KiB
Bash
Executable File

#!/bin/sh -e
for patch in *.patch; do
patch -p1 < "$patch"
done
# Update some crates which cause build failure with the latest
# Rust version (1.47.0). Fixes not backported to this ESR.
# This avoids patching 100 or so files which is just unreasonable.
# See: https://github.com/rust-lang/rust/issues/76482
# https://github.com/rust-lang/rust/issues/76480
# https://phabricator.services.mozilla.com/D89473
# https://hg.mozilla.org/mozilla-central/rev/281a323cde5f
# https://hg.mozilla.org/mozilla-central/rev/da77d5528a08
# https://bugzilla.mozilla.org/show_bug.cgi?id=1663715
# https://bugzilla.mozilla.org/show_bug.cgi?id=1670579
(
cd third_party/rust
for crate in *.crate; do
crate_name=${crate%-*}
crate_ver=${crate##*-}
crate_ver=${crate_ver%%.crate}
# Remove the pre-existing crate's files.
rm -rf "$crate_name"
# Add the updated crate's files.
tar xf "$crate"
# Rename <crate_name>-<crate_ver> to <crate_name>
mv -f "${crate%%.crate}" "$crate_name"
# Generate checksums.
sha256=$(sha256sum "$crate")
sha256=${sha256%% *}
# Create .cargo-checksum.json to appease tooling.
printf '{"package":"%s","files":{}}\n' "$sha256" \
> "$crate_name/.cargo-checksum.json"
# Update root Cargo.lock to reflect changes.
sed -i "/name = \"$crate_name\"/ {
N
s/version = \".*\"/version = \"$crate_ver\"/
N
N
s/checksum = \".*\"/checksum = \"$sha256\"/
}" ../../Cargo.lock
done
)
# Build autoconf 2.13 for Firefox's sole use.
# See: https://bugzilla.mozilla.org/show_bug.cgi?id=104642
(
cd autoconf2.13
./configure \
--prefix="$PWD/../junk" \
--program-suffix=-2.13
make
make install
)
# Build yasm for Firefox's sole use.
# Firefox is the only package which needs it
# and upstream is kinda dead.
(
cd yasm
./configure \
--prefix="$PWD/../junk"
make
make install
)
export PATH="$PWD/junk/bin:$PATH"
mkdir -p build
cd build
# Bypass 'ccache' as it's totally useless when building
# Firefox and only slows things down.
export CC="${CC:-/usr/bin/cc}"
export CXX="${CXX:-/usr/bin/c++}"
export LDFLAGS="$LDFLAGS -Wl,-rpath=/usr/lib/firefox"
export RUSTFLAGS="$RUSTFLAGS -Cdebuginfo=0"
export MOZ_DEBUG_FLAGS=-g0
export MOZ_NOSPAM=1
../configure \
--prefix=/usr \
--libdir=/usr/lib \
--enable-official-branding \
--enable-optimize="$CFLAGS -w" \
--enable-install-strip \
--enable-strip \
--enable-rust-simd \
--enable-application=browser \
--enable-release \
--enable-alsa \
--without-system-nspr \
--without-system-nss \
--with-system-jpeg \
--with-system-zlib \
--with-system-png \
--without-system-libvpx \
--with-system-pixman \
--with-system-ffi \
--disable-profiling \
--disable-accessibility \
--disable-tests \
--disable-system-extension-dirs \
--disable-parental-controls \
--disable-debug-symbols \
--disable-callgrind \
--disable-vtune \
--disable-elf-hack \
--disable-gold \
--disable-jemalloc \
--disable-pulseaudio \
--disable-crashreporter \
--disable-updater \
--disable-dbus \
--disable-eme \
--disable-necko-wifi
make
make DESTDIR="$1" install
# Remove a lot of uneeded "stuff".
rm -rf "$1/usr/include"
rm -rf "$1/usr/lib/firefox-devel"
rm -rf "$1/usr/share/idl"
rm -rf "$1/usr/lib/firefox/gtk2" # Drop GTK+2 runtime dependency.
rm -f "$1/usr/lib/firefox/browser/features/fxmonitor@mozilla.org.xpi"
rm -f "$1/usr/lib/firefox/browser/features/screenshots@mozilla.org.xpi"
rm -f "$1/usr/lib/firefox/browser/features/webcompat-reporter@mozilla.org.xpi"
rm -f "$1/usr/lib/firefox/browser/features/webcompat@mozilla.org.xpi"
rm -f "$1/usr/lib/firefox/browser/features/doh-rollout@mozilla.org.xpi"