]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
Merge remote-tracking branch 'mvo/feature/apt-ftparchive-srccache2' into debian/sid
[apt.git] / apt-pkg / aptconfiguration.cc
index f5c758e14524ac7d8a5c34c40d4dba90c2455e5c..9982759c634d7cda87fc16df3d1e803925395114 100644 (file)
 #include <apt-pkg/macros.h>
 #include <apt-pkg/strutl.h>
 
-#include <sys/types.h>
 #include <dirent.h>
 #include <stdio.h>
 #include <fcntl.h>
-
+#include <ctype.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include <algorithm>
 #include <string>
 #include <vector>
+
+#include <apti18n.h>
                                                                        /*}}}*/
 namespace APT {
 // getCompressionTypes - Return Vector of usable compressiontypes      /*{{{*/
@@ -270,7 +275,7 @@ std::vector<std::string> 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 +395,7 @@ std::vector<std::string> 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<std::string> const archs = getArchitectures(true);
@@ -426,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 */
@@ -457,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<std::string> const comp = _config->FindVector("APT::Compressor");
        for (std::vector<std::string>::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));
        }
@@ -508,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<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;
+}
+                                                                       /*}}}*/
 }