mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-20 15:27:26 +00:00
refactor: shell script simplification
This commit is contained in:
@@ -8,7 +8,6 @@ usage() {
|
|||||||
echo " -r <repository> Repository name"
|
echo " -r <repository> Repository name"
|
||||||
echo " -a <architecture> Repository architecture"
|
echo " -a <architecture> Repository architecture"
|
||||||
echo " -c <directory> Read devtools pacman configurations from this directory"
|
echo " -c <directory> Read devtools pacman configurations from this directory"
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repository=
|
repository=
|
||||||
@@ -20,12 +19,18 @@ while getopts ":r:a:c:" arg; do
|
|||||||
r) repository="$OPTARG" ;;
|
r) repository="$OPTARG" ;;
|
||||||
a) architecture="$OPTARG" ;;
|
a) architecture="$OPTARG" ;;
|
||||||
c) pacman_config_dir="$OPTARG" ;;
|
c) pacman_config_dir="$OPTARG" ;;
|
||||||
*) usage ;;
|
*) usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z $repository || -z $architecture ]]; then
|
if [[ -z $repository || -z $architecture ]]; then
|
||||||
usage
|
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
|
fi
|
||||||
|
|
||||||
source "/usr/share/devtools/lib/archroot.sh"
|
source "/usr/share/devtools/lib/archroot.sh"
|
||||||
@@ -35,13 +40,13 @@ check_root "SOURCE_DATE_EPOCH,SRCDEST,SRCPKGDEST,PKGDEST,LOGDEST,NPROC,MAKEFLAGS
|
|||||||
# here is a workaround, which uses unshare to bind-mount directory with configuration files
|
# here is a workaround, which uses unshare to bind-mount directory with configuration files
|
||||||
# for specific process
|
# for specific process
|
||||||
if [[ -n $pacman_config_dir && -z ${AHRIMAN_ARCHBUILD_MOUNTED:-} ]]; then
|
if [[ -n $pacman_config_dir && -z ${AHRIMAN_ARCHBUILD_MOUNTED:-} ]]; then
|
||||||
|
pacman_config_dir="$(readlink -e -- "$pacman_config_dir")"
|
||||||
export AHRIMAN_ARCHBUILD_MOUNTED=1
|
export AHRIMAN_ARCHBUILD_MOUNTED=1
|
||||||
exec unshare --mount --propagation private bash -e -c '
|
|
||||||
mount --bind "$0" /usr/share/devtools/pacman.conf.d
|
exec unshare --mount --propagation private \
|
||||||
exec "$@"
|
bash -c 'mount --bind -- "$0" /usr/share/devtools/pacman.conf.d && exec "$@"' \
|
||||||
' "$(readlink -f "$pacman_config_dir")" "${BASH_SOURCE[0]}" "$@"
|
"$pacman_config_dir" "${BASH_SOURCE[0]}" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec bash -c '
|
exec bash -c 'source "/usr/bin/archbuild" "$@"' \
|
||||||
source "$1" "${@:2}"
|
"${repository}-${architecture}-build" "${@:$OPTIND}"
|
||||||
' "${repository}-${architecture}-build" "archbuild" "${@:$OPTIND}"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user