]> git.saurik.com Git - apt.git/commitdiff
don't perform implicit crossgrades involving M-A:same
authorDavid Kalnischkies <david@kalnischkies.de>
Wed, 23 Nov 2016 18:02:51 +0000 (19:02 +0100)
committerDavid Kalnischkies <david@kalnischkies.de>
Wed, 23 Nov 2016 23:21:35 +0000 (00:21 +0100)
dpkg stumbles over these (#844300) and we haven't dropped 'easier'
removes to be implicit and to be scheduled by dpkg by default so far
so we shouldn't push the decision in such cases to dpkg either.

apt-pkg/deb/dpkgpm.cc
test/integration/test-crossgrades

index abf91fe2a88bb1f2ebd8b9368d9e5aa6b15bf8b5..d76b59449dff268f3f9086fa731ca7f530d7c63d 100644 (file)
@@ -1525,11 +1525,30 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
            continue;
 
         auto const Grp = I->Pkg.Group();
-        size_t installedInstances = 0;
+        size_t installedInstances = 0, wannabeInstances = 0;
+        bool multiArchInstances = false;
         for (auto Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
-           if (Pkg->CurrentVer != 0 || Cache[Pkg].Install())
+        {
+           if (Pkg->CurrentVer != 0)
+           {
               ++installedInstances;
-        if (installedInstances == 2)
+              if (Cache[Pkg].Delete() == false)
+                 ++wannabeInstances;
+           }
+           else if (PackageOps.find(Pkg.FullName()) != PackageOps.end())
+              ++wannabeInstances;
+           if (multiArchInstances == false)
+           {
+              auto const V = Cache[Pkg].InstVerIter(Cache);
+              if (V.end() == false && (Pkg->CurrentVer == 0 || V != Pkg.CurrentVer()))
+                 multiArchInstances = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same);
+           }
+        }
+        /* theoretically the installed check would be enough as some wannabe will
+           be first and hence be the crossgrade we were looking for, but #844300
+           prevents this so we keep these situations explicit removes.
+           It is also the reason why neither of them can be a M-A:same package */
+        if (installedInstances == 1 && wannabeInstances == 1 && multiArchInstances == false)
         {
            auto const FirstInstall = std::find_if_not(I, List.end(),
                  [](Item const &i) { return i.Op == Item::Remove || i.Op == Item::Purge; });
index 30195d30f1c6c4403bb5456e88bb3ec4deeb09d9..6398e7e7ffb863a1f38f39089d0760158859b393 100755 (executable)
@@ -26,8 +26,24 @@ singleinstance() {
        testdpkgnotinstalled 'crosser:i386' 'unrelated'
        testdpkginstalled 'crosser:amd64'
 
-       testsuccess apt purge crosser:amd64 -y --planner $1
-       testdpkgnotinstalled 'crosser:amd64'
+       testsuccess apt install crosser:armel=3 -y -o Debug::pkgDpkgPm=1 -o Dpkg::Use-Pty=0 --purge --planner $1
+       cp -a rootdir/tmp/testsuccess.output crosser.output
+       testsuccess grep -- '--remove.*crosser.*' crosser.output
+       testsuccess grep -- '--purge' crosser.output
+       testsuccess apt install crosser:armel=3 -y -o Debug::pkgDPkgProgressReporting=1 -o Dpkg::Use-Pty=0 --purge --planner $1
+       testdpkgnotinstalled 'crosser:i386' 'crosser:amd64' 'unrelated'
+       testdpkginstalled 'crosser:armel'
+
+       testsuccess apt install crosser=1 -y -o Debug::pkgDpkgPm=1 -o Dpkg::Use-Pty=0 --purge --planner $1 --allow-downgrades
+       cp -a rootdir/tmp/testsuccess.output crosser.output
+       testsuccess grep -- '--remove.*crosser.*' crosser.output
+       testsuccess grep -- '--purge' crosser.output
+       testsuccess apt install crosser=1 -y -o Debug::pkgDPkgProgressReporting=1 -o Dpkg::Use-Pty=0 --purge --planner $1 --allow-downgrades
+       testdpkgnotinstalled 'crosser:armel' 'crosser:amd64' 'unrelated'
+       testdpkginstalled 'crosser:i386'
+
+       testsuccess apt purge crosser:i386 -y --planner $1
+       testdpkgnotinstalled 'crosser:i386'
 }
 singleinstance 'internal'
 singleinstance 'apt'
@@ -52,7 +68,15 @@ multiinstance() {
        testdpkgnotinstalled 'crosser:amd64' 'unrelated'
        testdpkginstalled 'crosser:i386' 'crosser:armel'
 
-       testsuccess apt purge crosser:i386 crosser:armel -y --planner $1
-       testdpkgnotinstalled 'crosser:i386' 'crosser:armel' 'unrelated'
+       testsuccess apt install crosser:i386- crosser:armel=1 -y -o Debug::pkgDpkgPm=1 -o Dpkg::Use-Pty=0 --purge --planner $1 --allow-downgrades
+       cp -a rootdir/tmp/testsuccess.output crosser.output
+       testsuccess grep -- '--remove.*crosser.*' crosser.output
+       testsuccess grep -- '--purge' crosser.output
+       testsuccess apt install crosser:i386- crosser:armel=1 -y -o Debug::pkgDPkgProgressReporting=1 -o Dpkg::Use-Pty=0 --purge --planner $1 --allow-downgrades
+       testdpkgnotinstalled 'crosser:amd64' 'crosser:i386' 'unrelated'
+       testdpkginstalled 'crosser:armel'
+
+       testsuccess apt purge crosser:armel -y --planner $1 -o Debug::pkgDPkgProgressReporting=1
+       testdpkgnotinstalled 'crosser:i386' 'crosser:armel' 'crosser:amd64' 'unrelated'
 }
 multiinstance 'internal'