From 7a948ec719ecc020c2337fe3f41c5fc42699e2c1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 26 Jun 2013 17:37:57 +0200 Subject: Version 3 for DPkg::Pre-Install-Pkgs with MultiArch info Adds on top of Version 2 to all displayed version numbers the architecture as well as the MultiArch flag for consumption by the hooks. Most of the time the architecture will be the same for both versions displayed, but packages might change from "all" to "any" (or back) between versions so we can't display the architecture for packages. Pseudo-Format for Version 3: Examples: stuff - - none < 1 amd64 none **CONFIGURE** libsame 1 i386 same < 2 i386 same **CONFIGURE** stuff 2 i386 none > 1 i386 none **CONFIGURE** libsame 2 i386 same > - - none **REMOVE** toolkit 1 all foreign > - - none **REMOVE** Closes: #712116 --- ...bug-712116-dpkg-pre-install-pkgs-hook-multiarch | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch (limited to 'test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch') diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch new file mode 100755 index 000000000..aee44f76b --- /dev/null +++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch @@ -0,0 +1,95 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'amd64' 'i386' + +buildsimplenativepackage 'toolkit' 'all' '1' 'stable' 'Multi-Arch: foreign' +buildsimplenativepackage 'toolkit' 'amd64' '2' 'unstable' 'Multi-Arch: foreign' +buildsimplenativepackage 'libsame' 'i386,amd64' '1' 'stable' 'Multi-Arch: same' +buildsimplenativepackage 'libsame' 'i386,amd64' '2' 'unstable' 'Multi-Arch: same' +buildsimplenativepackage 'stuff' 'i386,amd64' '1' 'stable' 'Depends: libsame (= 1), toolkit (= 1)' +buildsimplenativepackage 'stuff' 'i386,amd64' '2' 'unstable' 'Depends: libsame (= 2), toolkit (= 2)' + +setupaptarchive + +hook='pre-install-pkgs' + +enablehookversion() { + echo "#!/bin/sh +while read line; do + if echo \"\$line\" | grep -Fq '**'; then + echo \"\$line\" + fi +done > ${hook}-v${1}.list" > ${hook}-v${1}.sh + chmod +x ${hook}-v${1}.sh + echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\"; +DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1 +} + +enablehookversion 2 +enablehookversion 3 + +observehook() { + rm -f ${hook}-v2.list ${hook}-v3.list + msgtest 'Observe hooks while' "$*" + aptget "$@" -y --force-yes >/dev/null 2>&1 && msgpass || msgfail +} + +observehook install stuff -t stable +testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE** +toolkit - < 1 **CONFIGURE** +stuff - < 1 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE** +toolkit - - none < 1 all foreign **CONFIGURE** +stuff - - none < 1 amd64 none **CONFIGURE**' + +observehook install stuff -t unstable +testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** +toolkit 1 < 2 **CONFIGURE** +stuff 1 < 2 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE** +toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE** +stuff 1 amd64 none < 2 amd64 none **CONFIGURE**' + +observehook install stuff:i386 -t unstable +testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE** +libsame - < 2 **CONFIGURE** +stuff - < 2 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE** +libsame - - none < 2 i386 same **CONFIGURE** +stuff - - none < 2 i386 none **CONFIGURE**' + +observehook remove libsame +testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**' +testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**' + +observehook install stuff:i386/stable libsame:i386/stable toolkit/stable +testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE** +toolkit 2 > 1 **CONFIGURE** +stuff 2 > 1 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE** +toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE** +stuff 2 i386 none > 1 i386 none **CONFIGURE**' + +observehook install 'libsame:*' +testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** +libsame - < 2 **CONFIGURE** +toolkit 1 < 2 **CONFIGURE** +stuff 1 < 2 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE** +libsame - - none < 2 amd64 same **CONFIGURE** +toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE** +stuff 1 i386 none < 2 i386 none **CONFIGURE**' + +observehook purge stuff:i386 'libsame:*' toolkit +testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE** +stuff 2 > - **REMOVE** +libsame 2 > - **REMOVE** +toolkit 2 > - **REMOVE**' +testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE** +stuff 2 i386 none > - - none **REMOVE** +libsame 2 i386 same > - - none **REMOVE** +toolkit 2 amd64 foreign > - - none **REMOVE**' -- cgit v1.2.3 From 86fdeec2a76f6b134ee8400eb1e53d06fe0974fe Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 16 Jul 2013 23:15:55 +0200 Subject: fix if-clause to generate hook-info for 'rc' packages The code incorrectly skips printing of current version information, if the package has no current version (for APT, but for dpkg as it is the case for packages which are removed but not purged) by using an unintended "else if" rather than an "if". Closes: 717006 --- ...bug-712116-dpkg-pre-install-pkgs-hook-multiarch | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch') diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch index aee44f76b..a89cb7191 100755 --- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch +++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch @@ -13,6 +13,13 @@ buildsimplenativepackage 'libsame' 'i386,amd64' '2' 'unstable' 'Multi-Arch: same buildsimplenativepackage 'stuff' 'i386,amd64' '1' 'stable' 'Depends: libsame (= 1), toolkit (= 1)' buildsimplenativepackage 'stuff' 'i386,amd64' '2' 'unstable' 'Depends: libsame (= 2), toolkit (= 2)' +setupsimplenativepackage 'confpkg' 'amd64' '1' 'unstable' +BUILDDIR='incoming/confpkg-1' +echo 'foo "bar";' > ${BUILDDIR}/pkg.conf +echo 'pkg.conf /etc/pkg.conf' >> ${BUILDDIR}/debian/install +buildpackage "$BUILDDIR" 'unstable' 'main' 'amd64' +rm -rf "$BUILDDIR" + setupaptarchive hook='pre-install-pkgs' @@ -93,3 +100,21 @@ testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE** stuff 2 i386 none > - - none **REMOVE** libsame 2 i386 same > - - none **REMOVE** toolkit 2 amd64 foreign > - - none **REMOVE**' + +observehook install confpkg +testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**' +testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**' + +observehook remove confpkg +testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' +testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' + +msgtest 'Conffiles of package remained after remove' 'confpkg' +dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail + +observehook purge confpkg +testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' +testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' + +msgtest 'Conffiles are gone after purge' 'confpkg' +dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass -- cgit v1.2.3 From 0440d936d70b1e331d49bbc32735f1b749632604 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 10 Aug 2013 10:01:06 +0200 Subject: add chronic-like testsuccess/testfailure helpers For many commands the output isn't stable (like then dpkg is called) but the exitcode is, so this helper enhances the common && msgpass || msgfail by generating automatically a msgtest and showing the output of the command in case of failure instead of discarding it unconditionally, the later being chronic-like behaviour Git-Dch: Ignore --- test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch') diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch index a89cb7191..af65397ea 100755 --- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch +++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch @@ -42,7 +42,7 @@ enablehookversion 3 observehook() { rm -f ${hook}-v2.list ${hook}-v3.list msgtest 'Observe hooks while' "$*" - aptget "$@" -y --force-yes >/dev/null 2>&1 && msgpass || msgfail + testsuccess --nomsg aptget "$@" -y --force-yes } observehook install stuff -t stable -- cgit v1.2.3 From 48498443e74b2a7e089709b954c50b7df374684b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Aug 2013 18:18:15 +0200 Subject: allow Pre-Install-Pkgs hooks to get info over an FD != stdin This adds ::InfoFD option alongside the ::Version one to request sending the information to the specified FD, by default it is STDIN as it was the case before. The environment variable APT_HOOK_INFO_FD contains the FD the data is on as a confirmation that the APT version used understood the request. Allowing the hook to choose the FD is needed/helpful e.g. for shellscripts which have a hard time accessing FDs above 9 (as >= 10 are usually used internally by them) Closes: #671728 --- ...bug-712116-dpkg-pre-install-pkgs-hook-multiarch | 94 +++++++++++++--------- 1 file changed, 55 insertions(+), 39 deletions(-) (limited to 'test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch') diff --git a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch index af65397ea..62355a6b5 100755 --- a/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch +++ b/test/integration/test-bug-712116-dpkg-pre-install-pkgs-hook-multiarch @@ -26,95 +26,111 @@ hook='pre-install-pkgs' enablehookversion() { echo "#!/bin/sh -while read line; do +FD=0 +echo -n > ${hook}-v${1}.list +if [ -n \"${2}\" ]; then + FD=\$APT_HOOK_INFO_FD + if [ "\$FD" != \"${2}\" ]; then echo \"ERROR: Information is not on requested FD: \$FD != ${2}\" >> ${hook}-v${1}.list; fi +fi +while read ${hook}-v${1}.list" > ${hook}-v${1}.sh +done >> ${hook}-v${1}.list" > ${hook}-v${1}.sh chmod +x ${hook}-v${1}.sh echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\"; DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1 + if [ -n "$2" ]; then + echo "DPkg::Tools::options::\"./${hook}-v${1}.sh\"::InfoFD \"${2}\";" >> rootdir/etc/apt/apt.conf.d/hook-v$1 + fi } -enablehookversion 2 -enablehookversion 3 - observehook() { rm -f ${hook}-v2.list ${hook}-v3.list msgtest 'Observe hooks while' "$*" testsuccess --nomsg aptget "$@" -y --force-yes } -observehook install stuff -t stable -testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE** +testrun() { + observehook install stuff -t stable + testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE** toolkit - < 1 **CONFIGURE** stuff - < 1 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE** + testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE** toolkit - - none < 1 all foreign **CONFIGURE** stuff - - none < 1 amd64 none **CONFIGURE**' -observehook install stuff -t unstable -testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** + observehook install stuff -t unstable + testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** toolkit 1 < 2 **CONFIGURE** stuff 1 < 2 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE** + testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE** toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE** stuff 1 amd64 none < 2 amd64 none **CONFIGURE**' -observehook install stuff:i386 -t unstable -testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE** + observehook install stuff:i386 -t unstable + testfileequal "${hook}-v2.list" 'stuff 2 > - **REMOVE** libsame - < 2 **CONFIGURE** stuff - < 2 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE** + testfileequal "${hook}-v3.list" 'stuff 2 amd64 none > - - none **REMOVE** libsame - - none < 2 i386 same **CONFIGURE** stuff - - none < 2 i386 none **CONFIGURE**' -observehook remove libsame -testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**' -testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**' + observehook remove libsame + testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**' + testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**' -observehook install stuff:i386/stable libsame:i386/stable toolkit/stable -testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE** + observehook install stuff:i386/stable libsame:i386/stable toolkit/stable + testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE** toolkit 2 > 1 **CONFIGURE** stuff 2 > 1 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE** + testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE** toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE** stuff 2 i386 none > 1 i386 none **CONFIGURE**' -observehook install 'libsame:*' -testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** + observehook install 'libsame:*' + testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** libsame - < 2 **CONFIGURE** toolkit 1 < 2 **CONFIGURE** stuff 1 < 2 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE** + testfileequal "${hook}-v3.list" 'libsame 1 i386 same < 2 i386 same **CONFIGURE** libsame - - none < 2 amd64 same **CONFIGURE** toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE** stuff 1 i386 none < 2 i386 none **CONFIGURE**' -observehook purge stuff:i386 'libsame:*' toolkit -testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE** + observehook purge stuff:i386 'libsame:*' toolkit + testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE** stuff 2 > - **REMOVE** libsame 2 > - **REMOVE** toolkit 2 > - **REMOVE**' -testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE** + testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE** stuff 2 i386 none > - - none **REMOVE** libsame 2 i386 same > - - none **REMOVE** toolkit 2 amd64 foreign > - - none **REMOVE**' -observehook install confpkg -testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**' -testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**' + observehook install confpkg + testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**' + testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**' + + observehook remove confpkg + testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' + testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' -observehook remove confpkg -testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' -testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' + msgtest 'Conffiles of package remained after remove' 'confpkg' + dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail -msgtest 'Conffiles of package remained after remove' 'confpkg' -dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail + observehook purge confpkg + testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' + testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' -observehook purge confpkg -testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' -testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' + msgtest 'Conffiles are gone after purge' 'confpkg' + dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass +} + +enablehookversion 2 +enablehookversion 3 +testrun -msgtest 'Conffiles are gone after purge' 'confpkg' -dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass +enablehookversion 2 13 +enablehookversion 3 13 +testrun -- cgit v1.2.3