]> git.saurik.com Git - apt.git/blob - apt-pkg/aptconfiguration.cc
Drop de and pl "translations" of manpages
[apt.git] / apt-pkg / aptconfiguration.cc
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4
5 Provide access methods to various configuration settings,
6 setup defaults and returns validate settings.
7
8 ##################################################################### */
9 /*}}}*/
10 // Include Files /*{{{*/
11 #include <apt-pkg/fileutl.h>
12 #include <apt-pkg/aptconfiguration.h>
13 #include <apt-pkg/configuration.h>
14
15 #include <vector>
16 #include <string>
17 /*}}}*/
18 namespace APT {
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) {
26 if (Cached == true)
27 return types;
28 else
29 types.clear();
30 }
31
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");
35
36 ::Configuration::Item const *Opts = _config->Tree("Acquire::CompressionTypes");
37 if (Opts != 0)
38 Opts = Opts->Child;
39
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")
44 foundLzma = true;
45 else if (Opts->Value == "bz2")
46 foundBzip2 = true;
47 else if (Opts->Value == "gz")
48 foundGzip = true;
49 }
50
51 // setup the defaults now
52 if (!foundBzip2)
53 _config->Set("Acquire::CompressionTypes::bz2","bzip2");
54 if (!foundLzma)
55 _config->Set("Acquire::CompressionTypes::lzma","lzma");
56 if (!foundGzip)
57 _config->Set("Acquire::CompressionTypes::gz","gzip");
58
59 // move again over the option tree to finially calculate our result
60 ::Configuration::Item const *Types = _config->Tree("Acquire::CompressionTypes");
61 if (Types != 0)
62 Types = Types->Child;
63
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)
70 continue;
71 }
72 types.push_back(Types->Tag);
73 }
74
75 return types;
76 }
77 /*}}}*/
78 }