X-Git-Url: https://git.hcoop.net/ntk/apt.git/blobdiff_plain/62d8a765b9b37354efab6ca838cbdb7f347f7cac..220cf74e3c33fefb9f90853a22a5f828a15ff521:/apt-pkg/aptconfiguration.cc diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 1ebcf97b..9982759c 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -17,19 +17,24 @@ #include #include -#include #include #include #include - +#include +#include +#include +#include +#include #include #include #include + +#include /*}}}*/ namespace APT { -// getCompressionTypes - Return Vector of usbale compressiontypes /*{{{*/ +// getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/ // --------------------------------------------------------------------- -/* return a vector of compression types in the prefered order. */ +/* return a vector of compression types in the preferred order. */ std::vector const Configuration::getCompressionTypes(bool const &Cached) { static std::vector types; @@ -49,11 +54,6 @@ const Configuration::getCompressionTypes(bool const &Cached) { setDefaultConfigurationForCompressors(); std::vector const compressors = getCompressors(); - // 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); - // load the order setting into our vector std::vector const order = _config->FindVector("Acquire::CompressionTypes::Order"); for (std::vector::const_iterator o = order.begin(); @@ -109,7 +109,7 @@ const Configuration::getCompressionTypes(bool const &Cached) { /*}}}*/ // GetLanguages - Return Vector of Language Codes /*{{{*/ // --------------------------------------------------------------------- -/* return a vector of language codes in the prefered order. +/* return a vector of language codes in the preferred order. the special word "environment" will be replaced with the long and the short code of the local settings and it will be insured that this will not add duplicates. So in an german local the setting "environment, de_DE, en, de" @@ -227,61 +227,11 @@ std::vector const Configuration::getLanguages(bool const &All, } } } else { + // cornercase: LANG=C, so we use only "en" Translation environment.push_back("en"); } - // Support settings like Acquire::Languages=none on the command line to - // override the configuration settings vector of languages. - string const forceLang = _config->Find("Acquire::Languages",""); - if (forceLang.empty() == false) { - if (forceLang == "none") { - codes.clear(); - allCodes.clear(); - allCodes.push_back("none"); - } else { - if (forceLang == "environment") - codes = environment; - else - codes.push_back(forceLang); - allCodes = codes; - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); - } - if (All == true) - return allCodes; - else - return codes; - } - - // cornercase: LANG=C, so we use only "en" Translation - if (envShort == "C") { - allCodes = codes = environment; - allCodes.insert(allCodes.end(), builtin.begin(), builtin.end()); - if (All == true) - return allCodes; - else - return codes; - } - - std::vector const lang = _config->FindVector("Acquire::Languages"); - // the default setting -> "environment, en" - if (lang.empty() == true) { - codes = environment; - if (envShort != "en") - codes.push_back("en"); - allCodes = codes; - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); - if (All == true) - return allCodes; - else - return codes; - } - + std::vector const lang = _config->FindVector("Acquire::Languages", "environment,en"); // the configs define the order, so add the environment // then needed and ensure the codes are not listed twice. bool noneSeen = false; @@ -308,10 +258,15 @@ std::vector const Configuration::getLanguages(bool const &All, allCodes.push_back(*l); } - for (std::vector::const_iterator b = builtin.begin(); - b != builtin.end(); ++b) - if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) - allCodes.push_back(*b); + if (allCodes.empty() == false) { + for (std::vector::const_iterator b = builtin.begin(); + b != builtin.end(); ++b) + if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end()) + allCodes.push_back(*b); + } else { + // "none" was forced + allCodes.push_back("none"); + } if (All == true) return allCodes; @@ -320,7 +275,7 @@ std::vector const Configuration::getLanguages(bool const &All, } /*}}}*/ // checkLanguage - are we interested in the given Language? /*{{{*/ -bool const Configuration::checkLanguage(std::string Lang, bool const All) { +bool Configuration::checkLanguage(std::string Lang, bool const All) { // the empty Language is always interesting as it is the original if (Lang.empty() == true) return true; @@ -330,7 +285,7 @@ bool const Configuration::checkLanguage(std::string Lang, bool const All) { return (std::find(langs.begin(), langs.end(), Lang) != langs.end()); } /*}}}*/ -// getArchitectures - Return Vector of prefered Architectures /*{{{*/ +// getArchitectures - Return Vector of preferred Architectures /*{{{*/ std::vector const Configuration::getArchitectures(bool const &Cached) { using std::string; @@ -440,7 +395,7 @@ std::vector const Configuration::getArchitectures(bool const &Cache } /*}}}*/ // checkArchitecture - are we interested in the given Architecture? /*{{{*/ -bool const Configuration::checkArchitecture(std::string const &Arch) { +bool Configuration::checkArchitecture(std::string const &Arch) { if (Arch == "all") return true; std::vector const archs = getArchitectures(true); @@ -476,7 +431,7 @@ void Configuration::setDefaultConfigurationForCompressors() { } } /*}}}*/ -// getCompressors - Return Vector of usbale compressors /*{{{*/ +// getCompressors - Return Vector of usealbe compressors /*{{{*/ // --------------------------------------------------------------------- /* return a vector of compressors used by apt-ftparchive in the multicompress functionality or to detect data.tar files */ @@ -507,13 +462,21 @@ const Configuration::getCompressors(bool const Cached) { #endif if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true) compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4)); +#ifdef HAVE_LZMA + else + compressors.push_back(Compressor("xz",".xz","false", NULL, NULL, 4)); +#endif if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true) compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5)); +#ifdef HAVE_LZMA + else + compressors.push_back(Compressor("lzma",".lzma","false", NULL, NULL, 5)); +#endif std::vector const comp = _config->FindVector("APT::Compressor"); for (std::vector::const_iterator c = comp.begin(); c != comp.end(); ++c) { - if (*c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz") + if (c->empty() || *c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz") continue; compressors.push_back(Compressor(c->c_str(), std::string(".").append(*c).c_str(), c->c_str(), "-9", "-d", 100)); } @@ -558,4 +521,28 @@ Configuration::Compressor::Compressor(char const *name, char const *extension, UncompressArgs.push_back(uncompressArg); } /*}}}*/ +// getBuildProfiles - return a vector of enabled build profiles /*{{{*/ +std::vector const Configuration::getBuildProfiles() { + // order is: override value (~= commandline), environment variable, list (~= config file) + std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES"); + if (profiles_env.empty() == false) { + profiles_env = SubstVar(profiles_env, " ", ","); + std::string const bp = _config->Find("APT::Build-Profiles"); + _config->Clear("APT::Build-Profiles"); + if (bp.empty() == false) + _config->Set("APT::Build-Profiles", bp); + } + return _config->FindVector("APT::Build-Profiles", profiles_env); +} +std::string const Configuration::getBuildProfilesString() { + std::vector profiles = getBuildProfiles(); + if (profiles.empty() == true) + return ""; + std::vector::const_iterator p = profiles.begin(); + std::string list = *p; + for (; p != profiles.end(); ++p) + list.append(",").append(*p); + return list; +} + /*}}}*/ }