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/integration/test-essential-force-loopbreak | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 test/integration/test-essential-force-loopbreak (limited to 'test/integration/test-essential-force-loopbreak') 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 From d91e3cfa1992599c088673ef68bcdfd4d0aedc85 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 30 May 2014 23:15:28 +0200 Subject: use 'native' instead of 'amd64' as pkg arch Git-Dch: Ignore --- test/integration/test-essential-force-loopbreak | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/integration/test-essential-force-loopbreak') diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak index 842dce61c..d60c6cbd5 100755 --- a/test/integration/test-essential-force-loopbreak +++ b/test/integration/test-essential-force-loopbreak @@ -5,18 +5,18 @@ TESTDIR=$(readlink -f $(dirname $0)) . $TESTDIR/framework setupenvironment -configarchitecture 'amd64' +configarchitecture 'native' -insertinstalledpackage 'sysvinit' 'amd64' '1' 'Essential: yes' +insertinstalledpackage 'sysvinit' 'native' '1' 'Essential: yes' -buildsimplenativepackage 'sysvinit' 'amd64' '2' 'sid' 'Pre-Depends: sysvinit-core | systemd-sysv +buildsimplenativepackage 'sysvinit' 'native' '2' 'sid' 'Pre-Depends: sysvinit-core | systemd-sysv Essential: yes' -buildsimplenativepackage 'sysvinit-core' 'amd64' '2' 'sid' +buildsimplenativepackage 'sysvinit-core' 'native' '2' 'sid' -buildsimplenativepackage 'systemd-sysv' 'amd64' '2~conflict' 'sid-conflict' 'Conflicts: sysvinit (<< 2) +buildsimplenativepackage 'systemd-sysv' 'native' '2~conflict' 'sid-conflict' 'Conflicts: sysvinit (<< 2) Breaks: sysvinit-core' -buildsimplenativepackage 'systemd-sysv' 'amd64' '2~break' 'sid-break' 'Breaks: sysvinit (<< 2), sysvinit-core' +buildsimplenativepackage 'systemd-sysv' 'native' '2~break' 'sid-break' 'Breaks: sysvinit (<< 2), sysvinit-core' setupaptarchive @@ -25,7 +25,7 @@ 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... + testequal "Reading package lists... Building dependency tree... The following extra packages will be installed: sysvinit @@ -34,8 +34,8 @@ The following NEW packages will be installed: 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 +E: This installation run will require temporarily removing the essential package sysvinit:$(getarchitecture 'native') 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' -- cgit v1.2.3 From eb197ed71b1535f3c1715c8a751485ef927b51b7 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 12 Jun 2014 10:09:24 +0200 Subject: test/integration/test-essential-force-loopbreak: fix on non-amd64 systems --- test/integration/test-essential-force-loopbreak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/integration/test-essential-force-loopbreak') diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak index d60c6cbd5..ac8fc6d28 100755 --- a/test/integration/test-essential-force-loopbreak +++ b/test/integration/test-essential-force-loopbreak @@ -35,7 +35,7 @@ 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:$(getarchitecture 'native') 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 +E: Internal Error, Could not early remove sysvinit:$(dpkg --print-architecture) (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' -- cgit v1.2.3 From 1df24acfdb8ba1cd8bbbaa166f170dda480ce41e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 19 Oct 2014 14:14:37 +0200 Subject: check for failure message in testsuccess/failure These functions check the exit code of the command, but for apt commands we can go further and require an error message for non-zero exits and none for zero exits. Git-Dch: Ignore --- test/integration/test-essential-force-loopbreak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/integration/test-essential-force-loopbreak') diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak index ac8fc6d28..1493430d8 100755 --- a/test/integration/test-essential-force-loopbreak +++ b/test/integration/test-essential-force-loopbreak @@ -37,13 +37,13 @@ The following packages will be upgraded: E: This installation run will require temporarily removing the essential package sysvinit:$(getarchitecture 'native') 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:$(dpkg --print-architecture) (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 + testfailure aptget install systemd-sysv -y -t "$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 + testsuccess aptget install systemd-sysv -y -t "$1" -o APT::Force-LoopBreak=1 testdpkginstalled 'sysvinit' 'systemd-sysv' } -- cgit v1.2.3 From 25b86db159fbc3c043628e285c0c1ef24dec2c6e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 10 Mar 2015 00:59:44 +0100 Subject: test exitcode as well as string equality We use test{success,failure} now all over the place in the framework, so its only consequencial to do this in the situations in which we test for a specific output as well. Git-Dch: Ignore --- test/integration/test-essential-force-loopbreak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/integration/test-essential-force-loopbreak') diff --git a/test/integration/test-essential-force-loopbreak b/test/integration/test-essential-force-loopbreak index 1493430d8..50c682d43 100755 --- a/test/integration/test-essential-force-loopbreak +++ b/test/integration/test-essential-force-loopbreak @@ -25,7 +25,7 @@ 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... + testfailureequal "Reading package lists... Building dependency tree... The following extra packages will be installed: sysvinit -- cgit v1.2.3