X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/42610b9d5a95ec108b74ffbc6446542cf6b0176a..b105ca65292e4af6ca2093351fd2a61180054e14:/apt-pkg/sourcelist.cc diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 022aff2fe..0da687895 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -327,6 +328,9 @@ bool pkgSourceList::ReadMainList() // Only warn if there is no sources.list file. _error->WarningE("RealFileExists", _("Unable to read %s"), Main.c_str()); + for (auto && file: _config->FindVector("APT::Sources::With")) + Res &= AddVolatileFile(file, nullptr); + return Res; } /*}}}*/ @@ -419,18 +423,18 @@ bool pkgSourceList::ParseFileOldStyle(std::string const &File) /* Returns: the number of stanzas parsed*/ bool pkgSourceList::ParseFileDeb822(string const &File) { - unsigned int i = 1; - // see if we can read the file FileFd Fd(File, FileFd::ReadOnly); pkgTagFile Sources(&Fd, pkgTagFile::SUPPORT_COMMENTS); if (Fd.IsOpen() == false || Fd.Failed()) - return _error->Error(_("Malformed stanza %u in source list %s (type)"),i,File.c_str()); + return _error->Error(_("Malformed stanza %u in source list %s (type)"),0,File.c_str()); // read step by step pkgTagSection Tags; + unsigned int i = 0; while (Sources.Step(Tags) == true) { + ++i; if(Tags.Exists("Types") == false) return _error->Error(_("Malformed stanza %u in source list %s (type)"),i,File.c_str()); @@ -448,8 +452,6 @@ bool pkgSourceList::ParseFileDeb822(string const &File) if (!Parse->ParseStanza(SrcList, Tags, i, Fd)) return false; - - ++i; } } return true; @@ -543,26 +545,92 @@ void pkgSourceList::AddVolatileFile(pkgIndexFile * const File) /*{{{*/ VolatileFiles.push_back(File); } /*}}}*/ -bool pkgSourceList::AddVolatileFile(std::string const &File) /*{{{*/ +static bool fileNameMatches(std::string const &filename, std::string const &idxtype)/*{{{*/ +{ + for (auto && type: APT::Configuration::getCompressionTypes()) + { + if (type == "uncompressed") + { + if (filename == idxtype || APT::String::Endswith(filename, '_' + idxtype)) + return true; + } + else if (filename == idxtype + '.' + type || + APT::String::Endswith(filename, '_' + idxtype + '.' + type)) + return true; + } + return false; +} + /*}}}*/ +bool pkgSourceList::AddVolatileFile(std::string const &File, std::vector * const VolatileCmdL)/*{{{*/ { // Note: FileExists matches directories and links, too! if (File.empty() || FileExists(File) == false) return false; std::string const ext = flExtension(File); - if (ext == "deb") + // udeb is not included as installing it is usually a mistake rather than intended + if (ext == "deb" || ext == "ddeb") AddVolatileFile(new debDebPkgFileIndex(File)); else if (ext == "dsc") 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; + { + auto const filename = flNotDir(File); + auto const Target = IndexTarget(File, filename, File, "file:" + File, false, true, { + { "FILENAME", File }, + { "REPO_URI", "file:" + flAbsPath(flNotFile(File)) + '/' }, + { "COMPONENT", "volatile-packages-file" }, + }); + if (fileNameMatches(filename, "Packages")) + AddVolatileFile(new debPackagesIndex(Target, true)); + else if (fileNameMatches(filename, "Sources")) + AddVolatileFile(new debSourcesIndex(Target, 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] == '/'))))