diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 13 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.cc | 21 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.h | 2 | ||||
-rw-r--r-- | apt-pkg/indexfile.cc | 1 | ||||
-rw-r--r-- | apt-pkg/indexfile.h | 1 | ||||
-rw-r--r-- | apt-pkg/sourcelist.cc | 1 |
6 files changed, 27 insertions, 12 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index c5b701fdc..1b76f1b7a 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1247,7 +1247,7 @@ string pkgAcqMetaClearSig::Custom600Headers() const return Header; } /*}}}*/ -bool pkgAcqMetaClearSig::VerifyDone(std::string const &Message, +bool pkgAcqMetaClearSig::VerifyDone(std::string const &Message, /*{{{*/ pkgAcquire::MethodConfig const * const Cnf) { Item::VerifyDone(Message, Cnf); @@ -1257,6 +1257,7 @@ bool pkgAcqMetaClearSig::VerifyDone(std::string const &Message, return true; } + /*}}}*/ // pkgAcqMetaClearSig::Done - We got a file /*{{{*/ void pkgAcqMetaClearSig::Done(std::string const &Message, HashStringList const &Hashes, @@ -2480,13 +2481,9 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc, // AcqIndex::AdjustForByHash - modify URI for by-hash support /*{{{*/ void pkgAcqIndex::InitByHashIfNeeded() { - // TODO: - // - (maybe?) add support for by-hash into the sources.list as flag - // - make apt-ftparchive generate the hashes (and expire?) - std::string HostKnob = "APT::Acquire::" + ::URI(Desc.URI).Host + "::By-Hash"; - if(_config->FindB("APT::Acquire::By-Hash", false) == true || - _config->FindB(HostKnob, false) == true || - TransactionManager->MetaIndexParser->GetSupportsAcquireByHash()) + std::string const useByHash = Target.Option(IndexTarget::BY_HASH); + if(useByHash == "force" || (StringToBool(useByHash) == true && + TransactionManager->MetaIndexParser->GetSupportsAcquireByHash())) { HashStringList const Hashes = GetExpectedHashes(); if(Hashes.usable()) diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 6ed722e68..a53d32d34 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -39,6 +39,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/ std::vector<std::string> Architectures; std::vector<std::string> Languages; bool UsePDiffs; + std::string UseByHash; }; std::vector<debSectionEntry> DebEntries; @@ -149,6 +150,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI, bool const KeepCompressed = APT_T_CONFIG_BOOL("KeepCompressed", GzipIndex); bool const DefaultEnabled = APT_T_CONFIG_BOOL("DefaultEnabled", true); bool const UsePDiffs = APT_T_CONFIG_BOOL("PDiffs", E->UsePDiffs); + std::string const UseByHash = APT_T_CONFIG_STR("By-Hash", E->UseByHash); std::string const CompressionTypes = APT_T_CONFIG_STR("CompressionTypes", DefCompressionTypes); #undef APT_T_CONFIG_BOOL #undef APT_T_CONFIG_STR @@ -245,6 +247,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI, Options.insert(std::make_pair("TARGET_OF", Type)); Options.insert(std::make_pair("CREATED_BY", *T)); Options.insert(std::make_pair("PDIFFS", UsePDiffs ? "yes" : "no")); + Options.insert(std::make_pair("BY_HASH", UseByHash)); Options.insert(std::make_pair("DEFAULTENABLED", DefaultEnabled ? "yes" : "no")); Options.insert(std::make_pair("COMPRESSIONTYPES", CompressionTypes)); Options.insert(std::make_pair("SOURCESENTRY", E->sourcesEntry)); @@ -286,12 +289,12 @@ void debReleaseIndex::AddComponent(std::string const &sourcesEntry, /*{{{*/ std::vector<std::string> const &Targets, std::vector<std::string> const &Architectures, std::vector<std::string> Languages, - bool const usePDiffs) + bool const usePDiffs, std::string const &useByHash) { if (Languages.empty() == true) Languages.push_back("none"); debReleaseIndexPrivate::debSectionEntry const entry = { - sourcesEntry, Name, Targets, Architectures, Languages, usePDiffs + sourcesEntry, Name, Targets, Architectures, Languages, usePDiffs, useByHash }; if (isSrc) d->DebSrcEntries.push_back(entry); @@ -822,6 +825,17 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ UsePDiffs = StringToBool(opt->second); } + std::string UseByHash = _config->Find("APT::Acquire::By-Hash", "yes"); + UseByHash = _config->Find("Acquire::By-Hash", UseByHash); + { + std::string const host = ::URI(URI).Host; + UseByHash = _config->Find("APT::Acquire::" + host + "::By-Hash", UseByHash); + UseByHash = _config->Find("Acquire::" + host + "::By-Hash", UseByHash); + std::map<std::string, std::string>::const_iterator const opt = Options.find("by-hash"); + if (opt != Options.end()) + UseByHash = opt->second; + } + auto const entry = Options.find("sourceslist-entry"); Deb->AddComponent( entry->second, @@ -830,7 +844,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ mytargets, parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()), parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true)), - UsePDiffs + UsePDiffs, + UseByHash ); if (Deb->SetTrusted(GetTriStateOption(Options, "trusted")) == false || diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index 419cbdc9d..37515f934 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -64,7 +64,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex std::vector<std::string> const &Targets, std::vector<std::string> const &Architectures, std::vector<std::string> Languages, - bool const usePDiffs); + bool const usePDiffs, std::string const &useByHash); }; #endif diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index fad339197..f57b442a3 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -148,6 +148,7 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/ APT_CASE(DEFAULTENABLED); APT_CASE(COMPRESSIONTYPES); APT_CASE(SOURCESENTRY); + APT_CASE(BY_HASH); #undef APT_CASE case FILENAME: return _config->FindDir("Dir::State::lists") + URItoFileName(URI); case EXISTING_FILENAME: diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index a09c39057..c3f01c774 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -89,6 +89,7 @@ class IndexTarget /*{{{*/ COMPRESSIONTYPES, DEFAULTENABLED, SOURCESENTRY, + BY_HASH, }; std::string Option(OptionKeys const Key) const; bool OptionBool(OptionKeys const Key) const; diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 4e5ff0578..2100b5d3c 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -108,6 +108,7 @@ bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List, /*{{{*/ mapping.insert(std::make_pair("Valid-Until-Max", std::make_pair("valid-until-max", false))); mapping.insert(std::make_pair("Signed-By", std::make_pair("signed-by", false))); mapping.insert(std::make_pair("PDiffs", std::make_pair("pdiffs", false))); + mapping.insert(std::make_pair("By-Hash", std::make_pair("by-hash", false))); for (std::map<char const * const, std::pair<char const * const, bool> >::const_iterator m = mapping.begin(); m != mapping.end(); ++m) if (Tags.Exists(m->first)) |