Hi!

On Wed, 2023-06-14 at 19:09:35 +0200, Johannes Schauer Marin Rodrigues wrote:
> Quoting Michael Prokop (2023-06-14 17:19:37)
> > since version 1.20.0, dpkg no longer creates /var/lib/dpkg/available (see
> > #647911).
> 
> I see that the bug talks about 1.20.0 but I've had code creating
> /var/lib/dpkg/available in mmdebstrap for a while and determined that it 
> wasn't
> necessary anymore since dpkg 1.17.11. Did you do practical tests or are you
> only basing your analysis on that bug?
> 
> I'm quite certain about the version requirement because I did tests using
> debbisect and using the suggestion below I'm able to create chroots for all of
> unstable since 2006-08-10.

So just to clarify, old and new dpkg in normal conditions works fine
for a long time when the available file is not present (since 1.17.11 as
you point out). The problem here as hinted at below is that apt tries to
set the package selections via «dpkg --set-selections» after having
refreshed the available file via «dpkg --merge-avail» where both these
commands fail if the available file is missing with versions earlier
than 1.20.0.

> > But on Debian releases until and including buster, dpkg fails to operate 
> > with
> > e.g. `dpkg --set-selections`, if /var/lib/dpkg/available doesn't exist:
> > 
> > | The following NEW packages will be installed:
> > | [...]
> > | debconf: delaying package configuration, since apt-utils is not installed
> > | dpkg: error: failed to open package info file '/var/lib/dpkg/available' 
> > for reading: No such file or directory
> > 
> > My workaround to work around this is to run:
> > 
> >   chroot "${TARGET}" /usr/lib/dpkg/methods/apt/update /var/lib/dpkg
> > 
> > As mmdebstrap seems to rely on dpkg of the host system, it would be
> > nice if mmdebstrap could ensure to create an environment where apt/dpkg of
> > the installed system doesn't stumble upon. :)
> 
> this already exists as a hook. :)

> Try running mmdebstrap with
> 
>     --hook-dir=/usr/share/mmdebstrap/hooks/jessie-or-older
> 
> which will unconditionally do certain things only necessary for old releases.
> 
> If you instead use
> 
>     --hook-dir=/usr/share/mmdebstrap/hooks/maybe-jessie-or-older
> 
> some detection code will only run the hook if necessary (in case you do not
> know upfront which release you are creating a chroot for).

Yeah I mentioned this also to Mika, but also encouraged him to file
this report as I think it might make sense for these hooks to be
adapted to cover up to buster out of the box.

Initially I thought that perhaps only the variants that end up with
apt installed so that it can work correctly, but given that with older
dpkg versions some of these actions will always fail, then perhaps it
makes sense to still add those unconditionally so that users do not
need to create the file manually if they use the other dpkg actions.

(Hope this clarifies things! :)

Thanks,
Guillem

Reply via email to