]> git.saurik.com Git - apt.git/commitdiff
Fix bug where the problemresolve can put a pkg into a heisenstate
authorMichael Vogt <mvo@ubuntu.com>
Tue, 15 Mar 2016 12:13:54 +0000 (13:13 +0100)
committerJulian Andres Klode <jak@debian.org>
Tue, 15 Mar 2016 17:55:02 +0000 (18:55 +0100)
The problemresolver will set the candidate version for pkg P back
to the current version if it encounters an impossible to satisfy
critical dependency on P. However it did not set the State of
the package back as well which lead to a situation where P is
neither in Keep,Install,Upgrade,Delete state.

Note that this can not be tested via the traditional sh based
framework. I added a python-apt based test for this.

LP: #1550741

[jak@debian.org: Make the test not fail if apt_pkg cannot be
 imported]

.travis.yml
apt-pkg/depcache.cc
debian/tests/control
test/integration/framework
test/integration/test-bug-lp1550741-heisestate [new file with mode: 0755]

index 75de61756f7a107419b63c3631e83c181f0e4991..a076d3e4c82ee0e15eb721d4eb2426d0cb1dab9b 100644 (file)
@@ -8,7 +8,7 @@ before_install:
  - sudo apt-get update -qq
 install:
  - sudo ./prepare-release travis-ci
  - sudo apt-get update -qq
 install:
  - sudo ./prepare-release travis-ci
- - sudo apt-get -qq -y -t wily install gettext liblz4-dev
+ - sudo apt-get -qq -y -t wily install gettext liblz4-dev python3-apt
  - make
 script:
  - make test
  - make
 script:
  - make test
index 8281949f97c5e776030a018d7bd44f2ae6958d5f..dd18305d24cde038c2fbd09671cf4da1a0472cc5 100644 (file)
@@ -1421,7 +1421,12 @@ bool pkgDepCache::IsInstallOkDependenciesSatisfiableByCandidates(PkgIterator con
         // the dependency is critical, but can't be installed, so discard the candidate
         // as the problemresolver will trip over it otherwise trying to install it (#735967)
         if (Pkg->CurrentVer != 0 && (PkgState[Pkg->ID].iFlags & Protected) != Protected)
         // the dependency is critical, but can't be installed, so discard the candidate
         // as the problemresolver will trip over it otherwise trying to install it (#735967)
         if (Pkg->CurrentVer != 0 && (PkgState[Pkg->ID].iFlags & Protected) != Protected)
+         {
            SetCandidateVersion(Pkg.CurrentVer());
            SetCandidateVersion(Pkg.CurrentVer());
+            StateCache &State = PkgState[Pkg->ID];
+            State.Mode = ModeKeep;
+            State.Update(Pkg, *this);
+         }
         return false;
       }
    }
         return false;
       }
    }
index 503fa9d30c19573ad07a5fcab3a096a42b5d3094..406679d371f2c51af86dbd2a45303a96917fc4e2 100644 (file)
@@ -1,4 +1,4 @@
 Tests: run-tests
 Restrictions: allow-stderr
 Depends: @, @builddeps@, fakeroot, wget, stunnel4, lsof, db-util, gnupg, gnupg2,
 Tests: run-tests
 Restrictions: allow-stderr
 Depends: @, @builddeps@, fakeroot, wget, stunnel4, lsof, db-util, gnupg, gnupg2,
-         libfile-fcntllock-perl
+         libfile-fcntllock-perl, python3-apt
index b65b0b86ff317af0f8680d6a9a633008a814c1fe..a1db232e9c7266f7f4e62201099f73cfb91be2af 100644 (file)
@@ -175,6 +175,7 @@ runapt() {
        esac
        MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" "$CMD" "$@"
 }
        esac
        MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH="${LIBRARYPATH}:${LD_LIBRARY_PATH}" "$CMD" "$@"
 }
+runpython3() { runapt command python3 "$@"; }
 aptconfig() { runapt apt-config "$@"; }
 aptcache() { runapt apt-cache "$@"; }
 aptcdrom() { runapt apt-cdrom "$@"; }
 aptconfig() { runapt apt-config "$@"; }
 aptcache() { runapt apt-cache "$@"; }
 aptcdrom() { runapt apt-cdrom "$@"; }
diff --git a/test/integration/test-bug-lp1550741-heisestate b/test/integration/test-bug-lp1550741-heisestate
new file mode 100755 (executable)
index 0000000..76fdcb8
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+
+setupenvironment
+configarchitecture 'amd64'
+
+insertpackage 'unstable' 'module-init-tools' 'amd64' '1.0' 'Depends: libkmod2 (= 21-1)'
+insertpackage 'unstable' 'libkmod2' 'amd64' '0.22-1'
+insertinstalledpackage 'module-init-tools' 'amd64' '0.1'
+
+setupaptarchive
+
+# this test only works if the python-apt is build against the same
+# ABI version as the apt we are testing here
+PYAPT_LIB_VER=$(runpython3 -c 'import apt_pkg;print(apt_pkg.LIB_VERSION)' 2>/dev/null || true)
+if [ ! -f $LIBRARYPATH/libapt-pkg.so.$PYAPT_LIB_VER ]; then
+    msgskip "python-apt build with the wrong library version: $PYAPT_LIB_VER"
+    exit 0
+fi
+
+# we can not test this using our normal sh tests
+cat > test.py <<EOF
+#!/usr/bin/python3
+import sys
+import apt
+def in_valid_state(pkg):
+   return (pkg.marked_keep or
+           pkg.marked_install or
+           pkg.marked_upgrade or
+           pkg.marked_delete or
+           pkg.marked_downgrade or
+           pkg.marked_reinstall)
+# main
+cache=apt.Cache()
+pkgname="module-init-tools"
+if not in_valid_state(cache[pkgname]):
+    print("the test is broken, %s should be in a valid state" % pkgname)
+    sys.exit(99)
+cache.upgrade(True)
+if not in_valid_state(cache[pkgname]):
+    print("package %s is in a heisen-state" % pkgname)
+    sys.exit(2)
+
+EOF
+testsuccess runpython3 test.py