From a5414e56403537678d5be87acf59c37a05f55719 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 24 Feb 2014 23:10:25 +0100 Subject: add default and override handling for Cnf::FindVector Automatically handle the override of list options via its parent value which can even be a comma-separated list of values. It also adds an easy way of providing a default for the list. --- apt-pkg/aptconfiguration.cc | 72 +++++++-------------------------------------- 1 file changed, 11 insertions(+), 61 deletions(-) (limited to 'apt-pkg/aptconfiguration.cc') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 0b0b546c5..f5c758e14 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -49,11 +49,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(); @@ -227,61 +222,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 +253,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; -- cgit v1.2.3 From ce7f128c020e1347f91c6074238fc5da58c5df71 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 25 Feb 2014 14:26:18 +0100 Subject: support DEB_BUILD_PROFILES and -P for build profiles Inspired by the rest of the patch in 661537, but abstract the parsing of various ways of setting the build profiles more so it can potentially be reused and all apt parts have the same behaviour. Especially config options, cmdline options and environment will not be combined as proposed as this isn't APTs usual behaviour and dpkg doesn't do it either, so one overrides the other as it normally does. --- apt-pkg/aptconfiguration.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'apt-pkg/aptconfiguration.cc') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index f5c758e14..3948854c6 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -426,7 +426,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 */ @@ -508,4 +508,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; +} + /*}}}*/ } -- cgit v1.2.3 From d64e130aa333837a8fda0f1bba51f2867ca520f7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 13:55:20 +0100 Subject: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] Reported-By: gcc -Wignored-qualifiers Git-Dch: Ignore --- apt-pkg/aptconfiguration.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/aptconfiguration.cc') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 3948854c6..4c609c603 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -270,7 +270,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; @@ -390,7 +390,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); -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- apt-pkg/aptconfiguration.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apt-pkg/aptconfiguration.cc') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 4c609c603..941a9c334 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -17,14 +17,19 @@ #include #include -#include #include #include #include - +#include +#include +#include +#include +#include #include #include #include + +#include /*}}}*/ namespace APT { // getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/ -- cgit v1.2.3 From 7f350a377e0c65a656b9b5437e27d037fd742901 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Mar 2014 14:39:18 +0100 Subject: use liblzma-dev to provide xz/lzma support We have xz/lzma support for a while, but only via an external binary provided by xz-utils. Now that the Debian archive provides xz by default and dpkg pre-depends on the library provided by liblzma-dev we can switch now to use this library as well to avoid requiring an external binary. For now the binary is in a prio:required package, but this might change in the future. API wise it is quiet similar to bz2 code expect that it doesn't provide file I/O methods, so we piece this together on our own. --- apt-pkg/aptconfiguration.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'apt-pkg/aptconfiguration.cc') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 941a9c334..6ba047560 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -462,8 +462,16 @@ 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(); -- cgit v1.2.3