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