From bc1c9081e826c2c7f265f23d388ba868d5011f6a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 15 May 2014 14:37:33 +0200 Subject: Never parse Version/Architecture tags in a Translation-$lang file Version/Architecture information in a Translation-$lang file is not allowed, so don't try to parse it. This is a fix for a bugreport where a Translation-en file contained the content of the regular Packages file (probably due to local FS corruption). This lead to strange error messages on file download. Thanks to Thomas Reusch for the report. --- .../test-apt-translation-has-no-packages | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 test/integration/test-apt-translation-has-no-packages (limited to 'test') diff --git a/test/integration/test-apt-translation-has-no-packages b/test/integration/test-apt-translation-has-no-packages new file mode 100755 index 000000000..bb2353a33 --- /dev/null +++ b/test/integration/test-apt-translation-has-no-packages @@ -0,0 +1,41 @@ +#!/bin/sh +# +# Due to corruption (local or network) a user might end up with a +# Translation-$lang file on disk that is actually a Packages file. In this +# case apt used to generate invalid package versions out of the +# Translation-$lang file (i.e. apt-cache policy foo) would show a version +# comming out of a Translation file. Downloading this versions fails as +# there is no acquire method available for the package +# +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture "amd64" + +if [ ! -x ${BUILDDIRECTORY}/apt ]; then + msgmsg "No ${BUILDDIRECTORY}/apt" + msgskip + exit 0 +fi + +buildsimplenativepackage 'foo' 'all' '1.0' +setupaptarchive + +APTARCHIVE=$(readlink -f ./aptarchive) + +# corrupt the Translation-en file to look like a regular Packages file +rm rootdir/var/cache/apt/*.bin +cp $APTARCHIVE/dists/unstable/main/binary-amd64/Packages \ + rootdir/var/lib/apt/lists/*Translation-en + +# ensure that there is no Version for the package foo generated out of +# the corrupted Translation-en file +testequal "foo: + Installed: (none) + Candidate: 1.0 + Version table: + 1.0 0 + 500 file:$APTARCHIVE/ unstable/main amd64 Packages" aptcache policy foo -- cgit v1.2.3 From 6f22aa086954064b2ee58cd11b50832b242d54ad Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 10 May 2014 14:21:10 +0200 Subject: add an additional test for arch specific conflicts In bugreport #747261 I confirmed with this testcase that apt actually supports the requested architecture-specific conflicts already since 2012 with commit cef094c2ec8214b2783a2ac3aa70cf835381eae1. The old test only does simulations which are handy to check apt, this one builds 'real' packages to see if dpkg agrees with us. Git-Dch: Ignore --- .../test-bug-747261-arch-specific-conflicts | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 test/integration/test-bug-747261-arch-specific-conflicts (limited to 'test') diff --git a/test/integration/test-bug-747261-arch-specific-conflicts b/test/integration/test-bug-747261-arch-specific-conflicts new file mode 100755 index 000000000..bfb2d089f --- /dev/null +++ b/test/integration/test-bug-747261-arch-specific-conflicts @@ -0,0 +1,36 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'sparc' 'armel' + +buildsimplenativepackage 'libc6' 'amd64,sparc,armel' '1' 'stable' 'Multi-Arch: same' +buildsimplenativepackage 'libc6-i386' 'amd64' '1' 'stable' 'Conflicts: libc6:sparc' + +setupaptarchive + +testsuccess aptget install 'libc6:amd64' 'libc6:sparc' -y +testdpkginstalled 'libc6:amd64' 'libc6:sparc' +testdpkgnotinstalled 'libc6-i386' 'libc6:armel' + +testsuccess aptget install libc6-i386 -y +testdpkginstalled 'libc6:amd64' 'libc6-i386' +testdpkgnotinstalled 'libc6:sparc' 'libc6:armel' + +testsuccess aptget install libc6:armel -y +testdpkginstalled 'libc6:amd64' 'libc6:armel' 'libc6-i386' +testdpkgnotinstalled 'libc6:sparc' + +testsuccess aptget install libc6:sparc -y +testdpkginstalled 'libc6:amd64' 'libc6:armel' 'libc6:sparc' +testdpkgnotinstalled 'libc6-i386' + +testsuccess aptget purge 'libc6:*' 'libc6-i386' -y +testdpkgnotinstalled 'libc6:amd64' 'libc6:armel' 'libc6:sparc' 'libc6-i386' + +# check that (the actually simpler) single arch is fine, too +configarchitecture 'amd64' +testfailure aptget install libc6:sparc -s +testsuccess aptget install libc6 libc6-i386 -y -- cgit v1.2.3 From a6fd378a9b2a541a18aeba722ecfedba9af567cb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 8 May 2014 18:52:51 +0200 Subject: make test independent from the actual Install-Size Git-Dch: Ignore --- test/integration/test-apt-ftparchive-cachedb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/integration/test-apt-ftparchive-cachedb b/test/integration/test-apt-ftparchive-cachedb index 147272a2c..0e1986bcd 100755 --- a/test/integration/test-apt-ftparchive-cachedb +++ b/test/integration/test-apt-ftparchive-cachedb @@ -5,7 +5,7 @@ ensure_correct_packages_file() { testequal "Package: foo Priority: optional Section: others -Installed-Size: 29 +$(dpkg-deb -I ./aptarchive/pool/main/foo_1_i386.deb | grep 'Installed-Size:' | sed 's#^ ##') Maintainer: Joe Sixpack Architecture: i386 Version: 1 @@ -25,7 +25,7 @@ usr/share/doc/foo/copyright others/foo" cat ./aptarchive/dists/test/Conte TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture "i386" +configarchitecture 'i386' mkdir -p aptarchive/dists/test/main/i18n/ mkdir -p aptarchive/dists/test/main/source/ -- cgit v1.2.3 From 0eb4af9d3d0c524c7afdc684238aa263ac287449 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 17 May 2014 12:37:13 +0200 Subject: fix tight loop detection and temporary removes As outlined in #748355 apt segfaulted if it encountered a loop between a package pre-depending on a package conflicting with the previous as it ended up in an endless loop trying to unpack 'the other package'. In this specific case as an essential package is involved a lot of force needs to be applied, but can also be caused by 'normal' tight loops and highlights a problem in how we handle breaks which we want to avoid. The fix comes in multiple entangled changes: 1. All Smart* calls are guarded with loop detection. Some already had it, some had parts of it, some did it incorrect, and some didn't even try. 2. temporary removes to avoid a loop (which is done if a loop is detected) prevent the unpack of this looping package (we tried to unpack it to avoid the conflict/breaks, but due to a loop we couldn't, so we remove/deconfigure it instead which means we can't unpack it now) 3. handle conflicts and breaks very similar instead of duplicating most of the code. The only remaining difference is, as it should: deconfigure is enough for breaks, for conflicts we need the big hammer --- .../test-bug-618288-multiarch-same-lockstep | 19 ++++---- .../test-bug-673536-pre-depends-breaks-loop | 28 +++++++++--- test/integration/test-conflicts-loop | 6 ++- test/integration/test-essential-force-loopbreak | 51 ++++++++++++++++++++++ 4 files changed, 86 insertions(+), 18 deletions(-) create mode 100755 test/integration/test-essential-force-loopbreak (limited to 'test') diff --git a/test/integration/test-bug-618288-multiarch-same-lockstep b/test/integration/test-bug-618288-multiarch-same-lockstep index e0305b64b..536124c2c 100755 --- a/test/integration/test-bug-618288-multiarch-same-lockstep +++ b/test/integration/test-bug-618288-multiarch-same-lockstep @@ -16,22 +16,23 @@ buildsimplenativepackage 'apt' 'i386' '2' 'unstable' 'Depends: libsame (= 2)' '' buildsimplenativepackage 'apt2' 'amd64' '2' 'unstable' 'Depends: libsame (= 2)' '' 'required' setupaptarchive -aptget dist-upgrade -s >output.apt 2>&1 +testsuccess aptget dist-upgrade -s -o Debug::pkgPackageManager=1 # order in switch libsame:{amd64,i386} are unpacked is irrelevant, as both are installed - but we need to do it together -LS_U_AMD="$(grep -o -n '^Inst libsame ' output.apt | cut -d: -f1)" -LS_U_INT="$(grep -o -n '^Inst libsame:i386 ' output.apt | cut -d: -f1)" -LS_C_AMD="$(grep -o -n '^Conf libsame ' output.apt | cut -d: -f1)" -LS_C_INT="$(grep -o -n '^Conf libsame:i386 ' output.apt | cut -d: -f1)" +OUTPUT=rootdir/tmp/testsuccess.output +LS_U_AMD="$(grep -o -n '^Inst libsame ' $OUTPUT | cut -d: -f1)" +LS_U_INT="$(grep -o -n '^Inst libsame:i386 ' $OUTPUT | cut -d: -f1)" +LS_C_AMD="$(grep -o -n '^Conf libsame ' $OUTPUT | cut -d: -f1)" +LS_C_INT="$(grep -o -n '^Conf libsame:i386 ' $OUTPUT | cut -d: -f1)" -msgtest 'Test if libsame:amd64 unpack before configure' +msgtest 'Test if' 'libsame:amd64 unpack before configure' test "$LS_U_AMD" -lt "$LS_C_AMD" && msgpass || msgfail -msgtest 'Test if libsame:i386 unpack before configure' +msgtest 'Test if' 'libsame:i386 unpack before configure' test "$LS_U_INT" -lt "$LS_C_INT" && msgpass || msgfail -msgtest 'Test if libsame:amd64 unpack is before libsame:i386 configure' +msgtest 'Test if' 'libsame:amd64 unpack is before libsame:i386 configure' test "$LS_U_AMD" -lt "$LS_C_INT" && msgpass || msgfail -msgtest 'Test if libsame:i386 unpack is before libsame:amd64 configure' +msgtest 'Test if' 'libsame:i386 unpack is before libsame:amd64 configure' test "$LS_U_INT" -lt "$LS_C_AMD" && msgpass || msgfail diff --git a/test/integration/test-bug-673536-pre-depends-breaks-loop b/test/integration/test-bug-673536-pre-depends-breaks-loop index f6a90b21f..21bd5e065 100755 --- a/test/integration/test-bug-673536-pre-depends-breaks-loop +++ b/test/integration/test-bug-673536-pre-depends-breaks-loop @@ -6,18 +6,32 @@ TESTDIR=$(readlink -f $(dirname $0)) setupenvironment configarchitecture 'native' -buildsimplenativepackage 'basic' 'native' '1' 'stable' +buildsimplenativepackage 'advanced' 'native' '1' 'stable' +buildsimplenativepackage 'advanced' 'native' '2' 'unstable' 'Pre-Depends: basic' buildsimplenativepackage 'basic' 'native' '2' 'unstable' 'Pre-Depends: common' -buildsimplenativepackage 'common' 'native' '2' 'unstable' 'Breaks: basic (<= 1)' + +buildsimplenativepackage 'common' 'native' '2~conflict' 'unstable-conflict' 'Conflicts: advanced (<= 1)' +buildsimplenativepackage 'common' 'native' '2~break' 'unstable-break' 'Conflicts: advanced (<= 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 -testsuccess aptget install basic=1 -y -testdpkginstalled basic -testdpkgnotinstalled common +cp -a rootdir/var/lib/dpkg/status dpkg.status.backup + +testloopbreak() { + cp -a dpkg.status.backup rootdir/var/lib/dpkg/status + rm -f rootdir/var/lib/apt/extended_states + + + testsuccess aptget install advanced=1 -y -t "$1" -o Debug::pkgPackageManager=1 + testdpkginstalled advanced + testdpkgnotinstalled basic common + + testsuccess aptget dist-upgrade -y -t "$1" -o Debug::pkgPackageManager=1 + testdpkginstalled advanced basic common +} -testsuccess aptget dist-upgrade -y -testdpkginstalled basic common +testloopbreak 'unstable-break' +testloopbreak 'unstable-conflict' diff --git a/test/integration/test-conflicts-loop b/test/integration/test-conflicts-loop index 4978fe1e8..a2c411aaf 100755 --- a/test/integration/test-conflicts-loop +++ b/test/integration/test-conflicts-loop @@ -20,11 +20,13 @@ 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. -Remv openjdk-6-jre [6b16-1.8-0ubuntu1] +Remv openjdk-6-jre-headless [6b16-1.8-0ubuntu1] Remv openjdk-6-jre-lib [6b16-1.8-0ubuntu1] -Inst openjdk-6-jre-headless [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Inst openjdk-6-jre [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Inst openjdk-6-jre-lib [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Conf openjdk-6-jre-lib (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Conf openjdk-6-jre (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) +Inst openjdk-6-jre-headless [6b16-1.8-0ubuntu1] (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386]) Conf openjdk-6-jre-headless (6b20-1.9.8-0ubuntu1~10.04.1 unstable [i386])' aptget dist-upgrade -s -o APT::Immediate-Configure-All=true + +testsuccess aptget dist-upgrade -s -o Debug::pkgPackageManager=1 diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak new file mode 100755 index 000000000..842dce61c --- /dev/null +++ b/test/integration/test-essential-force-loopbreak @@ -0,0 +1,51 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture 'amd64' + +insertinstalledpackage 'sysvinit' 'amd64' '1' 'Essential: yes' + +buildsimplenativepackage 'sysvinit' 'amd64' '2' 'sid' 'Pre-Depends: sysvinit-core | systemd-sysv +Essential: yes' +buildsimplenativepackage 'sysvinit-core' 'amd64' '2' 'sid' + +buildsimplenativepackage 'systemd-sysv' 'amd64' '2~conflict' 'sid-conflict' 'Conflicts: sysvinit (<< 2) +Breaks: sysvinit-core' + +buildsimplenativepackage 'systemd-sysv' 'amd64' '2~break' 'sid-break' 'Breaks: sysvinit (<< 2), sysvinit-core' + +setupaptarchive + +cp -a rootdir/var/lib/dpkg/status dpkg.status.backup + +testforcebreak() { + cp -a dpkg.status.backup rootdir/var/lib/dpkg/status + rm -f rootdir/var/lib/apt/extended_states + testequal 'Reading package lists... +Building dependency tree... +The following extra packages will be installed: + sysvinit +The following NEW packages will be installed: + systemd-sysv +The following packages will be upgraded: + sysvinit +1 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. +E: This installation run will require temporarily removing the essential package sysvinit:amd64 due to a Conflicts/Pre-Depends loop. This is often bad, but if you really want to do it, activate the APT::Force-LoopBreak option. +E: Internal Error, Could not early remove sysvinit:amd64 (2)' aptget install systemd-sysv -t "$1" -s + # ensure that really nothing happens + testfailure aptget install systemd-sysv -y -t "$1" -o Debug::pkgPackageManager=1 + testdpkginstalled 'sysvinit' + testdpkgnotinstalled 'systemd-sysv' + + # with enough force however … + cp -a dpkg.status.backup rootdir/var/lib/dpkg/status + testsuccess aptget install systemd-sysv -y -t "$1" -o Debug::pkgPackageManager=1 -o APT::Force-LoopBreak=1 + testdpkginstalled 'sysvinit' 'systemd-sysv' +} + +testforcebreak 'sid-conflict' +testforcebreak 'sid-break' -- cgit v1.2.3