diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-08-27 18:13:00 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-08-27 18:16:50 +0200 |
commit | 1a3a14ac63b0c4f18de53a7bddcf79d20a5e814f (patch) | |
tree | 970faeb03bf9407e145aa607d755a08f6e8a0add /apt-pkg | |
parent | bf33c3bd991be704494a060730f8370fd9cad52c (diff) |
sources.list and indextargets option for pdiffs
Disabling pdiffs can be useful occasionally, like if you have a fast
local mirror where the download doesn't matter, but still want to use it
for non-local mirrors. Also, some users might prefer it to only use it
for very big indextargets like Contents.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 2 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.cc | 20 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.h | 3 | ||||
-rw-r--r-- | apt-pkg/indexfile.cc | 6 | ||||
-rw-r--r-- | apt-pkg/indexfile.h | 2 | ||||
-rw-r--r-- | apt-pkg/sourcelist.cc | 1 |
6 files changed, 29 insertions, 5 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7dcaa25a4..4e9c435e1 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -957,7 +957,7 @@ void pkgAcqMetaBase::QueueIndexes(bool const verify) /*{{{*/ Target != IndexTargets.end(); ++Target) { - bool trypdiff = _config->FindB("Acquire::PDiffs", true); + bool trypdiff = Target->OptionBool(IndexTarget::PDIFFS); if (verify == true) { if (TransactionManager->MetaIndexParser->Exists(Target->MetaKey) == false) diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 69e41a6f4..78d54b04e 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -36,6 +36,7 @@ class APT_HIDDEN debReleaseIndexPrivate /*{{{*/ std::vector<std::string> Targets; std::vector<std::string> Architectures; std::vector<std::string> Languages; + bool UsePDiffs; }; std::vector<debSectionEntry> DebEntries; @@ -131,6 +132,7 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI, std::string const tplLongDesc = "$(SITE) " + APT_T_CONFIG(flatArchive ? "flatDescription" : "Description"); bool const IsOptional = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::Optional", true); bool const KeepCompressed = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::KeepCompressed", GzipIndex); + bool const UsePDiffs = _config->FindB(std::string("Acquire::IndexTargets::") + Type + "::" + *T + "::PDiffs", E->UsePDiffs); #undef APT_T_CONFIG if (tplMetaKey.empty()) continue; @@ -156,6 +158,10 @@ static void GetIndexTargetsFor(char const * const Type, std::string const &URI, Options.insert(std::make_pair("REPO_URI", URI)); Options.insert(std::make_pair("TARGET_OF", Type)); Options.insert(std::make_pair("CREATED_BY", *T)); + if (UsePDiffs) + Options.insert(std::make_pair("PDIFFS", "yes")); + else + Options.insert(std::make_pair("PDIFFS", "no")); std::string MetaKey = tplMetaKey; std::string ShortDesc = tplShortDesc; @@ -201,12 +207,13 @@ std::vector<IndexTarget> debReleaseIndex::GetIndexTargets() const void debReleaseIndex::AddComponent(bool const isSrc, std::string const &Name,/*{{{*/ std::vector<std::string> const &Targets, std::vector<std::string> const &Architectures, - std::vector<std::string> Languages) + std::vector<std::string> Languages, + bool const usePDiffs) { if (Languages.empty() == true) Languages.push_back("none"); debReleaseIndexPrivate::debSectionEntry const entry = { - Name, Targets, Architectures, Languages + Name, Targets, Architectures, Languages, usePDiffs }; if (isSrc) d->DebSrcEntries.push_back(entry); @@ -730,12 +737,19 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ else if (optValue == false && tarItr != mytargets.end()) mytargets.erase(std::remove(mytargets.begin(), mytargets.end(), target), mytargets.end()); } + bool UsePDiffs = _config->FindB("Acquire::PDiffs", true); + { + std::map<std::string, std::string>::const_iterator const opt = Options.find("pdiffs"); + if (opt != Options.end()) + UsePDiffs = StringToBool(opt->second); + } Deb->AddComponent( IsSrc, Section, mytargets, parsePlusMinusOptions("arch", Options, APT::Configuration::getArchitectures()), - parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true)) + parsePlusMinusOptions("lang", Options, APT::Configuration::getLanguages(true)), + UsePDiffs ); if (Deb->SetTrusted(GetTriStateOption(Options, "trusted")) == false || diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index e93959a21..bba0e344f 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -62,7 +62,8 @@ class APT_HIDDEN debReleaseIndex : public metaIndex void AddComponent(bool const isSrc, std::string const &Name, std::vector<std::string> const &Targets, std::vector<std::string> const &Architectures, - std::vector<std::string> Languages); + std::vector<std::string> Languages, + bool const usePDiffs); }; #endif diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 8e50ecfae..b81893260 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -143,6 +143,7 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/ APT_CASE(REPO_URI); APT_CASE(TARGET_OF); APT_CASE(CREATED_BY); + APT_CASE(PDIFFS); #undef APT_CASE case FILENAME: return _config->FindDir("Dir::State::lists") + URItoFileName(URI); case EXISTING_FILENAME: @@ -164,6 +165,11 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/ return M->second; } /*}}}*/ +bool IndexTarget::OptionBool(OptionKeys const EnumKey) const /*{{{*/ +{ + return StringToBool(Option(EnumKey)); +} + /*}}}*/ std::string IndexTarget::Format(std::string format) const /*{{{*/ { for (std::map<std::string, std::string>::const_iterator O = Options.begin(); O != Options.end(); ++O) diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 844f0cd3b..562b9f7b8 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -85,8 +85,10 @@ class IndexTarget /*{{{*/ TARGET_OF, FILENAME, EXISTING_FILENAME, + PDIFFS, }; std::string Option(OptionKeys const Key) const; + bool OptionBool(OptionKeys const Key) const; std::string Format(std::string format) const; }; /*}}}*/ diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index d3bcbce5f..c0b416820 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -107,6 +107,7 @@ bool pkgSourceList::Type::ParseStanza(vector<metaIndex *> &List, /*{{{*/ mapping.insert(std::make_pair("Valid-Until-Min", std::make_pair("valid-until-min", false))); 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))); 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)) |