summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/acquire-item.cc40
-rw-r--r--apt-pkg/acquire-item.h3
-rw-r--r--apt-pkg/deb/debmetaindex.cc18
3 files changed, 49 insertions, 12 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 8c11337ac..0e73b3b8c 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -684,6 +684,7 @@ class pkgAcquire::Item::Private
{
public:
std::vector<std::string> PastRedirections;
+ std::unordered_map<std::string, std::string> CustomFields;
unsigned int Retries;
Private() : Retries(_config->FindI("Acquire::Retries", 0))
@@ -709,7 +710,17 @@ pkgAcquire::Item::~Item()
/*}}}*/
std::string pkgAcquire::Item::Custom600Headers() const /*{{{*/
{
- return std::string();
+ std::ostringstream header;
+ for (auto const &f : d->CustomFields)
+ if (f.second.empty() == false)
+ header << '\n'
+ << f.first << ": " << f.second;
+ return header.str();
+}
+ /*}}}*/
+std::unordered_map<std::string, std::string> &pkgAcquire::Item::ModifyCustomFields() /*{{{*/
+{
+ return d->CustomFields;
}
/*}}}*/
unsigned int &pkgAcquire::Item::ModifyRetries() /*{{{*/
@@ -1051,6 +1062,15 @@ pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner, /*{{{*/
{
if (TransactionManager != this)
TransactionManager->Add(this);
+ ModifyCustomFields() = {
+ {"Target-Site", Target.Option(IndexTarget::SITE)},
+ {"Target-Repo-URI", Target.Option(IndexTarget::REPO_URI)},
+ {"Target-Base-URI", Target.Option(IndexTarget::BASE_URI)},
+ {"Target-Component", Target.Option(IndexTarget::COMPONENT)},
+ {"Target-Release", Target.Option(IndexTarget::RELEASE)},
+ {"Target-Architecture", Target.Option(IndexTarget::ARCHITECTURE)},
+ {"Target-Language", Target.Option(IndexTarget::LANGUAGE)},
+ };
}
/*}}}*/
pkgAcqTransactionItem::~pkgAcqTransactionItem() /*{{{*/
@@ -1228,7 +1248,8 @@ bool pkgAcqMetaBase::CheckStopAuthentication(pkgAcquire::Item * const I, const s
// ---------------------------------------------------------------------
string pkgAcqMetaBase::Custom600Headers() const
{
- std::string Header = "\nIndex-File: true";
+ std::string Header = pkgAcqTransactionItem::Custom600Headers();
+ Header.append("\nIndex-File: true");
std::string MaximumSize;
strprintf(MaximumSize, "\nMaximum-Size: %i",
_config->FindI("Acquire::MaxReleaseFileSize", 10*1000*1000));
@@ -3219,7 +3240,6 @@ void pkgAcqIndex::StageDecompressDone()
/*}}}*/
pkgAcqIndex::~pkgAcqIndex() {}
-
// AcqArchive::AcqArchive - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* This just sets up the initial fetch environment and queues the first
@@ -3346,6 +3366,20 @@ bool pkgAcqArchive::QueueNext()
Desc.Owner = this;
Desc.ShortDesc = Version.ParentPkg().FullName(true);
+ auto fields = ModifyCustomFields();
+ if (PkgF->Architecture != 0)
+ fields.emplace("Target-Architecture", PkgF.Architecture());
+ if (PkgF->Component != 0)
+ fields.emplace("Target-Component", PkgF.Component());
+ auto const RelF = PkgF.ReleaseFile();
+ if (RelF.end() == false)
+ {
+ if (RelF->Codename != 0)
+ fields.emplace("Target-Codename", RelF.Codename());
+ if (RelF->Archive != 0)
+ fields.emplace("Target-Suite", RelF.Archive());
+ }
+
// See if we already have the file. (Legacy filenames)
FileSize = Version->Size;
string FinalFile = _config->FindDir("Dir::Cache::Archives") + flNotDir(PkgFile);
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 7705f3ccb..7f5f75195 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -27,6 +27,7 @@
#include <map>
#include <string>
+#include <unordered_map>
#include <vector>
#ifndef APT_8_CLEANER_HEADERS
@@ -241,6 +242,8 @@ class pkgAcquire::Item : public WeakPointable /*{{{*/
virtual std::string Custom600Headers() const;
// Retries should really be a member of the Item, but can't be for ABI reasons
APT_HIDDEN unsigned int &ModifyRetries();
+ // this is more a hack than a proper external interface, hence hidden
+ APT_HIDDEN std::unordered_map<std::string, std::string> &ModifyCustomFields();
/** \brief A "descriptive" URI-like string.
*
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index ad27e2dcd..2688052a4 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -118,8 +118,6 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
{
bool const flatArchive = (Dist[Dist.length() - 1] == '/');
std::string const baseURI = constructMetaIndexURI(URI, Dist, "");
- std::string const Release = (Dist == "/") ? "" : Dist;
- std::string const Site = ::URI::ArchiveOnly(URI);
std::string DefCompressionTypes;
{
@@ -208,8 +206,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
constexpr static auto BreakPoint = "$(NATIVE_ARCHITECTURE)";
// available in templates
std::map<std::string, std::string> Options;
- Options.insert(std::make_pair("SITE", Site));
- Options.insert(std::make_pair("RELEASE", Release));
+ Options.insert(ReleaseOptions.begin(), ReleaseOptions.end());
if (tplMetaKey.find("$(COMPONENT)") != std::string::npos)
Options.emplace("COMPONENT", E->Name);
if (tplMetaKey.find("$(LANGUAGE)") != std::string::npos)
@@ -290,7 +287,6 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI,
}
// not available in templates, but in the indextarget
- Options.insert(ReleaseOptions.begin(), ReleaseOptions.end());
Options.insert(std::make_pair("IDENTIFIER", Identifier));
Options.insert(std::make_pair("TARGET_OF", Type));
Options.insert(std::make_pair("CREATED_BY", *T));
@@ -1070,7 +1066,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
}
for (auto&& key: KeysA)
{
- if (key == "BASE_URI" || key == "REPO_URI")
+ if (key == "BASE_URI" || key == "REPO_URI" || key == "SITE" || key == "RELEASE")
continue;
auto const a = OptionsA.find(key);
auto const b = OptionsB.find(key);
@@ -1083,9 +1079,11 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
static debReleaseIndex * GetDebReleaseIndexBy(std::vector<metaIndex *> &List, std::string const &URI,
std::string const &Dist, std::map<std::string, std::string> const &Options)
{
- std::map<std::string,std::string> ReleaseOptions = {{
- { "BASE_URI", constructMetaIndexURI(URI, Dist, "") },
- { "REPO_URI", URI },
+ std::map<std::string, std::string> ReleaseOptions{{
+ {"BASE_URI", constructMetaIndexURI(URI, Dist, "")},
+ {"REPO_URI", URI},
+ {"SITE", ::URI::ArchiveOnly(URI)},
+ {"RELEASE", (Dist == "/") ? "" : Dist},
}};
if (GetBoolOption(Options, "allow-insecure", _config->FindB("Acquire::AllowInsecureRepositories")))
ReleaseOptions.emplace("ALLOW_INSECURE", "true");
@@ -1134,6 +1132,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
bool const &IsSrc, std::map<std::string, std::string> const &Options) const
{
auto const Deb = GetDebReleaseIndexBy(List, URI, Dist, Options);
+ if (Deb == nullptr)
+ return false;
bool const UsePDiffs = GetBoolOption(Options, "pdiffs", _config->FindB("Acquire::PDiffs", true));