From b857d586edeb3639d996a75fccd55ebea370b491 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 12 Dec 2017 21:31:35 +0100 Subject: don't auto-switch candidate if installed is good enough If we perform candidate switching in requests like "apt install foo/bar" we should first check if the dependencies of foo from release bar are already satisfied by what is already installed before checking if the candidate (or switched candidate) would. --- apt-pkg/depcache.cc | 7 +++++++ test/integration/test-release-candidate-switching | 24 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index c66ab2ded..3787106f7 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1559,6 +1559,13 @@ bool pkgDepCache::SetCandidateRelease(pkgCache::VerIterator TargetVer, // virtual packages can't be a solution if (P.end() == true || (P->ProvidesList == 0 && P->VersionList == 0)) continue; + // if its already installed, check if this one is good enough + pkgCache::VerIterator const Now = P.CurrentVer(); + if (Now.end() == false && Start.IsSatisfied(Now)) + { + itsFine = true; + break; + } pkgCache::VerIterator const Cand = PkgState[P->ID].CandidateVerIter(*this); // no versioned dependency - but is it installable? if (Start.TargetVer() == 0 || Start.TargetVer()[0] == '\0') diff --git a/test/integration/test-release-candidate-switching b/test/integration/test-release-candidate-switching index d7f1c90f7..945f68084 100755 --- a/test/integration/test-release-candidate-switching +++ b/test/integration/test-release-candidate-switching @@ -417,3 +417,27 @@ The following packages have unmet dependencies: uninstallablepkg : Depends: libmtp8 (>= 10:0.20.1) but it is not going to be installed Depends: amarok-utils (= 2.3.2-2+exp) but 2.3.1-1+sid is to be installed E: Unable to correct problems, you have held broken packages." aptget install uninstallablepkg/experimental --trivial-only -V + +insertinstalledpackage 'libmtp8' 'i386' '1' +insertinstalledpackage 'amarok' 'i386' '3' 'Depends: amarok-common (= 3), libmtp8 (>= 1)' +insertinstalledpackage 'amarok-common' 'all' '3' +# note that libmtp8 isn't downgraded as there is no need +testfailureequal "Reading package lists... +Building dependency tree... +Selected version '2.3.1-1+sid' (unstable [i386]) for 'amarok' +Selected version '2.3.1-1+sid' (unstable [all]) for 'amarok-common' because of 'amarok' +The following additional packages will be installed: + amarok-common (2.3.1-1+sid) + amarok-utils (2.3.1-1+sid) + libc6 (2.11.2-7+sid) + phonon-backend-xine (4:4.6.0really4.4.2-1+sid) +The following NEW packages will be installed: + amarok-utils (2.3.1-1+sid) + libc6 (2.11.2-7+sid) + phonon-backend-xine (4:4.6.0really4.4.2-1+sid) +The following packages will be DOWNGRADED: + amarok (3 => 2.3.1-1+sid) + amarok-common (3 => 2.3.1-1+sid) +0 upgraded, 3 newly installed, 2 downgraded, 0 to remove and 0 not upgraded. +After this operation, 129 kB of additional disk space will be used. +E: Trivial Only specified but this is not a trivial operation." apt install amarok/sid --trivial-only -V -- cgit v1.2.3