]> git.saurik.com Git - apt.git/blame_incremental - test/integration/test-failing-maintainer-scripts
Fix crash with empty architecture list
[apt.git] / test / integration / test-failing-maintainer-scripts
... / ...
CommitLineData
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8configarchitecture 'native'
9configdpkgnoopchroot
10
11# create a bunch of failures
12createfailure() {
13 setupsimplenativepackage "failure-$1" 'native' '1.0' 'unstable' 'Depends: dependee'
14 BUILDDIR="incoming/failure-$1-1.0"
15 echo '#!/bin/sh
16exit 29' > "${BUILDDIR}/debian/$1"
17 buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
18 rm -rf "$BUILDDIR"
19}
20
21buildsimplenativepackage 'dependee' 'native' '1.0' 'unstable'
22createfailure 'preinst'
23createfailure 'postinst'
24createfailure 'prerm'
25createfailure 'postrm'
26
27setupaptarchive
28
29# setup some pre- and post- invokes to check the output isn't garbled later
30APTHOOK="${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apthook"
31echo '#!/bin/sh
32echo "$1: START"
33echo "$1: MaiN"
34echo "$1: ENd"' > "$APTHOOK"
35chmod +x "$APTHOOK"
36echo "DPKG::Pre-Invoke:: \"${APTHOOK} PRE\";
37DPKG::Post-Invoke:: \"${APTHOOK} POST\";" > rootdir/etc/apt/apt.conf.d/99apthooks
38
39testmyfailure() {
40 local PROGRESS='rootdir/tmp/progress.log'
41 exec 3> "$PROGRESS"
42 testfailure "$@" -o APT::Status-Fd=3
43 msgtest 'Test for failure message of maintainerscript in' 'console log'
44 local TEST='rootdir/tmp/testfailure.output'
45 if grep -q 'exit status 29' "$TEST"; then
46 msgpass
47 else
48 cat "$TEST"
49 msgfail
50 fi
51 msgtest 'Test for proper execution of invoke scripts in' 'console log'
52 if grep -q '^PRE: START$' "$TEST" &&
53 grep -q '^PRE: MaiN$' "$TEST" &&
54 grep -q '^PRE: ENd$' "$TEST" &&
55 grep -q '^POST: START$' "$TEST" &&
56 grep -q '^POST: MaiN$' "$TEST" &&
57 grep -q '^POST: ENd$' "$TEST"; then
58 msgpass
59 else
60 cat "$TEST"
61 msgfail
62 fi
63 msgtest 'Test for failure message of maintainerscript in' 'progress log'
64 if grep -q '^pmerror:.\+exit status 29$' "$PROGRESS"; then
65 msgpass
66 else
67 cat "$PROGRESS"
68 msgfail
69 fi
70 testmarkedauto 'dependee'
71}
72
73cp -a rootdir/var/lib/dpkg/status rootdir/var/lib/dpkg/status.backup
74testmyfailure aptget install failure-preinst -y
75cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status
76testmyfailure aptget install failure-postinst -y
77cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status
78testsuccess aptget install failure-prerm -y
79testdpkginstalled failure-prerm
80testmyfailure aptget purge failure-prerm -y
81cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status
82testsuccess aptget install failure-postrm -y
83testdpkginstalled failure-postrm
84testmyfailure aptget purge failure-postrm -y
85
86# FIXME: test with output going to a PTY as it usually does
87#cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status
88#aptget install failure-preinst -y