]> git.saurik.com Git - apt.git/blob - test/integration/test-external-dependency-solver-protocol
allow default build-essentials to be overridden
[apt.git] / test / integration / test-external-dependency-solver-protocol
1 #!/bin/sh
2 set -e
3
4 TESTDIR="$(readlink -f "$(dirname "$0")")"
5 . "$TESTDIR/framework"
6 setupenvironment
7 configarchitecture 'amd64' 'i386'
8
9 insertinstalledpackage 'cool' 'all' '1'
10 insertinstalledpackage 'stuff' 'all' '1'
11 insertinstalledpackage 'somestuff' 'all' '1' 'Depends: cool, stuff'
12
13 insertpackage 'unstable' 'cool' 'all' '2' 'Multi-Arch: foreign'
14 insertpackage 'unstable' 'stuff' 'all' '2' 'Multi-Arch: foreign'
15 insertpackage 'unstable' 'coolstuff' 'i386,amd64' '2' 'Depends: cool, stuff'
16 insertpackage 'unstable' 'awesome' 'all' '2' 'Multi-Arch: foreign
17 Conflicts: badstuff'
18 insertpackage 'unstable' 'badstuff' 'all' '2' 'Multi-Arch: foreign
19 Conflicts: awesome'
20 insertpackage 'unstable' 'awesomecoolstuff' 'i386' '2' 'Depends: coolstuff, awesome'
21
22 insertpackage 'experimental' 'cool' 'all' '3' 'Multi-Arch: foreign'
23 insertpackage 'experimental' 'stuff' 'all' '3' 'Multi-Arch: foreign'
24 insertpackage 'experimental' 'coolstuff' 'i386,amd64' '3' 'Depends: cool, stuff'
25
26 setupaptarchive
27
28 testsuccess aptget install --solver apt coolstuff -s
29 testempty find . -name 'edsp.last.*'
30 echo 'Dir::Log::Solver "edsp.last.xz";' > rootdir/etc/apt/apt.conf.d/log-edsp.conf
31
32 testfailure aptget install --solver dump coolstuff -s
33 testsuccess grep 'ERR_NO_FILENAME' rootdir/tmp/testfailure.output
34 testfailure test -s rootdir/var/log/apt/edsp.last.xz
35 export APT_EDSP_DUMP_FILENAME="/nonexistent/apt/edsp.dump"
36 testfailure aptget install --solver dump coolstuff -s
37 testsuccess grep 'ERR_CREATE_FILE' rootdir/tmp/testfailure.output
38 testfailure test -s rootdir/var/log/apt/edsp.last.xz
39 export APT_EDSP_DUMP_FILENAME="${TMPWORKINGDIRECTORY}/downloaded/dump.edsp"
40
41 testfailureequal 'Reading package lists...
42 Building dependency tree...
43 Execute external solver...
44 The solver encountered an error of type: ERR_JUST_DUMPING
45 The following information might help you to understand what is wrong:
46 I am too dumb, i can just dump!
47 Please use one of my friends instead!
48
49 E: External solver failed with: I am too dumb, i can just dump!' aptget install --solver dump coolstuff -s
50 testfailure test -s rootdir/var/log/apt/edsp.last.xz
51 testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
52
53 testsuccessequal 'Reading package lists...
54 Building dependency tree...
55 Execute external solver...
56 The following NEW packages will be installed:
57 coolstuff
58 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
59 Inst coolstuff (2 unstable [amd64])
60 Conf coolstuff (2 unstable [amd64])' aptget install --solver apt coolstuff -s
61 testsuccess test -s rootdir/var/log/apt/edsp.last.xz
62 sed -i -e 's#^Solver: dump$#Solver: apt#' "$APT_EDSP_DUMP_FILENAME"
63 testequal "$(cat "$APT_EDSP_DUMP_FILENAME")
64 " apthelper cat-file rootdir/var/log/apt/edsp.last.xz
65 cp rootdir/var/log/apt/edsp.last.xz rootdir/var/log/apt/edsp.last.xz.1
66 rm -f "$APT_EDSP_DUMP_FILENAME"
67
68 testsuccessequal 'Reading package lists...
69 Building dependency tree...
70 Execute external solver...
71 The following NEW packages will be installed:
72 coolstuff
73 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
74 Inst coolstuff (3 experimental [amd64])
75 Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff -s -t experimental
76 testfailure cmp rootdir/var/log/apt/edsp.last.xz rootdir/var/log/apt/edsp.last.xz.1
77
78 testsuccessequal "Reading package lists...
79 Building dependency tree...
80 Selected version '3' (experimental [amd64]) for 'coolstuff'
81 Execute external solver...
82 The following NEW packages will be installed:
83 coolstuff
84 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
85 Inst coolstuff (3 experimental [amd64])
86 Conf coolstuff (3 experimental [amd64])" aptget install --solver apt coolstuff/experimental -sq=0
87
88 testsuccessequal 'Reading package lists...
89 Building dependency tree...
90 Execute external solver...
91 The following NEW packages will be installed:
92 coolstuff
93 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
94 Inst coolstuff (3 experimental [amd64])
95 Conf coolstuff (3 experimental [amd64])' aptget install --solver apt coolstuff=3 -sq=0
96
97 testsuccessequal 'Reading package lists...
98 Building dependency tree...
99 Execute external solver...
100 The following packages will be REMOVED:
101 somestuff
102 0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded.
103 Remv somestuff [1]' aptget autoremove --solver apt somestuff -s
104 testsuccess aptmark auto cool stuff
105 testsuccessequal 'Reading package lists...
106 Building dependency tree...
107 Reading state information...
108 Execute external solver...
109 The following packages will be REMOVED:
110 cool somestuff stuff
111 0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
112 Remv somestuff [1]
113 Remv cool [1]
114 Remv stuff [1]' aptget autoremove --solver apt somestuff -s
115
116 AUTOREMOVE='apt autoremove'
117 if [ -n "$SUDO_USER" ]; then
118 AUTOREMOVE="sudo $AUTOREMOVE"
119 fi
120 testsuccessequal "Reading package lists...
121 Building dependency tree...
122 Reading state information...
123 Execute external solver...
124 The following package was automatically installed and is no longer required:
125 stuff
126 Use '$AUTOREMOVE' to remove it.
127 The following packages will be REMOVED:
128 cool* somestuff*
129 0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
130 Purg somestuff [1]
131 Purg cool [1]" aptget purge --solver apt cool -s
132
133 testsuccess aptget install awesomecoolstuff:i386 -s
134 testsuccess aptget install --solver apt awesomecoolstuff:i386 -s
135
136 rm -f "$APT_EDSP_DUMP_FILENAME"
137 testfailure aptget install --solver dump awesomecoolstuff:i386 -s
138 testsuccess test -s "$APT_EDSP_DUMP_FILENAME"
139 testequal 'Install: awesomecoolstuff:i386' grep :i386 "$APT_EDSP_DUMP_FILENAME"
140 testfailure grep -e ':amd64' -e 'Architecture: any' "$APT_EDSP_DUMP_FILENAME"
141
142 testsuccess aptget dist-upgrade -s
143 testsuccess aptget dist-upgrade -s --solver apt
144
145 testsuccess aptget upgrade -s
146 testsuccess aptget upgrade -s --solver apt
147
148 testfailure aptget install awesome badstuff -s
149 testfailure aptget install awesome badstuff -s --solver apt
150 testsuccess grep 'ERR_UNSOLVABLE' rootdir/tmp/testfailure.output
151 msgtest 'A resolving error is format as' 'valid parseable EDSP error'
152 if dpkg-checkbuilddeps -d 'dctrl-tools' /dev/null >/dev/null 2>&1; then
153 if apthelper cat-file rootdir/var/log/apt/edsp.last.xz | aptinternalsolver > solver.result 2>&1; then
154 testsuccess --nomsg grep-dctrl -FError ERR -- solver.result
155 else
156 msgfail
157 fi
158 else
159 msgskip 'dctrl-tools not installed'
160 fi
161 configarchitecture 'armel'
162 testfailure aptget install --solver apt awesomecoolstuff:i386 -s
163 msgtest 'An invalid EDSP file generates a' 'hard error'
164 if printf "%b\n" "Request: This is a test\nFoo: bar\n\n" | aptinternalsolver > solver.result 2>&1; then
165 cat solver.result
166 msgfail
167 else
168 msgpass
169 fi
170 msgtest 'Test direct calling is okay for' 'apt-internal-solver'
171 cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
172 if [ "$(tail -n2 solver.result | head -n1 )" = "Message: Done" ]; then
173 msgpass
174 else
175 cat solver.result
176 msgfail
177 fi
178 testsuccess grep '^APT-ID: 1$' "$APT_EDSP_DUMP_FILENAME"
179 sed -i -e 's#^APT-ID: 1$#APT-ID: 10000#' "$APT_EDSP_DUMP_FILENAME"
180 cat "$APT_EDSP_DUMP_FILENAME" | aptinternalsolver > solver.result 2>&1 || true
181 testsuccessequal 'Message: Done
182 ' tail -n2 solver.result
183 rm -f "$APT_EDSP_DUMP_FILENAME"
184
185 testsuccess aptinternalsolver scenario
186 testsuccessequal 'Package: stuff
187 Architecture: all
188 Version: 3
189 APT-ID: 1
190 Multi-Arch: foreign
191 Source: stuff
192 Source-Version: 3
193 Priority: optional
194 Section: other
195 APT-Release:
196 a=experimental,n=experimental,c=main,b=all
197 APT-Pin: 1
198
199 Package: stuff
200 Architecture: all
201 Version: 2
202 APT-ID: 3
203 Multi-Arch: foreign
204 Source: stuff
205 Source-Version: 2
206 Priority: optional
207 Section: other
208 APT-Release:
209 a=unstable,n=sid,c=main,b=all
210 APT-Pin: 500
211 APT-Candidate: yes
212
213 Package: stuff
214 Architecture: all
215 Version: 1
216 APT-ID: 8
217 Source: stuff
218 Source-Version: 1
219 Priority: optional
220 Section: other
221 Installed: yes
222 APT-Pin: 100
223 ' aptinternalsolver scenario stuff
224
225 cat > rootdir/usr/lib/apt/solvers/explicitremove << EOF
226 #!/bin/sh
227 set -e
228 while read line; do
229 if [ "APT-ID" = "\${line%:*}" ]; then
230 cat << APT
231 Install: \${line#*:}
232
233 Remove: \${line#*:}
234
235 APT
236 fi
237 done
238 EOF
239 chmod +x rootdir/usr/lib/apt/solvers/explicitremove
240 testfailure apt full-upgrade -s --solver explicitremove
241 testsuccess grep 'had a previous stanza' rootdir/tmp/testfailure.output
242
243 cat > rootdir/usr/lib/apt/solvers/removeall << EOF
244 #!/bin/sh
245 set -e
246 while read line; do
247 if [ "APT-ID" = "\${line%:*}" ]; then
248 cat << APT
249 Remove: \${line#*:}
250
251 APT
252 fi
253 done
254 EOF
255 chmod +x rootdir/usr/lib/apt/solvers/removeall
256 testwarning apt full-upgrade -s --solver removeall
257 testsuccess grep "which isn't installed!" rootdir/tmp/testwarning.output
258
259 cat > rootdir/usr/lib/apt/solvers/installall << EOF
260 #!/bin/sh
261 set -e
262 while read line; do
263 if [ "APT-ID" = "\${line%:*}" ]; then
264 cat << APT
265 Install: \${line#*:}
266
267 APT
268 fi
269 done
270 EOF
271 chmod +x rootdir/usr/lib/apt/solvers/installall
272 testfailure apt full-upgrade -s --solver installall
273 testsuccess grep "is already installed!" rootdir/tmp/testfailure.output
274
275 testsolverfailuremsg() {
276 local SOLVER="rootdir/usr/lib/apt/solvers/$1"
277 echo "$2" > "$SOLVER"
278 chmod +x "$SOLVER"
279 testfailuremsg "$3" apt full-upgrade -s --solver $1
280 }
281
282 testsolverfailuremsg 'exit0withmsg' "#!/bin/sh
283 echo 'Error: instant-exit
284 Message: This solver exits instantly'
285 exit 0" 'E: External solver failed with: This solver exits instantly'
286
287 testsolverfailuremsg 'exit1withoutmsg' "#!/bin/sh
288 exit 1" 'E: Sub-process exit1withoutmsg returned an error code (1)'
289
290 testsolverfailuremsg 'exit1withmsg' "#!/bin/sh
291 echo 'Error: instant-exit
292 Message: This solver exits instantly'
293 exit 1" 'E: External solver failed with: This solver exits instantly
294 E: Sub-process exit1withmsg returned an error code (1)'