From 1a3a14ac63b0c4f18de53a7bddcf79d20a5e814f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Aug 2015 18:13:00 +0200 Subject: 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. --- apt-pkg/acquire-item.cc | 2 +- apt-pkg/deb/debmetaindex.cc | 20 +++++++++++++++++--- apt-pkg/deb/debmetaindex.h | 3 ++- apt-pkg/indexfile.cc | 6 ++++++ apt-pkg/indexfile.h | 2 ++ apt-pkg/sourcelist.cc | 1 + cmdline/apt-get.cc | 7 ++++++- doc/acquire-additional-files.txt | 10 +++++++++- doc/apt.conf.5.xml | 6 ++++-- doc/sources.list.5.xml | 14 ++++++++++++++ 10 files changed, 62 insertions(+), 9 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 Targets; std::vector Architectures; std::vector Languages; + bool UsePDiffs; }; std::vector 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 debReleaseIndex::GetIndexTargets() const void debReleaseIndex::AddComponent(bool const isSrc, std::string const &Name,/*{{{*/ std::vector const &Targets, std::vector const &Architectures, - std::vector Languages) + std::vector 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::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 const &Targets, std::vector const &Architectures, - std::vector Languages); + std::vector 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::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 &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 >::const_iterator m = mapping.begin(); m != mapping.end(); ++m) if (Tags.Exists(m->first)) diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b6150a423..917530ace 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1499,7 +1499,12 @@ static bool DoIndexTargets(CommandLine &CmdL) for (std::map::const_iterator O = AddOptions.begin(); O != AddOptions.end(); ++O) stanza << format_key(O->first) << ": " << O->second << "\n"; for (std::map::const_iterator O = T->Options.begin(); O != T->Options.end(); ++O) - stanza << format_key(O->first) << ": " << O->second << "\n"; + { + if (O->first == "PDIFFS") + stanza << "PDiffs: " << O->second << "\n"; + else + stanza << format_key(O->first) << ": " << O->second << "\n"; + } stanza << "\n"; if (Filtered) diff --git a/doc/acquire-additional-files.txt b/doc/acquire-additional-files.txt index 71ce7b0cb..9110bfe79 100644 --- a/doc/acquire-additional-files.txt +++ b/doc/acquire-additional-files.txt @@ -85,7 +85,15 @@ file if it is available and uncompress it for you, just as it will also use pdiff patching if provided by the repository and enabled by the user. You only have to ensure that the Release file contains the information about the compressed files/pdiffs to make this happen. -NO properties have to be set to enable this. +*NO* properties have to be set to enable this! + + +Additional properties exist, but these should *NOT* be set by frontends +requesting files. They exist for internal and end-user usage only: +* PDiffs: controls if apt will try to use pdiffs for this target. + Defaults to the value of Acquire::PDiffs which is true by default. + Can be overridden per-source by the sources.list option of the same + name. See the documentation for both of these for details. # More examples diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml index 920b42ba1..62dffadc4 100644 --- a/doc/apt.conf.5.xml +++ b/doc/apt.conf.5.xml @@ -334,8 +334,10 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";}; Try to download deltas called PDiffs for - indexes (like Packages files) instead of downloading - whole ones. True by default. + indexes (like Packages files) instead of + downloading whole ones. True by default. Preferably, this can be set + for specific &sources-list; entries or index files by using the + option there. Two sub-options to limit the use of PDiffs are also available: FileLimit can be used to specify a maximum number of PDiff files should be downloaded to update a file. SizeLimit diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml index 4eb3c0ba0..cfd98e545 100644 --- a/doc/sources.list.5.xml +++ b/doc/sources.list.5.xml @@ -226,6 +226,20 @@ deb-src [ option1=value1 option2=value2 ] uri suite [component1] [component2] [. using the identifier as field name instead of using this multivalue option. + + () + is a yes/no value which controls if APT should try to use PDiffs + to update old indexes instead of downloading the new indexes + entirely. The value of this option is ignored if the repository + doesn't announce the availability of PDiffs. Defaults to the + value of the option with the same name for a specific index file + defined in the scope, + which itself default to the value of configuration option + which defaults to + yes. + + + Further more, there are options which if set effect -- cgit v1.2.3