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