}
/*}}}*/
+// IndexTarget - Constructor /*{{{*/
+IndexTarget::IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
+ std::string const &LongDesc, std::string const &URI, bool const IsOptional,
+ std::map<std::string, std::string> const &Options) :
+ URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey), IsOptional(IsOptional), Options(Options)
+{
+}
+ /*}}}*/
+
class APT_HIDDEN NoActionItem : public pkgAcquire::Item /*{{{*/
/* The sole purpose of this class is having an item which does nothing to
reach its done state to prevent cleanup deleting the mentioned file.
if (TransactionManager->MetaIndexParser->Exists((*Target)->MetaKey) == false)
{
// optional targets that we do not have in the Release file are skipped
- if ((*Target)->IsOptional())
+ if ((*Target)->IsOptional)
continue;
Status = StatAuthError;
if (stat(Final.c_str(),&Buf) == 0)
msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
- if(Target->IsOptional())
+ if(Target->IsOptional)
msg += "\nFail-Ignore: true";
return msg;
}
}
- if(Target->IsOptional() && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
+ if(Target->IsOptional && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
Status = StatDone;
else
TransactionManager->AbortTransaction();
#include <string>
#include <vector>
+#include <map>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/indexfile.h>
class IndexTarget;
class pkgAcqMetaBase;
-class APT_HIDDEN IndexTarget /*{{{*/
+class IndexTarget /*{{{*/
/** \brief Information about an index file. */
{
public:
std::string const ShortDesc;
/** \brief The key by which this index file should be
- * looked up within the meta signature file.
- */
+ looked up within the meta index file. */
std::string const MetaKey;
- virtual bool IsOptional() const {
- return false;
- }
+ /** \brief Is it okay if the file isn't found in the meta index */
+ bool const IsOptional;
- IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
- std::string const &LongDesc, std::string const &URI) :
- URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey) {}
-};
- /*}}}*/
-class APT_HIDDEN OptionalIndexTarget : public IndexTarget /*{{{*/
-/** \brief Information about an optional index file. */
-{
- public:
- virtual bool IsOptional() const {
- return true;
- }
+ /** \brief Target specific options defined by the implementation */
+ std::map<std::string, std::string> const Options;
- OptionalIndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
- std::string const &LongDesc, std::string const &URI) :
- IndexTarget(MetaKey, ShortDesc, LongDesc, URI) {}
+ IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
+ std::string const &LongDesc, std::string const &URI, bool const IsOptional,
+ std::map<std::string, std::string> const &Options);
};
/*}}}*/
class pkgAcquire::Item : public WeakPointable /*{{{*/
for (std::vector<std::string>::const_iterator T = targets.begin(); T != targets.end(); ++T)
{
#define APT_T_CONFIG(X) _config->Find(std::string("APT::Acquire::Targets::deb-src::") + *T + "::" + (X))
- std::string const URI = APT_T_CONFIG(flatArchive ? "flatURI" : "URI");
+ std::string const MetaKey = APT_T_CONFIG(flatArchive ? "flatMetaKey" : "MetaKey");
std::string const ShortDesc = APT_T_CONFIG("ShortDescription");
std::string const LongDesc = APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
bool const IsOptional = _config->FindB(std::string("APT::Acquire::Targets::deb-src::") + *T + "::Optional", true);
#undef APT_T_CONFIG
- if (URI.empty())
+ if (MetaKey.empty())
continue;
vector<debReleaseIndex::debSectionEntry const*> const SectionEntries = src->second;
{
for (vector<std::string>::const_iterator l = lang.begin(); l != lang.end(); ++l)
{
- if (*l == "none" && URI.find("$(LANGUAGE)") != std::string::npos)
+ if (*l == "none" && MetaKey.find("$(LANGUAGE)") != std::string::npos)
continue;
- struct SubstVar subst[] = {
- { "$(SITE)", &Site },
- { "$(RELEASE)", &Release },
- { "$(COMPONENT)", &((*I)->Section) },
- { "$(LANGUAGE)", &(*l) },
- { NULL, NULL }
- };
- Call(baseURI, *T, URI, ShortDesc, LongDesc, IsOptional, subst);
-
- if (URI.find("$(LANGUAGE)") == std::string::npos)
+ std::map<std::string, std::string> Options;
+ Options.insert(std::make_pair("SITE", Site));
+ Options.insert(std::make_pair("RELEASE", Release));
+ Options.insert(std::make_pair("COMPONENT", (*I)->Section));
+ 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("CREATED_BY", *T));
+ Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options);
+
+ if (MetaKey.find("$(LANGUAGE)") == std::string::npos)
break;
}
- if (URI.find("$(COMPONENT)") == std::string::npos)
+ if (MetaKey.find("$(COMPONENT)") == std::string::npos)
break;
}
}
for (std::vector<std::string>::const_iterator T = targets.begin(); T != targets.end(); ++T)
{
#define APT_T_CONFIG(X) _config->Find(std::string("APT::Acquire::Targets::deb::") + *T + "::" + (X))
- std::string const URI = APT_T_CONFIG(flatArchive ? "flatURI" : "URI");
+ std::string const MetaKey = APT_T_CONFIG(flatArchive ? "flatMetaKey" : "MetaKey");
std::string const ShortDesc = APT_T_CONFIG("ShortDescription");
std::string const LongDesc = APT_T_CONFIG(flatArchive ? "flatDescription" : "Description");
bool const IsOptional = _config->FindB(std::string("APT::Acquire::Targets::deb::") + *T + "::Optional", true);
#undef APT_T_CONFIG
- if (URI.empty())
+ if (MetaKey.empty())
continue;
for (map<string, vector<debReleaseIndex::debSectionEntry const*> >::const_iterator a = ArchEntries.begin();
for (vector<std::string>::const_iterator l = lang.begin(); l != lang.end(); ++l)
{
- if (*l == "none" && URI.find("$(LANGUAGE)") != std::string::npos)
+ if (*l == "none" && MetaKey.find("$(LANGUAGE)") != std::string::npos)
continue;
- struct SubstVar subst[] = {
- { "$(SITE)", &Site },
- { "$(RELEASE)", &Release },
- { "$(COMPONENT)", &((*I)->Section) },
- { "$(LANGUAGE)", &(*l) },
- { "$(ARCHITECTURE)", &(a->first) },
- { NULL, NULL }
- };
- Call(baseURI, *T, URI, ShortDesc, LongDesc, IsOptional, subst);
-
- if (URI.find("$(LANGUAGE)") == std::string::npos)
+ std::map<std::string, std::string> Options;
+ Options.insert(std::make_pair("SITE", Site));
+ Options.insert(std::make_pair("RELEASE", Release));
+ Options.insert(std::make_pair("COMPONENT", (*I)->Section));
+ 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("CREATED_BY", *T));
+ Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options);
+
+ if (MetaKey.find("$(LANGUAGE)") == std::string::npos)
break;
}
- if (URI.find("$(COMPONENT)") == std::string::npos)
+ if (MetaKey.find("$(COMPONENT)") == std::string::npos)
break;
}
- if (URI.find("$(ARCHITECTURE)") == std::string::npos)
+ if (MetaKey.find("$(ARCHITECTURE)") == std::string::npos)
break;
}
}
{
vector <IndexTarget *> * const IndexTargets;
- void operator()(std::string const &baseURI, std::string const &/*TargetName*/,
- std::string const &URI, std::string const &ShortDesc, std::string const &LongDesc,
- bool const IsOptional, struct SubstVar const * const subst)
+ void operator()(std::string MetaKey, std::string ShortDesc, std::string LongDesc,
+ bool const IsOptional, std::map<std::string, std::string> Options)
{
- std::string const name = SubstVar(URI, subst);
- IndexTarget * Target;
- if (IsOptional == true)
- {
- Target = new OptionalIndexTarget(
- name,
- SubstVar(ShortDesc, subst),
- SubstVar(LongDesc, subst),
- baseURI + name
- );
- }
- else
+ for (std::map<std::string, std::string>::const_iterator O = Options.begin(); O != Options.end(); ++O)
{
- Target = new IndexTarget(
- name,
- SubstVar(ShortDesc, subst),
- SubstVar(LongDesc, subst),
- baseURI + name
- );
+ MetaKey = SubstVar(MetaKey, std::string("$(") + O->first + ")", O->second);
+ ShortDesc = SubstVar(ShortDesc, std::string("$(") + O->first + ")", O->second);
+ LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second);
}
+ IndexTarget * Target = new IndexTarget(
+ MetaKey,
+ ShortDesc,
+ LongDesc,
+ Options.find("BASE_URI")->second + MetaKey,
+ IsOptional,
+ Options
+ );
IndexTargets->push_back(Target);
}
// special case for --print-uris
vector <IndexTarget *> const * const targets = ComputeIndexTargets();
-#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X))
+#define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
targets, iR);
std::string const Release;
bool const IsTrusted;
- void operator()(std::string const &/*baseURI*/, std::string const &TargetName,
- std::string const &/*URI*/, std::string const &/*ShortDesc*/, std::string const &/*LongDesc*/,
- bool const /*IsOptional*/, struct SubstVar const * const subst)
+ void operator()(std::string const &/*URI*/, std::string const &/*ShortDesc*/, std::string const &/*LongDesc*/,
+ bool const /*IsOptional*/, std::map<std::string, std::string> Options)
{
+ std::string const TargetName = Options.find("CREATED_BY")->second;
if (TargetName == "Packages")
{
Indexes->push_back(new debPackagesIndex(
URI,
Release,
- SubstVar("$(COMPONENT)", subst),
+ Options.find("COMPONENT")->second,
IsTrusted,
- SubstVar("$(ARCHITECTURE)", subst)
+ Options.find("ARCHITECTURE")->second
));
}
else if (TargetName == "Sources")
Indexes->push_back(new debSourcesIndex(
URI,
Release,
- SubstVar("$(COMPONENT)", subst),
+ Options.find("COMPONENT")->second,
IsTrusted
));
else if (TargetName == "Translations")
Indexes->push_back(new debTranslationsIndex(
URI,
Release,
- SubstVar("$(COMPONENT)", subst),
- SubstVar("$(LANGUAGE)", subst)
+ Options.find("COMPONENT")->second,
+ Options.find("LANGUAGE")->second
));
}
// The default user we drop to in the methods
Cnf.CndSet("APT::Sandbox::User", "_apt");
- Cnf.CndSet("APT::Acquire::Targets::deb::Packages::URI", "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages");
- Cnf.CndSet("APT::Acquire::Targets::deb::Packages::flatURI", "Packages");
+ Cnf.CndSet("APT::Acquire::Targets::deb::Packages::MetaKey", "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages");
+ Cnf.CndSet("APT::Acquire::Targets::deb::Packages::flatMetaKey", "Packages");
Cnf.CndSet("APT::Acquire::Targets::deb::Packages::ShortDescription", "Packages");
Cnf.CndSet("APT::Acquire::Targets::deb::Packages::Description", "$(SITE) $(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Packages");
Cnf.CndSet("APT::Acquire::Targets::deb::Packages::flatDescription", "$(SITE) $(RELEASE) Packages");
Cnf.CndSet("APT::Acquire::Targets::deb::Packages::Optional", false);
- Cnf.CndSet("APT::Acquire::Targets::deb::Translations::URI", "$(COMPONENT)/i18n/Translation-$(LANGUAGE)");
- Cnf.CndSet("APT::Acquire::Targets::deb::Translations::flatURI", "$(LANGUAGE)");
+ Cnf.CndSet("APT::Acquire::Targets::deb::Translations::MetaKey", "$(COMPONENT)/i18n/Translation-$(LANGUAGE)");
+ Cnf.CndSet("APT::Acquire::Targets::deb::Translations::flatMetaKey", "$(LANGUAGE)");
Cnf.CndSet("APT::Acquire::Targets::deb::Translations::ShortDescription", "Translation-$(LANGUAGE)");
Cnf.CndSet("APT::Acquire::Targets::deb::Translations::Description", "$(SITE) $(RELEASE)/$(COMPONENT) Translation-$(LANGUAGE)");
Cnf.CndSet("APT::Acquire::Targets::deb::Translations::flatDescription", "$(SITE) $(RELEASE) Translation-$(LANGUAGE)");
- Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::URI", "$(COMPONENT)/source/Sources");
- Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::flatURI", "Sources");
+ Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::MetaKey", "$(COMPONENT)/source/Sources");
+ Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::flatMetaKey", "Sources");
Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::ShortDescription", "Sources");
Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::Description", "$(SITE) $(RELEASE)/$(COMPONENT) Sources");
Cnf.CndSet("APT::Acquire::Targets::deb-src::Sources::flatDescription", "$(SITE) $(RELEASE) Sources");
like this (see also apt.conf(5) manpage for configuration file syntax):
APT::Acquire::Targets::deb::Packages {
- URI "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages";
+ MetaKey "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages";
ShortDescription "Packages";
Description "$(SITE) $(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Packages";
- flatURI "Packages";
+ flatMetaKey "Packages";
flatDescription "$(SITE) $(RELEASE) Packages";
Optional "false";
below the APT::Acquire::Targets scope. 'deb' is here the type of the
sources.list entry the file should be acquired for. The only other
supported value is hence 'deb-src'. Beware: You can't specify multiple
-types here and you can't download the same URI for multiple types!
+types here and you can't download the same MetaKey form multiple types!
After the type you can pick any valid and unique string which preferable
refers to the file it downloads (In the example we picked 'Packages').
This string is never shown or used.
All targets have three main properties you can define:
-* URI: The identifier of the file to be downloaded as used in the
+* MetaKey: The identifier of the file to be downloaded as used in the
Release file. It is also the relative location of the file from the
Release file. You can neither download from a different server
- entirely (absolute URI) nor should you try to access directories above
- the Release file (e.g. "../../").
+ entirely (absolute URI) nor access directories above the Release file
+ (e.g. "../../").
* ShortDescription: Very short string intended to be displayed to the
user e.g. while reporting progress. apt will e.g. use this string in
the last line to indicate progress of e.g. the download of a specific
progress lines.
Additional optional properties:
-* flat{URI,Description}: APT supports two types of repositories:
+* flat{MetaKey,Description}: APT supports two types of repositories:
dists-style repositories which are the default and by far the most
common which are named after the fact that the files are in an
elaborated directory structure. In contrast a flat-style repositories
APT::Acquire::Targets {
deb::Translations {
- URI "$(COMPONENT)/i18n/Translation-$(LANGUAGE)";
+ MetaKey "$(COMPONENT)/i18n/Translation-$(LANGUAGE)";
ShortDescription "Translation-$(LANGUAGE)";
Description "$(SITE) $(RELEASE)/$(COMPONENT) Translation-$(LANGUAGE)";
- flatURI "$(LANGUAGE)";
+ flatMetaKey "$(LANGUAGE)";
flatDescription "$(SITE) $(RELEASE) Translation-$(LANGUAGE)";
};
deb-src::Sources {
- URI "$(COMPONENT)/source/Sources";
+ MetaKey "$(COMPONENT)/source/Sources";
ShortDescription "Sources";
Description "$(SITE) $(RELEASE)/$(COMPONENT) Sources";
- flatURI "Sources";
+ flatMetaKey "Sources";
flatDescription "$(SITE) $(RELEASE) Sources";
Optional "false";
have a meaningful value here.
* $(LANGUAGE): Values are all entries (expect "none") of configuration
option Acquire::Languages, e.g. "en", "de" or "de_AT".
-
-These values are defined both for 'deb' as well as 'deb-src' targets.
-'deb' targets additional have the variable:
-
* $(ARCHITECTURE): Values are all entries of configuration option
APT::Architectures (potentially modified by sources.list options),
- e.g. "amd64", "i386" or "armel".
+ e.g. "amd64", "i386" or "armel" for the 'deb' type. In type 'deb-src'
+ this variable has the value "source".
cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
APT::Acquire::Targets::deb::Contents {
- URI "\$(COMPONENT)/Contents-\$(ARCHITECTURE)";
+ MetaKey "\$(COMPONENT)/Contents-\$(ARCHITECTURE)";
ShortDescription "Contents";
Description "\$(SITE) \$(RELEASE)/\$(COMPONENT) \$(ARCHITECTURE) Contents";
};
# only if we downloaded a compressed file, but target was uncompressed
cat > rootdir/etc/apt/apt.conf.d/content-target.conf <<EOF
APT::Acquire::Targets::deb::Contents {
- URI "\$(COMPONENT)/Contents-\$(ARCHITECTURE).gz";
+ MetaKey "\$(COMPONENT)/Contents-\$(ARCHITECTURE).gz";
ShortDescription "Contents.gz";
Description "\$(SITE) \$(RELEASE)/\$(COMPONENT) \$(ARCHITECTURE) Contents.gz";
};