]> git.saurik.com Git - apt.git/commitdiff
don't loop on pinning pkgs from absolute debs by regex
authorDavid Kalnischkies <david@kalnischkies.de>
Sun, 28 Aug 2016 20:56:17 +0000 (22:56 +0200)
committerJulian Andres Klode <jak@debian.org>
Wed, 5 Oct 2016 19:53:38 +0000 (21:53 +0200)
An absolute filename for a *.deb file starts with a /. A package with
the name of the file is inserted in the cache which is provided by the
"real" package for internal reasons. The pinning code detects a regex
based wildcard by having the regex start with /. That is no problem
as a / can not be included in a package name… expect that our virtual
filename package can and does.

We fix this two ways actually: First, a regex is only being considered a
regex if it also ends with / (we don't support flags). That stops our
problem with the virtual filename packages already, but to be sure we
also do not enter the loop if matcher and package name are equal.

It has to be noted that the creation of pins for virtual packages like
the here effected filename packages is pointless as only versions can be
pinned, but checking that a package is really purely virtual is too
costly compared to just creating an unused pin.

Closes: 835818
(cherry picked from commit e950b7e2f89b5e48192cd469c963a44fff9f1450)

apt-pkg/policy.cc
test/integration/test-apt-get-install-deb

index 06c516e53a55745a49661738938506786dbe983c..53165b5dbc9881a59c4671e5800fa8169a7e958e 100644 (file)
@@ -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);
index 3aacc301dcceef5722eddc9546ab95f7d6651a3e..994c0200def1f62a1ee38b7b7fecfc298902c6ce 100755 (executable)
@@ -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