summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
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
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')
-rw-r--r--apt-pkg/deb/debindexfile.cc381
-rw-r--r--apt-pkg/deb/debindexfile.h84
-rw-r--r--apt-pkg/deb/debmetaindex.cc56
3 files changed, 62 insertions, 459 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 20bf5ae50..3e60423ff 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -44,8 +44,8 @@ using std::string;
// SourcesIndex::debSourcesIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trusted) :
- pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section)
+debSourcesIndex::debSourcesIndex(IndexTarget const &Target,bool const Trusted) :
+ pkgIndexTargetFile(Target, Trusted)
{
}
/*}}}*/
@@ -56,16 +56,9 @@ debSourcesIndex::debSourcesIndex(string URI,string Dist,string Section,bool Trus
string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
pkgSrcRecords::File const &File) const
{
- string Res;
- Res = ::URI::ArchiveOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res += Dist;
- }
- else
- Res += Dist + '/' + Section;
-
+ string Res = Target.Description;
+ Res.erase(Target.Description.rfind(' '));
+
Res += " ";
Res += Record.Package();
Res += " ";
@@ -80,129 +73,19 @@ string debSourcesIndex::SourceInfo(pkgSrcRecords::Parser const &Record,
/* */
pkgSrcRecords::Parser *debSourcesIndex::CreateSrcParser() const
{
- string SourcesURI = _config->FindDir("Dir::State::lists") +
- URItoFileName(IndexURI("Sources"));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p;
- p = SourcesURI + '.' + *t;
- if (FileExists(p))
- return new debSrcRecordParser(p, this);
- }
+ string const SourcesURI = IndexFileName();
if (FileExists(SourcesURI))
return new debSrcRecordParser(SourcesURI, this);
return NULL;
}
/*}}}*/
-// SourcesIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::Describe(bool Short) const
-{
- char S[300];
- if (Short == true)
- snprintf(S,sizeof(S),"%s",Info("Sources").c_str());
- else
- snprintf(S,sizeof(S),"%s (%s)",Info("Sources").c_str(),
- IndexFile("Sources").c_str());
-
- return S;
-}
- /*}}}*/
-// SourcesIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::Info(const char *Type) const
-{
- string Info = ::URI::ArchiveOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- Info += Type;
- return Info;
-}
- /*}}}*/
-// SourcesIndex::Index* - Return the URI to the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debSourcesIndex::IndexFile(const char *Type) const
-{
- string s = URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
-}
-
-string debSourcesIndex::IndexURI(const char *Type) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/source/";
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// SourcesIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debSourcesIndex::Exists() const
-{
- return FileExists(IndexFile("Sources"));
-}
- /*}}}*/
-// SourcesIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-unsigned long debSourcesIndex::Size() const
-{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
- _error->PushToStack();
-
- FileFd f(IndexFile("Sources"), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
-
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
-}
- /*}}}*/
// PackagesIndex::debPackagesIndex - Contructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string const &Section,
- bool const &Trusted, string const &Arch) :
- pkgIndexFile(Trusted), URI(URI), Dist(Dist), Section(Section), Architecture(Arch)
+debPackagesIndex::debPackagesIndex(IndexTarget const &Target, bool const Trusted) :
+ pkgIndexTargetFile(Target, Trusted)
{
- if (Architecture == "native")
- Architecture = _config->Find("APT::Architecture");
}
/*}}}*/
// PackagesIndex::ArchiveInfo - Short version of the archive url /*{{{*/
@@ -210,135 +93,40 @@ debPackagesIndex::debPackagesIndex(string const &URI, string const &Dist, string
/* This is a shorter version that is designed to be < 60 chars or so */
string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
{
- string Res = ::URI::ArchiveOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res += Dist;
- }
- else
- Res += Dist + '/' + Section;
-
+ std::string const Dist = Target.Option("RELEASE");
+ string Res = Target.Option("SITE") + " " + Dist;
+ std::string const Component = Target.Option("COMPONENT");
+ if (Component.empty() == false)
+ Res += "/" + Component;
+
Res += " ";
Res += Ver.ParentPkg().Name();
Res += " ";
- if (Dist[Dist.size() - 1] != '/')
+ if (Dist.empty() == false && Dist[Dist.size() - 1] != '/')
Res.append(Ver.Arch()).append(" ");
Res += Ver.VerStr();
return Res;
}
/*}}}*/
-// PackagesIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This should help the user find the index in the sources.list and
- in the filesystem for problem solving */
-string debPackagesIndex::Describe(bool Short) const
-{
- char S[300];
- if (Short == true)
- snprintf(S,sizeof(S),"%s",Info("Packages").c_str());
- else
- snprintf(S,sizeof(S),"%s (%s)",Info("Packages").c_str(),
- IndexFile("Packages").c_str());
- return S;
-}
- /*}}}*/
-// PackagesIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debPackagesIndex::Info(const char *Type) const
-{
- string Info = ::URI::ArchiveOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- if (Dist[Dist.size() - 1] != '/')
- Info += Architecture + " ";
- Info += Type;
- return Info;
-}
- /*}}}*/
-// PackagesIndex::Index* - Return the URI to the index files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debPackagesIndex::IndexFile(const char *Type) const
-{
- string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
-}
-string debPackagesIndex::IndexURI(const char *Type) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/binary-" + Architecture + '/';
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// PackagesIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debPackagesIndex::Exists() const
-{
- return FileExists(IndexFile("Packages"));
-}
- /*}}}*/
-// PackagesIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This is really only used for progress reporting. */
-unsigned long debPackagesIndex::Size() const
-{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
- _error->PushToStack();
-
- FileFd f(IndexFile("Packages"), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
-
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
-}
- /*}}}*/
// PackagesIndex::Merge - Load the index file into a cache /*{{{*/
// ---------------------------------------------------------------------
/* */
bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
- string PackageFile = IndexFile("Packages");
+ string const PackageFile = IndexFileName();
FileFd Pkg(PackageFile,FileFd::ReadOnly, FileFd::Extension);
- debListParser Parser(&Pkg, Architecture);
+ debListParser Parser(&Pkg, Target.Option("ARCHITECTURE"));
if (_error->PendingError() == true)
return _error->Error("Problem opening %s",PackageFile.c_str());
if (Prog != NULL)
- Prog->SubProgress(0,Info("Packages"));
+ Prog->SubProgress(0, Target.Description);
+
+
+ std::string const URI = Target.Option("REPO_URI");
+ std::string Dist = Target.Option("RELEASE");
+ if (Dist.empty())
+ Dist = "/";
::URI Tmp(URI);
if (Gen.SelectFile(PackageFile,Tmp.Host,*this) == false)
return _error->Error("Problem with SelectFile %s",PackageFile.c_str());
@@ -370,7 +158,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
if (_error->PendingError() == true)
return false;
- Parser.LoadReleaseInfo(File,Rel,Section);
+ Parser.LoadReleaseInfo(File, Rel, Target.Option("COMPONENT"));
}
return true;
@@ -381,7 +169,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
/* */
pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
{
- string FileName = IndexFile("Packages");
+ string const FileName = IndexFileName();
pkgCache::PkgFileIterator File = Cache.FileBegin();
for (; File.end() == false; ++File)
{
@@ -411,113 +199,13 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
/*}}}*/
// TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-debTranslationsIndex::debTranslationsIndex(std::string const &URI, std::string const &Dist,
- std::string const &Section, std::string const &Translation) :
- pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section),
- Language(Translation)
+debTranslationsIndex::debTranslationsIndex(IndexTarget const &Target) :
+ pkgIndexTargetFile(Target, true)
{}
/*}}}*/
-// TranslationIndex::Trans* - Return the URI to the translation files /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debTranslationsIndex::IndexFile(const char *Type) const
-{
- string s =_config->FindDir("Dir::State::lists") + URItoFileName(IndexURI(Type));
-
- std::vector<std::string> types = APT::Configuration::getCompressionTypes();
- for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
- {
- string p = s + '.' + *t;
- if (FileExists(p))
- return p;
- }
- return s;
-}
-string debTranslationsIndex::IndexURI(const char *Type) const
-{
- string Res;
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Res = URI + Dist;
- else
- Res = URI;
- }
- else
- Res = URI + "dists/" + Dist + '/' + Section +
- "/i18n/Translation-";
-
- Res += Type;
- return Res;
-}
- /*}}}*/
-// TranslationsIndex::Describe - Give a descriptive path to the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This should help the user find the index in the sources.list and
- in the filesystem for problem solving */
-string debTranslationsIndex::Describe(bool Short) const
-{
- std::string S;
- if (Short == true)
- strprintf(S,"%s",Info(TranslationFile().c_str()).c_str());
- else
- strprintf(S,"%s (%s)",Info(TranslationFile().c_str()).c_str(),
- IndexFile(Language.c_str()).c_str());
- return S;
-}
- /*}}}*/
-// TranslationsIndex::Info - One liner describing the index URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-string debTranslationsIndex::Info(const char *Type) const
-{
- string Info = ::URI::ArchiveOnly(URI) + ' ';
- if (Dist[Dist.size() - 1] == '/')
- {
- if (Dist != "/")
- Info += Dist;
- }
- else
- Info += Dist + '/' + Section;
- Info += " ";
- Info += Type;
- return Info;
-}
- /*}}}*/
bool debTranslationsIndex::HasPackages() const /*{{{*/
{
- return FileExists(IndexFile(Language.c_str()));
-}
- /*}}}*/
-// TranslationsIndex::Exists - Check if the index is available /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool debTranslationsIndex::Exists() const
-{
- return FileExists(IndexFile(Language.c_str()));
-}
- /*}}}*/
-// TranslationsIndex::Size - Return the size of the index /*{{{*/
-// ---------------------------------------------------------------------
-/* This is really only used for progress reporting. */
-unsigned long debTranslationsIndex::Size() const
-{
- unsigned long size = 0;
-
- /* we need to ignore errors here; if the lists are absent, just return 0 */
- _error->PushToStack();
-
- FileFd f(IndexFile(Language.c_str()), FileFd::ReadOnly, FileFd::Extension);
- if (!f.Failed())
- size = f.Size();
-
- if (_error->PendingError() == true)
- size = 0;
- _error->RevertToStack();
-
- return size;
+ return Exists();
}
/*}}}*/
// TranslationsIndex::Merge - Load the index file into a cache /*{{{*/
@@ -526,7 +214,7 @@ unsigned long debTranslationsIndex::Size() const
bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
// Check the translation file, if in use
- string TranslationFile = IndexFile(Language.c_str());
+ string const TranslationFile = IndexFileName();
if (FileExists(TranslationFile))
{
FileFd Trans(TranslationFile,FileFd::ReadOnly, FileFd::Extension);
@@ -535,7 +223,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
return false;
if (Prog != NULL)
- Prog->SubProgress(0, Info(TranslationFile.c_str()));
+ Prog->SubProgress(0, Target.Description);
if (Gen.SelectFile(TranslationFile,string(),*this) == false)
return _error->Error("Problem with SelectFile %s",TranslationFile.c_str());
@@ -556,8 +244,8 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
/* */
pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const
{
- string FileName = IndexFile(Language.c_str());
-
+ string FileName = IndexFileName();
+
pkgCache::PkgFileIterator File = Cache.FileBegin();
for (; File.end() == false; ++File)
{
@@ -580,10 +268,11 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con
return pkgCache::PkgFileIterator(Cache);
}
return File;
- }
+ }
return File;
}
/*}}}*/
+
// StatusIndex::debStatusIndex - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h
index 1e5882071..dd3f212b2 100644
--- a/apt-pkg/deb/debindexfile.h
+++ b/apt-pkg/deb/debindexfile.h
@@ -30,19 +30,16 @@ class pkgCacheGenerator;
class APT_HIDDEN debStatusIndex : public pkgIndexFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
protected:
std::string File;
public:
virtual const Type *GetType() const APT_CONST;
-
+
// Interface for acquire
virtual std::string Describe(bool /*Short*/) const {return File;};
-
+
// Interface for the Cache Generator
virtual bool Exists() const;
virtual bool HasPackages() const {return true;};
@@ -54,91 +51,42 @@ class APT_HIDDEN debStatusIndex : public pkgIndexFile
debStatusIndex(std::string File);
virtual ~debStatusIndex();
};
-
-class APT_HIDDEN debPackagesIndex : public pkgIndexFile
-{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- std::string URI;
- std::string Dist;
- std::string Section;
- std::string Architecture;
-
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
+class APT_HIDDEN debPackagesIndex : public pkgIndexTargetFile
+{
public:
-
+
virtual const Type *GetType() const APT_CONST;
// Stuff for accessing files on remote items
virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const;
- virtual std::string ArchiveURI(std::string File) const {return URI + File;};
-
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
-
+
// Interface for the Cache Generator
- virtual bool Exists() const;
virtual bool HasPackages() const {return true;};
- virtual unsigned long Size() const;
virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
- debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section,
- bool const &Trusted, std::string const &Arch = "native");
+ debPackagesIndex(IndexTarget const &Target, bool const Trusted);
virtual ~debPackagesIndex();
};
-class APT_HIDDEN debTranslationsIndex : public pkgIndexFile
+class APT_HIDDEN debTranslationsIndex : public pkgIndexTargetFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- std::string const URI;
- std::string const Dist;
- std::string const Section;
- std::string const Language;
-
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
-
- APT_HIDDEN std::string TranslationFile() const {return std::string("Translation-").append(Language);};
-
public:
virtual const Type *GetType() const APT_CONST;
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
-
// Interface for the Cache Generator
- virtual bool Exists() const;
virtual bool HasPackages() const;
- virtual unsigned long Size() const;
virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const;
virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
- debTranslationsIndex(std::string const &URI,std::string const &Dist,std::string const &Section, std::string const &Language);
+ debTranslationsIndex(IndexTarget const &Target);
virtual ~debTranslationsIndex();
};
-class APT_HIDDEN debSourcesIndex : public pkgIndexFile
+class APT_HIDDEN debSourcesIndex : public pkgIndexTargetFile
{
- /** \brief dpointer placeholder (for later in case we need it) */
- void *d;
-
- std::string URI;
- std::string Dist;
- std::string Section;
-
- APT_HIDDEN std::string Info(const char *Type) const;
- APT_HIDDEN std::string IndexFile(const char *Type) const;
- APT_HIDDEN std::string IndexURI(const char *Type) const;
-
public:
virtual const Type *GetType() const APT_CONST;
@@ -146,20 +94,14 @@ class APT_HIDDEN debSourcesIndex : public pkgIndexFile
// Stuff for accessing files on remote items
virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record,
pkgSrcRecords::File const &File) const;
- virtual std::string ArchiveURI(std::string File) const {return URI + File;};
-
- // Interface for acquire
- virtual std::string Describe(bool Short) const;
// Interface for the record parsers
virtual pkgSrcRecords::Parser *CreateSrcParser() const;
-
+
// Interface for the Cache Generator
- virtual bool Exists() const;
virtual bool HasPackages() const {return false;};
- virtual unsigned long Size() const;
-
- debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted);
+
+ debSourcesIndex(IndexTarget const &Target, bool const Trusted);
virtual ~debSourcesIndex();
};
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) {