From 1a4c9766e0b31795b5d9869c6a98c1bba8380faa Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 15 Apr 2011 12:52:45 +0200 Subject: * apt-pkg/policy.cc: - Allow pinning by glob() expressions, and regular expressions surrounded by slashes (the "/" character). --- apt-pkg/policy.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 94c7fd4af..3d6ec1cdc 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -216,6 +216,21 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name, P->Data = Data; return; } + + // Allow pinning by wildcards + // TODO: Maybe we should always prefer specific pins over non- + // specific ones. + if (Name.find("*") != string::npos || Name.find("[") != string::npos + || Name.find("?") != string::npos || Name[0] == '/') { + pkgVersionMatch match(Data, Type); + for (pkgCache::PkgIterator P = Cache->PkgBegin(); + P != Cache->PkgEnd(); P++) { + if (match.ExpressionMatches(Name, P.Name())) { + CreatePin(Type, P.Name(), Data, Priority); + } + } + return; + } // Get a spot to put the pin pkgCache::GrpIterator Grp = Cache->FindGrp(Name); -- cgit v1.2.3-70-g09d2