Explorar el Código

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.
David Kalnischkies hace 11 años
padre
commit
1a3a14ac63

+ 1 - 1
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)

+ 17 - 3
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 ||

+ 2 - 1
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

+ 6 - 0
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)

+ 2 - 0
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;
 };
 									/*}}}*/

+ 1 - 0
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))

+ 6 - 1
cmdline/apt-get.cc

@@ -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)

+ 9 - 1
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
 

+ 4 - 2
doc/apt.conf.5.xml

@@ -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>

+ 14 - 0
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.
 	  </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