X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/9f5bf66a6218d1aec3f42713084078c18947eade..3d43e5390d83a95b08d09e8b811523f2d99a092c:/apt-pkg/policy.cc diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index e33d563a1..f9901bc9a 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -27,9 +27,10 @@ #include #include #include +#include #include #include - + #include #include @@ -262,6 +263,32 @@ class PreferenceSection : public pkgTagSection } }; /*}}}*/ +// ReadPinDir - Load the pin files from this dir into a Policy /*{{{*/ +// --------------------------------------------------------------------- +/* This will load each pin file in the given dir into a Policy. If the + given dir is empty the dir set in Dir::Etc::PreferencesParts is used. + Note also that this method will issue a warning if the dir does not + exists but it will return true in this case! */ +bool ReadPinDir(pkgPolicy &Plcy,string Dir) +{ + if (Dir.empty() == true) + Dir = _config->FindDir("Dir::Etc::PreferencesParts"); + + if (FileExists(Dir) == false) + { + _error->WarningE("FileExists",_("Unable to read %s"),Dir.c_str()); + return true; + } + + vector const List = GetListOfFilesInDir(Dir, "pref", true, true); + + // Read the files + for (vector::const_iterator I = List.begin(); I != List.end(); I++) + if (ReadPinFile(Plcy, *I) == false) + return false; + return true; +} + /*}}}*/ // ReadPinFile - Load the pin file into a Policy /*{{{*/ // --------------------------------------------------------------------- /* I'd like to see the preferences file store more than just pin information @@ -286,7 +313,7 @@ bool ReadPinFile(pkgPolicy &Plcy,string File) { string Name = Tags.FindS("Package"); if (Name.empty() == true) - return _error->Error(_("Invalid record in the preferences file, no Package header")); + return _error->Error(_("Invalid record in the preferences file %s, no Package header"), File.c_str()); if (Name == "*") Name = string();