summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Vogt <egon@debian-devbox>2012-10-17 10:12:41 +0200
committerMichael Vogt <egon@debian-devbox>2012-10-17 10:12:41 +0200
commit32ed73df439850ee47e5e5edb8bfe1fe647ed794 (patch)
tree3a36260d49079236ae8c3c100de02455eed2d86e /test
parentd624605d4a750ba8005b19b270c3a1617bbb9f72 (diff)
parent27a83019db71c604eb6eaecd4feed09ba376e980 (diff)
merged from debian-sid
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework36
-rwxr-xr-xtest/integration/test-apt-cdrom104
-rwxr-xr-xtest/integration/test-architecture-specification-parsing15
-rwxr-xr-xtest/integration/test-bug-632221-cross-dependency-satisfaction3
-rwxr-xr-xtest/integration/test-bug-679371-apt-get-autoclean-multiarch24
-rwxr-xr-xtest/integration/test-bug-680041-apt-mark-holds-correctly72
-rwxr-xr-xtest/integration/test-bug-683786-build-dep-on-virtual-packages81
-rwxr-xr-xtest/integration/test-bug-686346-package-missing-architecture109
-rwxr-xr-xtest/integration/test-cachecontainer-architecture-specification36
-rwxr-xr-xtest/integration/test-conflicts-real-multiarch-same50
-rwxr-xr-xtest/integration/test-specific-architecture-dependencies182
-rwxr-xr-xtest/integration/test-unpack-different-version-unpacked121
-rw-r--r--test/libapt/cdromreducesourcelist_test.cc86
-rw-r--r--test/libapt/indexcopytosourcelist_test.cc86
-rw-r--r--test/libapt/makefile12
15 files changed, 1008 insertions, 9 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 965f984ca..11f1c7be2 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 $*; }
@@ -467,7 +468,7 @@ insertpackage() {
local PRIORITY="${6:-optional}"
local ARCHS=""
for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
- if [ "$arch" = "all" ]; then
+ if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
ARCHS="$(getarchitectures)"
else
ARCHS="$arch"
@@ -481,9 +482,9 @@ insertpackage() {
Priority: $PRIORITY
Section: other
Installed-Size: 42
-Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $arch
-Version: $VERSION
+Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
+ test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
+ echo "Version: $VERSION
Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
@@ -523,17 +524,18 @@ insertinstalledpackage() {
local VERSION="$3"
local DEPENDENCIES="$4"
local PRIORITY="${5:-optional}"
+ local STATUS="${6:-install ok installed}"
local FILE='rootdir/var/lib/dpkg/status'
local INFO='rootdir/var/lib/dpkg/info'
for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
echo "Package: $NAME
-Status: install ok installed
+Status: $STATUS
Priority: $PRIORITY
Section: other
Installed-Size: 42
Maintainer: Joe Sixpack <joe@example.org>
-Architecture: $arch
Version: $VERSION" >> $FILE
+ test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed
If you find such a package installed on your system,
@@ -724,6 +726,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
@@ -746,6 +763,11 @@ testfileequal() {
fi
}
+testempty() {
+ msgtest "Test for no output of" "$*"
+ test -z "$($* 2>&1)" && msgpass || msgfail
+}
+
testequal() {
local COMPAREFILE=$(mktemp)
addtrap "rm $COMPAREFILE;"
@@ -806,7 +828,7 @@ testnopackage() {
testdpkginstalled() {
msgtest "Test for correctly installed package(s) with" "dpkg -l $*"
- local PKGS="$(dpkg -l $* | grep '^i' | wc -l)"
+ local PKGS="$(dpkg -l $* 2>/dev/null | grep '^i' | wc -l)"
if [ "$PKGS" != $# ]; then
echo $PKGS
dpkg -l $* | grep '^[a-z]'
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
diff --git a/test/integration/test-architecture-specification-parsing b/test/integration/test-architecture-specification-parsing
index 8f365dd55..2741509a7 100755
--- a/test/integration/test-architecture-specification-parsing
+++ b/test/integration/test-architecture-specification-parsing
@@ -4,7 +4,7 @@ set -e
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
-configarchitecture 'amd64'
+configarchitecture 'amd64' 'armel'
buildsimplenativepackage 'pkg-arch-foo' 'amd64' '1.0' 'stable' 'Build-Depends: foo [amd64 !amd64]
Depends: foo [amd64 !amd64]'
@@ -14,6 +14,8 @@ buildsimplenativepackage 'pkg-arch-foo-unrelated-no' 'amd64' '1.0' 'stable' 'Bui
Depends: foo [!kfreebsd-any amd64]'
buildsimplenativepackage 'pkg-arch-foo-unrelated-no2' 'amd64' '1.0' 'stable' 'Build-Depends: foo [amd64 !kfreebsd-any]
Depends: foo [amd64 !kfreebsd-any]'
+buildsimplenativepackage 'no-depends' 'armel' '1.0' 'stable' 'Build-Depends: foo [armhf], bar [arm]
+Depends: foo [armhf], bar [arm]'
buildsimplenativepackage 'foo' 'amd64' '1.0' 'stable'
@@ -93,4 +95,15 @@ The following NEW packages will be installed:
Inst foo (1.0 stable [amd64])
Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo-unrelated-no2 -s
+testequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget build-dep no-depends -s
+# this is not really testing APT - more that dpkg is in line with us
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ no-depends:armel
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst no-depends:armel (1.0 stable [armel])
+Conf no-depends:armel (1.0 stable [armel])' aptget install no-depends -s
diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction
index 208c613a2..d90a103c9 100755
--- a/test/integration/test-bug-632221-cross-dependency-satisfaction
+++ b/test/integration/test-bug-632221-cross-dependency-satisfaction
@@ -21,7 +21,7 @@ insertpackage 'unstable' 'foreigner' 'amd64,armel' '1.0' 'Multi-Arch: foreign'
insertpackage 'unstable' 'arm-stuff' 'armel' '1.0'
insertpackage 'unstable' 'linux-stuff' 'amd64,armel' '1.0'
-insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-arm] | linux-stuff [ linux-any]'
+insertsource 'unstable' 'apt' 'any' '0.8.15' 'Build-Depends: doxygen, libc6-dev, libc6-dev:native, cool:any, amdboot:amd64, foreigner, libfwibble-dev, arm-stuff [any-armel] | linux-stuff [ linux-any]'
insertsource 'unstable' 'forbidden-none' 'any' '1' 'Build-Depends: amdboot:any'
insertsource 'unstable' 'forbidden-same' 'any' '1' 'Build-Depends: libc6:any'
@@ -63,6 +63,7 @@ Inst libc6 (1.0 unstable [amd64])
Inst specific (1.0 unstable [amd64])
Conf libc6 (1.0 unstable [amd64])
Conf specific (1.0 unstable [amd64])' aptget build-dep source-specific-amd64 -s -a armel
+
testequal 'Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
diff --git a/test/integration/test-bug-679371-apt-get-autoclean-multiarch b/test/integration/test-bug-679371-apt-get-autoclean-multiarch
new file mode 100755
index 000000000..ba6857b73
--- /dev/null
+++ b/test/integration/test-bug-679371-apt-get-autoclean-multiarch
@@ -0,0 +1,24 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+buildsimplenativepackage 'pkgall' 'all' '1' 'stable'
+buildsimplenativepackage 'pkgnative' 'amd64' '1' 'stable'
+buildsimplenativepackage 'pkgforeign' 'i386' '1' 'stable'
+
+setupaptarchive
+
+changetowebserver
+
+aptget update -qq
+aptget install pkgall pkgnative pkgforeign -y -qq > /dev/null
+
+testdpkginstalled pkgall pkgnative pkgforeign
+
+testequal 'Reading package lists...
+Building dependency tree...
+Reading state information...' aptget autoclean -s
diff --git a/test/integration/test-bug-680041-apt-mark-holds-correctly b/test/integration/test-bug-680041-apt-mark-holds-correctly
new file mode 100755
index 000000000..2e5e39c8e
--- /dev/null
+++ b/test/integration/test-bug-680041-apt-mark-holds-correctly
@@ -0,0 +1,72 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'pkgarch' 'amd64' '1'
+insertinstalledpackage 'pkgall' 'all' '1'
+
+insertpackage 'unstable' 'pkgarch' 'amd64' '2'
+insertpackage 'unstable' 'pkgall' 'all' '2'
+
+setupaptarchive
+
+runtests() {
+ testempty aptmark showhold
+
+ testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+ pkgall pkgarch
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' aptget dist-upgrade --trivial-only
+
+ testequal 'pkgarch set on hold.' aptmark hold pkgarch
+ testequal 'pkgarch' aptmark showhold
+
+ testequal 'Reading package lists...
+Building dependency tree...
+The following packages have been kept back:
+ pkgarch
+The following packages will be upgraded:
+ pkgall
+1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' aptget dist-upgrade --trivial-only
+
+ testequal 'Canceled hold on pkgarch.' aptmark unhold pkgarch
+ testempty aptmark showhold
+
+ testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be upgraded:
+ pkgall pkgarch
+2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' aptget dist-upgrade --trivial-only
+
+ testequal 'pkgall set on hold.' aptmark hold pkgall
+ testequal 'pkgall' aptmark showhold
+
+ testequal 'Reading package lists...
+Building dependency tree...
+The following packages have been kept back:
+ pkgall
+The following packages will be upgraded:
+ pkgarch
+1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
+After this operation, 0 B of additional disk space will be used.
+E: Trivial Only specified but this is not a trivial operation.' aptget dist-upgrade --trivial-only
+
+ testequal 'Canceled hold on pkgall.' aptmark unhold pkgall
+ testempty aptmark showhold
+}
+# single-arch
+runtests
+# multi-arch
+configarchitecture 'amd64' 'i386'
+runtests
diff --git a/test/integration/test-bug-683786-build-dep-on-virtual-packages b/test/integration/test-bug-683786-build-dep-on-virtual-packages
new file mode 100755
index 000000000..879d6a3bc
--- /dev/null
+++ b/test/integration/test-bug-683786-build-dep-on-virtual-packages
@@ -0,0 +1,81 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'armel'
+
+insertinstalledpackage 'build-essential' 'all' '11.5' 'Multi-Arch: foreign'
+
+insertpackage 'unstable' 'po-debconf' 'all' '1'
+insertsource 'unstable' 'dash' 'any' '1' 'Build-Depends: po-debconf'
+insertpackage 'unstable' 'make-po-debconf-pure-virtual' 'armel' '1' 'Depends: po-debconf'
+
+insertpackage 'unstable' 'po-debconf' 'amd64' '1'
+insertsource 'unstable' 'diffutils' 'any' '1' 'Build-Depends: texi2html'
+
+insertpackage 'unstable' 'libselinux1-dev' 'amd64' '1' 'Provides: libselinux-dev'
+insertsource 'unstable' 'sed' 'any' '1' 'Build-Depends: libselinux-dev'
+
+insertpackage 'unstable' 'libsehurd1-dev' 'amd64,armel' '1' 'Provides: libsehurd-dev'
+insertsource 'unstable' 'sed2' 'any' '1' 'Build-Depends: libsehurd-dev'
+
+setupaptarchive
+
+testequal 'Package: po-debconf:armel
+Versions:
+
+Reverse Depends:
+ make-po-debconf-pure-virtual:armel,po-debconf:armel
+Dependencies:
+Provides:
+Reverse Provides: ' aptcache showpkg po-debconf:armel
+testequal 'N: Unable to locate package texi2html' aptcache showpkg texi2html:armel -q=0
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ po-debconf
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst po-debconf (1 unstable, unstable [all])
+Conf po-debconf (1 unstable, unstable [all])' aptget build-dep dash -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for dash cannot be satisfied because the package po-debconf cannot be found' aptget build-dep -aarmel dash -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for diffutils cannot be satisfied because the package texi2html cannot be found' aptget build-dep -aarmel diffutils -s
+
+testequal "Reading package lists...
+Building dependency tree...
+Note, selecting 'libselinux1-dev' instead of 'libselinux-dev'
+The following NEW packages will be installed:
+ libselinux1-dev
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libselinux1-dev (1 unstable [amd64])
+Conf libselinux1-dev (1 unstable [amd64])" aptget build-dep sed -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+E: Build-Depends dependency for sed cannot be satisfied because the package libselinux-dev cannot be found' aptget build-dep -aarmel sed -s
+
+testequal "Reading package lists...
+Building dependency tree...
+Note, selecting 'libsehurd1-dev' instead of 'libsehurd-dev'
+The following NEW packages will be installed:
+ libsehurd1-dev
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsehurd1-dev (1 unstable [amd64])
+Conf libsehurd1-dev (1 unstable [amd64])" aptget build-dep sed2 -s
+
+testequal "Reading package lists...
+Building dependency tree...
+Note, selecting 'libsehurd1-dev:armel' instead of 'libsehurd-dev:armel'
+The following NEW packages will be installed:
+ libsehurd1-dev:armel
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst libsehurd1-dev:armel (1 unstable [armel])
+Conf libsehurd1-dev:armel (1 unstable [armel])" aptget build-dep -aarmel sed2 -s
diff --git a/test/integration/test-bug-686346-package-missing-architecture b/test/integration/test-bug-686346-package-missing-architecture
new file mode 100755
index 000000000..b2c9ec9ee
--- /dev/null
+++ b/test/integration/test-bug-686346-package-missing-architecture
@@ -0,0 +1,109 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'pkgb' 'none' '1'
+insertinstalledpackage 'pkgd' 'none' '1'
+insertpackage 'unstable' 'pkga' 'amd64' '2' 'Depends: pkgb'
+insertpackage 'unstable' 'pkgb' 'amd64' '2'
+insertpackage 'unstable' 'pkgc' 'amd64' '1' 'Conflicts: pkgb'
+insertpackage 'unstable' 'pkge' 'none' '1'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ pkgb:none
+The following NEW packages will be installed:
+ pkgc
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv pkgb:none [1]
+Inst pkgc (1 unstable [amd64])
+Conf pkgc (1 unstable [amd64])' aptget install pkgc -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ pkgb
+The following packages will be REMOVED:
+ pkgb:none
+The following NEW packages will be installed:
+ pkga pkgb
+0 upgraded, 2 newly installed, 1 to remove and 0 not upgraded.
+Remv pkgb:none [1]
+Inst pkgb (2 unstable [amd64])
+Inst pkga (2 unstable [amd64])
+Conf pkgb (2 unstable [amd64])
+Conf pkga (2 unstable [amd64])' aptget install pkga -s
+
+# ensure that arch-less stanzas from Packages files are ignored
+msgtest 'Package is distributed in the Packages files' 'pkge'
+grep -q 'Package: pkge' $(find aptarchive -name 'Packages') && msgpass || msgfail
+testnopackage pkge
+testnopackage pkge:none
+testnopackage pkge:*
+
+# do not automatically change from none-arch to whatever-arch as
+# this breaks other none packages and dpkg has this ruleset as
+# this difference seems so important that it has to be maintained …
+testequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget dist-upgrade -s
+
+# pkgd has no update with an architecture
+testdpkginstalled pkgd
+msgtest 'Test apt-get purge' 'pkgd'
+aptget purge pkgd -y >/dev/null 2>&1 && msgpass || msgfail
+testdpkgnotinstalled pkgd
+
+# there is a pkgb with an architecture
+testdpkginstalled pkgb
+msgtest 'Test apt-get purge' 'pkgb:none'
+aptget purge pkgb:none -y >/dev/null 2>&1 && msgpass || msgfail
+testdpkgnotinstalled pkgb
+
+# check that dependencies are created after the none package exists in the cache
+rm rootdir/var/cache/apt/*.bin
+insertinstalledpackage 'pkgb' 'none' '1'
+insertinstalledpackage 'pkgf' 'none' '1' 'Conflicts: pkgb'
+insertinstalledpackage 'pkgg' 'amd64' '1' 'Conflicts: pkgb'
+insertinstalledpackage 'pkgb' 'amd64' '2'
+testequal "Reading package lists...
+Building dependency tree...
+Reading state information...
+You might want to run 'apt-get -f install' to correct these.
+The following packages have unmet dependencies:
+ pkgb : Conflicts: pkgb:none but 1 is installed
+ pkgb:none : Conflicts: pkgb but 2 is installed
+ pkgf:none : Conflicts: pkgb:none but 1 is installed
+ Conflicts: pkgb but 2 is installed
+ pkgg : Conflicts: pkgb but 2 is installed
+ Conflicts: pkgb:none but 1 is installed
+E: Unmet dependencies. Try using -f." aptget check
+
+# check that dependencies are generated for none-packages
+rm rootdir/var/lib/dpkg/status
+insertinstalledpackage 'pkgx' 'none' '1'
+insertinstalledpackage 'pkgy' 'none' '1' 'Depends: pkgz, pkgx (>= 1)'
+insertinstalledpackage 'pkgz' 'none' '1'
+testequal 'Reading package lists...
+Building dependency tree...
+Reading state information...
+The following packages will be REMOVED:
+ pkgx:none* pkgy:none*
+0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
+Purg pkgy:none [1]
+Purg pkgx:none [1]' aptget purge pkgx -s
+testequal 'Reading package lists...
+Building dependency tree...
+Reading state information...
+The following packages will be REMOVED:
+ pkgy:none* pkgz:none*
+0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
+Purg pkgy:none [1]
+Purg pkgz:none [1]' aptget purge pkgz -s
diff --git a/test/integration/test-cachecontainer-architecture-specification b/test/integration/test-cachecontainer-architecture-specification
index 174efb087..47abfb5b0 100755
--- a/test/integration/test-cachecontainer-architecture-specification
+++ b/test/integration/test-cachecontainer-architecture-specification
@@ -8,6 +8,7 @@ configarchitecture 'amd64' 'armel'
#insertinstalledpackage 'xserver-xorg-core' 'amd64' '2:1.7.6-2ubuntu7.10'
insertpackage 'unstable' 'libsame' 'armel,amd64' '1' 'Multi-Arch: same'
+insertpackage 'unstable' 'foo' 'all' '1'
setupaptarchive
@@ -27,6 +28,9 @@ Inst libsame:armel (1 unstable [armel])
Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:armel
testequal 'Reading package lists...
Building dependency tree...
+E: Unable to locate package libsame' aptget -s install libsame:armhf
+testequal 'Reading package lists...
+Building dependency tree...
The following NEW packages will be installed:
libsame
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
@@ -85,3 +89,35 @@ Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:linux-*
testequal 'Reading package lists...
Building dependency tree...
E: Unable to locate package libsame' aptget -s install libsame:windows-any
+
+testequal 'Reading package lists...
+Building dependency tree...
+E: Unable to locate package foo' aptget -s install foo:armel
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Conf foo (1 unstable [all])' aptget -s install foo
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Conf foo (1 unstable [all])' aptget -s install foo:all
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Conf foo (1 unstable [all])' aptget -s install foo:amd64
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo (1 unstable [all])
+Conf foo (1 unstable [all])' aptget -s install foo:native
diff --git a/test/integration/test-conflicts-real-multiarch-same b/test/integration/test-conflicts-real-multiarch-same
new file mode 100755
index 000000000..d9111677c
--- /dev/null
+++ b/test/integration/test-conflicts-real-multiarch-same
@@ -0,0 +1,50 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable' 'virtual-provider' 'amd64,i386' '2' 'Provides: virtual
+Conflicts: virtual
+Multi-Arch: same'
+insertpackage 'unstable' 'real' 'amd64,i386' '2' 'Conflicts: real
+Multi-Arch: same'
+insertpackage 'unstable' 'real-provider' 'amd64,i386' '2' 'Provides: real-provider
+Conflicts: real-provider
+Multi-Arch: same'
+setupaptarchive
+
+testequal "Reading package lists...
+Building dependency tree...
+Note, selecting 'virtual-provider' instead of 'virtual'
+Note, selecting 'virtual-provider:i386' instead of 'virtual:i386'
+The following NEW packages will be installed:
+ virtual-provider virtual-provider:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst virtual-provider (2 unstable [amd64])
+Inst virtual-provider:i386 (2 unstable [i386])
+Conf virtual-provider (2 unstable [amd64])
+Conf virtual-provider:i386 (2 unstable [i386])" aptget install virtual:* -s -q=0
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ real real:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst real (2 unstable [amd64])
+Inst real:i386 (2 unstable [i386])
+Conf real (2 unstable [amd64])
+Conf real:i386 (2 unstable [i386])' aptget install real:* -s -q=0
+
+# ensure that we are not confused by the provides
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ real-provider real-provider:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst real-provider (2 unstable [amd64])
+Inst real-provider:i386 (2 unstable [i386])
+Conf real-provider (2 unstable [amd64])
+Conf real-provider:i386 (2 unstable [i386])' aptget install real-provider:* -s -q=0
diff --git a/test/integration/test-specific-architecture-dependencies b/test/integration/test-specific-architecture-dependencies
new file mode 100755
index 000000000..078a84654
--- /dev/null
+++ b/test/integration/test-specific-architecture-dependencies
@@ -0,0 +1,182 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable' 'libc6' 'amd64,i386' '1' 'Multi-Arch: same'
+insertinstalledpackage 'libold' 'amd64,i386' '1' 'Multi-Arch: same'
+insertinstalledpackage 'provider' 'amd64' '1' 'Provides: foo'
+
+insertpackage 'unstable' 'pre-depender' 'all' '1' 'Pre-Depends: libc6:i386'
+insertpackage 'unstable' 'depender' 'all' '1' 'Depends: libc6:i386'
+
+insertpackage 'unstable' 'breaker' 'all' '1' 'Breaks: libold (<< 2)'
+insertpackage 'unstable' 'breaker-x32' 'amd64' '1' 'Breaks: libold:i386 (<< 2)'
+insertpackage 'unstable' 'breaker-x64' 'i386' '1' 'Breaks: libold:amd64 (<< 2)'
+# conflicts with no effect
+insertpackage 'unstable' 'oldconflictor' 'all' '1' 'Conflicts: libold (<< 0)'
+insertpackage 'unstable' 'oldconflictor-x32' 'amd64' '1' 'Conflicts: libold:i386 (<< 0)'
+insertpackage 'unstable' 'oldconflictor-x64' 'i386' '1' 'Conflicts: libold:amd64 (<< 0)'
+
+insertpackage 'unstable' 'foo-depender' 'i386,amd64' '1' 'Depends: foo'
+insertpackage 'unstable' 'foo-foreign-depender' 'i386' '1' 'Depends: foo:amd64'
+
+insertpackage 'unstable' 'foo-conflictor' 'i386,amd64' '1' 'Conflicts: foo'
+insertpackage 'unstable' 'foo-foreign-conflictor' 'i386' '1' 'Conflicts: foo:amd64'
+insertpackage 'unstable' 'foo-no-conflictor' 'i386' '1' 'Conflicts: foo:i386'
+
+setupaptarchive
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ libc6:i386
+The following NEW packages will be installed:
+ libc6:i386 pre-depender
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6:i386 (1 unstable [i386])
+Conf libc6:i386 (1 unstable [i386])
+Inst pre-depender (1 unstable [all])
+Conf pre-depender (1 unstable [all])' aptget install pre-depender -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following extra packages will be installed:
+ libc6:i386
+The following NEW packages will be installed:
+ depender libc6:i386
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst libc6:i386 (1 unstable [i386])
+Inst depender (1 unstable [all])
+Conf libc6:i386 (1 unstable [i386])
+Conf depender (1 unstable [all])' aptget install depender -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ libold libold:i386
+The following NEW packages will be installed:
+ breaker
+0 upgraded, 1 newly installed, 2 to remove and 0 not upgraded.
+Remv libold [1]
+Remv libold:i386 [1]
+Inst breaker (1 unstable [all])
+Conf breaker (1 unstable [all])' aptget install breaker -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ libold:i386
+The following NEW packages will be installed:
+ breaker-x32
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv libold:i386 [1]
+Inst breaker-x32 (1 unstable [amd64])
+Conf breaker-x32 (1 unstable [amd64])' aptget install breaker-x32 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ libold
+The following NEW packages will be installed:
+ breaker-x64:i386
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv libold [1]
+Inst breaker-x64:i386 (1 unstable [i386])
+Conf breaker-x64:i386 (1 unstable [i386])' aptget install breaker-x64 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ oldconflictor
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst oldconflictor (1 unstable [all])
+Conf oldconflictor (1 unstable [all])' aptget install oldconflictor -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ oldconflictor-x32
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst oldconflictor-x32 (1 unstable [amd64])
+Conf oldconflictor-x32 (1 unstable [amd64])' aptget install oldconflictor-x32 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ oldconflictor-x64:i386
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst oldconflictor-x64:i386 (1 unstable [i386])
+Conf oldconflictor-x64:i386 (1 unstable [i386])' aptget install oldconflictor-x64 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-depender
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo-depender (1 unstable [amd64])
+Conf foo-depender (1 unstable [amd64])' aptget install foo-depender -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo-depender:i386 : Depends: foo:i386 but it is not installable
+E: Unable to correct problems, you have held broken packages.' aptget install foo-depender:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-foreign-depender:i386
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo-foreign-depender:i386 (1 unstable [i386])
+Conf foo-foreign-depender:i386 (1 unstable [i386])' aptget install foo-foreign-depender:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ provider
+The following NEW packages will be installed:
+ foo-conflictor
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv provider [1]
+Inst foo-conflictor (1 unstable [amd64])
+Conf foo-conflictor (1 unstable [amd64])' aptget install foo-conflictor -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ provider
+The following NEW packages will be installed:
+ foo-conflictor:i386
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv provider [1]
+Inst foo-conflictor:i386 (1 unstable [i386])
+Conf foo-conflictor:i386 (1 unstable [i386])' aptget install foo-conflictor:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following packages will be REMOVED:
+ provider
+The following NEW packages will be installed:
+ foo-foreign-conflictor:i386
+0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
+Remv provider [1]
+Inst foo-foreign-conflictor:i386 (1 unstable [i386])
+Conf foo-foreign-conflictor:i386 (1 unstable [i386])' aptget install foo-foreign-conflictor:i386 -s
+
+testequal 'Reading package lists...
+Building dependency tree...
+The following NEW packages will be installed:
+ foo-no-conflictor:i386
+0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
+Inst foo-no-conflictor:i386 (1 unstable [i386])
+Conf foo-no-conflictor:i386 (1 unstable [i386])' aptget install foo-no-conflictor:i386 -s
diff --git a/test/integration/test-unpack-different-version-unpacked b/test/integration/test-unpack-different-version-unpacked
new file mode 100755
index 000000000..952f6e6b2
--- /dev/null
+++ b/test/integration/test-unpack-different-version-unpacked
@@ -0,0 +1,121 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'amd64' 'i386'
+
+insertpackage 'unstable' 'libqtcore4' 'i386,amd64' '2' 'Multi-Arch: same'
+setupaptarchive
+
+DPKGSTATUS='rootdir/var/lib/dpkg/status'
+cp $DPKGSTATUS dpkg.status
+
+cleanstatus() {
+ cp dpkg.status $DPKGSTATUS
+ rm rootdir/var/cache/apt/*.bin
+}
+
+#FIXME: the reported version is wrong, it should be 1, not 2
+insertinstalledpackage 'libqtcore4' 'i386,amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
+2 not fully installed or removed.
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+2 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+2 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same' '' 'install ok unpacked'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'amd64' '2' 'Multi-Arch: same'
+insertinstalledpackage 'libqtcore4' 'i386' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4:i386
+The following packages will be upgraded:
+ libqtcore4:i386
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4:i386 [1] (2 unstable [i386])
+Conf libqtcore4:i386 (2 unstable [i386])' aptget install -s -f
+
+cleanstatus
+insertinstalledpackage 'libqtcore4' 'i386' '2' 'Multi-Arch: same'
+insertinstalledpackage 'libqtcore4' 'amd64' '1' 'Multi-Arch: same' '' 'install ok unpacked'
+testequal 'Reading package lists...
+Building dependency tree...
+Correcting dependencies... Done
+The following extra packages will be installed:
+ libqtcore4
+The following packages will be upgraded:
+ libqtcore4
+1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+1 not fully installed or removed.
+Inst libqtcore4 [1] (2 unstable [amd64])
+Conf libqtcore4 (2 unstable [amd64])' aptget install -s -f
diff --git a/test/libapt/cdromreducesourcelist_test.cc b/test/libapt/cdromreducesourcelist_test.cc
new file mode 100644
index 000000000..729da23a6
--- /dev/null
+++ b/test/libapt/cdromreducesourcelist_test.cc
@@ -0,0 +1,86 @@
+#include <apt-pkg/cdrom.h>
+#include <apt-pkg/error.h>
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "assert.h"
+
+class Cdrom : public pkgCdrom {
+public:
+ std::vector<std::string> ReduceSourcelist(std::string CD,std::vector<std::string> List) {
+ pkgCdrom::ReduceSourcelist(CD, List);
+ return List;
+ }
+};
+
+int main(int argc, char const *argv[]) {
+ Cdrom cd;
+ std::vector<std::string> List;
+ std::string CD("/media/cdrom/");
+
+ std::vector<std::string> R = cd.ReduceSourcelist(CD, List);
+ equals(R.empty(), true);
+
+ List.push_back(" wheezy main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy main");
+
+ List.push_back(" wheezy main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy main");
+
+ List.push_back(" wheezy contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 1);
+ equals(R[0], " wheezy contrib main");
+
+ List.push_back(" wheezy-update contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib");
+
+ List.push_back(" wheezy-update contrib");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib");
+
+ List.push_back(" wheezy-update non-free");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib non-free");
+
+ List.push_back(" wheezy-update main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main");
+ equals(R[1], " wheezy-update contrib main non-free");
+
+ List.push_back(" wheezy non-free");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 2);
+ equals(R[0], " wheezy contrib main non-free");
+ equals(R[1], " wheezy-update contrib main non-free");
+
+ List.push_back(" sid main");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 3);
+ equals(R[0], " sid main");
+ equals(R[1], " wheezy contrib main non-free");
+ equals(R[2], " wheezy-update contrib main non-free");
+
+ List.push_back(" sid main-reduce");
+ R = cd.ReduceSourcelist(CD, List);
+ equals(R.size(), 3);
+ equals(R[0], " sid main main-reduce");
+ equals(R[1], " wheezy contrib main non-free");
+ equals(R[2], " wheezy-update contrib main non-free");
+
+ return 0;
+}
diff --git a/test/libapt/indexcopytosourcelist_test.cc b/test/libapt/indexcopytosourcelist_test.cc
new file mode 100644
index 000000000..69d8fae86
--- /dev/null
+++ b/test/libapt/indexcopytosourcelist_test.cc
@@ -0,0 +1,86 @@
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
+#include <apt-pkg/indexcopy.h>
+
+#include <string>
+
+#include "assert.h"
+
+class NoCopy : public IndexCopy {
+public:
+ std::string ConvertToSourceList(std::string CD,std::string Path) {
+ IndexCopy::ConvertToSourceList(CD, Path);
+ return Path;
+ }
+ bool GetFile(std::string &Filename,unsigned long long &Size) { return false; }
+ bool RewriteEntry(FILE *Target,std::string File) { return false; }
+ const char *GetFileName() { return NULL; }
+ const char *Type() { return NULL; }
+
+};
+
+int main(int argc, char const *argv[]) {
+ NoCopy ic;
+ std::string const CD("/media/cdrom/");
+
+ char const * Releases[] = { "unstable", "wheezy-updates", NULL };
+ char const * Components[] = { "main", "non-free", NULL };
+
+ for (char const ** Release = Releases; *Release != NULL; ++Release) {
+ for (char const ** Component = Components; *Component != NULL; ++Component) {
+ std::string const Path = std::string("dists/") + *Release + "/" + *Component + "/";
+ std::string const Binary = Path + "binary-";
+ std::string const A = Binary + "armel/";
+ std::string const B = Binary + "mips/";
+ std::string const C = Binary + "kfreebsd-mips/";
+ std::string const S = Path + "source/";
+ std::string const List = std::string(*Release) + " " + *Component;
+
+ _config->Clear("APT");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "mips");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "kfreebsd-mips");
+ _config->Set("APT::Architectures::", "kfreebsd-mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), A);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), B);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+
+ _config->Clear("APT");
+ _config->Set("APT::Architecture", "armel");
+ _config->Set("APT::Architectures::", "armel");
+ _config->Set("APT::Architectures::", "mips");
+ APT::Configuration::getArchitectures(false);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + A), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + B), List);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + C), C);
+ equals(ic.ConvertToSourceList("/media/cdrom/", CD + S), List);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index b2e6db2dd..5e225f240 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -86,3 +86,15 @@ PROGRAM = CdromFindPackages${BASENAME}
SLIBS = -lapt-pkg
SOURCE = cdromfindpackages_test.cc
include $(PROGRAM_H)
+
+# test cdroms index reduction for source.list
+PROGRAM = CdromReduceSourceList${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = cdromreducesourcelist_test.cc
+include $(PROGRAM_H)
+
+# text IndexCopy::ConvertToSourceList
+PROGRAM = IndexCopyToSourceList${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = indexcopytosourcelist_test.cc
+include $(PROGRAM_H)