Skip to content
Snippets Groups Projects
Commit e79f8e58 authored by Tyler Langlois's avatar Tyler Langlois
Browse files

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.
parent aff81d34
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment