blob: 6ee39077aa12b107b99d3f0bec3bc4fd8e091cb0 (
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
#!/bin/sh
set -e
TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework
setupenvironment
configarchitecture "i386"
buildaptarchive
setupflataptarchive
STATUS=$(readlink -f rootdir/var/lib/dpkg/status)
APTARCHIVE=$(readlink -f aptarchive)
tmppath=$(readlink -f .)
testequalpolicy() {
local SP="$1"
local AP="$2"
shift 2
testequal "Package files:
$(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS}
release a=now
$(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ Packages
release c=
Pinned packages:" aptcache policy $*
}
aptgetupdate() {
# just to be sure that no old files are used
rm -rf rootdir/var/lib/apt
if aptget update -qq 2>&1 | grep '^E: '; then
msgwarn 'apt-get update failed with an error'
fi
}
### not signed archive
aptgetupdate
testequalpolicy 100 500
testequalpolicy 990 500 -t now
sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
aptgetupdate
testequalpolicy 100 1 -o Test=NotAutomatic
testequalpolicy 990 1 -o Test=NotAutomatic -t now
sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
aptgetupdate
testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
aptgetupdate
testequalpolicy 100 500 -o Test=Automatic
testequalpolicy 990 500 -o Test=Automatic -t now
sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d'
### signed but no key in trusted
signreleasefiles 'Marvin Paranoid'
aptgetupdate
testequalpolicy 100 500
testequalpolicy 990 500 -t now
sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
signreleasefiles 'Marvin Paranoid'
aptgetupdate
testequalpolicy 100 1 -o Test=NotAutomatic
testequalpolicy 990 1 -o Test=NotAutomatic -t now
sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
signreleasefiles 'Marvin Paranoid'
aptgetupdate
testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
signreleasefiles 'Marvin Paranoid'
aptgetupdate
testequalpolicy 100 500 -o Test=Automatic
testequalpolicy 990 500 -o Test=Automatic -t now
### signed and valid key
buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
setupaptarchive
testequalpolicycoolstuff() {
local INSTALLED="${1:-(none)}"
local CANDIDATE="${2:-(none)}"
local AB="$3"
local AS="$4"
local PB="$5"
local PINVERSION="$6"
if [ -n "$PINVERSION" ]; then
PINVERSION="Package pin: $PINVERSION
"
fi
local IS=""
local IB=""
local SB=""
local SS=""
[ "$1" = "2.0~bpo1" ] && IB="***" && SB="
100 $STATUS" || IB=" "
[ "$1" = "1.0" ] && IS="***" && SS="
100 $STATUS" || IS=" "
local BPO1ARCHIVE=""
local BPO2ARCHIVE=""
if [ ! "$7" = "2.0~bpo2" ]; then
BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
else
BPO2ARCHIVE="
2.0~bpo2 $PB
$(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
SB="$(echo "$SB" | tail -n 1)"
shift
fi
shift 6
testequal "coolstuff:
Installed: $INSTALLED
Candidate: $CANDIDATE
${PINVERSION}Version table:${BPO2ARCHIVE}
$IB 2.0~bpo1 $PB
${BPO1ARCHIVE}$SB
$IS 1.0 $PB
$(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ stable/main i386 Packages$SS" \
aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
}
testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
echo "Package: *
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
echo "Package: *
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
#FIXME: policy can't differentiate between two sources where one has a package specific pin in place
# testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
# testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: -1" > rootdir/etc/apt/preferences
# testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
# testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
# testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
rm rootdir/etc/apt/preferences
sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
signreleasefiles
aptgetupdate
testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
echo "Package: *
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
echo "Package: *
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
rm rootdir/etc/apt/preferences
sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
signreleasefiles
aptgetupdate
testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
echo "Package: *
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
echo "Package: *
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 200" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 600" > rootdir/etc/apt/preferences
testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
rm rootdir/etc/apt/preferences
testsuccess aptget install coolstuff -y
testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
testsuccess aptget dist-upgrade -y
testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
testsuccess aptget install coolstuff -t backports -y
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
testsuccess aptget dist-upgrade -y
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
rm incoming/backports.main.pkglist incoming/backports.main.srclist
buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
setupaptarchive
sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
signreleasefiles
aptgetupdate
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
signreleasefiles
aptgetupdate
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports
msgmsg "Check that short-max/min is a valid pin"
currentpin() {
echo "Package: *
Pin: release n=backports
Pin-Priority: $1
" > rootdir/etc/apt/preferences
testsuccessequal "coolstuff:
Installed: 2.0~bpo1
Candidate: ${2}
Version table:
2.0~bpo2 0
${3:-$1} file:${tmppath}/aptarchive/ backports/main i386 Packages
*** 2.0~bpo1 0
100 ${tmppath}/rootdir/var/lib/dpkg/status
1.0 0
500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff
}
currentpin '32767' '2.0~bpo2'
currentpin '-32768' '2.0~bpo1' '-32767'
currentpin '-32767' '2.0~bpo1' '-32767'
msgmsg "Check for override pins"
msgmsg "Normal pins: First one wins"
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 990
Package: coolstuff
Pin: release n=backports
Pin-Priority: 991
" > rootdir/etc/apt/preferences
testsuccessequal "coolstuff:
Installed: 2.0~bpo1
Candidate: 2.0~bpo2
Package pin: 2.0~bpo2
Version table:
2.0~bpo2 990
100 file:${tmppath}/aptarchive/ backports/main i386 Packages
*** 2.0~bpo1 990
100 ${tmppath}/rootdir/var/lib/dpkg/status
1.0 990
500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff
msgmsg "Never pins: Never wins over package-specific"
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: 990
Package: *
Pin: release n=backports
Pin-Priority: never
" > rootdir/etc/apt/preferences
testsuccessequal "coolstuff:
Installed: 2.0~bpo1
Candidate: 2.0~bpo1
Package pin: 2.0~bpo2
Version table:
2.0~bpo2 990
-32768 file:${tmppath}/aptarchive/ backports/main i386 Packages
*** 2.0~bpo1 990
100 ${tmppath}/rootdir/var/lib/dpkg/status
1.0 990
500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff
msgmsg "Never pins: Never wins over other"
echo "Package: *
Pin: release n=backports
Pin-Priority: 990
Package: *
Pin: release n=backports
Pin-Priority: never
" > rootdir/etc/apt/preferences
testsuccessequal "coolstuff:
Installed: 2.0~bpo1
Candidate: 2.0~bpo1
Version table:
2.0~bpo2 0
-32768 file:${tmppath}/aptarchive/ backports/main i386 Packages
*** 2.0~bpo1 0
100 ${tmppath}/rootdir/var/lib/dpkg/status
1.0 0
500 file:${tmppath}/aptarchive/ stable/main i386 Packages" aptcache policy coolstuff
msgmsg "Check for package-specific never pin"
echo "Package: coolstuff
Pin: release n=backports
Pin-Priority: never
" > rootdir/etc/apt/preferences
testfailureequal "Reading package lists...
E: ${tmppath}/rootdir/etc/apt/preferences: The special 'Pin-Priority: never' can only be used for 'Package: *' records" \
aptget install -s coolstuff -o PinPriority=0
|