foxgirl-linux/scripts/4_Build_Binary_Tarball.sh

103 lines
2.8 KiB
Bash
Raw Normal View History

2020-03-07 19:44:22 +01:00
#!/bin/bash
2019-07-21 07:30:19 +02:00
printf "\n\n--------------------------------------- BUILD -----------------------------------------------\n";
set -e
2019-07-21 07:30:19 +02:00
# Setup Script Variables
2020-03-28 23:18:19 +01:00
srcdir=$1;
OUTPUT_TARBALL=$2;
CI_PROJECT_DIR=${CI_PROJECT_DIR:-$(realpath $(dirname $0)/../)}
2020-08-27 14:52:05 +02:00
_SOURCE_CODE_BINARY_TARBALL_LOCATION="${srcdir}/firefox-${pkgver}/obj/dist/librewolf*.tar.bz2";
2020-03-29 01:27:47 +01:00
_MOZBUILD=$srcdir/../mozbuild
2020-03-30 21:57:33 +02:00
export DEB_BUILD_HARDENING=1
export DEB_BUILD_HARDENING_STACKPROTECTOR=1
export DEB_BUILD_HARDENING_FORTIFY=1
export DEB_BUILD_HARDENING_FORMAT=1
export DEB_BUILD_HARDENING_PIE=1
# export PATH=/usr/lib/nasm-mozilla/bin:$PATH
2020-03-29 01:27:47 +01:00
2021-08-11 11:52:43 +02:00
# add cargo binary to path
2021-08-19 22:22:59 +02:00
# source /root/.cargo/env
# we do change / unset some of them later, but setting them as set by Arch
# might make it easier to maintain changes in build scripts on both sides
if [[ $CARCH == 'aarch64' ]]; then
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt"
export CXXFLAGS="-march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
else
export CPPFLAGS="-D_FORTIFY_SOURCE=2"
export CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
export CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
fi
export MOZ_NOSPAM=1
export MOZBUILD_STATE_PATH="${_MOZBUILD}"
2020-09-30 14:04:18 +02:00
export MACH_USE_SYSTEM_PYTHON=1
2020-03-29 01:27:47 +01:00
if [[ $CARCH == 'aarch64' ]]; then
2020-03-31 11:19:50 +02:00
export MOZ_DEBUG_FLAGS=" "
export CFLAGS+=" -g0"
export CXXFLAGS+=" -g0"
export RUSTFLAGS="-Cdebuginfo=0"
2020-07-31 01:32:35 +02:00
export LDFLAGS+=" -Wl,--no-keep-memory"
2020-03-29 01:27:47 +01:00
fi
# LTO needs more open files
ulimit -n 4096
2019-07-17 22:22:03 +02:00
# Prevents build from breaking in CI/CD environments
export SHELL=/bin/bash;
2019-07-21 07:30:19 +02:00
# Changes current folder to the source code folder
2020-03-28 23:18:19 +01:00
cd $srcdir;
# Runs bootstrapper to install dependencies
# printf "\nRunning bootstrapper to install build dependencies (using ./mach script within source code)\n";
# ./mach bootstrap --application-choice=browser --no-interactive
# ./mach configure
2020-03-30 00:40:04 +02:00
rm -f mozconfig
# install cbindgen
2021-09-10 11:02:10 +02:00
cargo install --version 0.20.0 cbindgen
2020-03-29 12:20:30 +02:00
if [[ $CARCH == 'aarch64' ]]; then
2020-03-29 01:27:47 +01:00
cat >.mozconfig ${CI_PROJECT_DIR}/mozconfig - <<END
# seems to break on arm
# ac_add_options --enable-linker=gold
END
else
2020-03-29 01:27:47 +01:00
cat >.mozconfig ${CI_PROJECT_DIR}/mozconfig - <<END
# seems to mess with the libstdc++-static patch
# ac_add_options --enable-linker=gold
END
fi
./mach build
echo "Building symbol archive..."
./mach buildsymbols
# End "build()" equivalent.
2019-07-21 07:30:19 +02:00
# Packages the build into a binary tarball
printf "\nPackaging LibreWolf\n";
./mach package;
2019-07-21 07:30:19 +02:00
# Moves the packaged tarball to the specified location
printf "\nMoving Binary Tarball to output location\n";
2019-07-21 07:30:19 +02:00
mv $_SOURCE_CODE_BINARY_TARBALL_LOCATION $OUTPUT_TARBALL;
2019-07-21 07:30:19 +02:00
# Deletes the source code
printf "\nDeleting source code\n";
2020-03-28 23:18:19 +01:00
rm -rf $srcdir;