X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/f6459e646f6fa45c34d1f13f37173ea4b92ffd5f..30060442025824c491f58887ca7369f3c572fa57:/apt-pkg/sourcelist.cc?ds=sidebyside diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 82d2ed3c6..000539582 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -98,8 +99,8 @@ bool pkgSourceList::Type::ParseStanza(vector &List, /*{{{*/ std::map > mapping; #define APT_PLUSMINUS(X, Y) \ mapping.insert(std::make_pair(X, std::make_pair(Y, true))); \ - mapping.insert(std::make_pair(X "Add", std::make_pair(Y "+", true))); \ - mapping.insert(std::make_pair(X "Remove", std::make_pair(Y "-", true))) + mapping.insert(std::make_pair(X "-Add", std::make_pair(Y "+", true))); \ + mapping.insert(std::make_pair(X "-Remove", std::make_pair(Y "-", true))) APT_PLUSMINUS("Architectures", "arch"); APT_PLUSMINUS("Languages", "lang"); APT_PLUSMINUS("Targets", "target"); @@ -311,18 +312,19 @@ bool pkgSourceList::ReadMainList() Reset(); // CNC:2003-11-28 - Entries in sources.list have priority over // entries in sources.list.d. - string Main = _config->FindFile("Dir::Etc::sourcelist"); - string Parts = _config->FindDir("Dir::Etc::sourceparts"); + string Main = _config->FindFile("Dir::Etc::sourcelist", "/dev/null"); + string Parts = _config->FindDir("Dir::Etc::sourceparts", "/dev/null"); if (RealFileExists(Main) == true) Res &= ReadAppend(Main); - else if (DirectoryExists(Parts) == false) + else if (DirectoryExists(Parts) == false && APT::String::Endswith(Parts, "/dev/null") == false) // Only warn if there are no sources.list.d. _error->WarningE("DirectoryExists", _("Unable to read %s"), Parts.c_str()); if (DirectoryExists(Parts) == true) Res &= ReadSourceDir(Parts); - else if (RealFileExists(Main) == false) + else if (Main.empty() == false && RealFileExists(Main) == false && + APT::String::Endswith(Parts, "/dev/null") == false) // Only warn if there is no sources.list file. _error->WarningE("RealFileExists", _("Unable to read %s"), Main.c_str()); @@ -542,7 +544,7 @@ void pkgSourceList::AddVolatileFile(pkgIndexFile * const File) /*{{{*/ VolatileFiles.push_back(File); } /*}}}*/ -bool pkgSourceList::AddVolatileFile(std::string const &File) /*{{{*/ +bool pkgSourceList::AddVolatileFile(std::string const &File, std::vector * const VolatileCmdL)/*{{{*/ { // Note: FileExists matches directories and links, too! if (File.empty() || FileExists(File) == false) @@ -555,13 +557,49 @@ bool pkgSourceList::AddVolatileFile(std::string const &File) /*{{{*/ AddVolatileFile(new debDscFileIndex(File)); else if (FileExists(flCombine(File, "debian/control"))) AddVolatileFile(new debDscFileIndex(flCombine(File, "debian/control"))); + else if (ext == "changes") + { + debDscRecordParser changes(File, nullptr); + std::vector fileslst; + if (changes.Files2(fileslst) == false || fileslst.empty()) + return false; + auto const basedir = flNotFile(File); + for (auto && file: fileslst) + { + auto const name = flCombine(basedir, file.Path); + AddVolatileFile(name, VolatileCmdL); + if (file.Hashes.VerifyFile(name) == false) + return _error->Error("The file %s does not match with the hashes in the %s file!", name.c_str(), File.c_str()); + } + return true; + } else return false; + if (VolatileCmdL != nullptr) + VolatileCmdL->push_back(File); return true; +} +bool pkgSourceList::AddVolatileFile(std::string const &File) +{ + return AddVolatileFile(File, nullptr); } /*}}}*/ -void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector * const VolatileCmdL)/*{{{*/ +void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector * const VolatileCmdL)/*{{{*/ +{ + std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) { + if (I != nullptr && (I[0] == '/' || (I[0] == '.' && ((I[1] == '.' && I[2] == '/') || I[1] == '/')))) + { + if (AddVolatileFile(I, VolatileCmdL)) + ; + else + _error->Error(_("Unsupported file %s given on commandline"), I); + return true; + } + return false; + }); +} +void pkgSourceList::AddVolatileFiles(CommandLine &CmdL, std::vector * const VolatileCmdL) { std::remove_if(CmdL.FileList + 1, CmdL.FileList + 1 + CmdL.FileSize(), [&](char const * const I) { if (I != nullptr && (I[0] == '/' || (I[0] == '.' && ((I[1] == '.' && I[2] == '/') || I[1] == '/'))))