]>
git.saurik.com Git - apt.git/blob - apt-pkg/aptconfiguration.cc
1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
5 Provide access methods to various configuration settings,
6 setup defaults and returns validate settings.
8 ##################################################################### */
10 // Include Files /*{{{*/
11 #include <apt-pkg/fileutl.h>
12 #include <apt-pkg/aptconfiguration.h>
13 #include <apt-pkg/configuration.h>
19 // getCompressionTypes - Return Vector of usbale compressiontypes /*{{{*/
20 // ---------------------------------------------------------------------
21 /* return a vector of compression types in the prefered order. */
22 std::vector
<std::string
>
23 const Configuration::getCompressionTypes(bool const &Cached
) {
24 static std::vector
<std::string
> types
;
25 if (types
.empty() == false) {
32 // Set default application paths to check for optional compression types
33 _config
->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
34 _config
->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
36 ::Configuration::Item
const *Opts
= _config
->Tree("Acquire::CompressionTypes");
40 // at first, move over the options to setup at least the default options
41 bool foundLzma
=false, foundBzip2
=false, foundGzip
=false;
42 for (; Opts
!= 0; Opts
= Opts
->Next
) {
43 if (Opts
->Value
== "lzma")
45 else if (Opts
->Value
== "bz2")
47 else if (Opts
->Value
== "gz")
51 // setup the defaults now
53 _config
->Set("Acquire::CompressionTypes::bz2","bzip2");
55 _config
->Set("Acquire::CompressionTypes::lzma","lzma");
57 _config
->Set("Acquire::CompressionTypes::gz","gzip");
59 // move again over the option tree to finially calculate our result
60 ::Configuration::Item
const *Types
= _config
->Tree("Acquire::CompressionTypes");
64 for (; Types
!= 0; Types
= Types
->Next
) {
65 string
const appsetting
= string("Dir::Bin::").append(Types
->Value
);
66 // ignore compression types we have no app ready to use
67 if (appsetting
.empty() == false && _config
->Exists(appsetting
) == true) {
68 std::string
const app
= _config
->FindFile(appsetting
.c_str(), "");
69 if (app
.empty() == false && FileExists(app
) == false)
72 types
.push_back(Types
->Tag
);