Browse Source

* 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)
debian/1.8.y
David Kalnischkies 11 years ago
parent
commit
7cb2894831
  1. 6
      apt-pkg/aptconfiguration.cc
  2. 8
      apt-pkg/deb/debmetaindex.cc
  3. 7
      debian/changelog
  4. 87
      test/integration/test-bug-624218-Translation-file-handling
  5. 15
      test/libapt/assert.h
  6. 12
      test/libapt/getlanguages_test.cc
  7. 3
      test/libapt/run-tests

6
apt-pkg/aptconfiguration.cc

@ -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)

8
apt-pkg/deb/debmetaindex.cc

@ -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);

7
debian/changelog

@ -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

87
test/integration/test-bug-624218-Translation-file-handling

@ -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

15
test/libapt/assert.h

@ -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) {

12
test/libapt/getlanguages_test.cc

@ -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");

3
test/libapt/run-tests

@ -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

Loading…
Cancel
Save