From d4b4e5ea2ceb02699e746d52256b3a8ac2d9bda2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 30 Aug 2012 12:21:32 +0200 Subject: * apt-pkg/packagemanager.cc: - unpack versions in case a different version from the package is currently in unpack state to recover from broken system states (like different file in M-A:same package and other dpkg errors) --- apt-pkg/packagemanager.cc | 4 +- debian/changelog | 10 ++ test/integration/framework | 3 +- .../test-unpack-different-version-unpacked | 121 +++++++++++++++++++++ 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100755 test/integration/test-unpack-different-version-unpacked diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index b93bf6ab9..d2d2753a8 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -882,7 +882,9 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c } } // packages which are already unpacked don't need to be unpacked again - else if (Pkg.State() != pkgCache::PkgIterator::NeedsConfigure && Install(Pkg,FileNames[Pkg->ID]) == false) + else if ((instVer != Pkg.CurrentVer() || + ((Cache[Pkg].iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall)) && + Install(Pkg,FileNames[Pkg->ID]) == false) return false; if (Immediate == true) { diff --git a/debian/changelog b/debian/changelog index b04867843..840033648 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +apt (0.9.7.5) UNRELEASED; urgency=low + + [ David Kalnischkies ] + * apt-pkg/packagemanager.cc: + - unpack versions in case a different version from the package + is currently in unpack state to recover from broken system states + (like different file in M-A:same package and other dpkg errors) + + -- David Kalnischkies Sun, 26 Aug 2012 10:49:17 +0200 + apt (0.9.7.4) unstable; urgency=low [ Manpages translation updates ] diff --git a/test/integration/framework b/test/integration/framework index da85d2332..05878d0a4 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -523,11 +523,12 @@ insertinstalledpackage() { local VERSION="$3" local DEPENDENCIES="$4" local PRIORITY="${5:-optional}" + local STATUS="${6:-install ok installed}" local FILE='rootdir/var/lib/dpkg/status' local INFO='rootdir/var/lib/dpkg/info' for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do echo "Package: $NAME -Status: install ok installed +Status: $STATUS Priority: $PRIORITY Section: other Installed-Size: 42 diff --git a/test/integration/test-unpack-different-version-unpacked b/test/integration/test-unpack-different-version-unpacked new file mode 100755 index 000000000..952f6e6b2 --- /dev/null +++ b/test/integration/test-unpack-different-version-unpacked @@ -0,0 +1,121 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +insertpackage 'unstable' 'libqtcore4' 'i386,amd64' '2' 'Multi-Arch: same' +setupaptarchive + +DPKGSTATUS='rootdir/var/lib/dpkg/status' +cp $DPKGSTATUS dpkg.status + +cleanstatus() { + cp dpkg.status $DPKGSTATUS + rm rootdir/var/cache/apt/*.bin +} + +#FIXME: the reported version is wrong, it should be 1, not 2 +insertinstalledpackage 'libqtcore4' 'i386,amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked' +testequal 'Reading package lists... +Building dependency tree... +0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded. +2 not fully installed or removed. +Conf libqtcore4 (2 unstable [amd64]) +Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked' +insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4:i386 +The following packages will be upgraded: + libqtcore4:i386 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +2 not fully installed or removed. +Inst libqtcore4:i386 [1] (2 unstable [i386]) +Conf libqtcore4:i386 (2 unstable [i386]) +Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked' +insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4 +The following packages will be upgraded: + libqtcore4 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +2 not fully installed or removed. +Inst libqtcore4 [1] (2 unstable [amd64]) +Conf libqtcore4 (2 unstable [amd64]) +Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked' +insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4:i386 +The following packages will be upgraded: + libqtcore4:i386 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +1 not fully installed or removed. +Inst libqtcore4:i386 [1] (2 unstable [i386]) +Conf libqtcore4:i386 (2 unstable [i386]) +Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked' +insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4 +The following packages will be upgraded: + libqtcore4 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +1 not fully installed or removed. +Inst libqtcore4 [1] (2 unstable [amd64]) +Conf libqtcore4 (2 unstable [amd64]) +Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' +insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4:i386 +The following packages will be upgraded: + libqtcore4:i386 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +1 not fully installed or removed. +Inst libqtcore4:i386 [1] (2 unstable [i386]) +Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f + +cleanstatus +insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' +insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked' +testequal 'Reading package lists... +Building dependency tree... +Correcting dependencies... Done +The following extra packages will be installed: + libqtcore4 +The following packages will be upgraded: + libqtcore4 +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +1 not fully installed or removed. +Inst libqtcore4 [1] (2 unstable [amd64]) +Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f -- cgit v1.2.3