mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-20 15:27:26 +00:00
53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
local cmd="${0##*/}"
|
|
echo "Usage: $cmd [options] -- [archbuild args]"
|
|
echo " -r <repository> Repository name"
|
|
echo " -a <architecture> Repository architecture"
|
|
echo " -c <directory> Read devtools pacman configurations from this directory"
|
|
}
|
|
|
|
repository=
|
|
architecture=
|
|
pacman_config_dir=
|
|
|
|
while getopts ":r:a:c:" arg; do
|
|
case "$arg" in
|
|
r) repository="$OPTARG" ;;
|
|
a) architecture="$OPTARG" ;;
|
|
c) pacman_config_dir="$OPTARG" ;;
|
|
*) usage >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $repository || -z $architecture ]]; then
|
|
usage >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n $pacman_config_dir && ! -d $pacman_config_dir ]]; then
|
|
echo "devtools configuration directory does not exist: $pacman_config_dir" >&2
|
|
exit 1
|
|
fi
|
|
|
|
source "/usr/share/devtools/lib/archroot.sh"
|
|
check_root "SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,NPROC,MAKEFLAGS,PACKAGER,GNUPGHOME" "${BASH_SOURCE[0]}" "$@"
|
|
|
|
# because devtools doesn't allow to read configuration from custom path
|
|
# here is a workaround, which uses unshare to bind-mount directory with configuration files
|
|
# for specific process
|
|
if [[ -n $pacman_config_dir && -z ${AHRIMAN_ARCHBUILD_MOUNTED:-} ]]; then
|
|
pacman_config_dir="$(readlink -e -- "$pacman_config_dir")"
|
|
export AHRIMAN_ARCHBUILD_MOUNTED=1
|
|
|
|
exec unshare --mount --propagation private \
|
|
bash -c 'mount --bind -- "$0" /usr/share/devtools/pacman.conf.d && exec "$@"' \
|
|
"$pacman_config_dir" "${BASH_SOURCE[0]}" "$@"
|
|
fi
|
|
|
|
exec bash -c 'source "/usr/bin/archbuild" "$@"' \
|
|
"${repository}-${architecture}-build" "${@:$OPTIND}"
|