summaryrefslogtreecommitdiff
path: root/apt-pkg/indexfile.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-11 16:40:45 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-11 16:49:29 +0200
commit8881b11eacd735148d087c8c0f53827cb537b582 (patch)
treeb8b0706b1afeaf9d4022cd845025014fbabcbffb /apt-pkg/indexfile.cc
parent001c76fe204e17916a6c8b351ff30b67d32cb779 (diff)
implement 'apt-get files' to access index targets
Downloading additional files is only half the job. We still need a way to allow external tools to know where the files are they requested for download given that we don't want them to choose their own location. 'apt-get files' is our answer to this showing by default in a deb822 format information about each IndexTarget with the potential to filter the records based on lines and an option to change the output format. The command serves also as an example on how to get to this information via libapt.
Diffstat (limited to 'apt-pkg/indexfile.cc')
-rw-r--r--apt-pkg/indexfile.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 72d35ddcc..33fb48e35 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -133,8 +133,10 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/
APT_CASE(ARCHITECTURE);
APT_CASE(BASE_URI);
APT_CASE(REPO_URI);
+ APT_CASE(TARGET_OF);
APT_CASE(CREATED_BY);
#undef APT_CASE
+ case FILENAME: return _config->FindDir("Dir::State::lists") + URItoFileName(URI);
}
std::map<std::string,std::string>::const_iterator const M = Options.find(Key);
if (M == Options.end())
@@ -142,6 +144,20 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/
return M->second;
}
/*}}}*/
+std::string IndexTarget::Format(std::string format) const /*{{{*/
+{
+ for (std::map<std::string, std::string>::const_iterator O = Options.begin(); O != Options.end(); ++O)
+ {
+ format = SubstVar(format, std::string("$(") + O->first + ")", O->second);
+ }
+ format = SubstVar(format, "$(METAKEY)", MetaKey);
+ format = SubstVar(format, "$(SHORTDESC)", ShortDesc);
+ format = SubstVar(format, "$(DESCRIPTION)", Description);
+ format = SubstVar(format, "$(URI)", URI);
+ format = SubstVar(format, "$(FILENAME)", Option(IndexTarget::FILENAME));
+ return format;
+}
+ /*}}}*/
pkgIndexTargetFile::pkgIndexTargetFile(IndexTarget const &Target, bool const Trusted) :/*{{{*/
pkgIndexFile(Trusted), Target(Target)
@@ -162,7 +178,7 @@ std::string pkgIndexTargetFile::Describe(bool Short) const /*{{{*/
/*}}}*/
std::string pkgIndexTargetFile::IndexFileName() const /*{{{*/
{
- std::string const s =_config->FindDir("Dir::State::lists") + URItoFileName(Target.URI);
+ std::string const s = Target.Option(IndexTarget::FILENAME);
if (FileExists(s))
return s;