Compare commits

...

1 Commits

Author SHA1 Message Date
Tyler Langlois
e79f8e588a arch-nspawn: generalize mirrorlist variable replacement
The host_mirrors value uses a sed pattern that is closely coupled with
the mirror URL pattern in-use by most Arch mirrors. For some variants,
like Arch Linux ARM, values such as $repo and $arch sit in other parts
in the mirror path. This change makes the sed replacement more generic
to accomodate for variations in mirrorlist URLs while remaining backward
compatible.
2020-11-21 21:54:41 -07:00

View File

@@ -58,17 +58,18 @@ shift 1
[[ -z $working_dir ]] && die 'Please specify a working directory.'
pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
pacconf_arch=$($pacconf_cmd architecture)
if (( ${#cache_dirs[@]} == 0 )); then
mapfile -t cache_dirs < <($pacconf_cmd --config "${pac_conf:-$working_dir/etc/pacman.conf}" CacheDir)
fi
# shellcheck disable=2016
host_mirrors=($($pacconf_cmd --repo extra Server 2> /dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#'))
host_mirrors=($($pacconf_cmd --repo extra Server 2> /dev/null | sed -r 's#'"${pacconf_arch}"'#$arch#;s#extra#$repo#'))
for host_mirror in "${host_mirrors[@]}"; do
if [[ $host_mirror == *file://* ]]; then
host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
host_mirror=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo[/.]*#\1#g')
for m in "$host_mirror"/pool/*/; do
in_array "$m" "${cache_dirs[@]}" || cache_dirs+=("$m")
done