Преглед изворни кода

* apt-pkg/policy.cc:
- Always return a candidate if there is at least one version pinned > 0
(Closes: #512318)

Julian Andres Klode пре 16 година
родитељ
комит
8f5525e967
2 измењених фајлова са 17 додато и 0 уклоњено
  1. 14 0
      apt-pkg/policy.cc
  2. 3 0
      debian/changelog

+ 14 - 0
apt-pkg/policy.cc

@@ -121,6 +121,10 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
    signed Max = GetPriority(Pkg);
    pkgCache::VerIterator Pref = GetMatch(Pkg);
 
+   // Alternatives in case we can not find our package pin (Bug#512318).
+   signed MaxAlt = 0;
+   pkgCache::VerIterator PrefAlt;
+
    // no package = no candidate version
    if (Pkg.end() == true)
       return Pref;
@@ -159,6 +163,11 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
 	 {
 	    Pref = Ver;
 	    Max = Prio;
+	 }
+	 if (Prio > MaxAlt)
+	 {
+	    PrefAlt = Ver;
+	    MaxAlt = Prio;
 	 }	 
       }      
       
@@ -175,6 +184,11 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator Pkg)
 	    break;
       }            
    }
+   // If we do not find our candidate, use the one with the highest pin.
+   // This means that if there is a version available with pin > 0; there
+   // will always be a candidate (Closes: #512318)
+   if (!Pref.IsGood() && MaxAlt > 0)
+       Pref = PrefAlt;
    return Pref;
 }
 									/*}}}*/

+ 3 - 0
debian/changelog

@@ -13,6 +13,9 @@ apt (0.7.26~exp3) UNRELEASED; urgency=low
     - Use the new python-apt API (and conflict with python-apt << 0.7.93.2).
   * apt-inst/contrib/arfile.h:
     - Add public ARArchive::Members() which returns the list of members.
+  * apt-pkg/policy.cc:
+    - Always return a candidate if there is at least one version pinned > 0
+      (Closes: #512318)
   * debian/rules:
     - Fix the libraries name to be e.g. libapt-pkg4.9 instead of
       libapt-pkg-4.9.