summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-09-03 12:28:19 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-09-03 12:28:19 +0200
commitc45233eaf6d08bb6bb6e2dbb57c90a1d52ca9a43 (patch)
tree9a61b39514cffbd0ad1fd48edb278302f108a2cd
parent12c7078f5098d7f26599a3761af9e24b392d9c1d (diff)
* 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")
-rw-r--r--apt-pkg/aptconfiguration.cc11
-rw-r--r--apt-pkg/aptconfiguration.h8
-rw-r--r--apt-pkg/cdrom.cc25
-rw-r--r--apt-pkg/cdrom.h1
-rw-r--r--debian/changelog9
-rw-r--r--test/integration/framework16
-rwxr-xr-xtest/integration/test-apt-cdrom104
7 files changed, 171 insertions, 3 deletions
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<std::string> 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<std::string> const langs = getLanguages(All, true);
+ return (std::find(langs.begin(), langs.end(), Lang) != langs.end());
+}
+ /*}}}*/
// getArchitectures - Return Vector of prefered Architectures /*{{{*/
std::vector<std::string> 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<std::string> 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
@@ -272,6 +272,29 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
return true;
}
/*}}}*/
+// DropTranslation - Dump unwanted Translation-<lang> files /*{{{*/
+// ---------------------------------------------------------------------
+/* Here we drop everything that is not configured in Acquire::Languages */
+bool pkgCdrom::DropTranslation(vector<string> &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;
+}
+ /*}}}*/
// DropRepeats - Drop repeated files resulting from symlinks /*{{{*/
// ---------------------------------------------------------------------
/* Here we go and stat every file that we found and strip dup inodes. */
@@ -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<std::string> &List);
bool DropRepeats(std::vector<std::string> &List,const char *Name);
+ bool DropTranslation(std::vector<std::string> &List);
void ReduceSourcelist(std::string CD,std::vector<std::string> &List);
bool WriteDatabase(Configuration &Cnf);
bool WriteSourceList(std::string Name,std::vector<std::string> &List,bool Source);
diff --git a/debian/changelog b/debian/changelog
index 6800c9864..67566bbe1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,12 @@ apt (0.9.7.5) UNRELEASED; urgency=low
* Japanese (KURASAWA Nozomu) (Closes: #684435)
[ David Kalnischkies ]
+ * 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/packagemanager.cc:
- unpack versions in case a different version from the package
is currently in unpack state to recover from broken system states
@@ -21,9 +27,6 @@ apt (0.9.7.5) UNRELEASED; urgency=low
- do not warn about files which have a record in the Release file, but
are not present on the CD to mirror the behavior of the other methods
and to allow uncompressed indexes to be dropped without scaring users
- * apt-pkg/cdrom.cc:
- - handle Components in the reduction for the source.list as multi-arch CDs
- otherwise create duplicated source entries (e.g. "wheezy main main")
-- David Kalnischkies <kalnischkies@gmail.com> Sun, 26 Aug 2012 10:49:17 +0200
diff --git a/test/integration/framework b/test/integration/framework
index 05878d0a4..57bf555af 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -91,6 +91,7 @@ runapt() {
}
aptconfig() { runapt apt-config $*; }
aptcache() { runapt apt-cache $*; }
+aptcdrom() { runapt apt-cdrom $*; }
aptget() { runapt apt-get $*; }
aptftparchive() { runapt apt-ftparchive $*; }
aptkey() { runapt apt-key $*; }
@@ -715,6 +716,21 @@ server.stat-cache-engine = \"disable\"" > lighttpd.conf
return 0
}
+changetocdrom() {
+ mkdir -p rootdir/media/cdrom/.disk
+ local CD="$(readlink -f rootdir/media/cdrom)"
+ echo "acquire::cdrom::mount \"${CD}\";" > rootdir/etc/apt/apt.conf.d/00cdrom
+ echo 'acquire::cdrom::autodetect 0;' >> rootdir/etc/apt/apt.conf.d/00cdrom
+ echo -n "$1" > ${CD}/.disk/info
+ if [ ! -d aptarchive/dists ]; then
+ msgdie 'Flat file archive cdroms can not be created currently'
+ return 1
+ fi
+ mv aptarchive/dists $CD
+ ln -s "$(readlink -f ./incoming)" $CD/pool
+ find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
+}
+
checkdiff() {
local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
if [ -n "$DIFFTEXT" ]; then
diff --git a/test/integration/test-apt-cdrom b/test/integration/test-apt-cdrom
new file mode 100755
index 000000000..f24c99b36
--- /dev/null
+++ b/test/integration/test-apt-cdrom
@@ -0,0 +1,104 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+buildsimplenativepackage 'testing' 'amd64,i386' '0.8.15' 'stable'
+setupaptarchive
+
+changetocdrom 'Debian APT Testdisk 0.8.15'
+
+# -de is not in the Release file, but picked up anyway for compatibility
+cd rootdir/media/cdrom/dists/stable/main/i18n
+sed -e '/^Description-en:/ d' -e '/^ / d' -e '/^$/ d' Translation-en > Translation-de
+echo 'Description-de: automatisch generiertes Testpaket testing=0.8.15/stable
+ Diese Pakete sind nur für das testen von APT gedacht,
+ sie erfüllen keinen Zweck auf einem normalen System…
+' >> Translation-de
+cat Translation-de | gzip > Translation-de.gz
+cat Translation-de | bzip2 > Translation-de.bz2
+cat Translation-de | xz --format=lzma > Translation-de.lzma
+cat Translation-de | xz > Translation-de.xz
+rm Translation-en Translation-de
+cd - > /dev/null
+
+aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1
+sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log
+testfileequal apt-cdrom.log "Scanning disc for index files..
+Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
+Found label 'Debian APT Testdisk 0.8.15'
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+Writing new source list
+Source list entries for this disc are:
+deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+Repeat this process for the rest of the CDs in your set."
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ testing
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst testing (0.8.15 stable [amd64])
+Conf testing (0.8.15 stable [amd64])' aptget install testing -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ testing:i386
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst testing:i386 (0.8.15 stable [i386])
+Conf testing:i386 (0.8.15 stable [i386])' aptget install testing:i386 -s
+
+# check Idempotence of apt-cdrom (and disabling of Translation dropping)
+aptcdrom add -m -o quiet=1 -o APT::CDROM::DropTranslation=0 > apt-cdrom.log 2>&1
+sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log
+testfileequal apt-cdrom.log "Scanning disc for index files..
+Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+Writing new source list
+Source list entries for this disc are:
+deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+Repeat this process for the rest of the CDs in your set."
+
+# take Translations from previous runs as needed
+aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1
+sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log
+testfileequal apt-cdrom.log "Scanning disc for index files..
+Found 2 package indexes, 1 source indexes, 2 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+Writing new source list
+Source list entries for this disc are:
+deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+Repeat this process for the rest of the CDs in your set."
+msgtest 'Test for the german description translation of' 'testing'
+aptcache show testing -o Acquire::Languages=de | grep -q '^Description-de: ' && msgpass || msgfail
+rm -rf rootdir/var/lib/apt/lists
+mkdir -p rootdir/var/lib/apt/lists/partial
+aptcdrom add -m -o quiet=1 > apt-cdrom.log 2>&1
+sed -i -e '/^Using CD-ROM/ d' -e '/gpgv/ d' -e '/^Identifying/ d' -e '/Reading / d' apt-cdrom.log
+testfileequal apt-cdrom.log "Scanning disc for index files..
+Found 2 package indexes, 1 source indexes, 1 translation indexes and 1 signatures
+This disc is called:
+'Debian APT Testdisk 0.8.15'
+Writing new source list
+Source list entries for this disc are:
+deb cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+deb-src cdrom:[Debian APT Testdisk 0.8.15]/ stable main
+Repeat this process for the rest of the CDs in your set."
+msgtest 'Test for the english description translation of' 'testing'
+aptcache show testing -o Acquire::Languages=en | grep -q '^Description-en: ' && msgpass || msgfail
+
+
+# check that we really can install from a 'cdrom'
+testdpkgnotinstalled testing
+aptget install testing -y > /dev/null 2>&1
+testdpkginstalled testing