summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-05-22 17:36:09 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-05-22 17:36:09 +0200
commita2fdb57ff93c1b1f35b796c3c99878ec3ae54a06 (patch)
treecb25d89bff41de4fe35366a8ec6033844df989ff /apt-pkg/acquire-item.cc
parentffa8189668e54572318d1834881e470c238f3642 (diff)
Add APT::Acquire::$(host)::By-Hash=1 knob, add Acquire-By-Hash to Release file
The by-hash can be configured on a per-hostname basis and a Release file can indicate that it has by-hash support via a new flag. The location of the hash now matches the AptByHash spec
Diffstat (limited to 'apt-pkg/acquire-item.cc')
-rw-r--r--apt-pkg/acquire-item.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 7fc556b7c..b7ca82c0c 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1018,31 +1018,31 @@ void pkgAcqIndex::Init(string const &URI, string const &URIDesc, string const &S
indexRecords::checkSum *Record = MetaIndexParser->Lookup(MetaKey);
if(Record)
FileSize = Record->Size;
- }
- // do the request by-hash
- // TODO:
- // - add Support-By-Hash hashtype into Release time so that we
- // know we can use it
- // - (maybe?) add support for by-hash into the sources.list as flag
- // - make apt-ftparchive generate the hashes (and expire?)
- if(_config->FindB("APT::Acquire::By-Hash", false) == true &&
- MetaIndexParser)
- {
- indexRecords::checkSum *Record = MetaIndexParser->Lookup(MetaKey);
- if(Record)
+ // TODO:
+ // - (maybe?) add support for by-hash into the sources.list as flag
+ // - make apt-ftparchive generate the hashes (and expire?)
+ // do the request by-hash
+ std::string HostKnob = "APT::Acquire::" + ::URI(URI).Host + "::By-Hash";
+ if(_config->FindB("APT::Acquire::By-Hash", false) == true ||
+ _config->FindB(HostKnob, false) == true ||
+ MetaIndexParser->GetSupportsAcquireByHash())
{
- // FIXME: make the hash used a config option or read from release file
- const HashString *TargetHash = Record->Hashes.find("SHA256");
- std::string ByHash = "/by-hash/" + TargetHash->HashValue();
- size_t trailing_slash = Desc.URI.find_last_of("/");
- Desc.URI = Desc.URI.replace(trailing_slash,
- Desc.URI.substr(trailing_slash+1).size()+1,
- ByHash);
- std::cerr << Desc.URI << std::endl;
- } else {
- _error->Warning("By-Hash requested but can not find record for %s",
- MetaKey.c_str());
+ indexRecords::checkSum *Record = MetaIndexParser->Lookup(MetaKey);
+ if(Record)
+ {
+ // FIXME: should we really use the best hash here? or a fixed one?
+ const HashString *TargetHash = Record->Hashes.find("");
+ std::string ByHash = "/by-hash/" + TargetHash->HashType() + "/" + TargetHash->HashValue();
+ size_t trailing_slash = Desc.URI.find_last_of("/");
+ Desc.URI = Desc.URI.replace(
+ trailing_slash,
+ Desc.URI.substr(trailing_slash+1).size()+1,
+ ByHash);
+ } else {
+ _error->Warning("By-Hash requested but can not find record for %s",
+ MetaKey.c_str());
+ }
}
}