Merge remote-tracking branch 'origin/github/pr/145'
[grml-live.git] / etc / grml / fai / config / hooks / instsoft.GRMLBASE
index f5c22d8..2c4a880 100755 (executable)
@@ -55,18 +55,24 @@ EOF
      $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 ! $ROOTCMD test -x /usr/bin/aptitude ; then
-      $ROOTCMD apt-get -y install aptitude
+     # the apt-get update might return an error if there's for example
+     # a hashsum mismatch on Debian mirror sources, we might want to continue
+     # but should warn the user
+     if ! $ROOTCMD apt-get update ; then
+       echo "Warning: there was an error executing apt-get update, continuing anyway."
+       echo "Warning: there was an error executing apt-get update, continuing anyway." >&2
+     fi
+
+     $ROOTCMD apt-get -y install aptitude
    fi
 
-   # newer aptitude versions won't remove essential packages using
-   # 'aptitude -f -y install file-rc' anymore, therefore force it:
-   $ROOTCMD aptitude -o Aptitude::ProblemResolver::Keep-All-Tier=60000 -f -y install file-rc
-
    # make sure we can upgrade automatically,
    # even with unsigned repos, but only if user wants it
    if [ "${FAI_ALLOW_UNSIGNED:-}" = "1" ] ; then
@@ -109,18 +115,6 @@ if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then
   $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe
 fi
 
-# make sure we have file-rc available before package_config/GRML* is being executed {{{
-# the apt-get update might return an error if there's for example
-# a hashsum mismatch on Debian mirror sources, we might want to continue
-# but should warn the user
-if ! $ROOTCMD apt-get update ; then
-   echo "Warning: there was an error executing apt-get update, continuing anyway."
-   echo "Warning: there was an error executing apt-get update, continuing anyway." >&2
-fi
-
-# newer aptitude versions won't remove essential packages using
-# 'aptitude -f -y install file-rc' anymore, therefore force it via:
-$ROOTCMD aptitude -o Aptitude::ProblemResolver::Keep-All-Tier=60000 -f -y install file-rc
 # }}}
 
 # we definitely don't want to fail running fai dirinstall just