]> git.saurik.com Git - apt.git/commitdiff
pkgPolicy: Introduce storage and helpers for per-version pins
authorJulian Andres Klode <jak@debian.org>
Mon, 10 Aug 2015 09:00:37 +0000 (11:00 +0200)
committerJulian Andres Klode <jak@debian.org>
Mon, 10 Aug 2015 09:00:37 +0000 (11:00 +0200)
Per-version pins should lead to more predictable results with
/etc/apt/preferences uses like pinning one version with -1.

apt-pkg/policy.cc
apt-pkg/policy.h

index 6da6ed606580d6ccce748b4cc4e87e5d5a91eb09..5d7ab0e6b50a736e15881e859e59d69a661a051e 100644 (file)
@@ -50,9 +50,12 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner)
       return;
    PFPriority = new signed short[Owner->Head().PackageFileCount];
    Pins = new Pin[Owner->Head().PackageCount];
+   VerPins = new Pin[Owner->Head().VersionCount];
 
    for (unsigned long I = 0; I != Owner->Head().PackageCount; I++)
       Pins[I].Type = pkgVersionMatch::None;
+   for (unsigned long I = 0; I != Owner->Head().VersionCount; I++)
+      VerPins[I].Type = pkgVersionMatch::None;
 
    // The config file has a master override.
    string DefRel = _config->Find("APT::Default-Release");
@@ -318,6 +321,12 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
       return Pins[Pkg->ID].Priority;
    return 0;
 }
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver)
+{
+   if (VerPins[Ver->ID].Type != pkgVersionMatch::None)
+      return VerPins[Ver->ID].Priority;
+   return 0;
+}
 APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgFileIterator const &File)
 {
    return PFPriority[File->ID];
@@ -440,4 +449,4 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
 }
                                                                        /*}}}*/
 
-pkgPolicy::~pkgPolicy() {delete [] PFPriority; delete [] Pins;}
+pkgPolicy::~pkgPolicy() {delete [] PFPriority; delete [] Pins; delete [] VerPins; }
index c4b1cbaddf3caa285e6a58c2e2774f26423be2e9..9deeb9d0eea489994871f1d4a619268e49e223ba 100644 (file)
@@ -63,6 +63,7 @@ class pkgPolicy : public pkgDepCache::Policy
    };
    
    Pin *Pins;
+   Pin *VerPins;
    signed short *PFPriority;
    std::vector<Pin> Defaults;
    std::vector<PkgPin> Unmatched;
@@ -79,6 +80,7 @@ class pkgPolicy : public pkgDepCache::Policy
    // Things for the cache interface.
    virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg);
    virtual signed short GetPriority(pkgCache::PkgIterator const &Pkg);
+   virtual signed short GetPriority(pkgCache::VerIterator const &Pkg);
    virtual signed short GetPriority(pkgCache::PkgFileIterator const &File);
 
    bool InitDefaults();