]> git.saurik.com Git - apt.git/commitdiff
sources.list and indextargets option for pdiffs
authorDavid Kalnischkies <david@kalnischkies.de>
Thu, 27 Aug 2015 16:13:00 +0000 (18:13 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Thu, 27 Aug 2015 16:16:50 +0000 (18:16 +0200)
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
apt-pkg/deb/debmetaindex.cc
apt-pkg/deb/debmetaindex.h
apt-pkg/indexfile.cc
apt-pkg/indexfile.h
apt-pkg/sourcelist.cc
cmdline/apt-get.cc
doc/acquire-additional-files.txt
doc/apt.conf.5.xml
doc/sources.list.5.xml

index 7dcaa25a48e9d26e86ca71a76a1e2a4812ce96a5..4e9c435e1aa8351e4182ac6ec468d32b069aaf69 100644 (file)
@@ -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)
index 69e41a6f46ea0572c8c2765c786323414a229ed3..78d54b04e0548b9c752cc53d8be7ddeafd646334 100644 (file)
@@ -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 ||
index e93959a21246be122d046420dc24cb72a89982c4..bba0e344f87fd3b6576874ba886d230eeebabaf8 100644 (file)
@@ -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
index 8e50ecfaef61ec7cecf001e9a2401fc71bd6f64d..b8189326044b0849b931b11d5fe58371e8ae5d23 100644 (file)
@@ -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)
index 844f0cd3b0908180b7d9b5f5cf11f9c8ac142aa2..562b9f7b83f613c0cda7cb0b9823783cba30aec9 100644 (file)
@@ -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;
 };
                                                                        /*}}}*/
index d3bcbce5fb1953da42658b83fdf3c174cc5df189..c0b416820a2199290e901fdc32774dc616d51eba 100644 (file)
@@ -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))
index b6150a4233b7abc4843da2de8955f4b7124377cc..917530ace2c13b8b6ea96e881a76e1785c936289 100644 (file)
@@ -1499,7 +1499,12 @@ static bool DoIndexTargets(CommandLine &CmdL)
            for (std::map<std::string,std::string>::const_iterator O = AddOptions.begin(); O != AddOptions.end(); ++O)
               stanza << format_key(O->first) << ": " << O->second << "\n";
            for (std::map<std::string,std::string>::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)
index 71ce7b0cb917d5c23e76b40e208c0716ccb8195a..9110bfe79655bd44d8fdcd9ca5e80ca460783995 100644 (file)
@@ -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
 
index 920b42ba1a14f9405111fab343d02118fe19af1c..62dffadc4d271d1996443c97041c21843a217c5b 100644 (file)
@@ -334,8 +334,10 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
 
      <varlistentry><term><option>PDiffs</option></term>
         <listitem><para>Try to download deltas called <literal>PDiffs</literal> for
-        indexes (like <filename>Packages</filename> files) instead of downloading
-        whole ones. True by default.</para>
+        indexes (like <filename>Packages</filename> 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>PDiffs</option> option there.</para>
         <para>Two sub-options to limit the use of PDiffs are also available:
         <literal>FileLimit</literal> can be used to specify a maximum number of
         PDiff files should be downloaded to update a file. <literal>SizeLimit</literal>
index 4eb3c0ba0c9cb528d6b98ae3552602cf831f1625..cfd98e545fa22d0fac271a41693272259a2e922c 100644 (file)
@@ -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.
          </para></listitem>
+
+         <listitem><para><option>PDiffs</option> (<option>pdiffs</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 <option>Acquire::IndexTargets</option> scope,
+               which itself default to the value of configuration option
+               <option>Acquire::PDiffs</option> which defaults to
+               <literal>yes</literal>.
+         </para></listitem>
+
+
        </itemizedlist>
 
        Further more, there are options which if set effect