From c45233eaf6d08bb6bb6e2dbb57c90a1d52ca9a43 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 3 Sep 2012 12:28:19 +0200 Subject: * apt-pkg/cdrom.cc: - copy only configured translation files from a CD-ROM and not all available translation files preventing new installs with d-i from being initialized with all translations (Closes: #678227) - handle Components in the reduction for the source.list as multi-arch CDs otherwise create duplicated source entries (e.g. "wheezy main main") --- apt-pkg/aptconfiguration.cc | 11 +++++++++++ apt-pkg/aptconfiguration.h | 8 ++++++++ apt-pkg/cdrom.cc | 25 +++++++++++++++++++++++++ apt-pkg/cdrom.h | 1 + 4 files changed, 45 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index d31ccb642..653775688 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -319,6 +319,17 @@ std::vector const Configuration::getLanguages(bool const &All, return codes; } /*}}}*/ +// checkLanguage - are we interested in the given Language? /*{{{*/ +bool const Configuration::checkLanguage(std::string Lang, bool const All) { + // the empty Language is always interesting as it is the original + if (Lang.empty() == true) + return true; + // filenames are encoded, so undo this + Lang = SubstVar(Lang, "%5f", "_"); + std::vector const langs = getLanguages(All, true); + return (std::find(langs.begin(), langs.end(), Lang) != langs.end()); +} + /*}}}*/ // getArchitectures - Return Vector of prefered Architectures /*{{{*/ std::vector const Configuration::getArchitectures(bool const &Cached) { using std::string; diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index e098d0fd6..516f451d9 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -67,6 +67,14 @@ public: /*{{{*/ std::vector static const getLanguages(bool const &All = false, bool const &Cached = true, char const ** const Locale = 0); + /** \brief Are we interested in the given Language? + * + * \param Lang is the language we want to check + * \param All defines if we check against all codes or only against used codes + * \return true if we are interested, false otherwise + */ + bool static const Configuration::checkLanguage(std::string Lang, bool const All = false); + /** \brief Returns a vector of Architectures we support * * \param Cached saves the result so we need to calculated it only once diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 8e746ee30..9a9a854bf 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -269,6 +269,29 @@ bool pkgCdrom::DropBinaryArch(vector &List) --I; // the next entry is at the same index after the erase } + return true; +} + /*}}}*/ +// DropTranslation - Dump unwanted Translation- files /*{{{*/ +// --------------------------------------------------------------------- +/* Here we drop everything that is not configured in Acquire::Languages */ +bool pkgCdrom::DropTranslation(vector &List) +{ + for (unsigned int I = 0; I < List.size(); I++) + { + const char *Start; + if ((Start = strstr(List[I].c_str(), "/Translation-")) == NULL) + continue; + Start += strlen("/Translation-"); + + if (APT::Configuration::checkLanguage(Start, true) == true) + continue; + + // not accepted -> Erase it + List.erase(List.begin() + I); + --I; // the next entry is at the same index after the erase + } + return true; } /*}}}*/ @@ -714,6 +737,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ DropRepeats(SigList,"InRelease"); _error->RevertToStack(); DropRepeats(TransList,""); + if (_config->FindB("APT::CDROM::DropTranslation", true) == true) + DropTranslation(TransList); if(log != NULL) { msg.str(""); ioprintf(msg, _("Found %zu package indexes, %zu source indexes, " diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index cedfccff7..4fc3d3928 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -60,6 +60,7 @@ class pkgCdrom /*{{{*/ unsigned int Depth = 0); bool DropBinaryArch(std::vector &List); bool DropRepeats(std::vector &List,const char *Name); + bool DropTranslation(std::vector &List); void ReduceSourcelist(std::string CD,std::vector &List); bool WriteDatabase(Configuration &Cnf); bool WriteSourceList(std::string Name,std::vector &List,bool Source); -- cgit v1.2.3