diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-02-18 19:40:13 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-02-18 19:40:13 +0100 |
commit | 8e3900d0d7efc11d538b944ed1d9e4e3d5286ff6 (patch) | |
tree | fa6d444ad9e323ae6c8b3809c8d1be606210b624 | |
parent | c0d58f4276a75f3cd6ebedf20458321a3477a048 (diff) |
* apt-pkg/acquire-item.cc:
- drop support for i18n/Index file (introduced in 0.8.11) and use
the Release file instead to get the Translations (Closes: #649314)
* ftparchive/writer.cc:
- add 'Translation-*' to the default patterns
i18n/Index was never used outside debian - and even here it isn't used
consistently as only 'main' has such a file. As the Release file now
includes the Translation-* files we therefore drop support for i18n/Index.
A version supporting it was never part of a debian release and still
supporting it would mean that we get 99% of the time a 404 as response
to the request anyway and confuse archive maintainers who want to
provide all files APT tries to acquire.
-rw-r--r-- | apt-pkg/acquire-item.cc | 67 | ||||
-rw-r--r-- | apt-pkg/deb/debmetaindex.cc | 36 | ||||
-rw-r--r-- | debian/changelog | 7 | ||||
-rw-r--r-- | ftparchive/writer.cc | 1 | ||||
-rw-r--r-- | test/integration/framework | 3 | ||||
-rwxr-xr-x | test/integration/test-bug-624218-Translation-file-handling | 9 |
6 files changed, 39 insertions, 84 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index f231c42b4..ca40b0bd7 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -189,14 +189,14 @@ void pkgAcquire::Item::ReportMirrorFailure(string FailCode) /*}}}*/ // AcqSubIndex::AcqSubIndex - Constructor /*{{{*/ // --------------------------------------------------------------------- -/* Get the Index file first and see if there are languages available - * If so, create a pkgAcqIndexTrans for the found language(s). - */ +/* Get a sub-index file based on checksums from a 'master' file and + possibly query additional files */ pkgAcqSubIndex::pkgAcqSubIndex(pkgAcquire *Owner, string const &URI, string const &URIDesc, string const &ShortDesc, HashString const &ExpectedHash) : Item(Owner), ExpectedHash(ExpectedHash) { + /* XXX: Beware: Currently this class does nothing (of value) anymore ! */ Debug = _config->FindB("Debug::pkgAcquire::SubIndex",false); DestFile = _config->FindDir("Dir::State::lists") + "partial/"; @@ -236,17 +236,7 @@ void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{* Status = StatDone; Dequeue(); - // No good Index is provided, so try guessing - std::vector<std::string> langs = APT::Configuration::getLanguages(true); - for (std::vector<std::string>::const_iterator l = langs.begin(); - l != langs.end(); ++l) - { - if (*l == "none") continue; - string const file = "Translation-" + *l; - new pkgAcqIndexTrans(Owner, Desc.URI.substr(0, Desc.URI.rfind('/')+1).append(file), - Desc.Description.erase(Desc.Description.rfind(' ')+1).append(file), - file); - } + // No good Index is provided } /*}}}*/ void pkgAcqSubIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ @@ -305,38 +295,7 @@ bool pkgAcqSubIndex::ParseIndex(string const &IndexFile) /*{{{*/ indexRecords SubIndexParser; if (FileExists(IndexFile) == false || SubIndexParser.Load(IndexFile) == false) return false; - - std::vector<std::string> lang = APT::Configuration::getLanguages(true); - for (std::vector<std::string>::const_iterator l = lang.begin(); - l != lang.end(); ++l) - { - if (*l == "none") - continue; - - string file = "Translation-" + *l; - indexRecords::checkSum const *Record = SubIndexParser.Lookup(file); - HashString expected; - if (Record == NULL) - { - // FIXME: the Index file provided by debian currently only includes bz2 records - Record = SubIndexParser.Lookup(file + ".bz2"); - if (Record == NULL) - continue; - } - else - { - expected = Record->Hash; - if (expected.empty() == true) - continue; - } - - IndexTarget target; - target.Description = Desc.Description.erase(Desc.Description.rfind(' ')+1).append(file); - target.MetaKey = file; - target.ShortDesc = file; - target.URI = Desc.URI.substr(0, Desc.URI.rfind('/')+1).append(file); - new pkgAcqIndexTrans(Owner, &target, expected, &SubIndexParser); - } + // so something with the downloaded index return true; } /*}}}*/ @@ -1385,6 +1344,18 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ return; } #endif + bool transInRelease = false; + { + std::vector<std::string> const keys = MetaIndexParser->MetaKeys(); + for (std::vector<std::string>::const_iterator k = keys.begin(); k != keys.end(); ++k) + // FIXME: Feels wrong to check for hardcoded string here, but what should we do else… + if (k->find("Translation-") != std::string::npos) + { + transInRelease = true; + break; + } + } + for (vector <struct IndexTarget*>::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); ++Target) @@ -1422,8 +1393,10 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ if ((*Target)->IsSubIndex() == true) new pkgAcqSubIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); - else + else if (transInRelease == false || MetaIndexParser->Exists((*Target)->MetaKey) == true) + { new pkgAcqIndexTrans(Owner, *Target, ExpectedIndexHash, MetaIndexParser); + } continue; } diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 5d3a80aa5..bcc617da7 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -128,7 +128,7 @@ string debReleaseIndex::TranslationIndexURISuffix(const char *Type, const string { string Res =""; if (Dist[Dist.size() - 1] != '/') - Res += Section + "/i18n/"; + Res += Section + "/i18n/Translation-"; return Res + Type; } @@ -210,31 +210,17 @@ vector <struct IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const { if (lang.empty() == true) return IndexTargets; - // get the Translations: - // - if its a dists-style repository get the i18n/Index first - // - if its flat try to acquire files by guessing - if (Dist[Dist.size() - 1] == '/') { - for (std::set<std::string>::const_iterator s = sections.begin(); - s != sections.end(); ++s) { - for (std::vector<std::string>::const_iterator l = lang.begin(); - l != lang.end(); ++l) { - IndexTarget * Target = new OptionalIndexTarget(); - Target->ShortDesc = "Translation-" + *l; - Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); - Target->URI = TranslationIndexURI(l->c_str(), *s); - Target->Description = Info (Target->ShortDesc.c_str(), *s); - IndexTargets->push_back(Target); - } - } - } else { - for (std::set<std::string>::const_iterator s = sections.begin(); - s != sections.end(); ++s) { - IndexTarget * Target = new OptionalSubIndexTarget(); - Target->ShortDesc = "TranslationIndex"; - Target->MetaKey = TranslationIndexURISuffix("Index", *s); - Target->URI = TranslationIndexURI("Index", *s); + // get the Translation-* files, later we will skip download of non-existent if we have an index + for (std::set<std::string>::const_iterator s = sections.begin(); + s != sections.end(); ++s) { + for (std::vector<std::string>::const_iterator l = lang.begin(); + l != lang.end(); ++l) { + IndexTarget * Target = new OptionalIndexTarget(); + Target->ShortDesc = "Translation-" + *l; + Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); + Target->URI = TranslationIndexURI(l->c_str(), *s); Target->Description = Info (Target->ShortDesc.c_str(), *s); - IndexTargets->push_back (Target); + IndexTargets->push_back(Target); } } diff --git a/debian/changelog b/debian/changelog index 7461e9a25..35a476d5f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,6 +27,11 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low - clean up lost atomic cachefiles with 'clean' (Closes: #650513) * apt-pkg/indexrecords.cc: - do not create empty Entries as a sideeffect of Lookup() + * apt-pkg/acquire-item.cc: + - drop support for i18n/Index file (introduced in 0.8.11) and use + the Release file instead to get the Translations (Closes: #649314) + * ftparchive/writer.cc: + - add 'Translation-*' to the default patterns [ Steve Langasek ] * cmdline/apt-get.cc: @@ -49,7 +54,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low * apt-pkg/contrib/fileutl.h: - fix compat with FileFd::OpenDescriptor() in ReadOnlyGzip mode - -- David Kalnischkies <kalnischkies@gmail.com> Sat, 18 Feb 2012 18:22:14 +0100 + -- David Kalnischkies <kalnischkies@gmail.com> Sat, 18 Feb 2012 19:23:42 +0100 apt (0.8.16~exp12) experimental; urgency=low diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 159772991..d02919969 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -941,6 +941,7 @@ ReleaseWriter::ReleaseWriter(string const &DB) AddPattern("Packages.bz2"); AddPattern("Packages.lzma"); AddPattern("Packages.xz"); + AddPattern("Translation-*"); AddPattern("Sources"); AddPattern("Sources.gz"); AddPattern("Sources.bz2"); diff --git a/test/integration/framework b/test/integration/framework index 350ee112e..99088b59b 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -572,9 +572,6 @@ generatereleasefiles() { # both should be given in notation date/touch can understand msgninfo "\tGenerate Release files… " if [ -e aptarchive/dists ]; then - for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do - aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index - done for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do local SUITE="$(echo "$dir" | cut -d'/' -f 4)" local CODENAME="$(getcodenamefromsuite $SUITE)" diff --git a/test/integration/test-bug-624218-Translation-file-handling b/test/integration/test-bug-624218-Translation-file-handling index a1e708d2e..d146b943c 100755 --- a/test/integration/test-bug-624218-Translation-file-handling +++ b/test/integration/test-bug-624218-Translation-file-handling @@ -42,16 +42,9 @@ 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') +sed -i '/i18n\/Translation-.*$/ 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 |