]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
Merge branch 'feature/extractar-filefd' into debian/experimental
[apt.git] / apt-pkg / aptconfiguration.cc
index 941a9c3348e3ab7b3ddef66ea48d9ed7123ab51d..f5bc18394ef5f38f4f52692229c204bc13407fca 100644 (file)
 #include <string>
 #include <vector>
 
-#include <apti18n.h>
                                                                        /*}}}*/
 namespace APT {
+// setDefaultConfigurationForCompressors                               /*{{{*/
+static void setDefaultConfigurationForCompressors() {
+       // Set default application paths to check for optional compression types
+       _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
+       _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
+       if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
+               _config->Set("Dir::Bin::lzma", _config->FindFile("Dir::Bin::xz"));
+               _config->Set("APT::Compressor::lzma::Binary", "xz");
+               if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
+                       _config->Set("APT::Compressor::lzma::CompressArg::", "--format=lzma");
+                       _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
+               }
+               if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
+                       _config->Set("APT::Compressor::lzma::UncompressArg::", "--format=lzma");
+                       _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
+               }
+       } else {
+               _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
+               if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
+                       _config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
+                       _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
+               }
+               if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
+                       _config->Set("APT::Compressor::lzma::UncompressArg::", "--suffix=");
+                       _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
+               }
+       }
+}
+                                                                       /*}}}*/
 // getCompressionTypes - Return Vector of usable compressiontypes      /*{{{*/
 // ---------------------------------------------------------------------
 /* return a vector of compression types in the preferred order. */
@@ -193,7 +221,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
        // get the environment language codes: LC_MESSAGES (and later LANGUAGE)
        // we extract both, a long and a short code and then we will
        // check if we actually need both (rare) or if the short is enough
-       string const envMsg = string(Locale == 0 ? std::setlocale(LC_MESSAGES, NULL) : *Locale);
+       string const envMsg = string(Locale == 0 ? ::setlocale(LC_MESSAGES, NULL) : *Locale);
        size_t const lenShort = (envMsg.find('_') != string::npos) ? envMsg.find('_') : 2;
        size_t const lenLong = (envMsg.find_first_of(".@") != string::npos) ? envMsg.find_first_of(".@") : (lenShort + 3);
 
@@ -402,35 +430,6 @@ bool Configuration::checkArchitecture(std::string const &Arch) {
        return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
 }
                                                                        /*}}}*/
-// setDefaultConfigurationForCompressors                               /*{{{*/
-void Configuration::setDefaultConfigurationForCompressors() {
-       // Set default application paths to check for optional compression types
-       _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
-       _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
-       if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
-               _config->Set("Dir::Bin::lzma", _config->FindFile("Dir::Bin::xz"));
-               _config->Set("APT::Compressor::lzma::Binary", "xz");
-               if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
-                       _config->Set("APT::Compressor::lzma::CompressArg::", "--format=lzma");
-                       _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
-               }
-               if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
-                       _config->Set("APT::Compressor::lzma::UncompressArg::", "--format=lzma");
-                       _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
-               }
-       } else {
-               _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
-               if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
-                       _config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
-                       _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
-               }
-               if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
-                       _config->Set("APT::Compressor::lzma::UncompressArg::", "--suffix=");
-                       _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
-               }
-       }
-}
-                                                                       /*}}}*/
 // getCompressors - Return Vector of usealbe compressors               /*{{{*/
 // ---------------------------------------------------------------------
 /* return a vector of compressors used by apt-ftparchive in the
@@ -462,13 +461,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));
        }
@@ -532,7 +539,7 @@ std::string const Configuration::getBuildProfilesString() {
                return "";
        std::vector<std::string>::const_iterator p = profiles.begin();
        std::string list = *p;
-       for (; p != profiles.end(); ++p)
+       for (++p; p != profiles.end(); ++p)
           list.append(",").append(*p);
        return list;
 }