From 0fedba61449df10ad89c6355260025cddcd49738 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 14 Jun 2023 17:15:03 +0200 Subject: [PATCH] MT#57643 Ensure /var/lib/dpkg/available exists on Debian releases <=buster Since version 1.20.0, dpkg no longer creates /var/lib/dpkg/available (see #647911). Now that we upgraded our Grml-Sipwise deployment system to bookworm, we have dpkg v1.21.22 on our live system, and mmdebstrap relies on dpkg of the host system for execution. 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: | nullmailer | [...] | 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 We *could* also switch from mmdebstrap to debootstrap for deploying Debian releases <=buster, but this would be slower and we use mmdebstrap since quite some time for everything. So instead let's create /var/lib/dpkg/available after bootstrapping the system. Reported towards mmdebstrap as #1037946. Change-Id: I0a87ca255d5eb7144a9c093051c0a6a3114a3c0b --- templates/scripts/includes/deployment.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh index 8ba9d3c..83fb20f 100755 --- a/templates/scripts/includes/deployment.sh +++ b/templates/scripts/includes/deployment.sh @@ -2144,6 +2144,19 @@ if [ -d "${TARGET}/var/lib/apt/lists/auxfiles" ]; then rmdir "${TARGET}/var/lib/apt/lists/auxfiles" fi +# MT#57643: dpkg >=1.20.0 (as present on Debian/bookworm and newer) no +# longer creates /var/lib/dpkg/available (see #647911). mmdebstrap relies +# on and uses dpkg of the host system. 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, so let's +# ensure /var/lib/dpkg/available exists on Debian releases <=buster. +case "${DEBIAN_RELEASE}" in + stretch|buster) + echo "Generating /var/lib/dpkg/available to work around dpkg >=1.20.0 issue for Debian release '${DEBIAN_RELEASE}'" + chroot "${TARGET}" /usr/lib/dpkg/methods/apt/update /var/lib/dpkg + ;; +esac + # MT#7805 if "$NGCP_INSTALLER" ; then cat << EOT | augtool --root="$TARGET"