From 58374246c4e32d14354345aef516d49207881ce2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 10 Jun 2018 17:20:48 -0400 Subject: 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 Signed-off-by: Levente Polyak --- arch-nspawn.in | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'arch-nspawn.in') 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 -- cgit v1.2.3-54-g00ecf