]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/aptconfiguration.cc
add options to disable specific checksums for Indexes
[apt.git] / apt-pkg / aptconfiguration.cc
index 44f1f318ad049083c8d1f8c494d8fa8bb79fc9e7..3cf4d24295bb0e55b4ef01e0ff68c4fc4994364a 100644 (file)
@@ -90,6 +90,14 @@ const Configuration::getCompressionTypes(bool const &Cached) {
                types.push_back(Types->Tag);
        }
 
+       // add the special "uncompressed" type
+       if (std::find(types.begin(), types.end(), "uncompressed") == types.end())
+       {
+               string const uncompr = _config->FindFile("Dir::Bin::uncompressed", "");
+               if (uncompr.empty() == true || FileExists(uncompr) == true)
+                       types.push_back("uncompressed");
+       }
+
        return types;
 }
                                                                        /*}}}*/
@@ -155,44 +163,6 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
        }
        closedir(D);
 
-       // 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);
-       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);
-
-       string envLong = envMsg.substr(0,lenLong);
-       string const envShort = envLong.substr(0,lenShort);
-       bool envLongIncluded = true;
-
-       // first cornercase: LANG=C, so we use only "en" Translation
-       if (envLong == "C") {
-               codes.push_back("en");
-               allCodes = codes;
-               allCodes.insert(allCodes.end(), builtin.begin(), builtin.end());
-               if (All == true)
-                       return allCodes;
-               else
-                       return codes;
-       }
-
-       // to save the servers from unneeded queries, we only try also long codes
-       // for languages it is realistic to have a long code translation fileā€¦
-       // TODO: Improve translation acquire system to drop them dynamic
-       char const *needLong[] = { "cs", "en", "pt", "sv", "zh", NULL };
-       if (envLong != envShort) {
-               for (char const **l = needLong; *l != NULL; l++)
-                       if (envShort.compare(*l) == 0) {
-                               envLongIncluded = false;
-                               break;
-                       }
-       }
-
-       // we don't add the long code, but we allow the user to do so
-       if (envLongIncluded == true)
-               envLong.clear();
-
        // FIXME: Remove support for the old APT::Acquire::Translation
        // it was undocumented and so it should be not very widthly used
        string const oldAcquire = _config->Find("APT::Acquire::Translation","");
@@ -214,40 +184,44 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                        return codes;
        }
 
-       // It is very likely we will need to environment codes later,
+       // 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);
+       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);
+
+       string const envLong = envMsg.substr(0,lenLong);
+       string const envShort = envLong.substr(0,lenShort);
+
+       // It is very likely we will need the environment codes later,
        // so let us generate them now from LC_MESSAGES and LANGUAGE
        std::vector<string> environment;
-       // take care of LC_MESSAGES
-       if (envLongIncluded == false)
-               environment.push_back(envLong);
-       environment.push_back(envShort);
-       // take care of LANGUAGE
-       const char *language_env = getenv("LANGUAGE") == 0 ? "" : getenv("LANGUAGE");
-       string envLang = Locale == 0 ? language_env : *(Locale+1);
-       if (envLang.empty() == false) {
-               std::vector<string> env = VectorizeString(envLang,':');
-               short addedLangs = 0; // add a maximum of 3 fallbacks from the environment
-               for (std::vector<string>::const_iterator e = env.begin();
-                    e != env.end() && addedLangs < 3; ++e) {
-                       if (unlikely(e->empty() == true) || *e == "en")
-                               continue;
-                       if (*e == envLong || *e == envShort)
-                               continue;
-                       if (std::find(environment.begin(), environment.end(), *e) != environment.end())
-                               continue;
-                       if (e->find('_') != string::npos) {
-                               // Drop LongCodes here - ShortCodes are also included
-                               string const shorty = e->substr(0, e->find('_'));
-                               char const **n = needLong;
-                               for (; *n != NULL; ++n)
-                                       if (shorty == *n)
-                                               break;
-                               if (*n == NULL)
+       if (envShort != "C") {
+               // take care of LC_MESSAGES
+               if (envLong != envShort)
+                       environment.push_back(envLong);
+               environment.push_back(envShort);
+               // take care of LANGUAGE
+               const char *language_env = getenv("LANGUAGE") == 0 ? "" : getenv("LANGUAGE");
+               string envLang = Locale == 0 ? language_env : *(Locale+1);
+               if (envLang.empty() == false) {
+                       std::vector<string> env = VectorizeString(envLang,':');
+                       short addedLangs = 0; // add a maximum of 3 fallbacks from the environment
+                       for (std::vector<string>::const_iterator e = env.begin();
+                            e != env.end() && addedLangs < 3; ++e) {
+                               if (unlikely(e->empty() == true) || *e == "en")
+                                       continue;
+                               if (*e == envLong || *e == envShort)
                                        continue;
+                               if (std::find(environment.begin(), environment.end(), *e) != environment.end())
+                                       continue;
+                               ++addedLangs;
+                               environment.push_back(*e);
                        }
-                       ++addedLangs;
-                       environment.push_back(*e);
                }
+       } else {
+               environment.push_back("en");
        }
 
        // Support settings like Acquire::Translation=none on the command line to
@@ -269,6 +243,16 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                        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<string> const lang = _config->FindVector("Acquire::Languages");
        // the default setting -> "environment, en"
        if (lang.empty() == true) {