From 86e3c55052737d57f9d0123f8aaacd044774c698 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Dec 2013 22:39:04 +0100 Subject: refactor --- cmdline/apt-get.cc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 5f04135d2..c38fd2d31 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -135,14 +135,15 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, } /*}}}*/ + // FIXME: move into more generic code (metaindex ?) #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) -std::string MetaIndexFileName(metaIndex *metaindex) +std::string MetaIndexFileNameOnDisk(metaIndex *metaindex) { // FIXME: this cast is the horror, the horror debReleaseIndex *r = (debReleaseIndex*)metaindex; #else -std::string MetaIndexFileName(metaIndex *r) +std::string MetaIndexFileNameOnDisk(metaIndex *r) { #endif @@ -152,14 +153,22 @@ std::string MetaIndexFileName(metaIndex *r) return PathInRelease; // and if not return the normal one - return r->MetaIndexFile("Release"); + if (FileExists(PathInRelease)) + return r->MetaIndexFile("Release"); + + return ""; } + +// GetReleaseForSourceRecord - Return Suite for the given srcrecord /*{{{*/ +// --------------------------------------------------------------------- +/* */ std::string GetReleaseForSourceRecord(pkgSourceList *SrcList, pkgSrcRecords::Parser *Parse) { // try to find release - const pkgIndexFile& SI = Parse->Index(); + const pkgIndexFile& CurrentIndexFile = Parse->Index(); + for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S) { @@ -167,19 +176,21 @@ std::string GetReleaseForSourceRecord(pkgSourceList *SrcList, for (vector::const_iterator IF = Indexes->begin(); IF != Indexes->end(); ++IF) { - if (&SI == (*IF)) + if (&CurrentIndexFile == (*IF)) { - std::string path = MetaIndexFileName(*S); - indexRecords records; - records.Load(path); - return records.GetSuite(); + std::string path = MetaIndexFileNameOnDisk(*S); + if (path != "") + { + indexRecords records; + records.Load(path); + return records.GetSuite(); + } } } } return ""; } - - + /*}}}*/ // FindSrc - Find a source record /*{{{*/ // --------------------------------------------------------------------- /* */ -- cgit v1.2.3