[arch-projects] [devtools] [PATCH 2/2] Proper fix for pacman-git returning file urls from the cache
Eli Schwartz
eschwartz at archlinux.org
Tue Jan 23 13:57:33 UTC 2018
It is much nicer to use a proper configuration parser to retrieve the
primary mirror, rather than clever hacks using undocumented APIs,
especially when their behavior as used then breaks in later releases.
Fortunately, pacutils exists now and pacconf handles this quite
elegantly. It has since been moved to pacman-git proper.
Check if pacman-conf from a new enough version of pacman exists and
fallback on pacconf from pacutils.
Signed-off-by: Eli Schwartz <eschwartz at archlinux.org>
---
arch-nspawn.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch-nspawn.in b/arch-nspawn.in
index 50ce674..b9c846e 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -58,8 +58,9 @@ else
cache_dirs=("$cache_dir")
fi
+pacconf_cmd=$(command -v pacman-conf || command -v pacconf)
# shellcheck disable=2016
-host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
+host_mirror=$($pacconf_cmd --repo extra Server 2> /dev/null | head -1 | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
# shellcheck disable=2016
[[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
--
2.16.1
More information about the arch-projects
mailing list