X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/defe3231c7bafc4d789219a3250be9ccfbc51914..fa74b4ece008f6600d530e28a609f31312c8c864:/apt-pkg/sourcelist.cc diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index d3bcbce5f..2100b5d3c 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -107,6 +107,8 @@ bool pkgSourceList::Type::ParseStanza(vector &List, /*{{{*/ mapping.insert(std::make_pair("Valid-Until-Min", std::make_pair("valid-until-min", false))); 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)) @@ -118,6 +120,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")); @@ -185,6 +193,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 [ @@ -321,7 +334,7 @@ void pkgSourceList::Reset() { for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; - SrcList.erase(SrcList.begin(),SrcList.end()); + SrcList.clear(); } /*}}}*/ // SourceList::Read - Parse the sourcelist file /*{{{*/ @@ -409,7 +422,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 @@ -440,34 +453,26 @@ bool pkgSourceList::ParseFileDeb822(string const &File) } /*}}}*/ // SourceList::FindIndex - Get the index associated with a file /*{{{*/ -// --------------------------------------------------------------------- -/* */ +static bool FindInIndexFileContainer(std::vector const &Cont, pkgCache::PkgFileIterator const &File, pkgIndexFile *&Found) +{ + auto const J = std::find_if(Cont.begin(), Cont.end(), [&File](pkgIndexFile const * const J) { + return J->FindInCache(*File.Cache()) == File; + }); + if (J != Cont.end()) + { + Found = (*J); + return true; + } + return false; +} bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const { for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) - { - vector *Indexes = (*I)->GetIndexFiles(); - for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); ++J) - { - if ((*J)->FindInCache(*File.Cache()) == File) - { - Found = (*J); - return true; - } - } - } - for (vector::const_iterator J = VolatileFiles.begin(); - J != VolatileFiles.end(); ++J) - { - if ((*J)->FindInCache(*File.Cache()) == File) - { - Found = (*J); + if (FindInIndexFileContainer(*(*I)->GetIndexFiles(), File, Found)) return true; - } - } - return false; + + return FindInIndexFileContainer(VolatileFiles, File, Found); } /*}}}*/ // SourceList::GetIndexes - Load the index files into the downloader /*{{{*/ @@ -516,11 +521,12 @@ time_t pkgSourceList::GetLastModifiedTime() List = GetListOfFilesInDir(Parts, "list", true); // calculate the time - time_t mtime_sources = GetModificationTime(Main); - for (vector::const_iterator I = List.begin(); I != List.end(); ++I) - mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); - - return mtime_sources; + std::vector modtimes; + modtimes.reserve(1 + List.size()); + modtimes.push_back(GetModificationTime(Main)); + std::transform(List.begin(), List.end(), std::back_inserter(modtimes), GetModificationTime); + auto const maxmtime = std::max_element(modtimes.begin(), modtimes.end()); + return *maxmtime; } /*}}}*/ std::vector pkgSourceList::GetVolatileFiles() const /*{{{*/