From 3498fbedafbf30e5c91deeaefa6a60d1e387593a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 31 Aug 2022 21:49:33 +0200 Subject: Avoid dealing with a fake dpkg stanza in the tests We needed a fake dpkg in our status file for dpkg --assert-multi-arch to work in the past, but recent dpkg versions do not require this anymore, so we can remove this somewhat surprising hackery in favour of better hidden hackery we only use if we work with an older dpkg (e.g. on current Debian stable). --- test/integration/framework | 60 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'test/integration/framework') diff --git a/test/integration/framework b/test/integration/framework index 8bb8c00d6..5e1e68a98 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -473,10 +473,56 @@ if [ -r '${TMPWORKINGDIRECTORY}/noopchroot.so' ]; then export LD_PRELOAD="noopchroot.so" fi fi +EXEC='exec' EOF cp "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/gdb-dpkg" + local DPKG_VERSION="$(command dpkg-query --showformat '${VERSION}' --show dpkg)" + if command dpkg --compare-versions "${DPKG_VERSION}" '<<' '1.21.0'; then + cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" </dev/null 2>&1; then + EXEC='' + ORIGINAL="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" + BACKUP="${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status.apt-backup" + restoredpkgstatus() { + if [ -n "\$BACKUP" ]; then + if [ -e "\$BACKUP" ]; then + mv -f "\$BACKUP" "\$ORIGINAL" + else + rm -f "\$ORIGINAL" + fi + BACKUP='' + fi + } + trap "restoredpkgstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM + if [ -e "\$ORIGINAL" ]; then + cp -a "\$ORIGINAL" "\$BACKUP" + fi + cat >> "${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status" << EOS + +Package: dpkg +Architecture: all +Version: ${DPKG_VERSION}+fake +Status: install ok installed +Maintainer: Joe Sixpack +Installed-Size: 42 +Description: tells dpkg it supports what we need + Some versions of dpkg check its own version from the status file + to know if it supports multi-arch and stuff in --assert-*. + +EOS +fi +EOF + fi cat >> "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" < rootdir/etc/apt/apt.conf.d/99dpkg { - if ! command dpkg --assert-multi-arch >/dev/null 2>&1; then - echo "DPKG::options:: \"--force-architecture\";" # Added to test multiarch before dpkg is ready for it… - fi echo 'quiet "0";' echo 'quiet::NoUpdate "true";' echo 'quiet::NoStatistic "true";' @@ -588,12 +631,6 @@ configdpkg() { fi fi rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg - # make sure dpkg can detect itself as capable of it - if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then - # dpkg doesn't really check the version as long as it is fully installed, - # but just to be sure we choose one above the required version - insertinstalledpackage 'dpkg' "all" '1.16.2+fake' - fi if dpkg --assert-multi-arch >/dev/null 2>&1 ; then local ARCHS="$(getarchitectures)" local DPKGARCH="$(dpkg --print-architecture)" @@ -613,6 +650,9 @@ configdpkg() { fi fi done + else + # test multiarch before dpkg is ready for it… + echo "DPKG::options:: \"--force-architecture\";" > rootdir/etc/apt/apt.conf.d/00foreigndpkg fi } -- cgit v1.2.3-70-g09d2