]> git.saurik.com Git - apt.git/blame - test/integration/test-failing-maintainer-scripts
Merge commit 'e2073b0276226b625897ef475f225bf8f508719e' as 'triehash'
[apt.git] / test / integration / test-failing-maintainer-scripts
CommitLineData
d151adbf
DK
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
d151adbf
DK
6
7setupenvironment
8configarchitecture 'native'
0c787570 9configdpkgnoopchroot
d151adbf
DK
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
63c71412 16exit 29' > "${BUILDDIR}/debian/$1"
d151adbf
DK
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
d151adbf
DK
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"
63c71412
DK
34echo "$1: ENd"' > "$APTHOOK"
35chmod +x "$APTHOOK"
d151adbf
DK
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'
63c71412 41 exec 3> "$PROGRESS"
d151adbf
DK
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'
a11f6c97 45 if grep -q 'exit status 29' "$TEST"; then
d151adbf
DK
46 msgpass
47 else
63c71412 48 cat "$TEST"
d151adbf
DK
49 msgfail
50 fi
51 msgtest 'Test for proper execution of invoke scripts in' 'console log'
63c71412
DK
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
d151adbf
DK
58 msgpass
59 else
63c71412 60 cat "$TEST"
d151adbf
DK
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
63c71412 67 cat "$PROGRESS"
d151adbf
DK
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
915f4ac6
DK
87if false; then
88 cp -a rootdir/var/lib/dpkg/status.backup rootdir/var/lib/dpkg/status
89 apt install dependee -y || true
90 apt install failure-postinst -y || true
91fi