summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-06-29 23:26:38 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-06-29 23:26:38 +0200
commite2bba11c9a1858c98954e7c5299d20a6c0966cc7 (patch)
tree989524c6e7833911ac3bb8de7fdac48450eb1075
parent1925ea3d0cd6579a4034acb7308e532d025319c7 (diff)
- ensure that only the first specific stanza for a package is used
- save all stanzas which had no effect in Unmatched
-rw-r--r--apt-pkg/policy.cc27
-rw-r--r--apt-pkg/policy.h1
-rw-r--r--debian/changelog4
-rwxr-xr-xtest/integration/test-pin-non-existent-package15
4 files changed, 30 insertions, 17 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 827c9145c..78f44d635 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -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;
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index f8b2678de..a5e6c6048 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -55,6 +55,7 @@ class pkgPolicy : public pkgDepCache::Policy
struct PkgPin : Pin
{
string Pkg;
+ PkgPin(string const &Pkg) : Pin(), Pkg(Pkg) {};
};
Pin *Pins;
diff --git a/debian/changelog b/debian/changelog
index c4f7af623..77b448e77 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/test/integration/test-pin-non-existent-package b/test/integration/test-pin-non-existent-package
index 1031272e2..bd6ccc476 100755
--- a/test/integration/test-pin-non-existent-package
+++ b/test/integration/test-pin-non-existent-package
@@ -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'
@@ -37,6 +43,13 @@ 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
testequal 'Reading package lists...