]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
support DEB_BUILD_PROFILES and -P for build profiles
[apt.git] / apt-pkg / aptconfiguration.cc
index f5c758e14524ac7d8a5c34c40d4dba90c2455e5c..3948854c66496c9b683c315a3d87b14f606a0209 100644 (file)
@@ -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;
+}
+                                                                       /*}}}*/
 }