Hi,

Quick followup given new insights.

On Sun, Sep 24, 2023 at 05:51:47PM +0200, Helmut Grohne wrote:
> Hi Johannes,
> 
> On Sun, Sep 24, 2023 at 10:27:37AM +0200, Johannes Schauer Marin Rodrigues 
> wrote:
> > There is really not much magic. The core of it is to pass this to your
> > mmdebstrap or debvm-create invocation:
> > 
> >     --setup-hook='for f in /etc/apt/sources.list /etc/apt/sources.list.d/* 
> > /etc/apt/preferences.d/*;
> >                   do [ -e "$f" ] && { echo; sed "s| file://| copy://|" 
> > "$f"; } | tee "$1/$f" >&2; done'
> >     --hook-dir=/usr/share/mmdebstrap/hooks/file-mirror-automount
> 
> This sounds simple, but reality is a little more elaborate.
> 
> For one thing, there also is
> /usr/share/mmdebstrap/hooks/copy-host-apt-sources-and-preferences. This
> hook directory is similar but subtly different from the above setup
> hook:
>  * It does not perform the translation of file:// uris into copy://uris.

The gist is that accessing file:// URIs from within the mmdebstrap
chroot won't work out of the box. One can either turn the into copy://
URIs or use the file-mirror-automount hook to issue bind mounts for
them. According to Johannes, the latter is to be considered more
reliable.

> What seems to work is this:
> 
>     debvm-create
>         --skip=usrmerge
>       ...
>       --
>       --hook-dir=/usr/share/mmdebstrap/hooks/file-mirror-automount
>       
> --hook-dir=/usr/share/mmdebstrap/hooks/copy-host-apt-sources-and-preferences
>       --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr
>       ""
> 
> That final empty string supplies the apt sources. Does this sound about
> right? If yes, I'd like to add this as a non-flaky autopkgtest to debvm.

This is subtly wrong. The file-mirror-automount hook must come after
copy-host-apt-sources-and-preferences or it may miss URIs to mount and
it must come before maybe-merged-usr or it won't have done its job in
time. So rather use this pattern:

    debvm-create
        --skip=usrmerge
        ...
        --
        
--hook-dir=/usr/share/mmdebstrap/hooks/copy-host-apt-sources-and-preferences
        --hook-dir=/usr/share/mmdebstrap/hooks/file-mirror-automount
        --hook-dir=/usr/share/mmdebstrap/hooks/maybe-merged-usr
        ""

The sbuild autopkgtest uses something roughly like this and debvm's
autopkgtest also now use this (and actually pass that way).

Beware of one horny detail. When mmdebstrap fails resolving dependencies
(and that can happen during debci), it kills its process group as a
mechanism to get rid of its children. This works fine if your
autopkgtest does not have needs-root. If it does, this failure mode can
currently damage debci infrastructure (yes, really). So if you use this
together with needs-root, please also wrap it in "setsid -w" to keep
debci in a healthy state.

And with these instructions, I think I've also resolved #1036919!

Helmut

Reply via email to