From: Michael Vogt Date: Wed, 4 Dec 2013 07:18:58 +0000 (+0100) Subject: refactor and move generation of the MetaIndex FileName out of the FindSrc() X-Git-Tag: 0.9.14.1~3^2~8 X-Git-Url: https://git.hcoop.net/ntk/apt.git/commitdiff_plain/7b33ae1070f3ecff0f20745db7edeead8dfc3a05 refactor and move generation of the MetaIndex FileName out of the FindSrc() --- diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 3003c197..3205fd90 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -63,6 +63,8 @@ #include #include +#include + #include #include @@ -132,6 +134,26 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, return true; } /*}}}*/ + +// FIXME: move into more generic code (metaindex ?) +std::string MetaIndexFileName(metaIndex *metaindex) +{ + // FIXME: this cast is the horror, the horror + debReleaseIndex *r = (debReleaseIndex*)metaindex; + + // see if we have a InRelease file + std::string PathInRelease = _config->FindDir("Dir::State::lists") + + URItoFileName(r->MetaIndexURI("InRelease")); + if (FileExists(PathInRelease)) + return PathInRelease; + + // and if not return the normal one + return _config->FindDir("Dir::State::lists") + + URItoFileName(r->MetaIndexURI("Release")); +} + + + // FindSrc - Find a source record /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -268,6 +290,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, unsigned long Offset = 0; string Version; string FoundRel; + pkgSourceList *SrcList = CacheFile.GetSourceList(); /* Iterate over all of the hits, which includes the resulting binary packages in the search */ @@ -279,10 +302,9 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { const string Ver = Parse->Version(); - - // find release + // try to find release const pkgIndexFile& SI = Parse->Index(); - pkgSourceList *SrcList = CacheFile.GetSourceList(); + for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S) { @@ -292,11 +314,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, { if (&SI == (*IF)) { - std::string dirname = _config->FindDir("Dir::State::lists"); - std::string path; - path = dirname + URItoFileName((*S)->GetURI()) + "dists_" + (*S)->GetDist() + "_Release"; - if (!FileExists(path)) - path = dirname + URItoFileName((*S)->GetURI()) + "dists_" + (*S)->GetDist() + "_InRelease"; + std::string path = MetaIndexFileName(*S); indexRecords records; records.Load(path); if (records.GetSuite() == DefRel)