]> git.saurik.com Git - apt.git/commitdiff
- ensure that only the first specific stanza for a package is used
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 29 Jun 2011 21:26:38 +0000 (23:26 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 29 Jun 2011 21:26:38 +0000 (23:26 +0200)
  - save all stanzas which had no effect in Unmatched

apt-pkg/policy.cc
apt-pkg/policy.h
debian/changelog
test/integration/test-pin-non-existent-package

index 827c9145c396547929e92608d1e49cd140b959bf..78f44d635619e1ca50c10aca94ef500610958df1 100644 (file)
@@ -229,28 +229,25 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
       return;
    }
 
-   // Get a spot to put the pin
+   // find the package group this pin applies to
    pkgCache::GrpIterator Grp = Cache->FindGrp(Name);
    if (Grp.end() == true)
+   {
+      Pin *P = &*Unmatched.insert(Unmatched.end(),PkgPin(Name));
+      P->Type = Type;
+      P->Priority = Priority;
+      P->Data = Data;
       return;
+   }
 
    for (pkgCache::PkgIterator Pkg = Grp.PackageList();
        Pkg.end() != true; Pkg = Grp.NextPkg(Pkg))
    {
-      Pin *P = 0;
-      if (Pkg.end() == false)
-        P = Pins + Pkg->ID;
-      else
-      {
-        // Check the unmatched table
-        for (vector<PkgPin>::iterator I = Unmatched.begin();
-             I != Unmatched.end() && P == 0; I++)
-           if (I->Pkg == Name)
-              P = &*I;
-
-        if (P == 0)
-           P = &*Unmatched.insert(Unmatched.end(),PkgPin());
-      }
+      Pin *P = Pins + Pkg->ID;
+      // the first specific stanza for a package is the ruler,
+      // all others need to be ignored
+      if (P->Type != pkgVersionMatch::None)
+        P = &*Unmatched.insert(Unmatched.end(),PkgPin(Pkg.FullName()));
       P->Type = Type;
       P->Priority = Priority;
       P->Data = Data;
index f8b2678de434997d9d5825fda8c1588376b33a33..a5e6c6048020ba2c4c89d6c24832a726a68179fa 100644 (file)
@@ -55,6 +55,7 @@ class pkgPolicy : public pkgDepCache::Policy
    struct PkgPin : Pin
    {
       string Pkg;
+      PkgPin(string const &Pkg) : Pin(), Pkg(Pkg) {};
    };
    
    Pin *Pins;
index c4f7af623ceea6b60fe7ec80e6a949fa97bfe5e9..77b448e77158a25138376a19e41f034586add301 100644 (file)
@@ -15,8 +15,10 @@ apt (0.8.15.1) unstable; urgency=low
     - do not segfault in pinning if a package with this name doesn't exist.
       Thanks to Ferdinand Thommes for the report!
     - Defaults is a vector of Pin not of PkgPin
+    - ensure that only the first specific stanza for a package is used
+    - save all stanzas which had no effect in Unmatched
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 29 Jun 2011 23:15:35 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 29 Jun 2011 23:21:12 +0200
 
 apt (0.8.15) unstable; urgency=low
 
index 1031272e24ae85a6e71ac374761687857a02df2d..bd6ccc4769f6867dca4c0bca9bacabca5924573d 100755 (executable)
@@ -12,7 +12,13 @@ setupaptarchive
 
 testcandidate() {
        msgtest "Test that the Candidate for $1 is" $2
-       test "$(aptcache policy $1 | grep '^  Candidate:')" = "  Candidate: $2" && msgpass || msgfail
+       if [ "$(aptcache policy $1 | grep '^  Candidate:')" = "  Candidate: $2" ]; then
+               msgpass
+       else
+               echo
+               aptcache policy $1
+               msgfail
+       fi
 }
 
 testcandidate apt '0.8.15'
@@ -36,6 +42,13 @@ Package: doesntexist
 Pin: release a=unstable
 Pin-Priority: 1000' >> rootdir/etc/apt/preferences
 
+testcandidate apt '(none)'
+
+echo '
+Package: apt
+Pin: release a=unstable
+Pin-Priority: 1000' >> rootdir/etc/apt/preferences
+
 testcandidate apt '(none)'
 testequal 'N: Unable to locate package doesntexist' aptcache policy doesntexist -q=0