From a17482f89b636a52aacc57776bfc8041cf4da508 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 11:47:56 +0100 Subject: only consider versioned kernel packages in autoremove Metapackages like "linux-image-amd64" are otherwise matched by our extraction as well, which later on can't be successfully compared via dpkg --compare-versions as the 'amd64' bit isn't a version number. (Luckily none of our architectures starts with a digit.) This was broken by me in 0.9.16 as I moved a shell-glob matcher to a regex-based one which has slightly different semantics regarding '*'. Closes: 741962 --- test/integration/test-kernel-helper-autoremove | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove index 7713c0875..c51caa758 100755 --- a/test/integration/test-kernel-helper-autoremove +++ b/test/integration/test-kernel-helper-autoremove @@ -20,6 +20,7 @@ CURRENTKERNEL="linux-image-$(uname -r)" insertinstalledpackage "$CURRENTKERNEL" 'amd64' '1' insertinstalledpackage 'linux-image-1.0.0-2-generic' 'amd64' '1.0.0-2' insertinstalledpackage 'linux-image-100.0.0-1-generic' 'amd64' '100.0.0-1' +insertinstalledpackage 'linux-image-amd64' 'amd64' '100.0.0-1' # ensure that the '.' is really a dot and not a wildcard insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1' -- cgit v1.2.3 From a1b6a4e7c5f5a859d27e00c2753b7f7b7e9ae14d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 21 Mar 2014 13:31:34 +0100 Subject: add testcase for APT::Architectures "arch1,arch2" Git-Dch: Ignore --- test/integration/test-bug-612958-use-dpkg-multiarch-config | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/integration/test-bug-612958-use-dpkg-multiarch-config b/test/integration/test-bug-612958-use-dpkg-multiarch-config index 4d1f00ca0..7bf5781e8 100755 --- a/test/integration/test-bug-612958-use-dpkg-multiarch-config +++ b/test/integration/test-bug-612958-use-dpkg-multiarch-config @@ -42,6 +42,15 @@ testpass 'apt config' 'armel' rm $CONFFILE +echo '#clear APT::Architectures;' >> $CONFFILE +echo 'APT::Architectures "i386,amd64";' >> $CONFFILE + +testpass 'apt config' 'i386' +testpass 'apt config' 'amd64' +testfail 'apt config' 'armel' + +rm $CONFFILE + echo '#clear APT::Architectures;' >> $CONFFILE echo 'Dir::Bin::dpkg "./dpkg-printer";' >> $CONFFILE -- cgit v1.2.3 From d151adbf2cc4d23c240c6c4fcfbfda439a98c36f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 22 Mar 2014 21:35:57 +0100 Subject: ensure proper teardown in dpkg error cases We have to properly close our pseudo terminals even in error cases before we call post-invoke scripts. This is done now by breaking from the dpkg calling loop instead of copying the handling, which did it in the wrong order before. This also ensures that our state file is written in error cases to record autobit and co as this was forgotten before. Closes: 738969 --- .../test-apt-progress-fd-error-postinst | 22 ---- test/integration/test-failing-maintainer-scripts | 132 +++++++++++++++++++++ 2 files changed, 132 insertions(+), 22 deletions(-) delete mode 100755 test/integration/test-apt-progress-fd-error-postinst create mode 100755 test/integration/test-failing-maintainer-scripts (limited to 'test') diff --git a/test/integration/test-apt-progress-fd-error-postinst b/test/integration/test-apt-progress-fd-error-postinst deleted file mode 100755 index 0b6e70212..000000000 --- a/test/integration/test-apt-progress-fd-error-postinst +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -set -e - -TESTDIR=$(readlink -f $(dirname $0)) -. $TESTDIR/framework - -setupenvironment -configarchitecture 'amd64' 'i386' - -mkdir -p DEBIAN/ -echo "#!/bin/sh\nexit 1" > DEBIAN/postinst -chmod 755 DEBIAN/postinst - -buildsimplenativepackage 'postinst-error' 'amd64,i386' '0.8.15' 'stable' '' 'pkg with posinst error' '' '' './DEBIAN' - -setupaptarchive - -exec 3> apt-progress.log -testfailure aptget install postinst-error -y -o APT::Status-Fd=3 -msgtest "Ensure correct error message for postinst error" -grep -q "pmerror:postinst-error :80:subprocess installed post-installation script returned error exit status 2" apt-progress.log && msgpass || msgfail - diff --git a/test/integration/test-failing-maintainer-scripts b/test/integration/test-failing-maintainer-scripts new file mode 100755 index 000000000..cb82ebc7a --- /dev/null +++ b/test/integration/test-failing-maintainer-scripts @@ -0,0 +1,132 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework + +setupenvironment +configarchitecture 'native' + +# create a bunch of failures +createfailure() { + setupsimplenativepackage "failure-$1" 'native' '1.0' 'unstable' 'Depends: dependee' + BUILDDIR="incoming/failure-$1-1.0" + echo '#!/bin/sh +exit 29' > ${BUILDDIR}/debian/$1 + buildpackage "$BUILDDIR" 'unstable' 'main' 'native' + rm -rf "$BUILDDIR" +} + +buildsimplenativepackage 'dependee' 'native' '1.0' 'unstable' +createfailure 'preinst' +createfailure 'postinst' +createfailure 'prerm' +createfailure 'postrm' + +setupaptarchive + +# create a library to noop chroot() and rewrite maintainer script executions +# via execvp() as used by dpkg as we don't want our rootdir to be a fullblown +# chroot directory dpkg could chroot into to execute the maintainer scripts +cat << EOF > noopchroot.c +#define _GNU_SOURCE +#include +#include +#include +#include + +static char * chrootdir = NULL; + +int chroot(const char *path) { + printf("WARNING: CHROOTing to %s was ignored!\n", path); + free(chrootdir); + chrootdir = strdup(path); + return 0; +} +int execvp(const char *file, char *const argv[]) { + static int (*func_execvp) (const char *, char * const []) = NULL; + if (func_execvp == NULL) + func_execvp = (int (*) (const char *, char * const [])) dlsym(RTLD_NEXT, "execvp"); + if (chrootdir == NULL || strncmp(file, "/var/lib/dpkg/", strlen("/var/lib/dpkg/")) != 0) + return func_execvp(file, argv); + printf("REWRITE execvp call %s into %s\n", file, chrootdir); + char newfile[strlen(chrootdir) + strlen(file)]; + strcpy(newfile, chrootdir); + strcat(newfile, file); + return func_execvp(newfile, argv); +} +EOF +testsuccess gcc -fPIC -shared -o noopchroot.so noopchroot.c -ldl + +mkdir -p "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/" +DPKG="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/dpkg" +echo "#!/bin/sh +if [ -n \"\$LD_PRELOAD\" ]; then + export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so \${LD_PRELOAD}\" +else + export LD_PRELOAD=\"${TMPWORKINGDIRECTORY}/noopchroot.so\" +fi +dpkg \"\$@\"" > $DPKG +chmod +x $DPKG +sed -ie "s|^DPKG::options:: \"dpkg\";\$|DPKG::options:: \"$DPKG\";|" aptconfig.conf + +# setup some pre- and post- invokes to check the output isn't garbled later +APTHOOK="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apthook" +echo '#!/bin/sh +echo "$1: START" +echo "$1: MaiN" +echo "$1: ENd"' > $APTHOOK +chmod +x $APTHOOK +echo "DPKG::Pre-Invoke:: \"${APTHOOK} PRE\"; +DPKG::Post-Invoke:: \"${APTHOOK} POST\";" > rootdir/etc/apt/apt.conf.d/99apthooks + +testmyfailure() { + local PROGRESS='rootdir/tmp/progress.log' + exec 3> $PROGRESS + testfailure "$@" -o APT::Status-Fd=3 + msgtest 'Test for failure message of maintainerscript in' 'console log' + local TEST='rootdir/tmp/testfailure.output' + if grep -q 'exit status 29$' "$TEST"; then + msgpass + else + cat $TEST + msgfail + fi + msgtest 'Test for proper execution of invoke scripts in' 'console log' + if grep -q '^PRE: START$' $TEST && + grep -q '^PRE: MaiN$' $TEST && + grep -q '^PRE: ENd$' $TEST && + grep -q '^POST: START$' $TEST && + grep -q '^POST: MaiN$' $TEST && + grep -q '^POST: ENd$' $TEST; then + msgpass + else + cat $TEST + msgfail + fi + msgtest 'Test for failure message of maintainerscript in' 'progress log' + if grep -q '^pmerror:.\+exit status 29$' "$PROGRESS"; then + msgpass + else + cat $PROGRESS + msgfail + fi + testmarkedauto 'dependee' +} + +cp -a rootdir/var/lib/dpkg/status rootdir/var/lib/dpkg/status.backup +testmyfailure aptget install failure-preinst -y +cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status +testmyfailure aptget install failure-postinst -y +cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status +testsuccess aptget install failure-prerm -y +testdpkginstalled failure-prerm +testmyfailure aptget purge failure-prerm -y +cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status +testsuccess aptget install failure-postrm -y +testdpkginstalled failure-postrm +testmyfailure aptget purge failure-postrm -y + +# FIXME: test with output going to a PTY as it usually does +#cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status +#aptget install failure-preinst -y -- cgit v1.2.3 From 21b3eac8f9ab8e12b43fa8998a5aa5465f29adc5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Mar 2014 10:31:44 +0100 Subject: discard candidates via IsInstallOk to allow override In commit 446551c8 I changed MarkInstall to discard the candidate if the candidate can't satisfy the dependency. This breaks interactive solvers like aptitude which can change the candidate on-the-fly later. In commit df77d8a5 I introduced this 'early' loop-breaking to begin with which can't be that helpful for interactive solvers as well, but makes perfect sense for non-interactives to stop them from exploring trees which can't be satisfied, but it isn't perfect as ideally we would check this before auto-installing the first dependency. This commit therefore moves the loop into its own IsInstallOk hook so that frontends can override this check if they want to and in exchange removes the loop-breaking from MarkInstall itself and does it before any dependency is installed. Closes: 740750 --- test/integration/test-bug-735967-lib32-to-i386-unavailable | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/integration/test-bug-735967-lib32-to-i386-unavailable b/test/integration/test-bug-735967-lib32-to-i386-unavailable index 4dbe1d25d..e9f3bf96d 100755 --- a/test/integration/test-bug-735967-lib32-to-i386-unavailable +++ b/test/integration/test-bug-735967-lib32-to-i386-unavailable @@ -12,6 +12,9 @@ insertpackage 'unstable' 'libnss-mdns' 'amd64,i386' '0.10-6' 'Multi-Arch: same Breaks: lib32nss-mdns (<< 0.10-6)' insertpackage 'unstable' 'libnss-mdns-i386' 'i386' '0.10-6' 'Multi-Arch: foreign Depends: libnss-mdns' +# introduce some dummies so that there are versions, but none works +insertpackage 'unstable' 'libnss-mdns-i386' 'amd64' '0.1-6' +insertpackage 'experimental' 'libnss-mdns-amd64' 'i386,amd64' '0.10-6' 'Provides: libnss-mdns-i386' insertpackage 'unstable' 'foo' 'amd64' '1' 'Depends: libfoo' insertpackage 'unstable' 'libfoo' 'amd64' '1' 'Depends: libfoo-bin' -- cgit v1.2.3