summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/policy.cc36
-rw-r--r--apt-pkg/policy.h1
2 files changed, 37 insertions, 0 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 2d1f2a5d4..e1dc3aef5 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -26,6 +26,7 @@
#include <apt-pkg/cacheiterators.h>
#include <apt-pkg/pkgcache.h>
#include <apt-pkg/versionmatch.h>
+#include <apt-pkg/version.h>
#include <ctype.h>
#include <stddef.h>
@@ -131,6 +132,10 @@ bool pkgPolicy::InitDefaults()
best package is. */
pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator const &Pkg)
{
+ if (_config->FindI("APT::Policy", 1) >= 1) {
+ return GetCandidateVerNew(Pkg);
+ }
+
// Look for a package pin and evaluate it.
signed Max = GetPriority(Pkg);
pkgCache::VerIterator Pref = GetMatch(Pkg);
@@ -217,6 +222,37 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator const &Pk
return Pref;
}
+
+// Policy::GetCandidateVer - Get the candidate install version /*{{{*/
+// ---------------------------------------------------------------------
+/* Evaluate the package pins and the default list to deteremine what the
+ best package is. */
+pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const &Pkg)
+{
+ // TODO: Replace GetCandidateVer()
+ pkgCache::VerIterator cand;
+ 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;
+
+ candPriority = priority;
+ candInstalled = installed;
+ cand = ver;
+ }
+
+ return cand;
+}
/*}}}*/
// Policy::CreatePin - Create an entry in the pin table.. /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index 9deeb9d0e..4efe2ec50 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -88,6 +88,7 @@ class pkgPolicy : public pkgDepCache::Policy
pkgPolicy(pkgCache *Owner);
virtual ~pkgPolicy();
private:
+ pkgCache::VerIterator GetCandidateVerNew(pkgCache::PkgIterator const &Pkg);
void *d;
};