X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/8dd562a894c2472e3705fe13c212f665b55744a9..c368b3abe198f59d5bd4d715a801e1b187b698a7:/apt-pkg/sourcelist.cc diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index b083da936..6773b069f 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include @@ -108,6 +110,7 @@ bool pkgSourceList::Type::ParseStanza(vector &List, /*{{{*/ mapping.insert(std::make_pair("Valid-Until-Max", std::make_pair("valid-until-max", false))); mapping.insert(std::make_pair("Signed-By", std::make_pair("signed-by", false))); mapping.insert(std::make_pair("PDiffs", std::make_pair("pdiffs", false))); + mapping.insert(std::make_pair("By-Hash", std::make_pair("by-hash", false))); for (std::map >::const_iterator m = mapping.begin(); m != mapping.end(); ++m) if (Tags.Exists(m->first)) @@ -119,6 +122,12 @@ bool pkgSourceList::Type::ParseStanza(vector &List, /*{{{*/ Options[m->second.first] = option; } + { + std::string entry; + strprintf(entry, "%s:%i", Fd.Name().c_str(), i); + Options["sourceslist-entry"] = entry; + } + // now create one item per suite/section string Suite = Tags.FindS("Suites"); Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture")); @@ -186,6 +195,11 @@ bool pkgSourceList::Type::ParseLine(vector &List, // Parse option field if it exists // e.g.: [ option1=value1 option2=value2 ] map Options; + { + std::string entry; + strprintf(entry, "%s:%i", File.c_str(), CurLine); + Options["sourceslist-entry"] = entry; + } if (Buffer != 0 && Buffer[0] == '[') { ++Buffer; // ignore the [ @@ -410,7 +424,7 @@ bool pkgSourceList::ParseFileDeb822(string const &File) // see if we can read the file FileFd Fd(File, FileFd::ReadOnly); pkgTagFile Sources(&Fd); - if (_error->PendingError() == true) + if (Fd.IsOpen() == false || Fd.Failed()) return _error->Error(_("Malformed stanza %u in source list %s (type)"),i,File.c_str()); // read step by step @@ -524,7 +538,44 @@ std::vector pkgSourceList::GetVolatileFiles() const /*{{{*/ /*}}}*/ void pkgSourceList::AddVolatileFile(pkgIndexFile * const File) /*{{{*/ { - if (File != NULL) + if (File != nullptr) VolatileFiles.push_back(File); } /*}}}*/ +bool pkgSourceList::AddVolatileFile(std::string const &File) /*{{{*/ +{ + // Note: FileExists matches directories and links, too! + if (File.empty() || FileExists(File) == false) + return false; + + std::string const ext = flExtension(File); + if (ext == "deb") + 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 + return false; + + return true; +} + /*}}}*/ +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)) + { + if (VolatileCmdL != nullptr) + VolatileCmdL->push_back(I); + } + else + _error->Error(_("Unsupported file %s given on commandline"), I); + return true; + } + return false; + }); +} + /*}}}*/