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 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg/depcache.cc') 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') -- cgit v1.2.3