[devtools,1/1] arch-nspawn: get mirror url from chroot's pacman.conf

Message ID 20170714100450.5223-1-list@eworm.de
State Superseded
Headers show
Series [devtools,1/1] arch-nspawn: get mirror url from chroot's pacman.conf | expand

Commit Message

Christian Hesse July 14, 2017, 10:04 a.m. UTC
From: Christian Hesse <mail@eworm.de>

My system has a mirror configuration where only the host can access a
special url from pacman.conf but chroots and containers fail.

Instead of host's pacman.conf use $pac_conf or pacman.conf from chroot.
This still uses host's /etc/pacman.d/mirrorlist and should achieve the
expected results.

Signed-off-by: Christian Hesse <mail@eworm.de>
---
 arch-nspawn.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Hesse July 14, 2017, 7:12 p.m. UTC | #1
Christian Hesse <list@eworm.de> on Fri, 2017/07/14 12:04:
> From: Christian Hesse <mail@eworm.de>
> 
> My system has a mirror configuration where only the host can access a
> special url from pacman.conf but chroots and containers fail.
> 
> Instead of host's pacman.conf use $pac_conf or pacman.conf from chroot.
> This still uses host's /etc/pacman.d/mirrorlist and should achieve the
> expected results.

Oh, this breaks if the chroot has repositories configured that the host does
not have. *sigh*
Luke Shumaker July 14, 2017, 11:10 p.m. UTC | #2
On Fri, 14 Jul 2017 06:04:50 -0400,
Christian Hesse wrote:
> -host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
> +host_mirror=$(pacman --config "${pac_conf:-$working_dir/etc/pacman.conf}" --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | 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')

While we're at it: what is the point of setting host_mirror anyway?
I've had users complain about it causing problems like this and
others.
Emil Velikov via arch-projects July 15, 2017, 9:46 a.m. UTC | #3
On Sat, Jul 15, 2017, 01:10 Luke Shumaker <lukeshu@lukeshu.com> wrote:

> On Fri, 14 Jul 2017 06:04:50 -0400,
> Christian Hesse wrote:
> > -host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools
> 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
> > +host_mirror=$(pacman --config
> "${pac_conf:-$working_dir/etc/pacman.conf}" --cachedir /doesnt/exist -Sddp
> extra/devtools 2>/dev/null | 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')
>
> While we're at it: what is the point of setting host_mirror anyway?
> I've had users complain about it causing problems like this and
> others.
>

Our build server also hosts a compete rsync'ed mirror, so the first server
in the mirrorlist has a file:// URL, while additional cache dirs point into
the mirror package pool.

>
<div class="gmail_quote"><div dir="ltr">On Sat, Jul 15, 2017, 01:10 Luke Shumaker &lt;<a href="mailto:lukeshu@lukeshu.com">lukeshu@lukeshu.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 14 Jul 2017 06:04:50 -0400,<br>
Christian Hesse wrote:<br>
&gt; -host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2&gt;/dev/null | sed -r &#39;s#(.*/)extra/os/.*#\1$repo/os/$arch#&#39;)<br>
&gt; +host_mirror=$(pacman --config &quot;${pac_conf:-$working_dir/etc/pacman.conf}&quot; --cachedir /doesnt/exist -Sddp extra/devtools 2&gt;/dev/null | sed -r &#39;s#(.*/)extra/os/.*#\1$repo/os/$arch#&#39;)<br>
&gt;  # shellcheck disable=2016<br>
&gt;  [[ $host_mirror == *file://* ]] &amp;&amp; host_mirror_path=$(echo &quot;$host_mirror&quot; | sed -r &#39;s#file://(/.*)/\$repo/os/\$arch#\1#g&#39;)<br>
<br>
While we&#39;re at it: what is the point of setting host_mirror anyway?<br>
I&#39;ve had users complain about it causing problems like this and<br>
others.<br></blockquote></div><div><br></div><div>Our build server also hosts a compete rsync&#39;ed mirror, so the first server in the mirrorlist has a file:// URL, while additional cache dirs point into the mirror package pool.</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div>

Patch

diff --git a/arch-nspawn.in b/arch-nspawn.in
index c21b2ce..ffc7267 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -59,7 +59,7 @@  else
 fi
 
 # shellcheck disable=2016
-host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
+host_mirror=$(pacman --config "${pac_conf:-$working_dir/etc/pacman.conf}" --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | 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')