summaryrefslogtreecommitdiffstats
path: root/test/integration/test-apt-patterns
blob: 85370aee8c205545bf6b9fc5b1c6cca49590d7c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/bin/sh
TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configarchitecture 'i386' 'amd64'

insertpackage 'unstable' 'available' 'all' '1.0' 'Section: asection'

insertinstalledpackage 'manual1' 'i386' '1.0' 'Depends: automatic1'
insertinstalledpackage 'manual2' 'i386' '1.0'

insertinstalledpackage 'automatic1' 'i386' '1.0' 'Source: automatic (0)'
insertinstalledpackage 'automatic2' 'i386' '1.0' 'Source: automatic (1)'

insertinstalledpackage 'essential' 'i386' '1.0' 'Essential: yes
Section: asection'
insertinstalledpackage 'required' 'i386' '1.0' 'Priority: required'
insertinstalledpackage 'conf-only' 'i386' '1.0' '' '' 'deinstall ok config-files'
insertinstalledpackage 'broken' 'i386' '1.0' 'Depends: does-not-exist'

insertinstalledpackage 'not-obsolete' 'i386' '1.0'
insertpackage 'unstable' 'not-obsolete' 'all' '2.0'

insertpackage 'unstable' 'foreign' 'amd64' '2.0'

getoriginfromsuite() { echo -n 'meow'; }
setupaptarchive

cat >> rootdir/var/lib/dpkg/status <<EOF

Package: notinstalled
Status: hold ok not-installed
Architecture: amd64

Package: nosection
Status: install ok installed
Architecture: amd64
Version: 29
EOF

testsuccess aptmark auto automatic1 automatic2

msgmsg "Check that commands understand patterns"

testfailureequal "E: input:0-14: error: Unrecognized pattern '?not-a-pattern'
   ?not-a-pattern
   ^^^^^^^^^^^^^^
N: Unable to locate package ?not-a-pattern
E: input:0-14: error: Unrecognized pattern '?not-a-pattern'
   ?not-a-pattern
   ^^^^^^^^^^^^^^
N: Unable to locate package ?not-a-pattern
E: No packages found" apt show '?not-a-pattern'

testfailureequal "Listing...
E: input:0-14: error: Unrecognized pattern '?not-a-pattern'
   ?not-a-pattern
   ^^^^^^^^^^^^^^" apt list '?not-a-pattern'

testfailureequal "Reading package lists...
Building dependency tree...
Reading state information...
E: input:0-14: error: Unrecognized pattern '?not-a-pattern'
   ?not-a-pattern
   ^^^^^^^^^^^^^^
E: Unable to locate package ?not-a-pattern" apt install -s '?not-a-pattern'


msgmsg "Ensure that argument lists are present where needed, and absent elsewhere"

testfailureequal "Listing...
E: input:0-7: error: ?true does not expect an argument list
   ?true()
   ^^^^^^^"  apt list '?true()'
testfailureequal "Listing...
E: input:0-4: error: ?and expects an argument list
   ?and
   ^^^^" apt list '?and'
testfailureequal "Listing...
E: input:0-3: error: ?or expects an argument list
   ?or
   ^^^" apt list '?or'


msgmsg "Basic logic: true, false, not, ?or, ?and"
for pattern in '?true' '?not(?false)'; do
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]
available/unstable 1.0 all
broken/now 1.0 i386 [installed,local]
conf-only/now 1.0 i386 [residual-config]
essential/now 1.0 i386 [installed,local]
foreign/unstable 2.0 amd64
manual1/now 1.0 i386 [installed,local]
manual2/now 1.0 i386 [installed,local]
nosection/now 29 amd64 [installed,local]
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
required/now 1.0 i386 [installed,local]" apt list "$pattern"
done
testsuccessequal "Listing..." apt list '?false'
testsuccessequal "Listing..." apt list '?not(?true)'
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]
manual1/now 1.0 i386 [installed,local]
manual2/now 1.0 i386 [installed,local]" apt list '?or(?name(^automatic),?name(^manual))'
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]" apt list '?and(?name(^automatic),?name(1$))'


msgmsg "Narrow and friends"
testsuccessequal "Listing...
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?and(?version(^1\.0$),?version(^2\.0$))'

testsuccessequal "Listing..." apt list '?any-version(?and(?version(^1\.0$),?version(^2\.0$)))'
testsuccessequal "Listing..." apt list '?narrow(?version(^1\.0$),?version(^2\.0$))'

# XXX FIXME: I guess we do want this to only show version 1.0?
testsuccessequal "Listing...
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?any-version(?and(?version(^1\.0$),?name(not-obsolete)))'
testsuccessequal "Listing...
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?narrow(?version(^1\.0$),?name(not-obsolete))'


testsuccessequal "Listing...
foreign/unstable 2.0 amd64
nosection/now 29 amd64 [installed,local]
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?not(?all-versions(?version(^1)))'

msgmsg "Package patterns"

testsuccessequal "Listing...
foreign/unstable 2.0 amd64
nosection/now 29 amd64 [installed,local]" apt list '?architecture(amd64)'

# XXX FIXME We should have support for foreign and native
testsuccessequal "Listing..." apt list '?architecture(foreign)'
testsuccessequal "Listing..." apt list '?architecture(native)'

testsuccessequal "Listing...
available/unstable 1.0 all
foreign/unstable 2.0 amd64
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?archive(^unstable$)'

testsuccessequal "Listing...
available/unstable 1.0 all
foreign/unstable 2.0 amd64
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?codename(^sid$)'

testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list '?automatic'

testsuccessequal "Listing...
broken/now 1.0 i386 [installed,local]" apt list '?broken'

testsuccessequal "Listing...
conf-only/now 1.0 i386 [residual-config]" apt list '?config-files'

testsuccessequal "Listing...
essential/now 1.0 i386 [installed,local]" apt list '?essential'

testsuccessequal "Listing...
required/now 1.0 i386 [installed,local]" apt list '?priority(required)'

testsuccessequal "Listing..." apt list '?exact-name(automatic)'
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]" apt list '?exact-name(automatic1)'

testsuccessequal "Listing...
automatic2/now 1.0 i386 [installed,local]" apt list '?garbage'

testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]
broken/now 1.0 i386 [installed,local]
essential/now 1.0 i386 [installed,local]
manual1/now 1.0 i386 [installed,local]
manual2/now 1.0 i386 [installed,local]
nosection/now 29 amd64 [installed,local]
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
required/now 1.0 i386 [installed,local]" apt list '?installed'

testsuccessequal "Listing...
available/unstable 1.0 all
conf-only/now 1.0 i386 [residual-config]
foreign/unstable 2.0 amd64" apt list '?not(?installed)'

testsuccessequal "Listing...
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?installed?exact-name(not-obsolete)?version(2.0)'

testsuccessequal "Listing..." apt list '?narrow(?installed?exact-name(not-obsolete)?version(2.0))'

testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list '?name(^automatic)'

testsuccessequal "Listing...
available/unstable 1.0 all
conf-only/now 1.0 i386 [residual-config]
foreign/unstable 2.0 amd64
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?not(?obsolete)'

testsuccessequal "Listing...
available/unstable 1.0 all
foreign/unstable 2.0 amd64
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?origin(^meow$)'

testsuccessequal "Listing...
available/unstable 1.0 all
essential/now 1.0 i386 [installed,local]" apt list '?section(asection)'

testsuccessequal 'Listing...
essential/now 1.0 i386 [installed,local]' apt list '~i !~M (~slibs|~sasection)'

testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list '?source-package(^automatic$)'

testsuccessequal "Listing...
automatic2/now 1.0 i386 [installed,local]" apt list '?source-version(^1$)'

testsuccessequal "Listing...
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]
N: There is 1 additional version. Please use the '-a' switch to see it" apt list '?upgradable'

testsuccessequal "Listing...
foreign/unstable 2.0 amd64
not-obsolete/unstable 2.0 i386 [upgradable from: 1.0]" apt list '?version(2.0)'

testsuccessequal "Package: does-not-exist
State: not a real package (virtual)
Package: notinstalled:amd64
State: not a real package (virtual)
N: Can't select candidate version from package does-not-exist as it has no candidate
N: Can't select candidate version from package notinstalled:amd64 as it has no candidate
N: Can't select versions from package 'does-not-exist' as it is purely virtual
N: Can't select versions from package 'notinstalled:amd64' as it is purely virtual
N: No packages found" apt show '?virtual'

testsuccessequal "Listing..." apt list '?x-name-fnmatch(1)'
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
manual1/now 1.0 i386 [installed,local]" apt list '?x-name-fnmatch(*1)'


# * wildcards should still work
testsuccessequal "Listing...
automatic1/now 1.0 i386 [installed,local]
automatic2/now 1.0 i386 [installed,local]" apt list 'automatic*'

testfailureequal "Reading package lists...
Building dependency tree...
Reading state information...
Note, selecting 'automatic1' for glob 'automatic*'
Note, selecting 'automatic2' for glob 'automatic*'
automatic1 is already the newest version (1.0).
automatic1 set to manually installed.
automatic2 is already the newest version (1.0).
automatic2 set to manually installed.
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 broken : Depends: does-not-exist but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)." apt install -s 'automatic*'

# other wildcards should fail

testfailureequal "Listing...
E: input:0-10: error: Expected pattern
   automatic?
   ^^^^^^^^^^" apt list 'automatic?'



testfailureequal "Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package automatic?" apt install -s 'automatic?'