summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/policy.cc9
-rwxr-xr-xtest/integration/test-apt-get-install-deb6
2 files changed, 9 insertions, 6 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 06c516e53..53165b5db 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -278,14 +278,13 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
Name.erase(found);
}
- // Allow pinning by wildcards
- // TODO: Maybe we should always prefer specific pins over non-
- // specific ones.
- if (Name[0] == '/' || Name.find_first_of("*[?") != string::npos)
+ // Allow pinning by wildcards - beware of package names looking like wildcards!
+ // TODO: Maybe we should always prefer specific pins over non-specific ones.
+ if ((Name[0] == '/' && Name[Name.length() - 1] == '/') || Name.find_first_of("*[?") != string::npos)
{
pkgVersionMatch match(Data, Type);
for (pkgCache::GrpIterator G = Cache->GrpBegin(); G.end() != true; ++G)
- if (match.ExpressionMatches(Name, G.Name()))
+ if (Name != G.Name() && match.ExpressionMatches(Name, G.Name()))
{
if (Arch.empty() == false)
CreatePin(Type, string(G.Name()).append(":").append(Arch), Data, Priority);
diff --git a/test/integration/test-apt-get-install-deb b/test/integration/test-apt-get-install-deb
index 3aacc301d..994c0200d 100755
--- a/test/integration/test-apt-get-install-deb
+++ b/test/integration/test-apt-get-install-deb
@@ -108,8 +108,12 @@ createpkg 'leading-newline' '
createpkg 'trailing-newline' '' '
'
+echo 'Package: /pkg-/
+Pin: release a=experimental
+Pin-Priority: 501' > rootdir/etc/apt/preferences.d/pinit
+
testsuccess aptget install ./incoming/pkg-as-it-should-be_0_all.deb
-testsuccess aptget install ./incoming/pkg-leading-newline_0_all.deb
+testsuccess aptget install "$(readlink -f ./incoming/pkg-leading-newline_0_all.deb)"
testsuccess aptget install ./incoming/pkg-trailing-newline_0_all.deb
testempty apt clean