* apt-pkg/packagemanager.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 30 Aug 2012 10:21:32 +0000 (12:21 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 30 Aug 2012 10:21:32 +0000 (12:21 +0200)
  - 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
debian/changelog
test/integration/framework
test/integration/test-unpack-different-version-unpacked [new file with mode: 0755]

index b93bf6a..d2d2753 100644 (file)
@@ -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) {
index b048678..8400336 100644 (file)
@@ -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 <kalnischkies@gmail.com>  Sun, 26 Aug 2012 10:49:17 +0200
+
 apt (0.9.7.4) unstable; urgency=low
 
   [ Manpages translation updates ]
index da85d23..05878d0 100644 (file)
@@ -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 (executable)
index 0000000..952f6e6
--- /dev/null
@@ -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