ソースを参照

* 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")

David Kalnischkies 14 年 前
コミット
c45233eaf6
共有7 個のファイルを変更した171 個の追加3 個の削除を含む
  1. 11 0
      apt-pkg/aptconfiguration.cc
  2. 8 0
      apt-pkg/aptconfiguration.h
  3. 25 0
      apt-pkg/cdrom.cc
  4. 1 0
      apt-pkg/cdrom.h
  5. 6 3
      debian/changelog
  6. 16 0
      test/integration/framework
  7. 104 0
      test/integration/test-apt-cdrom

+ 11 - 0
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;

+ 8 - 0
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

+ 25 - 0
apt-pkg/cdrom.cc

@@ -269,6 +269,29 @@ bool pkgCdrom::DropBinaryArch(vector<string> &List)
       --I; // the next entry is at the same index after the erase
    }
    
+   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;
 }
 									/*}}}*/
@@ -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, "

+ 1 - 0
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);

+ 6 - 3
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
 

+ 16 - 0
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

+ 104 - 0
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