Rebuild /var/lib/dpkg/available to install not-yet-installed packages in update runs
authorMichael Prokop <mika@grml.org>
Tue, 10 Sep 2019 09:05:05 +0000 (11:05 +0200)
committerMichael Prokop <mika@grml.org>
Tue, 10 Sep 2019 09:48:52 +0000 (11:48 +0200)
When executing grml-live in update mode (grml-live [...] -u) using an
existing grml_chroot, then script GRMLBASE/98-clean-chroot has emptied
/var/lib/dpkg/available in a previous run already.

Executing `apt-get update` does NOT re-generate the file. This leads to
FAI's install_packages with its mkpackagelist() and clean_pkg_list()
failing to install requested packages, but reporting all packages with:

| WARNING: These unknown packages are removed from the installation list: [...]

This is unexpected, as an update run shouldn't just update existing
packages, but also try to install any additionally requested packages
from the software selection (as a package might not have been installed
due to missing dependencies, that have been taken care of in the
meanwhile).

So if we'd detect an existing /var/lib/dpkg/available that is empty,
then we would have to rebuild it using /usr/lib/dpkg/methods/apt/update.
Since /usr/lib/dpkg/methods/apt/update essentially also executes
'apt-get update' underneath, there's no need to run 'apt-get update'
only with empty /var/lib/dpkg/available, instead let's always rely on
/usr/lib/dpkg/methods/apt/update.

etc/grml/fai/config/hooks/instsoft.GRMLBASE

index eb0204a..c9932d8 100755 (executable)
@@ -60,9 +60,11 @@ EOF
      $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe
    fi
 
      $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe
    fi
 
-   # Update package lists (so they exist at all), so we actually can
-   # install software.
-   $ROOTCMD apt-get update
+   # Update package lists (so they exist at all), so we can install
+   # software; if /var/lib/dpkg/available is empty, it was was probably
+   # cleaned by GRMLBASE/98-clean-chroot, so we need to rebuild it
+   # anyway
+   $ROOTCMD /usr/lib/dpkg/methods/apt/update /var/lib/dpkg/ apt apt
 
   if $FILE_RC ; then
     echo "Installing file-rc as FILE_RC class is enabled."
 
   if $FILE_RC ; then
     echo "Installing file-rc as FILE_RC class is enabled."