summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-08-10 15:00:16 +0200
committerJulian Andres Klode <jak@debian.org>2015-08-10 15:00:16 +0200
commit3436218c5fbbd7ff543863dc4c2d590b9f12c377 (patch)
treed761b402d5e7ffc62328be1527ec49c35069793c /apt-pkg/policy.cc
parenta91aae406112df1d8fe16d00212333a20210f674 (diff)
policy: Fix the new policy implementation to handle downgrades correctly
This was broken previously, as we'd choose a downgrade when it's pin was higher than the previously selected candidate.
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index e1dc3aef5..78e34a344 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -231,23 +231,22 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const
{
// TODO: Replace GetCandidateVer()
pkgCache::VerIterator cand;
+ pkgCache::VerIterator cur = Pkg.CurrentVer();
int candPriority = -1;
- bool candInstalled = false;
pkgVersioningSystem *vs = Cache->VS;
for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) {
int priority = GetPriority(ver);
- bool installed = ver->ID == Pkg.CurrentVer()->ID;
- if (priority < candPriority)
- continue;
- if (priority < 1000
- && (priority == candPriority || installed < candInstalled)
- && (cand.IsGood() && vs->CmpVersion(ver.VerStr(), cand.VerStr()) < 0))
- continue;
+ if (priority <= candPriority)
+ continue;
+
+ // TODO: Maybe optimize to not compare versions
+ if (!cur.end() && priority < 1000
+ && (vs->CmpVersion(ver.VerStr(), cur.VerStr()) < 0))
+ continue;
candPriority = priority;
- candInstalled = installed;
cand = ver;
}