summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/debmetaindex.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-11 11:38:04 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-11 11:38:04 +0200
commite3c1cfc767f17f5e9b2cd99f2658db3d6ac8edd9 (patch)
tree3114a44b2499c76baea4aa24ec1b408c3e21cf3d /apt-pkg/deb/debmetaindex.cc
parent1da3b7b8e15b642135b54684e70a0c271471f07a (diff)
use IndexTarget to get to IndexFile
Removes a bunch of duplicated code in the deb-specific parts. Especially the Description part is now handled centrally by IndexTarget instead of being duplicated to the derivations of IndexFile. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/deb/debmetaindex.cc')
-rw-r--r--apt-pkg/deb/debmetaindex.cc56
1 files changed, 14 insertions, 42 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index d4e340be0..9108a5097 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -140,6 +140,7 @@ void foreachTarget(std::string const URI, std::string const Dist,
Options.insert(std::make_pair("LANGUAGE", *l));
Options.insert(std::make_pair("ARCHITECTURE", "source"));
Options.insert(std::make_pair("BASE_URI", baseURI));
+ Options.insert(std::make_pair("REPO_URI", URI));
Options.insert(std::make_pair("CREATED_BY", *T));
Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options);
@@ -186,6 +187,7 @@ void foreachTarget(std::string const URI, std::string const Dist,
Options.insert(std::make_pair("LANGUAGE", *l));
Options.insert(std::make_pair("ARCHITECTURE", a->first));
Options.insert(std::make_pair("BASE_URI", baseURI));
+ Options.insert(std::make_pair("REPO_URI", URI));
Options.insert(std::make_pair("CREATED_BY", *T));
Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options);
@@ -294,55 +296,25 @@ bool debReleaseIndex::IsTrusted() const
return FileExists(VerifiedSigFile);
}
-struct GetIndexFilesClass
+std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
{
- vector <pkgIndexFile *> * const Indexes;
- std::string const URI;
- std::string const Release;
- bool const IsTrusted;
+ if (Indexes != NULL)
+ return Indexes;
- void operator()(std::string const &/*URI*/, std::string const &/*ShortDesc*/, std::string const &/*LongDesc*/,
- bool const /*IsOptional*/, std::map<std::string, std::string> Options)
+ Indexes = new std::vector<pkgIndexFile*>();
+ std::vector<IndexTarget> const Targets = GetIndexTargets();
+ bool const istrusted = IsTrusted();
+ for (std::vector<IndexTarget>::const_iterator T = Targets.begin(); T != Targets.end(); ++T)
{
- std::string const TargetName = Options.find("CREATED_BY")->second;
+ std::string const TargetName = T->Options.find("CREATED_BY")->second;
if (TargetName == "Packages")
- {
- Indexes->push_back(new debPackagesIndex(
- URI,
- Release,
- Options.find("COMPONENT")->second,
- IsTrusted,
- Options.find("ARCHITECTURE")->second
- ));
- }
+ Indexes->push_back(new debPackagesIndex(*T, istrusted));
else if (TargetName == "Sources")
- Indexes->push_back(new debSourcesIndex(
- URI,
- Release,
- Options.find("COMPONENT")->second,
- IsTrusted
- ));
+ Indexes->push_back(new debSourcesIndex(*T, istrusted));
else if (TargetName == "Translations")
- Indexes->push_back(new debTranslationsIndex(
- URI,
- Release,
- Options.find("COMPONENT")->second,
- Options.find("LANGUAGE")->second
- ));
+ Indexes->push_back(new debTranslationsIndex(*T));
}
-
- GetIndexFilesClass(std::string const &URI, std::string const &Release, bool const IsTrusted) :
- Indexes(new vector <pkgIndexFile*>), URI(URI), Release(Release), IsTrusted(IsTrusted) {}
-};
-
-std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
-{
- if (Indexes != NULL)
- return Indexes;
-
- GetIndexFilesClass comp(URI, Dist, IsTrusted());
- foreachTarget(URI, Dist, ArchEntries, comp);
- return Indexes = comp.Indexes;
+ return Indexes;
}
void debReleaseIndex::PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry) {