ptrcports/abr/abr

108 lines
2.5 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" \
${CARGO_HOME:+CARGO_HOME="$CARGO_HOME"} \
${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"} \
"$0" "$@"
fi
while getopts "j:fmnsx" 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
;;
'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"
;;
esac
done
shift "$((OPTIND - 1))"
# loop again to check if rootbld
for arg; do
if eltest "$arg" =~ "rootbld" || [ -n "$nosccache" ]; then
# pointless in rootbld
# TODO: maybe we can mount something into rootbld without patches
:
else
extra="$extra sccache"
export RUSTC_WRAPPER=sccache
fi
done
if [ -z "$nomemhack" ]; then
extra="$extra scudo-malloc"
export 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"
if [ -n "$full" ]; then
abuild checksum
fi
$nicewrap abuild -fr "$@"
if [ -n "$full" ]; then
checkapk
abuild sanitycheck
apkbuild-shellcheck
apkbuild-anitya
fi