135 lines
3.2 KiB
Bash
Executable file
135 lines
3.2 KiB
Bash
Executable file
#!/bin/sh -e
|
|
|
|
# clean self and do not pass through any environment
|
|
# except path/home, because it doesn't matter too much for this specific purpose,
|
|
# and home is required
|
|
# and a few that are useful to keep some cache paths
|
|
if [ -z "$_CLEAN" ]; then
|
|
exec env -i \
|
|
_CLEAN=1 \
|
|
HOME="$HOME" \
|
|
PATH="$PATH" \
|
|
USER="$USER" \
|
|
TERM="xterm" \
|
|
${CARGO_HOME:+CARGO_HOME="$CARGO_HOME"} \
|
|
${CBUILD:+CBUILD="$CBUILD"} \
|
|
${GNUPGHOME:+GNUPGHOME="$GNUPGHOME"} \
|
|
${GOCACHE:+GOCACHE="$GOCACHE"} \
|
|
${GOMODCACHE:+GOMODCACHE="$GOMODCACHE"} \
|
|
${GOPATH:+GOPATH="$GOPATH"} \
|
|
${GOTMPDIR:+GOTMPDIR="$GOTMPDIR"} \
|
|
${XDG_CACHE_HOME:+XDG_CACHE_HOME="$XDG_CACHE_HOME"} \
|
|
${XDG_CONFIG_HOME:+XDG_CONFIG_HOME="$XDG_CONFIG_HOME"} \
|
|
${DISTFILES_MIRROR:+DISTFILES_MIRROR="$DISTFILES_MIRROR"} \
|
|
${mirror:+mirror="$mirror"} \
|
|
"$0" "$@"
|
|
fi
|
|
|
|
while getopts "j:fhmnsx" opt; do
|
|
case "$opt" in
|
|
'j')
|
|
jobs="$OPTARG"
|
|
export JOBS="$jobs"
|
|
export MAKEFLAGS="-j$jobs"
|
|
export SAMUFLAGS="-j$jobs"
|
|
export CARGO_BUILD_JOBS="$jobs"
|
|
;;
|
|
'f')
|
|
# also run checksum/checkapk
|
|
full=1
|
|
;;
|
|
'h')
|
|
fsynchack=1
|
|
;;
|
|
'm')
|
|
# don't set LD_PRELOAD for another alloc
|
|
# since i set this normally, this unexports it.
|
|
# XXX: funnily, any extra alloc breaks gjs-based testsuites (why?)
|
|
nomemhack=1
|
|
unset LD_PRELOAD
|
|
;;
|
|
'n')
|
|
nonice=1
|
|
;;
|
|
's')
|
|
nosccache=1
|
|
;;
|
|
'x')
|
|
# skip checks
|
|
export ABUILD_BOOTSTRAP=1
|
|
;;
|
|
*)
|
|
echo "invalid argument passed"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift "$((OPTIND - 1))"
|
|
|
|
# loop again to check if rootbld
|
|
for arg; do
|
|
if eltest "$arg" =~ "rootbld"; then
|
|
rootbld=1
|
|
fi
|
|
done
|
|
|
|
# always prevent installing all the firmware for no reason
|
|
extra="linux-firmware-none"
|
|
|
|
if [ -n "$rootbld" ]; then
|
|
if [ -n "$fsynchack" ]; then
|
|
# in rootbld, should be safe to skip fsync
|
|
extra="$extra libeatmydata"
|
|
export LD_PRELOAD="$LD_PRELOAD /usr/lib/libeatmydata.so"
|
|
fi
|
|
else
|
|
if [ -z "$nosccache" ]; then
|
|
# not rootbld use sccache
|
|
# TODO: maybe we can mount something into rootbld without patches
|
|
extra="$extra sccache"
|
|
export RUSTC_WRAPPER=sccache
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$nomemhack" ]; then
|
|
extra="$extra scudo-malloc"
|
|
export LD_PRELOAD="$LD_PRELOAD /usr/lib/libscudo.so"
|
|
fi
|
|
|
|
if [ -z "$nonice" ]; then
|
|
# max bg idle
|
|
# note that there is no nice here,
|
|
# but nice is mostly useless with modern linux process groups.
|
|
# (and this is in its' own by virtue of a new terminal)
|
|
nicewrap="chrt -i 0 ionice -c 2 -n 7"
|
|
fi
|
|
|
|
root="$(git rev-parse --show-toplevel)"
|
|
|
|
if [ -n "$root" ]; then
|
|
# abuild cannot detect the root dir to get .rootbld-repositories
|
|
# to work, unless the dir has aports in git remotes or is ~/aports
|
|
# ...
|
|
export APORTSDIR="$root"
|
|
fi
|
|
|
|
export EXTRADEPENDS_BUILD="$extra pigz xz"
|
|
|
|
# ignore user gitconfig always
|
|
export GIT_CONFIG_GLOBAL="$(mktemp)"
|
|
|
|
trap 'rm -f "$GIT_CONFIG_GLOBAL"' EXIT INT TERM HUP
|
|
|
|
if [ -n "$full" ]; then
|
|
abuild checksum
|
|
fi
|
|
|
|
$nicewrap abuild -fr "$@"
|
|
|
|
if [ -n "$full" ]; then
|
|
checkapk
|
|
abuild sanitycheck
|
|
apkbuild-shellcheck || true
|
|
apkbuild-anitya || true
|
|
fi
|