summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-06-10 23:20:48 +0200
committerLevente Polyak <anthraxx@archlinux.org>2019-08-09 19:39:45 +0200
commit58374246c4e32d14354345aef516d49207881ce2 (patch)
tree0037f29930b5490404a0e3a165e3f3936d03fc45
parentf522ce2277100a147baa2656753231b14cf1f71d (diff)
downloaddevtools-58374246c4e32d14354345aef516d49207881ce2.tar.gz
devtools-58374246c4e32d14354345aef516d49207881ce2.tar.xz
Migrate pacman.conf CacheDir parsing to pacman-conf
And while we're at it, make this more consistent. Currently we unnecessarily support only one -c /path/to/cachedir option. This requires slightly more thorough handling in mkarchroot to ensure all custom cachedirs are passed on to arch-nspawn. Rework to simply forward all arguments to arch-nspawn (minus final arguments used for pacman -Sy packagelist). Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--arch-nspawn.in11
-rw-r--r--mkarchroot.in18
2 files changed, 14 insertions, 15 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index e68e2e7..3d03c91 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -35,7 +35,7 @@ while getopts 'hC:M:c:f:s' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;;
- c) cache_dir="$OPTARG" ;;
+ c) cache_dirs+=("$OPTARG") ;;
f) files+=("$OPTARG") ;;
s) nosetarch=1 ;;
h|?) usage ;;
@@ -52,13 +52,12 @@ shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.'
-if [[ -z $cache_dir ]]; then
- cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
-else
- cache_dirs=("$cache_dir")
+pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
+
+if (( ${#cache_dirs[@]} == 0 )); then
+ mapfile -t cache_dirs < <($pacconf_cmd CacheDir)
fi
-pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
# shellcheck disable=2016
host_mirrors=($($pacconf_cmd --repo extra Server 2> /dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#'))
# shellcheck disable=2016
diff --git a/mkarchroot.in b/mkarchroot.in
index a9a5a0f..9d23b60 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -16,6 +16,7 @@ m4_include(lib/archroot.sh)
working_dir=''
files=()
+nspawn_args=()
usage() {
echo "Usage: ${0##*/} [options] working-dir package-list..."
@@ -33,12 +34,14 @@ while getopts 'hC:M:c:f:s' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
M) makepkg_conf="$OPTARG" ;;
- c) cache_dir="$OPTARG" ;;
+ c) cache_dirs+=("$OPTARG") ;;
f) files+=("$OPTARG") ;;
s) nosetarch=1 ;;
h|?) usage ;;
*) error "invalid argument '%s'" "$arg"; usage ;;
esac
+ nspawn_args+=("-$arg")
+ [[ -v OPTARG ]] && nspawn_args+=("$OPTARG")
done
shift $((OPTIND - 1))
@@ -51,10 +54,10 @@ shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.'
-if [[ -z $cache_dir ]]; then
- cache_dirs=($(pacman -v "$cache_conf" 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
-else
- cache_dirs=(${cache_dir})
+pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
+
+if (( ${#cache_dirs[@]} == 0 )); then
+ mapfile -t cache_dirs < <($pacconf_cmd CacheDir)
fi
umask 0022
@@ -93,8 +96,5 @@ echo "$CHROOT_VERSION" > "$working_dir/.arch-chroot"
systemd-machine-id-setup --root="$working_dir"
exec arch-nspawn \
- ${nosetarch:+-s} \
- ${pac_conf:+-C "$pac_conf"} \
- ${makepkg_conf:+-M "$makepkg_conf"} \
- ${cache_dir:+-c "$cache_dir"} \
+ "${nspawn_args[@]}" \
"$working_dir" locale-gen