From 3d5e93f7cd6bea364ca811c7f64b5e1d4174a4ac Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 10 Aug 2015 15:52:06 +0200 Subject: policy: Fix the handling of config-files states Gbp-Dch: ignore --- apt-pkg/policy.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'apt-pkg/policy.cc') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 78e34a344..7947103d5 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -238,7 +238,7 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) { int priority = GetPriority(ver); - if (priority <= candPriority) + if (priority == 0 || priority <= candPriority) continue; // TODO: Maybe optimize to not compare versions @@ -376,8 +376,17 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver) int priority = INT_MIN; for (pkgCache::VerFileIterator file = Ver.FileList(); file.end() == false; file++) { - if (GetPriority(file.File()) > priority) - priority = GetPriority(file.File()); + /* If this is the status file, and the current version is not the + version in the status file (ie it is not installed, or somesuch) + then it is not a candidate for installation, ever. This weeds + out bogus entries that may be due to config-file states, or + other. */ + if (file.File().Flagged(pkgCache::Flag::NotSource) && Ver.ParentPkg().CurrentVer() != Ver) { + if (priority < 0) + priority = 0; + } else if (GetPriority(file.File()) > priority) { + priority = GetPriority(file.File()); + } } return priority == INT_MIN ? 0 : priority; -- cgit v1.2.3