]> git.saurik.com Git - apt.git/commitdiff
cherrypick from my apt/experimental branch
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 5 Oct 2011 21:00:47 +0000 (23:00 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 5 Oct 2011 21:00:47 +0000 (23:00 +0200)
* apt-pkg/deb/debmetaindex.cc:
  - none is a separator, not a language: no need for Index (Closes: #624218)
* apt-pkg/aptconfiguration.cc:
  - do not builtin languages only if none is forced (Closes: #643787)

apt-pkg/aptconfiguration.cc
apt-pkg/deb/debmetaindex.cc
debian/changelog
test/integration/test-bug-624218-Translation-file-handling [new file with mode: 0755]
test/libapt/assert.h
test/libapt/getlanguages_test.cc
test/libapt/run-tests

index 6ec5fa03a5d4f42113daf75864c3c8a6c1efa961..bc385b2dc5e44349ae615b810a6809196ba1a8fc 100644 (file)
@@ -140,7 +140,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
                        string const name = Ent->d_name;
                        size_t const foundDash = name.rfind("-");
-                       size_t const foundUnderscore = name.rfind("_");
+                       size_t const foundUnderscore = name.rfind("_", foundDash);
                        if (foundDash == string::npos || foundUnderscore == string::npos ||
                            foundDash <= foundUnderscore ||
                            name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
@@ -151,7 +151,7 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                        // Skip unusual files, like backups or that alike
                        string::const_iterator s = c.begin();
                        for (;s != c.end(); ++s) {
-                               if (isalpha(*s) == 0)
+                               if (isalpha(*s) == 0 && *s != '_')
                                        break;
                        }
                        if (s != c.end())
@@ -232,6 +232,8 @@ std::vector<std::string> const Configuration::getLanguages(bool const &All,
                        codes = environment;
                } else if (forceLang != "none")
                        codes.push_back(forceLang);
+               else //if (forceLang == "none")
+                       builtin.clear();
                allCodes = codes;
                for (std::vector<string>::const_iterator b = builtin.begin();
                     b != builtin.end(); ++b)
index f6c50742e0f6725b152a36c3007a3f34cb41de40..22effdc8fea04cf8a5d414d7e9e633a099db39c3 100644 (file)
@@ -9,6 +9,7 @@
 #include <apt-pkg/error.h>
 
 #include <set>
+#include <algorithm>
 
 using namespace std;
 
@@ -195,7 +196,11 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
                }
        }
 
-       std::vector<std::string> const lang = APT::Configuration::getLanguages(true);
+       std::vector<std::string> lang = APT::Configuration::getLanguages(true);
+       std::vector<std::string>::iterator lend = std::remove(lang.begin(), lang.end(), "none");
+       if (lend != lang.end())
+               lang.erase(lend);
+
        if (lang.empty() == true)
                return IndexTargets;
 
@@ -207,7 +212,6 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const {
                     s != sections.end(); ++s) {
                        for (std::vector<std::string>::const_iterator l = lang.begin();
                             l != lang.end(); ++l) {
-                               if (*l == "none") continue;
                                IndexTarget * Target = new OptionalIndexTarget();
                                Target->ShortDesc = "Translation-" + *l;
                                Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s);
index 6a27ff49a0d7ea3c1df37e15cbf9f5581a475d87..7cd353718d570566bfe8323e7791b7cfdc30cbb8 100644 (file)
@@ -17,6 +17,10 @@ apt (0.8.15.9) UNRELEASED; urgency=low
     - silently ignore *.orig and *.save files by default
   * apt-pkg/policy.cc:
     - accept generic release pin expressions again in -t (Closes: #644166)
+  * apt-pkg/deb/debmetaindex.cc:
+    - none is a separator, not a language: no need for Index (Closes: #624218)
+  * apt-pkg/aptconfiguration.cc:
+    - do not builtin languages only if none is forced (Closes: #643787)
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 03 Oct 2011 23:35:40 +0200
 
diff --git a/test/integration/test-bug-624218-Translation-file-handling b/test/integration/test-bug-624218-Translation-file-handling
new file mode 100755 (executable)
index 0000000..a1e708d
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+buildsimplenativepackage 'coolstuff' 'all' '1.0' 'unstable'
+
+setupaptarchive
+
+changetowebserver
+
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'No download of non-existent locals' 'with Index'
+LC_ALL="" aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of existent locals' 'with Index'
+LC_ALL="" aptget update | grep -q -e 'Translation-en ' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of en in LC_ALL=C' 'with Index'
+LC_ALL=C aptget update | grep -q -e 'Translation-en ' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of en as forced language' 'with Index'
+aptget update -o Acquire::Languages=en | grep -q -e 'Translation-en ' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of nothing else in forced language' 'with Index'
+aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download no Translation- if forced language is non-existent' 'with Index'
+aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of nothing if none is forced' 'with Index'
+aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+sed -i '/i18n\/Index$/ d' $(find aptarchive -name 'Release')
+signreleasefiles
+
+# we have to try as not every archive includes the i18n Index in the Release file - if it has one at all
+msgtest 'Download no Translation- if forced language is non-existent' 'with not-announced Index'
+aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+find aptarchive -name 'Index' -delete
+
+msgtest 'Download of en as forced language' 'without Index'
+aptget update -o Acquire::Languages=en | grep -q -e 'Translation-en ' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of nothing else in forced language' 'without Index'
+aptget update -o Acquire::Languages=en | grep -q -e 'Translation-[^e][^n] ' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of ast_DE as forced language' 'without Index'
+aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-ast_DE$' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of nothing else in forced language' 'without Index'
+aptget update -o Acquire::Languages=ast_DE | grep -q -e 'Translation-[^a][^s]' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+msgtest 'Download of nothing if none is forced' 'without Index'
+aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
+
+mkdir -p rootdir/var/lib/apt/lists
+touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE
+
+msgtest 'Download of builtin files' 'without Index'
+aptget update | grep -q -e 'Translation-ast_DE' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+
+mkdir -p rootdir/var/lib/apt/lists
+touch rootdir/var/lib/apt/lists/localhost:8080_dists_unstable_main_i18n_Translation-ast_DE
+
+msgtest 'Download of nothing (even builtin) if none is forced' 'without Index'
+aptget update -o Acquire::Languages=none | grep -q -e 'Translation' && msgfail || msgpass
+rm -rf rootdir/var/lib/apt/lists
index fae9b6c6423c33fa0c56402735fa0c5e7ad904c0..ce5accc1c537e3876308aebe31cd5bccb55644dd 100644 (file)
@@ -54,6 +54,21 @@ void assertEqualsOr2(int const &expect1, int const &expect2, unsigned int const
 }
 
 
+#define equalsOr3(w,x,y,z) assertEqualsOr3(x, y, z, w, __LINE__)
+
+template < typename X, typename Y >
+void OutputAssertEqualOr3(X expect1, X expect2, X expect3, char const* compare, Y get, unsigned long const &line) {
+       std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« " << compare << " »" << get << "« at line " << line << std::endl;
+}
+
+template < typename X, typename Y >
+void assertEqualsOr3(X expect1, X expect2, X expect3, Y get, unsigned long const &line) {
+       if (expect1 == get || expect2 == get || expect3 == get)
+               return;
+       OutputAssertEqualOr3(expect1, expect2, expect3, "==", get, line);
+}
+
+
 // simple helper to quickly output a vectors
 template < typename X >
 void dumpVector(X vec) {
index f6aa7a69785baaca4e11cad929934f61dd8ccf0c..a1c801ea207afd09da7675bf7ea0d2bc00629b53 100644 (file)
@@ -126,13 +126,19 @@ int main(int argc,char *argv[])
 
        _config->Set("Dir::State::lists", argv[1]);
        vec = APT::Configuration::getLanguages(true, false, env);
-       equals(vec.size(), 6);
+       equals(vec.size(), 7);
        equals(vec[0], "de_DE");
        equals(vec[1], "de");
        equals(vec[2], "en");
        equals(vec[3], "none");
-       equalsOr2(vec[4], "pt", "tr");
-       equalsOr2(vec[5], "tr", "pt");
+       equalsOr3(vec[4], "pt", "tr", "ast_DE");
+       equalsOr3(vec[5], "tr", "pt", "ast_DE");
+       equalsOr3(vec[6], "tr", "pt", "ast_DE");
+
+       _config->Set("Acquire::Languages", "none");
+       vec = APT::Configuration::getLanguages(true, false, env);
+       equals(vec.size(), 0);
+       _config->Set("Acquire::Languages", "");
 
        _config->Set("Dir::State::lists", "/non-existing-dir");
        _config->Set("Acquire::Languages::1", "none");
index 275a789b23a0a017ae9ddbd322ae335395aa3d56..9dad36f5b5f0bc286c79502ceab226e3a0b79f5b 100755 (executable)
@@ -64,7 +64,8 @@ do
                touch "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tr" \
                        "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
                        "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
-                       "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
+                       "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \
+                       "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE"
        elif [ $name = "CompareVersion${EXT}" ]; then
                tmppath="${DIR}/versions.lst"
        fi