Browse Source

Rework the CompressionTypes system by adding an Order subgroup to

simplify customisation of the order and improve the documentation
about this setting group.
debian/1.8.y
David Kalnischkies 13 years ago
parent
commit
8bd02d8bd6
  1. 56
      apt-pkg/aptconfiguration.cc
  2. 3
      debian/changelog
  3. 32
      doc/apt.conf.5.xml
  4. 9
      doc/examples/configure-index

56
apt-pkg/aptconfiguration.cc

@ -14,6 +14,7 @@
#include <vector>
#include <string>
#include <algorithm>
/*}}}*/
namespace APT {
// getCompressionTypes - Return Vector of usbale compressiontypes /*{{{*/
@ -29,41 +30,52 @@ const Configuration::getCompressionTypes(bool const &Cached) {
types.clear();
}
// setup the defaults for the compressiontypes => method mapping
_config->CndSet("Acquire::CompressionTypes::bz2","bzip2");
_config->CndSet("Acquire::CompressionTypes::lzma","lzma");
_config->CndSet("Acquire::CompressionTypes::gz","gzip");
// Set default application paths to check for optional compression types
_config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
_config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
::Configuration::Item const *Opts = _config->Tree("Acquire::CompressionTypes");
if (Opts != 0)
Opts = Opts->Child;
// accept non-list order as override setting for config settings on commandline
std::string const overrideOrder = _config->Find("Acquire::CompressionTypes::Order","");
if (overrideOrder.empty() == false)
types.push_back(overrideOrder);
// at first, move over the options to setup at least the default options
bool foundLzma=false, foundBzip2=false, foundGzip=false;
for (; Opts != 0; Opts = Opts->Next) {
if (Opts->Value == "lzma")
foundLzma = true;
else if (Opts->Value == "bz2")
foundBzip2 = true;
else if (Opts->Value == "gz")
foundGzip = true;
// load the order setting into our vector
std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
for (std::vector<std::string>::const_iterator o = order.begin();
o != order.end(); o++) {
if ((*o).empty() == true)
continue;
// ignore types we have no method ready to use
if (_config->Exists(string("Acquire::CompressionTypes::").append(*o)) == false)
continue;
// ignore types we have no app ready to use
string const appsetting = string("Dir::Bin::").append(*o);
if (_config->Exists(appsetting) == true) {
std::string const app = _config->FindFile(appsetting.c_str(), "");
if (app.empty() == false && FileExists(app) == false)
continue;
}
types.push_back(*o);
}
// setup the defaults now
if (!foundBzip2)
_config->Set("Acquire::CompressionTypes::bz2","bzip2");
if (!foundLzma)
_config->Set("Acquire::CompressionTypes::lzma","lzma");
if (!foundGzip)
_config->Set("Acquire::CompressionTypes::gz","gzip");
// move again over the option tree to finially calculate our result
// move again over the option tree to add all missing compression types
::Configuration::Item const *Types = _config->Tree("Acquire::CompressionTypes");
if (Types != 0)
Types = Types->Child;
for (; Types != 0; Types = Types->Next) {
if (Types->Tag == "Order" || Types->Tag.empty() == true)
continue;
// ignore types we already have in the vector
if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
continue;
// ignore types we have no app ready to use
string const appsetting = string("Dir::Bin::").append(Types->Value);
// ignore compression types we have no app ready to use
if (appsetting.empty() == false && _config->Exists(appsetting) == true) {
std::string const app = _config->FindFile(appsetting.c_str(), "");
if (app.empty() == false && FileExists(app) == false)

3
debian/changelog

@ -24,6 +24,9 @@ apt (0.7.24) UNRELEASED; urgency=low
- replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208)
* doc/apt-get.8.xml:
- fix two little typos in the --simulate description.
* apt-pkg/aptconfiguration.cc, doc/apt.conf.5.xml:
- add an order subgroup to the compression types to simplify reordering
a bit and improve the documentation for this option group.
-- David Kalnischkies <kalnischkies@gmail.com> Fri, 28 Aug 2009 09:40:08 +0200

32
doc/apt.conf.5.xml

@ -90,7 +90,7 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
<literal>#include</literal> will include the given file, unless the filename
ends in a slash, then the whole directory is included.
<literal>#clear</literal> is used to erase a part of the configuration tree. The
specified element and all its descendents are erased.</para>
specified element and all its descendants are erased.</para>
<para>All of the APT tools take a -o option which allows an arbitrary configuration
directive to be specified on the command line. The syntax is a full option
@ -312,16 +312,30 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
<varlistentry><term>CompressionTypes</term>
<listitem><para>List of compression types which are understood by the acquire methods.
Files like <filename>Packages</filename> can be available in various compression formats.
This list defines in which order the acquire methods will try to download these files.
Per default <command>bzip2</command> compressed files will be prefered over
<command>lzma</command>, <command>gzip</command> and uncompressed files. The syntax for
the configuration fileentry is
Per default the acquire methods can decompress <command>bzip2</command>, <command>lzma</command>
and <command>gzip</command> compressed files, with this setting more formats can be added
on the fly or the used method can be changed. The syntax for this is:
<synopsis>Acquire::CompressionTypes::<replaceable>FileExtension</replaceable> "<replaceable>Methodname</replaceable>";</synopsis>
e.g. <synopsis>Acquire::CompressionTypes::bz2 "bzip2";</synopsis>
Note that at runtime the <literal>Dir::Bin::<replaceable>Methodname</replaceable></literal> will
</para><para>Also the <literal>Order</literal> subgroup can be used to define in which order
the acquire system will try to download the compressed files. The acquire system will try the first
and proceed with the next compression type in this list on error, so to prefer one over the other type
simple add the preferred type at first - not already added default types will be added at run time
to the end of the list, so e.g. <synopsis>Acquire::CompressionTypes::Order:: "gz";</synopsis> can
be used to prefer <command>gzip</command> compressed files over <command>bzip2</command> and <command>lzma</command>.
If <command>lzma</command> should be preferred over <command>gzip</command> and <command>bzip2</command> the
configure setting should look like this <synopsis>Acquire::CompressionTypes::Order { "lzma"; "gz"; };</synopsis>
It is not needed to add <literal>bz2</literal> explicit to the list as it will be added automatic.</para>
<para>Note that at run time the <literal>Dir::Bin::<replaceable>Methodname</replaceable></literal> will
be checked: If this setting exists the method will only be used if this file exists, e.g. for
the bzip2 method above (the inbuilt) setting is <literallayout>Dir::Bin::bzip2 "/bin/bzip2";</literallayout>
</para></listitem>
the bzip2 method (the inbuilt) setting is <literallayout>Dir::Bin::bzip2 "/bin/bzip2";</literallayout>
Note also that list entries specified on the commandline will be added at the end of the list
specified in the configuration files, but before the default entries. To prefer a type in this case
over the ones specified in in the configuration files you can set the option direct - not in list style.
This will not override the defined list, it will only prefix the list with this type.</para>
<para>While it is possible to add an empty compression type to the order list, but APT in its current
version doesn't understand it correctly and will display many warnings about not downloaded files -
these warnings are most of the time false negatives. Future versions will maybe include a way to
really prefer uncompressed files to support the usage of local mirrors.</para></listitem>
</varlistentry>
</variablelist>
</para>

9
doc/examples/configure-index

@ -246,6 +246,15 @@ Acquire
{
Options {"--ignore-time-conflict";} // not very useful on a normal system
};
CompressionTypes
{
bz2 "bzip2";
lzma "lzma";
gz "gzip";
Order { "gz"; "lzma"; "bz2"; };
};
};
// Directory layout

Loading…
Cancel
Save