]> git.saurik.com Git - apt.git/commitdiff
* apt-pkg/deb/debmetaindex.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 5 Oct 2011 20:45:22 +0000 (22:45 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 5 Oct 2011 20:45:22 +0000 (22:45 +0200)
  - 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 a0566e05e3be4f8b2f0f507d50d681d0ee209c86..7441b452c9537d01472a500e7f2c7165b10e93da 100644 (file)
@@ -142,7 +142,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")
@@ -153,7 +153,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())
@@ -234,6 +234,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 c509c29c7ec094c10d011b8ca2068e44125a8bb0..5d3a80aa56cc114c82ef0717637965512de3c59c 100644 (file)
@@ -13,6 +13,7 @@
 #include <apt-pkg/error.h>
 
 #include <set>
+#include <algorithm>
 
 using namespace std;
 
@@ -201,7 +202,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;
 
@@ -213,7 +218,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 f32f7a282e41a93990dfebe3d7a586f134744be8..055268619da52af5a42871710761732f798eab20 100644 (file)
@@ -18,6 +18,10 @@ apt (0.8.16~exp7) UNRELEASEDexperimental; urgency=low
   * apt-pkg/deb/deblistparser.cc:
     - fix crash when the dynamic mmap needs to be grown in
       LoadReleaseInfo (LP: #854090)
+  * 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)
 
   [ Michael Vogt ]
   * apt-pkg/contrib/configuration.cc:
@@ -32,8 +36,7 @@ apt (0.8.16~exp7) UNRELEASEDexperimental; urgency=low
   * ftparchive/cachedb.cc:
     - fix buffersize in bytes2hex
 
-
- -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 05 Oct 2011 18:40:57 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 05 Oct 2011 22:40:25 +0200
 
 apt (0.8.16~exp6) experimental; urgency=low
 
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 8cb2e049ca60edc4ef681858375a0d6db8b26263..ada2dc38b0a84e8b6b97afe6a875e221ddca0b9c 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 = "HashSums${EXT}" ]; then
                TMP="$(mktemp)"
                dmesg > $TMP