diff options
Diffstat (limited to 'test')
49 files changed, 2597 insertions, 223 deletions
diff --git a/test/Makefile b/test/Makefile index da0a49b0c..74bffccb7 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,8 +6,8 @@ ifndef NOISY .SILENT: endif -.PHONY: headers library clean veryclean all binary program doc test -all clean veryclean binary program dirs test: +.PHONY: startup headers library clean veryclean all binary program doc test update-po +startup all clean veryclean binary program dirs test update-po manpages debiandoc: $(MAKE) -C libapt $@ $(MAKE) -C interactive-helper $@ diff --git a/test/integration/framework b/test/integration/framework index a738d27cc..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 $*; } @@ -107,6 +108,10 @@ aptitude() { LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $* fi } +gdb() { + echo "gdb: run »$*«" + APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which gdb) ${BUILDDIRECTORY}/$1 +} addtrap() { CURRENTTRAP="$CURRENTTRAP $1" @@ -151,7 +156,7 @@ setupenvironment() { echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf - if ! $(which dpkg) --assert-multi-arch; then + if ! $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it… fi echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf @@ -199,7 +204,7 @@ configdpkg() { echo -n > rootdir/var/lib/dpkg/status fi fi - if $(which dpkg) --assert-multi-arch; then + if $(which dpkg) --assert-multi-arch 2>&1 > /dev/null; then local ARCHS="$(getarchitectures)" if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then DPKGARCH="$(dpkg --print-architecture)" @@ -207,7 +212,9 @@ configdpkg() { if [ "${ARCH}" != "${DPKGARCH}" ]; then dpkg --add-architecture ${ARCH}; fi done if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then - insertinstalledpackage 'dpkg' "all" '1.16.2~wipmultiarch~fake' + # dpkg doesn't really check the version as long as it is fully installed, + # but just to be sure we choose one above the required version + insertinstalledpackage 'dpkg' "all" '1.16.2+fake' fi fi fi @@ -298,23 +305,28 @@ echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME} Section: $SECTION Priority: $PRIORITY Maintainer: Joe Sixpack <joe@example.org> -Standards-Version: 3.9.1 +Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control + local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')" + test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control + echo " +Package: $NAME" >> ${BUILDDIR}/debian/control -Package: $NAME" > ${BUILDDIR}/debian/control if [ "$ARCH" = 'all' ]; then echo "Architecture: all" >> ${BUILDDIR}/debian/control else echo "Architecture: any" >> ${BUILDDIR}/debian/control fi - test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control + local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')" + test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control if [ -z "$DESCRIPTION" ]; then echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} If you find such a package installed on your system, YOU did something horribly wrong! They are autogenerated und used only by testcases for APT and surf no other propose…" >> ${BUILDDIR}/debian/control else - echo "Description: $DESCRIPTION" >> ${BUILDIR}/debian/control + echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control fi + echo '3.0 (native)' > ${BUILDDIR}/debian/source/format local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')" for SRC in $SRCS; do @@ -456,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" @@ -470,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} @@ -502,7 +514,8 @@ Architecture: $ARCH" >> $FILE test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE echo "Files: d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc - d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE + d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz +" >> $FILE } insertinstalledpackage() { @@ -511,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, @@ -556,7 +570,7 @@ buildaptarchivefromfiles() { msgninfo "\t${line} file… " cat ${line} | gzip > ${line}.gz cat ${line} | bzip2 > ${line}.bz2 - cat ${line} | lzma > ${line}.lzma + cat ${line} | xz --format=lzma > ${line}.lzma cat ${line} | xz > ${line}.xz msgdone "info" done @@ -676,20 +690,30 @@ signreleasefiles() { } changetowebserver() { - if which weborf > /dev/null; then - weborf -xb aptarchive/ 2>&1 > /dev/null & + if [ -n "$1" ] && ! test -x ${BUILDDIRECTORY}/aptwebserver; then + msgdie 'Need the aptwebserver when passing arguments' + fi + + local LOG='/dev/null' + if test -x ${BUILDDIRECTORY}/aptwebserver; then + cd aptarchive + LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/aptwebserver $@ 2> $LOG > $LOG & + addtrap "kill $!;" + cd - > /dev/null + elif which weborf > /dev/null; then + weborf -xb aptarchive/ 2> $LOG > $LOG & addtrap "kill $!;" elif which gatling > /dev/null; then cd aptarchive - gatling -p 8080 -F -S 2>&1 > /dev/null & + gatling -p 8080 -F -S 2> $LOG > $LOG & addtrap "kill $!;" cd - > /dev/null elif which lighttpd > /dev/null; then echo "server.document-root = \"$(readlink -f ./aptarchive)\" server.port = 8080 server.stat-cache-engine = \"disable\"" > lighttpd.conf - lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid' - lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null & + lighttpd -t -f lighttpd.conf 2> $LOG > $LOG || msgdie 'Can not change to webserver: our lighttpd config is invalid' + lighttpd -D -f lighttpd.conf 2> $LOG > $LOG & addtrap "kill $!;" else msgdie 'You have to install weborf or lighttpd first' @@ -702,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 @@ -724,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;" @@ -784,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/skip-aptwebserver b/test/integration/skip-aptwebserver new file mode 100755 index 000000000..0622941ce --- /dev/null +++ b/test/integration/skip-aptwebserver @@ -0,0 +1,25 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture 'amd64' + +buildsimplenativepackage 'apt' 'all' '1.0' 'stable' + +setupaptarchive +changetowebserver + +rm -rf rootdir/var/lib/apt/lists +aptget update -qq +testequal 'Hit http://localhost stable InRelease +Hit http://localhost stable/main Sources +Hit http://localhost stable/main amd64 Packages +Hit http://localhost stable/main Translation-en +Reading package lists...' aptget update + +mv rootdir/var/lib/apt/lists/localhost* rootdir/var/lib/apt/lists/partial +aptget update + diff --git a/test/integration/skip-bug-602412-dequote-redirect b/test/integration/skip-bug-602412-dequote-redirect deleted file mode 100755 index a63d36246..000000000 --- a/test/integration/skip-bug-602412-dequote-redirect +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -set -e - -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework -setupenvironment -configarchitecture 'i386' - -if ! which lighttpd > /dev/null; then - msgdie 'You need lighttpd for this testcase, sorry…' - exit 1 -fi - -buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable' - -setupaptarchive - -echo "server.modules = ( \"mod_redirect\" ) -server.document-root = \"$(readlink -f ./aptarchive)\" -server.port = 8080 -server.stat-cache-engine = \"disable\" -url.redirect = ( \"^/pool/(.*)$\" => \"/newpool/\$1\" )" > lighttpd.conf - -mv aptarchive/pool aptarchive/newpool -lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid' -lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null & -addtrap "kill $!;" - -local APTARCHIVE="file://$(readlink -f ./aptarchive)" -for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do - sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#" -done - -aptget update -qq || msgdie 'apt-get update failed' -aptget install unrelated --download-only -qq || msgdie 'downloading package failed' - 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-apt-get-changelog b/test/integration/test-apt-get-changelog index 0a80cc08c..d013cc458 100755 --- a/test/integration/test-apt-get-changelog +++ b/test/integration/test-apt-get-changelog @@ -17,6 +17,9 @@ echo 'Apt::Changelogs::Server "http://localhost:8080/";' >> ./aptconfig.conf testequal "'http://localhost:8080//pool/apt_1.0/changelog'" aptget changelog apt --print-uris +testequal "'http://localhost:8080//pool/apt_1.0/changelog' +'http://localhost:8080//pool/apt_1.0/changelog'" aptget changelog apt apt --print-uris + aptget changelog apt -qq > apt.changelog testfileequal 'apt.changelog' "$(cat aptarchive/pool/apt_1.0/changelog)" rm apt.changelog diff --git a/test/integration/test-apt-get-download b/test/integration/test-apt-get-download index 4edb7c173..b164f7dba 100755 --- a/test/integration/test-apt-get-download +++ b/test/integration/test-apt-get-download @@ -9,6 +9,7 @@ configarchitecture "i386" buildsimplenativepackage 'apt' 'all' '1.0' 'stable' buildsimplenativepackage 'apt' 'all' '2.0' 'unstable' +insertinstalledpackage 'vrms' 'all' '1.0' setupaptarchive @@ -26,3 +27,6 @@ testdownload apt_2.0_all.deb apt DEBFILE="$(readlink -f aptarchive)/pool/apt_2.0_all.deb" testequal "'file://${DEBFILE}' apt_2.0_all.deb $(stat -c%s $DEBFILE) sha256:$(sha256sum $DEBFILE | cut -d' ' -f 1)" aptget download apt --print-uris + +# deb:677887 +testequal "E: Can't find a source to download version '1.0' of 'vrms:i386'" aptget download vrms diff --git a/test/integration/test-architecture-specification-parsing b/test/integration/test-architecture-specification-parsing new file mode 100755 index 000000000..2741509a7 --- /dev/null +++ b/test/integration/test-architecture-specification-parsing @@ -0,0 +1,109 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'armel' + +buildsimplenativepackage 'pkg-arch-foo' 'amd64' '1.0' 'stable' 'Build-Depends: foo [amd64 !amd64] +Depends: foo [amd64 !amd64]' +buildsimplenativepackage 'pkg-arch-no-foo' 'amd64' '1.0' 'stable' 'Build-Depends: foo [!amd64 amd64] +Depends: foo [!amd64 amd64]' +buildsimplenativepackage 'pkg-arch-foo-unrelated-no' 'amd64' '1.0' 'stable' 'Build-Depends: foo [!kfreebsd-any amd64] +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' + +insertinstalledpackage 'build-essential' 'all' '11.5' 'Multi-Arch: foreign' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following NEW packages will be installed: + foo pkg-arch-foo +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst foo (1.0 stable [amd64]) +Inst pkg-arch-foo (1.0 stable [amd64]) +Conf foo (1.0 stable [amd64]) +Conf pkg-arch-foo (1.0 stable [amd64])' aptget install pkg-arch-foo -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + pkg-arch-no-foo +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst pkg-arch-no-foo (1.0 stable [amd64]) +Conf pkg-arch-no-foo (1.0 stable [amd64])' aptget install pkg-arch-no-foo -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following NEW packages will be installed: + foo pkg-arch-foo-unrelated-no +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst foo (1.0 stable [amd64]) +Inst pkg-arch-foo-unrelated-no (1.0 stable [amd64]) +Conf foo (1.0 stable [amd64]) +Conf pkg-arch-foo-unrelated-no (1.0 stable [amd64])' aptget install pkg-arch-foo-unrelated-no -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following NEW packages will be installed: + foo pkg-arch-foo-unrelated-no2 +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst foo (1.0 stable [amd64]) +Inst pkg-arch-foo-unrelated-no2 (1.0 stable [amd64]) +Conf foo (1.0 stable [amd64]) +Conf pkg-arch-foo-unrelated-no2 (1.0 stable [amd64])' aptget install pkg-arch-foo-unrelated-no2 -s + +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.0 stable [amd64]) +Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo -s + +testequal 'Reading package lists... +Building dependency tree... +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' aptget build-dep pkg-arch-no-foo -s + +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.0 stable [amd64]) +Conf foo (1.0 stable [amd64])' aptget build-dep pkg-arch-foo-unrelated-no -s + +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.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-593360-modifiers-in-names b/test/integration/test-bug-593360-modifiers-in-names index 83a3cfabf..74826cbdb 100755 --- a/test/integration/test-bug-593360-modifiers-in-names +++ b/test/integration/test-bug-593360-modifiers-in-names @@ -15,6 +15,11 @@ The following NEW packages will be installed: Inst g++ (4:4.4.5-1 localhost [i386]) Conf g++ (4:4.4.5-1 localhost [i386])' aptget install g++ -s +testequal "Reading package lists... +Building dependency tree... +Package 'g++' is not installed, so not removed +0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded." aptget remove g++ -s + testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: diff --git a/test/integration/test-bug-595691-empty-and-broken-archive-files b/test/integration/test-bug-595691-empty-and-broken-archive-files index bb1ac0e54..63883b380 100755 --- a/test/integration/test-bug-595691-empty-and-broken-archive-files +++ b/test/integration/test-bug-595691-empty-and-broken-archive-files @@ -28,10 +28,10 @@ testaptgetupdate() { createemptyarchive() { find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete if [ "en" = "$1" ]; then - echo -n "" | $COMPRESSOR > aptarchive/Packages.$COMPRESS + echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS fi touch aptarchive/Packages - echo -n "" | $COMPRESSOR > aptarchive/${1}.$COMPRESS + echo -n "" | $COMPRESSOR_CMD > aptarchive/${1}.$COMPRESS generatereleasefiles signreleasefiles rm -f aptarchive/Packages @@ -40,7 +40,7 @@ createemptyarchive() { createemptyfile() { find aptarchive/ \( -name "Packages*" -o -name "en*" \) -type f -delete if [ "en" = "$1" ]; then - echo -n "" | $COMPRESSOR > aptarchive/Packages.$COMPRESS + echo -n "" | $COMPRESSOR_CMD > aptarchive/Packages.$COMPRESS fi touch aptarchive/Packages aptarchive/${1}.$COMPRESS generatereleasefiles @@ -50,6 +50,7 @@ createemptyfile() { setupcompressor() { COMPRESSOR="$1" + COMPRESSOR_CMD="$1" case $COMPRESSOR in gzip) COMPRESS="gz";; bzip2) COMPRESS="bz2";; @@ -66,10 +67,13 @@ Dir::Bin::xz \"/does/not/exist\";" > rootdir/etc/apt/apt.conf.d/00compressor echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor elif [ -e "/usr/bin/${COMPRESSOR}" ]; then echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> rootdir/etc/apt/apt.conf.d/00compressor + elif [ "${COMPRESSOR}" = 'lzma' ]; then + echo "Dir::Bin::xz \"/usr/bin/xz\";" >> rootdir/etc/apt/apt.conf.d/00compressor + COMPRESSOR_CMD='xz --format=lzma' else msgtest "Test for availability of compressor" "${COMPRESSOR}" msgfail - exit 1 + #exit 1 fi } diff --git a/test/integration/test-bug-602412-dequote-redirect b/test/integration/test-bug-602412-dequote-redirect new file mode 100755 index 000000000..f1e67c6d8 --- /dev/null +++ b/test/integration/test-bug-602412-dequote-redirect @@ -0,0 +1,29 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' + +buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable' + +setupaptarchive +changetowebserver -o aptwebserver::redirect::replace::/pool/=/newpool/ \ + -o aptwebserver::redirect::replace::/dists/=/newdists/ + +mv aptarchive/pool aptarchive/newpool +mv aptarchive/dists aptarchive/newdists + +msgtest 'Test redirection works in' 'apt-get update' +aptget update -qq && msgpass || msgfail + +# check that I-M-S header is kept in redirections +testequal 'Hit http://localhost unstable InRelease +Hit http://localhost unstable/main Sources +Hit http://localhost unstable/main amd64 Packages +Hit http://localhost unstable/main Translation-en +Reading package lists...' aptget update + +msgtest 'Test redirection works in' 'package download' +aptget install unrelated --download-only -qq && msgpass || msgfail diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove index 2875d547a..5820fb0dc 100755 --- a/test/integration/test-bug-604222-new-and-autoremove +++ b/test/integration/test-bug-604222-new-and-autoremove @@ -16,7 +16,7 @@ Building dependency tree... Reading state information... The following package was automatically installed and is no longer required: libvtk5.4 -Use 'apt-get autoremove' to remove them. +Use 'apt-get autoremove' to remove it. The following NEW packages will be installed: libavcodec52 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. @@ -28,7 +28,7 @@ Building dependency tree... Reading state information... The following package was automatically installed and is no longer required: libvtk5.4 -Use 'apt-get autoremove' to remove them. +Use 'apt-get autoremove' to remove it. The following extra packages will be installed: libavcodec52 libopenal-dev libvtk5.4 The following NEW packages will be installed: diff --git a/test/integration/test-bug-613420-new-garbage-dependency b/test/integration/test-bug-613420-new-garbage-dependency index 34cf38cbc..7a08871ca 100755 --- a/test/integration/test-bug-613420-new-garbage-dependency +++ b/test/integration/test-bug-613420-new-garbage-dependency @@ -22,7 +22,7 @@ testequal "Reading package lists... Building dependency tree... Reading state information... The following packages were automatically installed and are no longer required: - openoffice.org-officebean libreoffice-officebean + libreoffice-officebean openoffice.org-officebean Use 'apt-get autoremove' to remove them. The following extra packages will be installed: libreoffice-core libreoffice-officebean openoffice.org-officebean diff --git a/test/integration/test-bug-632221-cross-dependency-satisfaction b/test/integration/test-bug-632221-cross-dependency-satisfaction index 30df48604..d90a103c9 100755 --- a/test/integration/test-bug-632221-cross-dependency-satisfaction +++ b/test/integration/test-bug-632221-cross-dependency-satisfaction @@ -18,16 +18,77 @@ insertpackage 'unstable' 'libfwibble-dev' 'amd64,armel' '1.0' 'Depends: libfwibb insertpackage 'unstable' 'cool' 'amd64,armel' '1.0' 'Multi-Arch: allowed' insertpackage 'unstable' 'amdboot' 'amd64' '1.0' 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' +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' +insertsource 'unstable' 'forbidden-foreign' 'any' '1' 'Build-Depends: doxygen:any' + +insertpackage 'unstable' 'specific' 'amd64' '1.0' 'Depends: libc6:amd64' +insertpackage 'unstable' 'specific' 'armel' '1.0' 'Depends: libc6:armel' + +insertsource 'unstable' 'source-specific-amd64' 'amd64' '1' 'Build-Depends: specific:amd64' +insertsource 'unstable' 'source-specific-armel' 'armel' '1' 'Build-Depends: specific:armel' setupaptarchive +testequal "Reading package lists... +Building dependency tree... +E: Build-Depends dependency for forbidden-none can't be satisfied because amdboot:any is not allowed on 'Multi-Arch: none' packages" aptget build-dep forbidden-none -s -a armel +testequal "Reading package lists... +Building dependency tree... +E: Build-Depends dependency for forbidden-same can't be satisfied because libc6:any is not allowed on 'Multi-Arch: same' packages" aptget build-dep forbidden-same -s -a armel +testequal "Reading package lists... +Building dependency tree... +E: Build-Depends dependency for forbidden-foreign can't be satisfied because doxygen:any is not allowed on 'Multi-Arch: foreign' packages" aptget build-dep forbidden-foreign -s -a armel + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libc6 specific +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +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 +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libc6 specific +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +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: + libc6:armel specific:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libc6:armel (1.0 unstable [armel]) +Inst specific:armel (1.0 unstable [armel]) +Conf libc6:armel (1.0 unstable [armel]) +Conf specific:armel (1.0 unstable [armel])' aptget build-dep source-specific-armel -s +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libc6:armel specific:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libc6:armel (1.0 unstable [armel]) +Inst specific:armel (1.0 unstable [armel]) +Conf libc6:armel (1.0 unstable [armel]) +Conf specific:armel (1.0 unstable [armel])' aptget build-dep source-specific-armel -s -a armel + testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: amdboot cool doxygen foreigner libc6 libc6-dev libfwibble-dev libfwibble1 -0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. + linux-stuff +0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Inst amdboot (1.0 unstable [amd64]) Inst cool (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [amd64]) @@ -36,6 +97,7 @@ Inst libc6 (1.0 unstable [amd64]) Inst libc6-dev (1.0 unstable [amd64]) Inst libfwibble1 (1.0 unstable [amd64]) Inst libfwibble-dev (1.0 unstable [amd64]) +Inst linux-stuff (1.0 unstable [amd64]) Conf amdboot (1.0 unstable [amd64]) Conf cool (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [amd64]) @@ -43,15 +105,17 @@ Conf foreigner (1.0 unstable [amd64]) Conf libc6 (1.0 unstable [amd64]) Conf libc6-dev (1.0 unstable [amd64]) Conf libfwibble1 (1.0 unstable [amd64]) -Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s +Conf libfwibble-dev (1.0 unstable [amd64]) +Conf linux-stuff (1.0 unstable [amd64])' aptget build-dep apt -s testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: - amdboot cool doxygen foreigner libc6 libc6:armel libc6-dev libc6-dev:armel - libfwibble-dev:armel libfwibble1:armel -0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. + amdboot arm-stuff:armel cool doxygen foreigner libc6 libc6:armel libc6-dev + libc6-dev:armel libfwibble-dev:armel libfwibble1:armel +0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded. Inst amdboot (1.0 unstable [amd64]) +Inst arm-stuff:armel (1.0 unstable [armel]) Inst cool (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [amd64]) Inst foreigner (1.0 unstable [amd64]) @@ -62,6 +126,7 @@ Inst libc6-dev:armel (1.0 unstable [armel]) Inst libfwibble1:armel (1.0 unstable [armel]) Inst libfwibble-dev:armel (1.0 unstable [armel]) Conf amdboot (1.0 unstable [amd64]) +Conf arm-stuff:armel (1.0 unstable [armel]) Conf cool (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [amd64]) Conf foreigner (1.0 unstable [amd64]) @@ -77,10 +142,11 @@ configarchitecture 'armel' 'amd64' testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: - amdboot:amd64 cool doxygen foreigner libc6 libc6-dev libfwibble-dev - libfwibble1 -0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded. + amdboot:amd64 arm-stuff cool doxygen foreigner libc6 libc6-dev + libfwibble-dev libfwibble1 +0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Inst amdboot:amd64 (1.0 unstable [amd64]) +Inst arm-stuff (1.0 unstable [armel]) Inst cool (1.0 unstable [armel]) Inst doxygen (1.0 unstable [armel]) Inst foreigner (1.0 unstable [armel]) @@ -89,6 +155,7 @@ Inst libc6-dev (1.0 unstable [armel]) Inst libfwibble1 (1.0 unstable [armel]) Inst libfwibble-dev (1.0 unstable [armel]) Conf amdboot:amd64 (1.0 unstable [amd64]) +Conf arm-stuff (1.0 unstable [armel]) Conf cool (1.0 unstable [armel]) Conf doxygen (1.0 unstable [armel]) Conf foreigner (1.0 unstable [armel]) @@ -101,8 +168,8 @@ testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: amdboot:amd64 cool doxygen foreigner libc6:amd64 libc6 libc6-dev:amd64 - libc6-dev libfwibble-dev:amd64 libfwibble1:amd64 -0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. + libc6-dev libfwibble-dev:amd64 libfwibble1:amd64 linux-stuff:amd64 +0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded. Inst amdboot:amd64 (1.0 unstable [amd64]) Inst cool (1.0 unstable [armel]) Inst doxygen (1.0 unstable [armel]) @@ -113,6 +180,7 @@ Inst libc6-dev:amd64 (1.0 unstable [amd64]) Inst libc6-dev (1.0 unstable [armel]) Inst libfwibble1:amd64 (1.0 unstable [amd64]) Inst libfwibble-dev:amd64 (1.0 unstable [amd64]) +Inst linux-stuff:amd64 (1.0 unstable [amd64]) Conf amdboot:amd64 (1.0 unstable [amd64]) Conf cool (1.0 unstable [armel]) Conf doxygen (1.0 unstable [armel]) @@ -122,7 +190,8 @@ Conf libc6 (1.0 unstable [armel]) Conf libc6-dev:amd64 (1.0 unstable [amd64]) Conf libc6-dev (1.0 unstable [armel]) Conf libfwibble1:amd64 (1.0 unstable [amd64]) -Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64 +Conf libfwibble-dev:amd64 (1.0 unstable [amd64]) +Conf linux-stuff:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64 configarchitecture 'amd64' 'armel' @@ -132,28 +201,31 @@ insertinstalledpackage 'foreigner' 'armel' '0.5' testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: - amdboot doxygen libc6 libc6-dev libfwibble-dev libfwibble1 -0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded. + amdboot doxygen libc6 libc6-dev libfwibble-dev libfwibble1 linux-stuff +0 upgraded, 7 newly installed, 0 to remove and 2 not upgraded. Inst amdboot (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [amd64]) Inst libc6 (1.0 unstable [amd64]) Inst libc6-dev (1.0 unstable [amd64]) Inst libfwibble1 (1.0 unstable [amd64]) Inst libfwibble-dev (1.0 unstable [amd64]) +Inst linux-stuff (1.0 unstable [amd64]) Conf amdboot (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [amd64]) Conf libc6 (1.0 unstable [amd64]) Conf libc6-dev (1.0 unstable [amd64]) Conf libfwibble1 (1.0 unstable [amd64]) -Conf libfwibble-dev (1.0 unstable [amd64])' aptget build-dep apt -s +Conf libfwibble-dev (1.0 unstable [amd64]) +Conf linux-stuff (1.0 unstable [amd64])' aptget build-dep apt -s testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: - amdboot doxygen libc6 libc6:armel libc6-dev libc6-dev:armel + amdboot arm-stuff:armel doxygen libc6 libc6:armel libc6-dev libc6-dev:armel libfwibble-dev:armel libfwibble1:armel -0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded. +0 upgraded, 9 newly installed, 0 to remove and 2 not upgraded. Inst amdboot (1.0 unstable [amd64]) +Inst arm-stuff:armel (1.0 unstable [armel]) Inst doxygen (1.0 unstable [amd64]) Inst libc6 (1.0 unstable [amd64]) Inst libc6:armel (1.0 unstable [armel]) @@ -162,6 +234,7 @@ Inst libc6-dev:armel (1.0 unstable [armel]) Inst libfwibble1:armel (1.0 unstable [armel]) Inst libfwibble-dev:armel (1.0 unstable [armel]) Conf amdboot (1.0 unstable [amd64]) +Conf arm-stuff:armel (1.0 unstable [armel]) Conf doxygen (1.0 unstable [amd64]) Conf libc6 (1.0 unstable [amd64]) Conf libc6:armel (1.0 unstable [armel]) @@ -178,10 +251,12 @@ Building dependency tree... The following packages will be REMOVED: cool:amd64 The following NEW packages will be installed: - amdboot:amd64 cool doxygen libc6 libc6-dev libfwibble-dev libfwibble1 -0 upgraded, 7 newly installed, 1 to remove and 1 not upgraded. + amdboot:amd64 arm-stuff cool doxygen libc6 libc6-dev libfwibble-dev + libfwibble1 +0 upgraded, 8 newly installed, 1 to remove and 1 not upgraded. Remv cool:amd64 [0.5] Inst amdboot:amd64 (1.0 unstable [amd64]) +Inst arm-stuff (1.0 unstable [armel]) Inst cool (1.0 unstable [armel]) Inst doxygen (1.0 unstable [armel]) Inst libc6 (1.0 unstable [armel]) @@ -189,6 +264,7 @@ Inst libc6-dev (1.0 unstable [armel]) Inst libfwibble1 (1.0 unstable [armel]) Inst libfwibble-dev (1.0 unstable [armel]) Conf amdboot:amd64 (1.0 unstable [amd64]) +Conf arm-stuff (1.0 unstable [armel]) Conf cool (1.0 unstable [armel]) Conf doxygen (1.0 unstable [armel]) Conf libc6 (1.0 unstable [armel]) @@ -200,8 +276,8 @@ testequal 'Reading package lists... Building dependency tree... The following NEW packages will be installed: amdboot:amd64 doxygen libc6:amd64 libc6 libc6-dev:amd64 libc6-dev - libfwibble-dev:amd64 libfwibble1:amd64 -0 upgraded, 8 newly installed, 0 to remove and 2 not upgraded. + libfwibble-dev:amd64 libfwibble1:amd64 linux-stuff:amd64 +0 upgraded, 9 newly installed, 0 to remove and 2 not upgraded. Inst amdboot:amd64 (1.0 unstable [amd64]) Inst doxygen (1.0 unstable [armel]) Inst libc6:amd64 (1.0 unstable [amd64]) @@ -210,6 +286,7 @@ Inst libc6-dev:amd64 (1.0 unstable [amd64]) Inst libc6-dev (1.0 unstable [armel]) Inst libfwibble1:amd64 (1.0 unstable [amd64]) Inst libfwibble-dev:amd64 (1.0 unstable [amd64]) +Inst linux-stuff:amd64 (1.0 unstable [amd64]) Conf amdboot:amd64 (1.0 unstable [amd64]) Conf doxygen (1.0 unstable [armel]) Conf libc6:amd64 (1.0 unstable [amd64]) @@ -217,6 +294,5 @@ Conf libc6 (1.0 unstable [armel]) Conf libc6-dev:amd64 (1.0 unstable [amd64]) Conf libc6-dev (1.0 unstable [armel]) Conf libfwibble1:amd64 (1.0 unstable [amd64]) -Conf libfwibble-dev:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64 - - +Conf libfwibble-dev:amd64 (1.0 unstable [amd64]) +Conf linux-stuff:amd64 (1.0 unstable [amd64])' aptget build-dep apt -s -a amd64 diff --git a/test/integration/test-bug-673536-pre-depends-breaks-loop b/test/integration/test-bug-673536-pre-depends-breaks-loop new file mode 100755 index 000000000..e9d3c4de6 --- /dev/null +++ b/test/integration/test-bug-673536-pre-depends-breaks-loop @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'native' + +buildsimplenativepackage 'basic' 'native' '1' 'stable' +buildsimplenativepackage 'basic' 'native' '2' 'unstable' 'Pre-Depends: common' +buildsimplenativepackage 'common' 'native' '2' 'unstable' 'Breaks: basic (<= 1)' + +setupaptarchive + +# we check with 'real' packages here as the simulation reports a 'Conf broken' +# which is technical correct for the simulation, but testing errormsg is ugly + +aptget install basic=1 -qq > /dev/null +testdpkginstalled basic +testdpkgnotinstalled common + +aptget dist-upgrade -qq > /dev/null +testdpkginstalled basic common diff --git a/test/integration/test-bug-675449-essential-are-protected b/test/integration/test-bug-675449-essential-are-protected new file mode 100755 index 000000000..7d8cc3484 --- /dev/null +++ b/test/integration/test-bug-675449-essential-are-protected @@ -0,0 +1,88 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +insertinstalledpackage 'pkg-native' 'amd64' '1' 'Multi-Arch: foreign +Essential: yes' +insertinstalledpackage 'pkg-foreign' 'i386' '1' 'Multi-Arch: foreign +Essential: yes' +insertinstalledpackage 'pkg-none-native' 'amd64' '1' 'Essential: yes' +insertinstalledpackage 'pkg-none-foreign' 'i386' '1' 'Essential: yes' + +insertpackage 'unstable' 'pkg-native' 'amd64,i386' '2' 'Multi-Arch: foreign +Essential: yes' +insertpackage 'unstable' 'pkg-foreign' 'amd64,i386' '2' 'Multi-Arch: foreign +Depends: pkg-depends-new +Essential: yes' +insertpackage 'unstable' 'pkg-none-native' 'amd64,i386' '2' 'Essential: yes' +insertpackage 'unstable' 'pkg-none-foreign' 'amd64,i386' '2' 'Essential: yes +Depends: pkg-depends-new' + +insertpackage 'unstable' 'pkg-none-new' 'amd64,i386' '2' 'Essential: yes' +insertpackage 'unstable' 'pkg-depends-new' 'amd64,i386' '2' 'Essential: yes' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + pkg-native* +WARNING: The following essential packages will be removed. +This should NOT be done unless you know exactly what you are doing! + pkg-native +0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded. +Purg pkg-native [1]' aptget purge pkg-native -s + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + pkg-foreign:i386* +WARNING: The following essential packages will be removed. +This should NOT be done unless you know exactly what you are doing! + pkg-foreign:i386 +0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded. +Purg pkg-foreign:i386 [1]' aptget purge pkg-foreign:i386 -s + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + pkg-none-native* +WARNING: The following essential packages will be removed. +This should NOT be done unless you know exactly what you are doing! + pkg-none-native +0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded. +Purg pkg-none-native [1]' aptget purge pkg-none-native -s + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be REMOVED: + pkg-none-foreign:i386* +WARNING: The following essential packages will be removed. +This should NOT be done unless you know exactly what you are doing! + pkg-none-foreign:i386 +0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded. +Purg pkg-none-foreign:i386 [1]' aptget purge pkg-none-foreign:i386 -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + pkg-depends-new:i386 pkg-none-new +The following packages will be upgraded: + pkg-foreign:i386 pkg-native pkg-none-foreign:i386 pkg-none-native +4 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst pkg-depends-new:i386 (2 unstable [i386]) +Conf pkg-depends-new:i386 (2 unstable [i386]) +Inst pkg-foreign:i386 [1] (2 unstable [i386]) +Conf pkg-foreign:i386 (2 unstable [i386]) +Inst pkg-native [1] (2 unstable [amd64]) +Conf pkg-native (2 unstable [amd64]) +Inst pkg-none-foreign:i386 [1] (2 unstable [i386]) +Conf pkg-none-foreign:i386 (2 unstable [i386]) +Inst pkg-none-native [1] (2 unstable [amd64]) +Conf pkg-none-native (2 unstable [amd64]) +Inst pkg-none-new (2 unstable [amd64]) +Conf pkg-none-new (2 unstable [amd64])' aptget dist-upgrade -s 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 new file mode 100755 index 000000000..47abfb5b0 --- /dev/null +++ b/test/integration/test-cachecontainer-architecture-specification @@ -0,0 +1,123 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +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 + +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. +Inst libsame (1 unstable [amd64]) +Conf libsame (1 unstable [amd64])' aptget -s install libsame +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libsame:armel +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +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. +Inst libsame (1 unstable [amd64]) +Conf libsame (1 unstable [amd64])' aptget -s install libsame:amd64 +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libsame libsame:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libsame (1 unstable [amd64]) +Inst libsame:armel (1 unstable [armel]) +Conf libsame (1 unstable [amd64]) +Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:armel libsame:amd64 +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libsame libsame:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libsame (1 unstable [amd64]) +Inst libsame:armel (1 unstable [armel]) +Conf libsame (1 unstable [amd64]) +Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:* +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. +Inst libsame (1 unstable [amd64]) +Conf libsame (1 unstable [amd64])' aptget -s install libsame:any +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libsame libsame:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libsame (1 unstable [amd64]) +Inst libsame:armel (1 unstable [armel]) +Conf libsame (1 unstable [amd64]) +Conf libsame:armel (1 unstable [armel])' aptget -s install libsame:a* +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. +Inst libsame (1 unstable [amd64]) +Conf libsame (1 unstable [amd64])' aptget -s install libsame:linux-any +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + libsame libsame:armel +0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +Inst libsame (1 unstable [amd64]) +Inst libsame:armel (1 unstable [armel]) +Conf libsame (1 unstable [amd64]) +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-loop b/test/integration/test-conflicts-loop index 25f005969..4407fbd9d 100755 --- a/test/integration/test-conflicts-loop +++ b/test/integration/test-conflicts-loop @@ -19,10 +19,10 @@ testequal 'Reading package lists... Building dependency tree... The following packages will be upgraded: openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib -3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. openjdk-6-jre-lib:i386 conflicts with openjdk-6-jre:i386 openjdk-6-jre:i386 conflicts with openjdk-6-jre-headless:i386 openjdk-6-jre-headless:i386 conflicts with openjdk-6-jre:i386 +3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Remv openjdk-6-jre [6b16-1.8-0ubuntu1] openjdk-6-jre-headless:i386 conflicts with openjdk-6-jre-lib:i386 Remv openjdk-6-jre-lib [6b16-1.8-0ubuntu1] 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-disappearing-packages b/test/integration/test-disappearing-packages index 0e0e9618d..d2ac4edc6 100755 --- a/test/integration/test-disappearing-packages +++ b/test/integration/test-disappearing-packages @@ -39,7 +39,7 @@ COMPAREFILE=$(mktemp) echo "The following package disappeared from your system as all files have been overwritten by other packages: old-pkg -Note: This is done automatic and on purpose by dpkg." > $COMPAREFILE +Note: This is done automatically and on purpose by dpkg." > $COMPAREFILE $CMD 2>&1 | tail -n 4 | diff $COMPAREFILE - && msgpass || msgfail rm $COMPAREFILE diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification index 3ac9eccfb..99ea8bffa 100755 --- a/test/integration/test-hashsum-verification +++ b/test/integration/test-hashsum-verification @@ -23,7 +23,7 @@ prepare() { find aptarchive -name 'Release' -delete cat aptarchive/Packages | gzip > aptarchive/Packages.gz cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2 - cat aptarchive/Packages | lzma > aptarchive/Packages.lzma + cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma # create Release file with incorret checksums cat > aptarchive/Release <<EOF Date: Fri, 05 Aug 2011 09:22:08 UTC diff --git a/test/integration/test-ignore-provides-if-versioned-breaks b/test/integration/test-ignore-provides-if-versioned-breaks new file mode 100755 index 000000000..f8b4544a0 --- /dev/null +++ b/test/integration/test-ignore-provides-if-versioned-breaks @@ -0,0 +1,150 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' 'amd64' + +insertpackage 'unstable' 'unrlated' 'all' '1.0' + +insertinstalledpackage 'foo' 'i386' '2.0' +insertpackage 'unstable' 'foo' 'i386' '4.0' +insertpackage 'unstable' 'foo-provider' 'i386' '1.0' 'Provides: foo' +insertpackage 'unstable' 'foo-breaker-3' 'i386' '1.0' 'Breaks: foo (<< 3.0)' +insertpackage 'unstable' 'foo-breaker-2' 'i386' '1.0' 'Breaks: foo (<< 2.0)' +insertpackage 'unstable' 'foo-breaker-none' 'i386' '1.0' 'Breaks: foo' + +insertinstalledpackage 'foo-foreign' 'amd64' '2.0' 'Multi-Arch: foreign' +insertpackage 'unstable' 'foo-foreign' 'amd64' '4.0' 'Multi-Arch: foreign' +insertpackage 'unstable' 'foo-foreign-provider' 'i386' '1.0' 'Provides: foo-foreign' +insertpackage 'unstable' 'foo-foreign-breaker-3' 'i386' '1.0' 'Breaks: foo-foreign (<< 3.0)' +insertpackage 'unstable' 'foo-foreign-breaker-2' 'i386' '1.0' 'Breaks: foo-foreign (<< 2.0)' +insertpackage 'unstable' 'foo-foreign-breaker-none' 'i386' '1.0' 'Breaks: foo-foreign' + +insertinstalledpackage 'foo-same' 'i386,amd64' '2.0' 'Multi-Arch: same' +insertpackage 'unstable' 'foo-same' 'i386,amd64' '4.0' 'Multi-Arch: same' +insertpackage 'unstable' 'foo-same-provider' 'i386' '1.0' 'Provides: foo-same' +insertpackage 'unstable' 'foo-same-breaker-3' 'i386' '1.0' 'Breaks: foo-same (<< 3.0)' +insertpackage 'unstable' 'foo-same-breaker-2' 'i386' '1.0' 'Breaks: foo-same (<< 2.0)' +insertpackage 'unstable' 'foo-same-breaker-none' 'i386' '1.0' 'Breaks: foo-same' + + + +setupaptarchive + +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-breaker-none : Breaks: foo +E: Unable to correct problems, you have held broken packages.' aptget install foo-provider foo-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-breaker-2 foo-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-breaker-2 (1.0 unstable [i386]) +Inst foo-provider (1.0 unstable [i386]) +Conf foo-breaker-2 (1.0 unstable [i386]) +Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following NEW packages will be installed: + foo-breaker-3 foo-provider +The following packages will be upgraded: + foo +1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. +Inst foo [2.0] (4.0 unstable [i386]) +Inst foo-breaker-3 (1.0 unstable [i386]) +Inst foo-provider (1.0 unstable [i386]) +Conf foo (4.0 unstable [i386]) +Conf foo-breaker-3 (1.0 unstable [i386]) +Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-3 -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-foreign-breaker-none : Breaks: foo-foreign +E: Unable to correct problems, you have held broken packages.' aptget install foo-foreign-provider foo-foreign-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-foreign-breaker-2 foo-foreign-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-foreign-breaker-2 (1.0 unstable [i386]) +Inst foo-foreign-provider (1.0 unstable [i386]) +Conf foo-foreign-breaker-2 (1.0 unstable [i386]) +Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo-foreign:amd64 +The following NEW packages will be installed: + foo-foreign-breaker-3 foo-foreign-provider +The following packages will be upgraded: + foo-foreign:amd64 +1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. +Inst foo-foreign:amd64 [2.0] (4.0 unstable [amd64]) +Inst foo-foreign-breaker-3 (1.0 unstable [i386]) +Inst foo-foreign-provider (1.0 unstable [i386]) +Conf foo-foreign:amd64 (4.0 unstable [amd64]) +Conf foo-foreign-breaker-3 (1.0 unstable [i386]) +Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-3 -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-same-breaker-none : Breaks: foo-same +E: Unable to correct problems, you have held broken packages.' aptget install foo-same-provider foo-same-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-same-breaker-2 foo-same-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-same-breaker-2 (1.0 unstable [i386]) +Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same-breaker-2 (1.0 unstable [i386]) +Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo-same:amd64 foo-same +The following NEW packages will be installed: + foo-same-breaker-3 foo-same-provider +The following packages will be upgraded: + foo-same:amd64 foo-same +2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded. +Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ] +Inst foo-same [2.0] (4.0 unstable [i386]) +Conf foo-same:amd64 (4.0 unstable [amd64]) +Conf foo-same (4.0 unstable [i386]) +Inst foo-same-breaker-3 (1.0 unstable [i386]) +Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same-breaker-3 (1.0 unstable [i386]) +Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s diff --git a/test/integration/test-ignore-provides-if-versioned-conflicts b/test/integration/test-ignore-provides-if-versioned-conflicts new file mode 100755 index 000000000..44eafcff1 --- /dev/null +++ b/test/integration/test-ignore-provides-if-versioned-conflicts @@ -0,0 +1,150 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' 'amd64' + +insertpackage 'unstable' 'unrlated' 'all' '1.0' + +insertinstalledpackage 'foo' 'i386' '2.0' +insertpackage 'unstable' 'foo' 'i386' '4.0' +insertpackage 'unstable' 'foo-provider' 'i386' '1.0' 'Provides: foo' +insertpackage 'unstable' 'foo-breaker-3' 'i386' '1.0' 'Conflicts: foo (<< 3.0)' +insertpackage 'unstable' 'foo-breaker-2' 'i386' '1.0' 'Conflicts: foo (<< 2.0)' +insertpackage 'unstable' 'foo-breaker-none' 'i386' '1.0' 'Conflicts: foo' + +insertinstalledpackage 'foo-foreign' 'amd64' '2.0' 'Multi-Arch: foreign' +insertpackage 'unstable' 'foo-foreign' 'amd64' '4.0' 'Multi-Arch: foreign' +insertpackage 'unstable' 'foo-foreign-provider' 'i386' '1.0' 'Provides: foo-foreign' +insertpackage 'unstable' 'foo-foreign-breaker-3' 'i386' '1.0' 'Conflicts: foo-foreign (<< 3.0)' +insertpackage 'unstable' 'foo-foreign-breaker-2' 'i386' '1.0' 'Conflicts: foo-foreign (<< 2.0)' +insertpackage 'unstable' 'foo-foreign-breaker-none' 'i386' '1.0' 'Conflicts: foo-foreign' + +insertinstalledpackage 'foo-same' 'i386,amd64' '2.0' 'Multi-Arch: same' +insertpackage 'unstable' 'foo-same' 'i386,amd64' '4.0' 'Multi-Arch: same' +insertpackage 'unstable' 'foo-same-provider' 'i386' '1.0' 'Provides: foo-same' +insertpackage 'unstable' 'foo-same-breaker-3' 'i386' '1.0' 'Conflicts: foo-same (<< 3.0)' +insertpackage 'unstable' 'foo-same-breaker-2' 'i386' '1.0' 'Conflicts: foo-same (<< 2.0)' +insertpackage 'unstable' 'foo-same-breaker-none' 'i386' '1.0' 'Conflicts: foo-same' + + + +setupaptarchive + +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-breaker-none : Conflicts: foo +E: Unable to correct problems, you have held broken packages.' aptget install foo-provider foo-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-breaker-2 foo-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-breaker-2 (1.0 unstable [i386]) +Inst foo-provider (1.0 unstable [i386]) +Conf foo-breaker-2 (1.0 unstable [i386]) +Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo +The following NEW packages will be installed: + foo-breaker-3 foo-provider +The following packages will be upgraded: + foo +1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. +Inst foo [2.0] (4.0 unstable [i386]) +Inst foo-breaker-3 (1.0 unstable [i386]) +Inst foo-provider (1.0 unstable [i386]) +Conf foo (4.0 unstable [i386]) +Conf foo-breaker-3 (1.0 unstable [i386]) +Conf foo-provider (1.0 unstable [i386])' aptget install foo-provider foo-breaker-3 -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-foreign-breaker-none : Conflicts: foo-foreign +E: Unable to correct problems, you have held broken packages.' aptget install foo-foreign-provider foo-foreign-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-foreign-breaker-2 foo-foreign-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-foreign-breaker-2 (1.0 unstable [i386]) +Inst foo-foreign-provider (1.0 unstable [i386]) +Conf foo-foreign-breaker-2 (1.0 unstable [i386]) +Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo-foreign:amd64 +The following NEW packages will be installed: + foo-foreign-breaker-3 foo-foreign-provider +The following packages will be upgraded: + foo-foreign:amd64 +1 upgraded, 2 newly installed, 0 to remove and 3 not upgraded. +Inst foo-foreign:amd64 [2.0] (4.0 unstable [amd64]) +Inst foo-foreign-breaker-3 (1.0 unstable [i386]) +Inst foo-foreign-provider (1.0 unstable [i386]) +Conf foo-foreign:amd64 (4.0 unstable [amd64]) +Conf foo-foreign-breaker-3 (1.0 unstable [i386]) +Conf foo-foreign-provider (1.0 unstable [i386])' aptget install foo-foreign-provider foo-foreign-breaker-3 -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-same-breaker-none : Conflicts: foo-same +E: Unable to correct problems, you have held broken packages.' aptget install foo-same-provider foo-same-breaker-none -s + +testequal 'Reading package lists... +Building dependency tree... +The following NEW packages will be installed: + foo-same-breaker-2 foo-same-provider +0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. +Inst foo-same-breaker-2 (1.0 unstable [i386]) +Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same-breaker-2 (1.0 unstable [i386]) +Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-2 -s + +testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + foo-same:amd64 foo-same +The following NEW packages will be installed: + foo-same-breaker-3 foo-same-provider +The following packages will be upgraded: + foo-same:amd64 foo-same +2 upgraded, 2 newly installed, 0 to remove and 2 not upgraded. +Inst foo-same:amd64 [2.0] (4.0 unstable [amd64]) [foo-same:amd64 on foo-same:i386] [foo-same:i386 on foo-same:amd64] [foo-same:i386 ] +Inst foo-same [2.0] (4.0 unstable [i386]) +Conf foo-same:amd64 (4.0 unstable [amd64]) +Conf foo-same (4.0 unstable [i386]) +Inst foo-same-breaker-3 (1.0 unstable [i386]) +Inst foo-same-provider (1.0 unstable [i386]) +Conf foo-same-breaker-3 (1.0 unstable [i386]) +Conf foo-same-provider (1.0 unstable [i386])' aptget install foo-same-provider foo-same-breaker-3 -s diff --git a/test/integration/test-pdiff-usage b/test/integration/test-pdiff-usage index 0a8293018..29301d07d 100755 --- a/test/integration/test-pdiff-usage +++ b/test/integration/test-pdiff-usage @@ -21,7 +21,7 @@ testequal "$(cat ${PKGFILE}) cp ${PKGFILE}-new aptarchive/Packages cat aptarchive/Packages | gzip > aptarchive/Packages.gz cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2 -cat aptarchive/Packages | lzma > aptarchive/Packages.lzma +cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma rm -rf aptarchive/Packages.diff mkdir -p aptarchive/Packages.diff PATCHFILE="aptarchive/Packages.diff/$(date +%Y-%m-%d-%H%M.%S)" diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index 4f65cfa3b..d3ea91de5 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -24,7 +24,7 @@ prepare() { find aptarchive -name 'Release' -delete cat aptarchive/Packages | gzip > aptarchive/Packages.gz cat aptarchive/Packages | bzip2 > aptarchive/Packages.bz2 - cat aptarchive/Packages | lzma > aptarchive/Packages.lzma + cat aptarchive/Packages | xz --format=lzma > aptarchive/Packages.lzma generatereleasefiles "$DATE" } 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-ubuntu-bug-346386-apt-get-update-paywall b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall new file mode 100755 index 000000000..25cccf067 --- /dev/null +++ b/test/integration/test-ubuntu-bug-346386-apt-get-update-paywall @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +ensure_n_canary_strings_in_dir() { + DIR=$1 + CANARY_STRING=$2 + EXPECTED_N=$3 + + msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in" "$DIR" + + N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l ) + if [ "$N" = "$EXPECTED_N" ]; then + msgpass + return 0 + else + msgfail "Expected $EXPECTED_N canaries, got $N" + return 1 + fi +} + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture 'native' + +insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable' + +setupaptarchive +changetowebserver --simulate-paywall + +rm -rf rootdir/var/lib/apt/lists +msgtest 'excpected failure of' 'apt-get update' +aptget update -qq 2>/dev/null && msgfail || msgpass + +ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'ni ni ni' 0 +testequal 'partial' ls rootdir/var/lib/apt/lists/ + +# again, this time with pre-existing files valid data +for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do + echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f} +done + +# this will fail, the important part is that the canaries remain +msgtest 'excpected failure of' 'apt-get update' +aptget update -qq 2>/dev/null && msgfail || msgpass +ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'canary' 4 diff --git a/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first index a9a4069cf..269038d0f 100755 --- a/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first +++ b/test/integration/test-ubuntu-bug-835625-multiarch-lockstep-installed-first @@ -14,7 +14,7 @@ insertpackage 'unstable' 'apt' 'i386' '2' 'Depends: libsame (= 2)' setupaptarchive -testequal 'Reading package lists... +testequalor2 'Reading package lists... Building dependency tree... The following extra packages will be installed: apt:i386 libsame:i386 @@ -28,4 +28,18 @@ Inst libsame (2 unstable [amd64]) [apt:i386 ] Conf libsame:i386 (2 unstable [i386]) [apt:i386 ] Conf libsame (2 unstable [amd64]) [apt:i386 ] Inst apt:i386 [1] (2 unstable [i386]) +Conf apt:i386 (2 unstable [i386])' 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + apt:i386 libsame:i386 +The following NEW packages will be installed: + libsame +The following packages will be upgraded: + apt:i386 libsame:i386 +2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +Inst apt:i386 [1] (2 unstable [i386]) [] +Inst libsame:i386 [1] (2 unstable [i386]) +Inst libsame (2 unstable [amd64]) +Conf libsame:i386 (2 unstable [i386]) +Conf libsame (2 unstable [amd64]) Conf apt:i386 (2 unstable [i386])' aptget install libsame:amd64 -s diff --git a/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering b/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering new file mode 100755 index 000000000..462acad00 --- /dev/null +++ b/test/integration/test-ubuntu-bug-985852-pre-depends-or-group-ordering @@ -0,0 +1,21 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' + +insertinstalledpackage 'custom' 'amd64' '1.0' 'Pre-Depends: grub-pc | grub' +insertinstalledpackage 'grub' 'amd64' '1.0' +insertpackage 'unstable' 'custom' 'amd64' '2.0' 'Pre-Depends: grub-pc | grub' + +setupaptarchive + +testequal 'Reading package lists... +Building dependency tree... +The following packages will be upgraded: + custom +1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. +Inst custom [1.0] (2.0 unstable [amd64]) +Conf custom (2.0 unstable [amd64])' aptget dist-upgrade -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/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc new file mode 100644 index 000000000..ff60d64a3 --- /dev/null +++ b/test/interactive-helper/aptwebserver.cc @@ -0,0 +1,513 @@ +#include <config.h> + +#include <apt-pkg/strutl.h> +#include <apt-pkg/fileutl.h> +#include <apt-pkg/error.h> +#include <apt-pkg/cmndline.h> +#include <apt-pkg/configuration.h> +#include <apt-pkg/init.h> + +#include <vector> +#include <string> +#include <list> +#include <sstream> + +#include <sys/socket.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <netinet/in.h> +#include <unistd.h> +#include <errno.h> +#include <time.h> +#include <stdlib.h> +#include <dirent.h> +#include <signal.h> + +char const * const httpcodeToStr(int const httpcode) { /*{{{*/ + switch (httpcode) { + // Informational 1xx + case 100: return "100 Continue"; + case 101: return "101 Switching Protocols"; + // Successful 2xx + case 200: return "200 OK"; + case 201: return "201 Created"; + case 202: return "202 Accepted"; + case 203: return "203 Non-Authoritative Information"; + case 204: return "204 No Content"; + case 205: return "205 Reset Content"; + case 206: return "206 Partial Content"; + // Redirections 3xx + case 300: return "300 Multiple Choices"; + case 301: return "301 Moved Permanently"; + case 302: return "302 Found"; + case 303: return "303 See Other"; + case 304: return "304 Not Modified"; + case 305: return "304 Use Proxy"; + case 307: return "307 Temporary Redirect"; + // Client errors 4xx + case 400: return "400 Bad Request"; + case 401: return "401 Unauthorized"; + case 402: return "402 Payment Required"; + case 403: return "403 Forbidden"; + case 404: return "404 Not Found"; + case 405: return "405 Method Not Allowed"; + case 406: return "406 Not Acceptable"; + case 407: return "407 Proxy Authentication Required"; + case 408: return "408 Request Time-out"; + case 409: return "409 Conflict"; + case 410: return "410 Gone"; + case 411: return "411 Length Required"; + case 412: return "412 Precondition Failed"; + case 413: return "413 Request Entity Too Large"; + case 414: return "414 Request-URI Too Large"; + case 415: return "415 Unsupported Media Type"; + case 416: return "416 Requested range not satisfiable"; + case 417: return "417 Expectation Failed"; + // Server error 5xx + case 500: return "500 Internal Server Error"; + case 501: return "501 Not Implemented"; + case 502: return "502 Bad Gateway"; + case 503: return "503 Service Unavailable"; + case 504: return "504 Gateway Time-out"; + case 505: return "505 HTTP Version not supported"; + } + return NULL; +} + /*}}}*/ +void addFileHeaders(std::list<std::string> &headers, FileFd &data) { /*{{{*/ + std::ostringstream contentlength; + contentlength << "Content-Length: " << data.FileSize(); + headers.push_back(contentlength.str()); + + std::string lastmodified("Last-Modified: "); + lastmodified.append(TimeRFC1123(data.ModificationTime())); + headers.push_back(lastmodified); + + std::string const fileext = flExtension(data.Name()); + if (fileext.empty() == false && fileext != data.Name()) { + std::string confcontenttype("aptwebserver::ContentType::"); + confcontenttype.append(fileext); + std::string const contenttype = _config->Find(confcontenttype); + if (contenttype.empty() == false) { + std::string header("Content-Type: "); + header.append(contenttype); + headers.push_back(header); + } + } +} + /*}}}*/ +void addDataHeaders(std::list<std::string> &headers, std::string &data) {/*{{{*/ + std::ostringstream contentlength; + contentlength << "Content-Length: " << data.size(); + headers.push_back(contentlength.str()); +} + /*}}}*/ +bool sendHead(int const client, int const httpcode, std::list<std::string> &headers) { /*{{{*/ + std::string response("HTTP/1.1 "); + response.append(httpcodeToStr(httpcode)); + headers.push_front(response); + + headers.push_back("Server: APT webserver"); + + std::string date("Date: "); + date.append(TimeRFC1123(time(NULL))); + headers.push_back(date); + + headers.push_back("Accept-Ranges: bytes"); + + std::clog << ">>> RESPONSE >>>" << std::endl; + bool Success = true; + for (std::list<std::string>::const_iterator h = headers.begin(); + Success == true && h != headers.end(); ++h) { + Success &= FileFd::Write(client, h->c_str(), h->size()); + if (Success == true) + Success &= FileFd::Write(client, "\r\n", 2); + std::clog << *h << std::endl; + } + if (Success == true) + Success &= FileFd::Write(client, "\r\n", 2); + std::clog << "<<<<<<<<<<<<<<<<" << std::endl; + return Success; +} + /*}}}*/ +bool sendFile(int const client, FileFd &data) { /*{{{*/ + bool Success = true; + char buffer[500]; + unsigned long long actual = 0; + while ((Success &= data.Read(buffer, sizeof(buffer), &actual)) == true) { + if (actual == 0) + break; + if (Success == true) + Success &= FileFd::Write(client, buffer, actual); + } + if (Success == true) + Success &= FileFd::Write(client, "\r\n", 2); + return Success; +} + /*}}}*/ +bool sendData(int const client, std::string const &data) { /*{{{*/ + bool Success = true; + Success &= FileFd::Write(client, data.c_str(), data.size()); + if (Success == true) + Success &= FileFd::Write(client, "\r\n", 2); + return Success; +} + /*}}}*/ +void sendError(int const client, int const httpcode, std::string const &request, bool content, std::string const &error = "") { /*{{{*/ + std::list<std::string> headers; + std::string response("<html><head><title>"); + response.append(httpcodeToStr(httpcode)).append("</title></head>"); + response.append("<body><h1>").append(httpcodeToStr(httpcode)).append("</h1>"); + if (error.empty() == false) + response.append("<p><em>Error</em>: ").append(error).append("</p>"); + response.append("This error is a result of the request: <pre>"); + response.append(request).append("</pre></body></html>"); + addDataHeaders(headers, response); + sendHead(client, httpcode, headers); + if (content == true) + sendData(client, response); +} + /*}}}*/ +void sendRedirect(int const client, int const httpcode, std::string const &uri, std::string const &request, bool content) { /*{{{*/ + std::list<std::string> headers; + std::string response("<html><head><title>"); + response.append(httpcodeToStr(httpcode)).append("</title></head>"); + response.append("<body><h1>").append(httpcodeToStr(httpcode)).append("</h1"); + response.append("<p>You should be redirected to <em>").append(uri).append("</em></p>"); + response.append("This page is a result of the request: <pre>"); + response.append(request).append("</pre></body></html>"); + addDataHeaders(headers, response); + std::string location("Location: "); + if (strncmp(uri.c_str(), "http://", 7) != 0) + location.append("http://").append(LookupTag(request, "Host")).append("/").append(uri); + else + location.append(uri); + headers.push_back(location); + sendHead(client, httpcode, headers); + if (content == true) + sendData(client, response); +} + /*}}}*/ +// sendDirectoryLisiting /*{{{*/ +int filter_hidden_files(const struct dirent *a) { + if (a->d_name[0] == '.') + return 0; +#ifdef _DIRENT_HAVE_D_TYPE + // if we have the d_type check that only files and dirs will be included + if (a->d_type != DT_UNKNOWN && + a->d_type != DT_REG && + a->d_type != DT_LNK && // this includes links to regular files + a->d_type != DT_DIR) + return 0; +#endif + return 1; +} +int grouped_alpha_case_sort(const struct dirent **a, const struct dirent **b) { +#ifdef _DIRENT_HAVE_D_TYPE + if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_DIR); + else if ((*a)->d_type == DT_DIR && (*b)->d_type == DT_REG) + return -1; + else if ((*b)->d_type == DT_DIR && (*a)->d_type == DT_REG) + return 1; + else +#endif + { + struct stat f_prop; //File's property + stat((*a)->d_name, &f_prop); + int const amode = f_prop.st_mode; + stat((*b)->d_name, &f_prop); + int const bmode = f_prop.st_mode; + if (S_ISDIR(amode) && S_ISDIR(bmode)); + else if (S_ISDIR(amode)) + return -1; + else if (S_ISDIR(bmode)) + return 1; + } + return strcasecmp((*a)->d_name, (*b)->d_name); +} +void sendDirectoryListing(int const client, std::string const &dir, std::string const &request, bool content) { + std::list<std::string> headers; + std::ostringstream listing; + + struct dirent **namelist; + int const counter = scandir(dir.c_str(), &namelist, filter_hidden_files, grouped_alpha_case_sort); + if (counter == -1) { + sendError(client, 500, request, content); + return; + } + + listing << "<html><head><title>Index of " << dir << "</title>" + << "<style type=\"text/css\"><!-- td {padding: 0.02em 0.5em 0.02em 0.5em;}" + << "tr:nth-child(even){background-color:#dfdfdf;}" + << "h1, td:nth-child(3){text-align:center;}" + << "table {margin-left:auto;margin-right:auto;} --></style>" + << "</head>" << std::endl + << "<body><h1>Index of " << dir << "</h1>" << std::endl + << "<table><tr><th>#</th><th>Name</th><th>Size</th><th>Last-Modified</th></tr>" << std::endl; + if (dir != ".") + listing << "<tr><td>d</td><td><a href=\"..\">Parent Directory</a></td><td>-</td><td>-</td></tr>"; + for (int i = 0; i < counter; ++i) { + struct stat fs; + std::string filename(dir); + filename.append("/").append(namelist[i]->d_name); + stat(filename.c_str(), &fs); + if (S_ISDIR(fs.st_mode)) { + listing << "<tr><td>d</td>" + << "<td><a href=\"" << namelist[i]->d_name << "/\">" << namelist[i]->d_name << "</a></td>" + << "<td>-</td>"; + } else { + listing << "<tr><td>f</td>" + << "<td><a href=\"" << namelist[i]->d_name << "\">" << namelist[i]->d_name << "</a></td>" + << "<td>" << SizeToStr(fs.st_size) << "B</td>"; + } + listing << "<td>" << TimeRFC1123(fs.st_mtime) << "</td></tr>" << std::endl; + } + listing << "</table></body></html>" << std::endl; + + std::string response(listing.str()); + addDataHeaders(headers, response); + sendHead(client, 200, headers); + if (content == true) + sendData(client, response); +} + /*}}}*/ +bool parseFirstLine(int const client, std::string const &request, std::string &filename, bool &sendContent, bool &closeConnection) { /*{{{*/ + if (strncmp(request.c_str(), "HEAD ", 5) == 0) + sendContent = false; + if (strncmp(request.c_str(), "GET ", 4) != 0) + { + sendError(client, 501, request, true); + return false; + } + + size_t const lineend = request.find('\n'); + size_t filestart = request.find(' '); + for (; request[filestart] == ' '; ++filestart); + size_t fileend = request.rfind(' ', lineend); + if (lineend == std::string::npos || filestart == std::string::npos || + fileend == std::string::npos || filestart == fileend) { + sendError(client, 500, request, sendContent, "Filename can't be extracted"); + return false; + } + + size_t httpstart = fileend; + for (; request[httpstart] == ' '; ++httpstart); + if (strncmp(request.c_str() + httpstart, "HTTP/1.1\r", 9) == 0) + closeConnection = strcasecmp(LookupTag(request, "Connection", "Keep-Alive").c_str(), "Keep-Alive") != 0; + else if (strncmp(request.c_str() + httpstart, "HTTP/1.0\r", 9) == 0) + closeConnection = strcasecmp(LookupTag(request, "Connection", "Keep-Alive").c_str(), "close") == 0; + else { + sendError(client, 500, request, sendContent, "Not an HTTP/1.{0,1} request"); + return false; + } + + filename = request.substr(filestart, fileend - filestart); + if (filename.find(' ') != std::string::npos) { + sendError(client, 500, request, sendContent, "Filename contains an unencoded space"); + return false; + } + filename = DeQuoteString(filename); + + // this is not a secure server, but at least prevent the obvious … + if (filename.empty() == true || filename[0] != '/' || + strncmp(filename.c_str(), "//", 2) == 0 || + filename.find_first_of("\r\n\t\f\v") != std::string::npos || + filename.find("/../") != std::string::npos) { + sendError(client, 400, request, sendContent, "Filename contains illegal character (sequence)"); + return false; + } + + // nuke the first character which is a / as we assured above + filename.erase(0, 1); + if (filename.empty() == true) + filename = "."; + return true; +} + /*}}}*/ +int main(int const argc, const char * argv[]) +{ + CommandLine::Args Args[] = { + {0, "simulate-paywall", "aptwebserver::Simulate-Paywall", + CommandLine::Boolean}, + {0, "port", "aptwebserver::port", CommandLine::HasArg}, + {'c',"config-file",0,CommandLine::ConfigFile}, + {'o',"option",0,CommandLine::ArbItem}, + {0,0,0,0} + }; + + CommandLine CmdL(Args, _config); + if(CmdL.Parse(argc,argv) == false) { + _error->DumpErrors(); + exit(1); + } + + // create socket, bind and listen to it {{{ + // ignore SIGPIPE, this can happen on write() if the socket closes connection + signal(SIGPIPE, SIG_IGN); + int sock = socket(AF_INET6, SOCK_STREAM, 0); + if(sock < 0 ) { + _error->Errno("aptwerbserver", "Couldn't create socket"); + _error->DumpErrors(std::cerr); + return 1; + } + + // get the port + int const port = _config->FindI("aptwebserver::port", 8080); + bool const simulate_broken_server = _config->FindB("aptwebserver::Simulate-Paywall", false); + + // ensure that we accept all connections: v4 or v6 + int const iponly = 0; + setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &iponly, sizeof(iponly)); + // to not linger to an address + int const enable = 1; + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); + + struct sockaddr_in6 locAddr; + memset(&locAddr, 0, sizeof(locAddr)); + locAddr.sin6_family = AF_INET6; + locAddr.sin6_port = htons(port); + locAddr.sin6_addr = in6addr_any; + + if (bind(sock, (struct sockaddr*) &locAddr, sizeof(locAddr)) < 0) { + _error->Errno("aptwerbserver", "Couldn't bind"); + _error->DumpErrors(std::cerr); + return 2; + } + + if (simulate_broken_server) { + std::clog << "Simulating a broken web server that return nonsense " + "for all querries" << std::endl; + } else { + std::clog << "Serving ANY file on port: " << port << std::endl; + } + + listen(sock, 1); + /*}}}*/ + + std::vector<std::string> messages; + int client; + while ((client = accept(sock, NULL, NULL)) != -1) { + std::clog << "ACCEPT client " << client + << " on socket " << sock << std::endl; + + while (ReadMessages(client, messages)) { + bool closeConnection = false; + for (std::vector<std::string>::const_iterator m = messages.begin(); + m != messages.end() && closeConnection == false; ++m) { + std::clog << ">>> REQUEST >>>>" << std::endl << *m + << std::endl << "<<<<<<<<<<<<<<<<" << std::endl; + std::list<std::string> headers; + std::string filename; + bool sendContent = true; + if (parseFirstLine(client, *m, filename, sendContent, closeConnection) == false) + continue; + + std::string host = LookupTag(*m, "Host", ""); + if (host.empty() == true) { + // RFC 2616 §14.23 requires Host + sendError(client, 400, *m, sendContent, "Host header is required"); + continue; + } + + if (simulate_broken_server == true) { + std::string data("ni ni ni\n"); + addDataHeaders(headers, data); + sendHead(client, 200, headers); + sendData(client, data); + } + else if (RealFileExists(filename) == true) { + FileFd data(filename, FileFd::ReadOnly); + std::string condition = LookupTag(*m, "If-Modified-Since", ""); + if (condition.empty() == false) { + time_t cache; + if (RFC1123StrToTime(condition.c_str(), cache) == true && + cache >= data.ModificationTime()) { + sendHead(client, 304, headers); + continue; + } + } + condition = LookupTag(*m, "If-Range", ""); + bool ignoreRange = false; + if (condition.empty() == false) { + time_t cache; + if (RFC1123StrToTime(condition.c_str(), cache) == false || + cache < data.ModificationTime()) + ignoreRange = true; + } + condition = LookupTag(*m, "Range", ""); + if (ignoreRange == false && condition.empty() == false && + strncmp(condition.c_str(), "bytes=", 6) == 0) { + size_t end = condition.find(','); + // FIXME: support multiple byte-ranges + if (end == std::string::npos) { + size_t start = 6; + unsigned long long filestart = strtoull(condition.c_str() + start, NULL, 10); + // FIXME: no fileend support + size_t dash = condition.find('-') + 1; + unsigned long long fileend = strtoull(condition.c_str() + dash, NULL, 10); + unsigned long long filesize = data.FileSize(); + if (fileend == 0 || fileend == filesize) { + if (filesize > filestart) { + data.Skip(filestart); + std::ostringstream contentlength; + contentlength << "Content-Length: " << (filesize - filestart); + headers.push_back(contentlength.str()); + std::ostringstream contentrange; + contentrange << "Content-Range: bytes " << filestart << "-" + << filesize - 1 << "/" << filesize; + headers.push_back(contentrange.str()); + sendHead(client, 206, headers); + if (sendContent == true) + sendFile(client, data); + continue; + } else { + headers.push_back("Content-Length: 0"); + std::ostringstream contentrange; + contentrange << "Content-Range: bytes 0-0/" << filesize; + headers.push_back(contentrange.str()); + sendHead(client, 416, headers); + continue; + } + } + } + } + + addFileHeaders(headers, data); + sendHead(client, 200, headers); + if (sendContent == true) + sendFile(client, data); + } + else if (DirectoryExists(filename) == true) { + if (filename == "." || filename[filename.length()-1] == '/') + sendDirectoryListing(client, filename, *m, sendContent); + else + sendRedirect(client, 301, filename.append("/"), *m, sendContent); + } + else + { + ::Configuration::Item const *Replaces = _config->Tree("aptwebserver::redirect::replace"); + if (Replaces != NULL) { + std::string redirect = "/" + filename; + for (::Configuration::Item *I = Replaces->Child; I != NULL; I = I->Next) + redirect = SubstVar(redirect, I->Tag, I->Value); + redirect.erase(0,1); + if (redirect != filename) { + sendRedirect(client, 301, redirect, *m, sendContent); + continue; + } + } + sendError(client, 404, *m, sendContent); + } + } + _error->DumpErrors(std::cerr); + messages.clear(); + if (closeConnection == true) + break; + } + + std::clog << "CLOSE client " << client + << " on socket " << sock << std::endl; + close(client); + } + return 0; +} diff --git a/test/interactive-helper/extract-control.cc b/test/interactive-helper/extract-control.cc index a1b3600aa..3f7feabcb 100644 --- a/test/interactive-helper/extract-control.cc +++ b/test/interactive-helper/extract-control.cc @@ -21,8 +21,7 @@ bool ExtractMember(const char *File,const char *Member) if (Extract.Control == 0) return true; - write(STDOUT_FILENO,Extract.Control,Extract.Length); - return true; + return write(STDOUT_FILENO,Extract.Control,Extract.Length) != -1; } int main(int argc, const char *argv[]) diff --git a/test/interactive-helper/makefile b/test/interactive-helper/makefile index b96139fda..fee94cd77 100644 --- a/test/interactive-helper/makefile +++ b/test/interactive-helper/makefile @@ -11,28 +11,24 @@ SLIBS = SOURCE = mthdcat.cc include $(PROGRAM_H) -# Version compare tester -PROGRAM=testextract -SLIBS = -lapt-pkg -lapt-inst -LIB_MAKES = apt-pkg/makefile apt-inst/makefile -SOURCE = testextract.cc -include $(PROGRAM_H) - # Program for testing the tar/deb extractor PROGRAM=testdeb SLIBS = -lapt-pkg -lapt-inst +LIB_MAKES = apt-pkg/makefile apt-inst/makefile SOURCE = testdeb.cc include $(PROGRAM_H) # Program for testing tar extraction PROGRAM=extract-control SLIBS = -lapt-pkg -lapt-inst +LIB_MAKES = apt-pkg/makefile apt-inst/makefile SOURCE = extract-control.cc include $(PROGRAM_H) # Program for testing udevcdrom PROGRAM=test_udevcdrom -SLIBS = -lapt-pkg +SLIBS = -lapt-pkg +LIB_MAKES = apt-pkg/makefile SOURCE = test_udevcdrom.cc include $(PROGRAM_H) @@ -41,3 +37,10 @@ include $(PROGRAM_H) #SLIBS = -lapt-pkg -lrpm #SOURCE = rpmver.cc #include $(PROGRAM_H) + +# very simple webserver for APT testing +PROGRAM=aptwebserver +SLIBS = -lapt-pkg +LIB_MAKES = apt-pkg/makefile +SOURCE = aptwebserver.cc +include $(PROGRAM_H) diff --git a/test/interactive-helper/testextract.cc b/test/interactive-helper/testextract.cc deleted file mode 100644 index f7ddb72f0..000000000 --- a/test/interactive-helper/testextract.cc +++ /dev/null @@ -1,103 +0,0 @@ -#include <apt-pkg/dpkgdb.h> -#include <apt-pkg/debfile.h> -#include <apt-pkg/error.h> -#include <apt-pkg/configuration.h> -#include <apt-pkg/progress.h> -#include <apt-pkg/extract.h> -#include <apt-pkg/init.h> -#include <apt-pkg/strutl.h> -#include <apt-pkg/fileutl.h> -#include <apt-pkg/pkgsystem.h> - -#include <stdio.h> -#include <stdlib.h> - -using namespace std; - -bool Go(int argc,char *argv[]) -{ - // Init the database - debDpkgDB Db; - { - OpTextProgress Prog; - - if (Db.ReadyPkgCache(Prog) == false) - return false; - Prog.Done(); - - if (Db.ReadyFileList(Prog) == false) - return false; - } - - for (int I = 1; I < argc; I++) - { - const char *Fake = 0; - for (unsigned J = 0; argv[I][J] != 0; J++) - { - if (argv[I][J] != ',') - continue; - Fake = argv[I] + J + 1; - argv[I][J] = 0; - } - - FileFd F(argv[I],FileFd::ReadOnly); - debDebFile Deb(F); - - if (_error->PendingError() == true) - return false; - - if (Deb.ExtractControl(Db) == false) - return false; - cout << argv[I] << endl; - - pkgCache::VerIterator Ver = Deb.MergeControl(Db); - if (Ver.end() == true) - return false; - - cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl; - - pkgExtract Extract(Db.GetFLCache(),Ver); - - if (Fake != 0) - { - pkgExtract::Item Itm; - memset(&Itm,0,sizeof(Itm)); - FILE *F = fopen(Fake,"r"); - while (feof(F) == 0) - { - char Line[300]; - fgets(Line,sizeof(Line),F); - Itm.Name = _strstrip(Line); - Itm.Type = pkgDirStream::Item::File; - if (Line[strlen(Line)-1] == '/') - Itm.Type = pkgDirStream::Item::Directory; - - int Fd; - if (Extract.DoItem(Itm,Fd) == false) { - fclose(F); - return false; - } - } - fclose(F); - } - else - if (Deb.ExtractArchive(Extract) == false) - return false; - } - return true; -} - -int main(int argc,char *argv[]) -{ - pkgInitConfig(*_config); - pkgInitSystem(*_config,_system); - _config->Set("Dir::State::status","/tmp/testing/status"); - - Go(argc,argv); - - if (_error->PendingError() == true) - { - _error->DumpErrors(); - return 0; - } -} diff --git a/test/libapt/assert.h b/test/libapt/assert.h index a07be4b57..fdf6740c6 100644 --- a/test/libapt/assert.h +++ b/test/libapt/assert.h @@ -1,6 +1,7 @@ #include <iostream> #define equals(x,y) assertEquals(y, x, __LINE__) +#define equalsNot(x,y) assertEqualsNot(y, x, __LINE__) template < typename X, typename Y > void OutputAssertEqual(X expect, char const* compare, Y get, unsigned long const &line) { @@ -14,6 +15,13 @@ void assertEquals(X expect, Y get, unsigned long const &line) { OutputAssertEqual(expect, "==", get, line); } +template < typename X, typename Y > +void assertEqualsNot(X expect, Y get, unsigned long const &line) { + if (expect != get) + return; + OutputAssertEqual(expect, "!=", get, line); +} + void assertEquals(unsigned int const &expect, int const &get, unsigned long const &line) { if (get < 0) OutputAssertEqual(expect, "==", get, line); @@ -80,6 +88,19 @@ void assertEqualsOr3(X expect1, X expect2, X expect3, Y get, unsigned long const OutputAssertEqualOr3(expect1, expect2, expect3, "==", get, line); } +#define equalsOr4(v,w,x,y,z) assertEqualsOr4(w, x, y, z, v, __LINE__) + +template < typename X, typename Y > +void OutputAssertEqualOr4(X expect1, X expect2, X expect3, X expect4, char const* compare, Y get, unsigned long const &line) { + std::cerr << "Test FAILED: »" << expect1 << "« or »" << expect2 << "« or »" << expect3 << "« or »" << expect4 << "« " << compare << " »" << get << "« at line " << line << std::endl; +} + +template < typename X, typename Y > +void assertEqualsOr4(X expect1, X expect2, X expect3, X expect4, Y get, unsigned long const &line) { + if (expect1 == get || expect2 == get || expect3 == get || expect4 == get) + return; + OutputAssertEqualOr4(expect1, expect2, expect3, expect4, "==", get, line); +} // simple helper to quickly output a vectors template < typename X > 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/commandline_test.cc b/test/libapt/commandline_test.cc new file mode 100644 index 000000000..de8a30bd6 --- /dev/null +++ b/test/libapt/commandline_test.cc @@ -0,0 +1,32 @@ +#include <apt-pkg/cmndline.h> + +#include "assert.h" + +int main() +{ + CommandLine::Args Args[] = { + { 't', 0, "Test::Worked", 0 }, + { 'z', "zero", "Test::Zero", 0 }, + {0,0,0,0} + }; + CommandLine CmdL(Args,_config); + + char const * argv[] = { "test", "--zero", "-t" }; + CmdL.Parse(3 , argv); + equals(true, _config->FindB("Test::Worked", false)); + equals(true, _config->FindB("Test::Zero", false)); + + _config->Clear("Test"); + equals(false, _config->FindB("Test::Worked", false)); + equals(false, _config->FindB("Test::Zero", false)); + + _config->Set("Test::Zero", true); + equals(true, _config->FindB("Test::Zero", false)); + + char const * argv2[] = { "test", "--no-zero", "-t" }; + CmdL.Parse(3 , argv2); + equals(true, _config->FindB("Test::Worked", false)); + equals(false, _config->FindB("Test::Zero", false)); + + return 0; +} diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 5120e86c9..2c974ee0a 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -80,6 +80,24 @@ int main(int argc,const char *argv[]) { equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt"); equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude"); + Cnf.Set("RootDir", "/"); + equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt"); + equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude"); + Cnf.Set("RootDir", "//./////.////"); + equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt"); + equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude"); + Cnf.Set("RootDir", "/rootdir"); + equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt"); + equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude"); + Cnf.Set("RootDir", "/rootdir/"); + equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt"); + equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude"); + + Cnf.Set("Dir::State", "/dev/null"); + Cnf.Set("Dir::State::lists", "lists/"); + equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null"); + equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null"); + Cnf.Set("Moo::Bar", "1"); Cnf.Clear(); equals(Cnf.Find("Moo::Bar"), ""); diff --git a/test/libapt/fileutl_test.cc b/test/libapt/fileutl_test.cc new file mode 100644 index 000000000..b6b8ac579 --- /dev/null +++ b/test/libapt/fileutl_test.cc @@ -0,0 +1,42 @@ +#include <apt-pkg/error.h> +#include <apt-pkg/fileutl.h> + +#include "assert.h" +#include <string> +#include <vector> + +#include <stdio.h> +#include <iostream> +#include <stdlib.h> + + +int main(int argc,char *argv[]) +{ + std::vector<std::string> files; + + // normal match + files = Glob("*.lst"); + if (files.size() != 1) + { + _error->DumpErrors(); + return 1; + } + + // not there + files = Glob("xxxyyyzzz"); + if (files.size() != 0 || _error->PendingError()) + { + _error->DumpErrors(); + return 1; + } + + // many matches (number is a bit random) + files = Glob("*.cc"); + if (files.size() < 10) + { + _error->DumpErrors(); + return 1; + } + + return 0; +} diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index a1c801ea2..cef89bde6 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -126,18 +126,26 @@ int main(int argc,char *argv[]) _config->Set("Dir::State::lists", argv[1]); vec = APT::Configuration::getLanguages(true, false, env); - equals(vec.size(), 7); + equals(vec.size(), 8); equals(vec[0], "de_DE"); equals(vec[1], "de"); equals(vec[2], "en"); equals(vec[3], "none"); - equalsOr3(vec[4], "pt", "tr", "ast_DE"); - equalsOr3(vec[5], "tr", "pt", "ast_DE"); - equalsOr3(vec[6], "tr", "pt", "ast_DE"); + equalsOr4(vec[4], "pt", "tr", "ast_DE", "tlh_DE"); + equalsOr4(vec[5], "tr", "pt", "ast_DE", "tlh_DE"); + equalsOr4(vec[6], "tr", "pt", "ast_DE", "tlh_DE"); + equalsOr4(vec[7], "tr", "pt", "ast_DE", "tlh_DE"); + equalsNot(vec[4], vec[5]); + equalsNot(vec[4], vec[6]); + equalsNot(vec[4], vec[7]); + equalsNot(vec[5], vec[6]); + equalsNot(vec[5], vec[7]); + equalsNot(vec[6], vec[7]); _config->Set("Acquire::Languages", "none"); vec = APT::Configuration::getLanguages(true, false, env); - equals(vec.size(), 0); + equals(vec.size(), 1); + equals(vec[0], "none"); _config->Set("Acquire::Languages", ""); _config->Set("Dir::State::lists", "/non-existing-dir"); @@ -161,7 +169,8 @@ int main(int argc,char *argv[]) _config->Set("Acquire::Languages", "none"); env[0] = "de_DE.UTF-8"; vec = APT::Configuration::getLanguages(true, false, env); - equals(vec.size(), 0); + equals(vec.size(), 1); + equals(vec[0], "none"); _config->Set("Acquire::Languages", ""); //FIXME: Remove support for this deprecated setting diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc index 396e4cf6b..e2d0aec5b 100644 --- a/test/libapt/hashsums_test.cc +++ b/test/libapt/hashsums_test.cc @@ -42,6 +42,28 @@ template <class T> void TestMill(const char *Out) int main(int argc, char** argv) { + // test HashSumValue which doesn't calculate but just stores sums + { + string md5sum = argv[2]; + MD5SumValue md5(md5sum); + equals(md5.Value(), md5sum); + } + { + string sha1sum = argv[3]; + SHA1SumValue sha1(sha1sum); + equals(sha1.Value(), sha1sum); + } + { + string sha2sum = argv[4]; + SHA256SumValue sha2(sha2sum); + equals(sha2.Value(), sha2sum); + } + { + string sha2sum = argv[5]; + SHA512SumValue sha2(sha2sum); + equals(sha2.Value(), sha2sum); + } + // From FIPS PUB 180-1 Test<SHA1Summation>("","da39a3ee5e6b4b0d3255bfef95601890afd80709"); Test<SHA1Summation>("abc","a9993e364706816aba3e25717850c26c9cd0d89d"); 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 1952051e2..578f2da4d 100644 --- a/test/libapt/makefile +++ b/test/libapt/makefile @@ -34,6 +34,12 @@ SOURCE = getlistoffilesindir_test.cc include $(PROGRAM_H) # Program for testing CommandLine reconstruction +PROGRAM = Commandline${BASENAME} +SLIBS = -lapt-pkg +SOURCE = commandline_test.cc +include $(PROGRAM_H) + +# Program for testing CommandLine reconstruction PROGRAM = CommandlineAsString${BASENAME} SLIBS = -lapt-pkg SOURCE = commandlineasstring_test.cc @@ -80,3 +86,20 @@ 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 + +# test fileutls +PROGRAM = FileUtl${BASENAME} +SLIBS = -lapt-pkg +SOURCE = fileutl_test.cc +include $(PROGRAM_H) diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc index b5d92d9d2..677b1c892 100644 --- a/test/libapt/parsedepends_test.cc +++ b/test/libapt/parsedepends_test.cc @@ -10,7 +10,7 @@ int main(int argc,char *argv[]) { unsigned int Null = 0; bool StripMultiArch = true; bool ParseArchFlags = false; - _config->Set("APT::Architecture","dsk"); + _config->Set("APT::Architecture","amd64"); const char* Depends = "debhelper:any (>= 5.0), " @@ -19,13 +19,13 @@ int main(int argc,char *argv[]) { "libcurl4-gnutls-dev:native | libcurl3-gnutls-dev (>> 7.15.5), " "debiandoc-sgml, " "apt (>= 0.7.25), " - "not-for-me [ !dsk ], " - "only-for-me [ dsk ], " + "not-for-me [ !amd64 ], " + "only-for-me [ amd64 ], " "any-for-me [ any ], " "not-for-darwin [ !darwin-any ], " - "cpu-for-me [ any-dsk ], " + "cpu-for-me [ any-amd64 ], " "os-for-me [ linux-any ], " - "cpu-not-for-me [ any-amd64 ], " + "cpu-not-for-me [ any-armel ], " "os-not-for-me [ kfreebsd-any ], " "overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), " ; diff --git a/test/libapt/run-tests b/test/libapt/run-tests index d4341412d..45a3157f7 100755 --- a/test/libapt/run-tests +++ b/test/libapt/run-tests @@ -65,11 +65,12 @@ do "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \ "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak" \ - "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" + "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-ast_DE" \ + "${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-tlh%5fDE" elif [ $name = "HashSums${EXT}" ]; then TMP="$(readlink -f "./${0}")" - echo -n "Testing with \033[1;35m${name}\033[0m ... " - LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m" + echo -n "Testing with ${NAME} " + LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "$TESTOKAY" || echo "$TESTFAIL" continue elif [ $name = "CompareVersion${EXT}" ]; then tmppath="${DIR}/versions.lst" |