diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-02-25 14:26:18 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-03-13 13:58:44 +0100 |
commit | ce7f128c020e1347f91c6074238fc5da58c5df71 (patch) | |
tree | d7ee2d69fd674597f61c170e415ffc4d1b7d6570 /apt-pkg | |
parent | 565ded7b65240b25ad8551789ac388c8ce72b1f4 (diff) |
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.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 26 | ||||
-rw-r--r-- | apt-pkg/aptconfiguration.h | 5 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 2 |
3 files changed, 31 insertions, 2 deletions
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<std::string> 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<std::string> profiles = getBuildProfiles(); + if (profiles.empty() == true) + return ""; + std::vector<std::string>::const_iterator p = profiles.begin(); + std::string list = *p; + for (; p != profiles.end(); ++p) + list.append(",").append(*p); + return list; +} + /*}}}*/ } diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index bf7deae85..026493c6d 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -117,6 +117,11 @@ public: /*{{{*/ /** \brief Return a vector of extensions supported for data.tar's */ std::vector<std::string> static const getCompressorExtensions(); + + /** \return Return a vector of enabled build profile specifications */ + std::vector<std::string> static const getBuildProfiles(); + /** \return Return a comma-separated list of enabled build profile specifications */ + std::string static const getBuildProfilesString(); /*}}}*/ private: /*{{{*/ void static setDefaultConfigurationForCompressors(); diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index a4795f15d..89f3514c9 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -625,7 +625,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, if (unlikely(I == Stop)) return 0; - std::vector<string> const profiles = _config->FindVector("APT::Build-Profiles"); + std::vector<string> const profiles = APT::Configuration::getBuildProfiles(); const char *End = I; bool Found = false; |