]>
Commit | Line | Data |
---|---|---|
7a948ec7 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
3abb6a6a DK |
4 | TESTDIR="$(readlink -f "$(dirname "$0")")" |
5 | . "$TESTDIR/framework" | |
7a948ec7 DK |
6 | setupenvironment |
7 | configarchitecture 'amd64' 'i386' | |
8 | ||
9 | buildsimplenativepackage 'toolkit' 'all' '1' 'stable' 'Multi-Arch: foreign' | |
10 | buildsimplenativepackage 'toolkit' 'amd64' '2' 'unstable' 'Multi-Arch: foreign' | |
11 | buildsimplenativepackage 'libsame' 'i386,amd64' '1' 'stable' 'Multi-Arch: same' | |
12 | buildsimplenativepackage 'libsame' 'i386,amd64' '2' 'unstable' 'Multi-Arch: same' | |
13 | buildsimplenativepackage 'stuff' 'i386,amd64' '1' 'stable' 'Depends: libsame (= 1), toolkit (= 1)' | |
14 | buildsimplenativepackage 'stuff' 'i386,amd64' '2' 'unstable' 'Depends: libsame (= 2), toolkit (= 2)' | |
15 | ||
86fdeec2 DK |
16 | setupsimplenativepackage 'confpkg' 'amd64' '1' 'unstable' |
17 | BUILDDIR='incoming/confpkg-1' | |
18 | echo 'foo "bar";' > ${BUILDDIR}/pkg.conf | |
19 | echo 'pkg.conf /etc/pkg.conf' >> ${BUILDDIR}/debian/install | |
20 | buildpackage "$BUILDDIR" 'unstable' 'main' 'amd64' | |
21 | rm -rf "$BUILDDIR" | |
22 | ||
7a948ec7 DK |
23 | setupaptarchive |
24 | ||
25 | hook='pre-install-pkgs' | |
26 | ||
27 | enablehookversion() { | |
28 | echo "#!/bin/sh | |
48498443 DK |
29 | FD=0 |
30 | echo -n > ${hook}-v${1}.list | |
31 | if [ -n \"${2}\" ]; then | |
32 | FD=\$APT_HOOK_INFO_FD | |
33 | if [ "\$FD" != \"${2}\" ]; then echo \"ERROR: Information is not on requested FD: \$FD != ${2}\" >> ${hook}-v${1}.list; fi | |
34 | fi | |
35 | while read </proc/\$\$/fd/\$FD line; do | |
7a948ec7 DK |
36 | if echo \"\$line\" | grep -Fq '**'; then |
37 | echo \"\$line\" | |
38 | fi | |
48498443 | 39 | done >> ${hook}-v${1}.list" > ${hook}-v${1}.sh |
7a948ec7 DK |
40 | chmod +x ${hook}-v${1}.sh |
41 | echo "dpkg::${hook}:: \"./${hook}-v${1}.sh --foo -bar\"; | |
42 | DPkg::Tools::options::\"./${hook}-v${1}.sh\"::Version \"$1\";" > rootdir/etc/apt/apt.conf.d/hook-v$1 | |
48498443 DK |
43 | if [ -n "$2" ]; then |
44 | echo "DPkg::Tools::options::\"./${hook}-v${1}.sh\"::InfoFD \"${2}\";" >> rootdir/etc/apt/apt.conf.d/hook-v$1 | |
45 | fi | |
7a948ec7 DK |
46 | } |
47 | ||
7a948ec7 DK |
48 | observehook() { |
49 | rm -f ${hook}-v2.list ${hook}-v3.list | |
50 | msgtest 'Observe hooks while' "$*" | |
28557f94 DK |
51 | testsuccess --nomsg aptget "$@" -y --allow-downgrades --planner $planner |
52 | # different planners have different orders – we don't care in this test here | |
53 | if [ -e ${hook}-v2.list ]; then | |
54 | sort < ${hook}-v2.list > ${hook}-v2.list.new | |
55 | mv ${hook}-v2.list.new ${hook}-v2.list | |
56 | fi | |
57 | if [ -e ${hook}-v3.list ]; then | |
58 | sort < ${hook}-v3.list > ${hook}-v3.list.new | |
59 | mv ${hook}-v3.list.new ${hook}-v3.list | |
60 | fi | |
7a948ec7 DK |
61 | } |
62 | ||
48498443 DK |
63 | testrun() { |
64 | observehook install stuff -t stable | |
65 | testfileequal "${hook}-v2.list" 'libsame - < 1 **CONFIGURE** | |
28557f94 DK |
66 | stuff - < 1 **CONFIGURE** |
67 | toolkit - < 1 **CONFIGURE**' | |
48498443 | 68 | testfileequal "${hook}-v3.list" 'libsame - - none < 1 amd64 same **CONFIGURE** |
28557f94 DK |
69 | stuff - - none < 1 amd64 none **CONFIGURE** |
70 | toolkit - - none < 1 all foreign **CONFIGURE**' | |
7a948ec7 | 71 | |
48498443 DK |
72 | observehook install stuff -t unstable |
73 | testfileequal "${hook}-v2.list" 'libsame 1 < 2 **CONFIGURE** | |
28557f94 DK |
74 | stuff 1 < 2 **CONFIGURE** |
75 | toolkit 1 < 2 **CONFIGURE**' | |
48498443 | 76 | testfileequal "${hook}-v3.list" 'libsame 1 amd64 same < 2 amd64 same **CONFIGURE** |
28557f94 DK |
77 | stuff 1 amd64 none < 2 amd64 none **CONFIGURE** |
78 | toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**' | |
7a948ec7 | 79 | |
48498443 | 80 | observehook install stuff:i386 -t unstable |
28557f94 DK |
81 | testfileequal "${hook}-v2.list" 'libsame - < 2 **CONFIGURE** |
82 | stuff - < 2 **CONFIGURE** | |
83 | stuff 2 > - **REMOVE**' | |
84 | testfileequal "${hook}-v3.list" 'libsame - - none < 2 i386 same **CONFIGURE** | |
85 | stuff - - none < 2 i386 none **CONFIGURE** | |
86 | stuff 2 amd64 none > - - none **REMOVE**' | |
7a948ec7 | 87 | |
48498443 DK |
88 | observehook remove libsame |
89 | testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE**' | |
90 | testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE**' | |
7a948ec7 | 91 | |
48498443 DK |
92 | observehook install stuff:i386/stable libsame:i386/stable toolkit/stable |
93 | testfileequal "${hook}-v2.list" 'libsame 2 > 1 **CONFIGURE** | |
28557f94 DK |
94 | stuff 2 > 1 **CONFIGURE** |
95 | toolkit 2 > 1 **CONFIGURE**' | |
48498443 | 96 | testfileequal "${hook}-v3.list" 'libsame 2 i386 same > 1 i386 same **CONFIGURE** |
28557f94 DK |
97 | stuff 2 i386 none > 1 i386 none **CONFIGURE** |
98 | toolkit 2 amd64 foreign > 1 all foreign **CONFIGURE**' | |
7a948ec7 | 99 | |
48498443 | 100 | observehook install 'libsame:*' |
28557f94 DK |
101 | testfileequal "${hook}-v2.list" 'libsame - < 2 **CONFIGURE** |
102 | libsame 1 < 2 **CONFIGURE** | |
103 | stuff 1 < 2 **CONFIGURE** | |
104 | toolkit 1 < 2 **CONFIGURE**' | |
105 | testfileequal "${hook}-v3.list" 'libsame - - none < 2 amd64 same **CONFIGURE** | |
106 | libsame 1 i386 same < 2 i386 same **CONFIGURE** | |
107 | stuff 1 i386 none < 2 i386 none **CONFIGURE** | |
108 | toolkit 1 all foreign < 2 amd64 foreign **CONFIGURE**' | |
7a948ec7 | 109 | |
48498443 DK |
110 | observehook purge stuff:i386 'libsame:*' toolkit |
111 | testfileequal "${hook}-v2.list" 'libsame 2 > - **REMOVE** | |
7a948ec7 | 112 | libsame 2 > - **REMOVE** |
28557f94 | 113 | stuff 2 > - **REMOVE** |
7a948ec7 | 114 | toolkit 2 > - **REMOVE**' |
48498443 | 115 | testfileequal "${hook}-v3.list" 'libsame 2 amd64 same > - - none **REMOVE** |
7a948ec7 | 116 | libsame 2 i386 same > - - none **REMOVE** |
28557f94 | 117 | stuff 2 i386 none > - - none **REMOVE** |
7a948ec7 | 118 | toolkit 2 amd64 foreign > - - none **REMOVE**' |
86fdeec2 | 119 | |
48498443 DK |
120 | observehook install confpkg |
121 | testfileequal "${hook}-v2.list" 'confpkg - < 1 **CONFIGURE**' | |
122 | testfileequal "${hook}-v3.list" 'confpkg - - none < 1 amd64 none **CONFIGURE**' | |
123 | ||
124 | observehook remove confpkg | |
125 | testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' | |
126 | testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' | |
86fdeec2 | 127 | |
48498443 DK |
128 | msgtest 'Conffiles of package remained after remove' 'confpkg' |
129 | dpkg -l confpkg | grep -q '^rc' && msgpass || msgfail | |
86fdeec2 | 130 | |
48498443 DK |
131 | observehook purge confpkg |
132 | testfileequal "${hook}-v2.list" 'confpkg 1 > - **REMOVE**' | |
133 | testfileequal "${hook}-v3.list" 'confpkg 1 amd64 none > - - none **REMOVE**' | |
86fdeec2 | 134 | |
48498443 DK |
135 | msgtest 'Conffiles are gone after purge' 'confpkg' |
136 | dpkg -l confpkg 2>/dev/null | grep -q '^rc' && msgfail || msgpass | |
137 | } | |
138 | ||
28557f94 DK |
139 | runwithplanner() |
140 | { | |
141 | msgmsg 'Running with planner' "$1" | |
142 | planner="$1" | |
143 | enablehookversion 2 | |
144 | enablehookversion 3 | |
145 | testrun | |
146 | ||
147 | enablehookversion 2 13 | |
148 | enablehookversion 3 13 | |
149 | testrun | |
150 | } | |
86fdeec2 | 151 | |
28557f94 | 152 | runwithplanner 'apt' |