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);
bool ReadPinDir(pkgPolicy &Plcy,string Dir)
{
if (Dir.empty() == true)
- Dir = _config->FindDir("Dir::Etc::PreferencesParts");
+ Dir = _config->FindDir("Dir::Etc::PreferencesParts", "/dev/null");
if (DirectoryExists(Dir) == false)
{
- if (Dir != "/dev/null")
+ if (APT::String::Endswith(Dir, "/dev/null") == false)
_error->WarningE("DirectoryExists",_("Unable to read %s"),Dir.c_str());
return true;
}
+ _error->PushToStack();
vector<string> const List = GetListOfFilesInDir(Dir, "pref", true, true);
+ bool const PendingErrors = _error->PendingError();
+ _error->MergeWithStack();
+ if (PendingErrors)
+ return false;
// Read the files
for (vector<string>::const_iterator I = List.begin(); I != List.end(); ++I)