]>
Commit | Line | Data |
---|---|---|
5ed56f93 DK |
1 | #!/bin/sh |
2 | set -e | |
3 | ||
9962ae93 | 4 | TESTDIR=$(readlink -f $(dirname $0)) |
5ed56f93 DK |
5 | . $TESTDIR/framework |
6 | ||
7 | setupenvironment | |
8 | configarchitecture "i386" | |
9 | ||
10 | buildaptarchive | |
11 | setupflataptarchive | |
12 | ||
13 | STATUS=$(readlink -f rootdir/var/lib/dpkg/status) | |
14 | APTARCHIVE=$(readlink -f aptarchive) | |
15 | ||
16 | testequalpolicy() { | |
17 | local SP="$1" | |
18 | local AP="$2" | |
19 | shift 2 | |
25b86db1 | 20 | testsuccessequal "Package files: |
5ed56f93 DK |
21 | $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS} |
22 | release a=now | |
1da3b7b8 | 23 | $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} Packages |
5ed56f93 | 24 | release c= |
b07aeb1a | 25 | Pinned packages:" aptcache policy "$@" |
5ed56f93 DK |
26 | } |
27 | ||
3f732aa6 DK |
28 | testglobalpolicy() { |
29 | aptgetupdate | |
5ed56f93 | 30 | |
3f732aa6 DK |
31 | testequalpolicy 100 500 |
32 | testequalpolicy 990 500 -t now | |
5ed56f93 | 33 | |
3f732aa6 DK |
34 | sed -i aptarchive/Release -e 1i"NotAutomatic: yes" |
35 | aptgetupdate | |
5ed56f93 | 36 | |
3f732aa6 DK |
37 | testequalpolicy 100 1 -o Test=NotAutomatic |
38 | testequalpolicy 990 1 -o Test=NotAutomatic -t now | |
451ea3d4 | 39 | |
3f732aa6 DK |
40 | sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes" |
41 | aptgetupdate | |
451ea3d4 | 42 | |
3f732aa6 DK |
43 | testequalpolicy 100 100 -o Test=ButAutomaticUpgrades |
44 | testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now | |
451ea3d4 | 45 | |
3f732aa6 DK |
46 | sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d' |
47 | aptgetupdate | |
451ea3d4 | 48 | |
3f732aa6 DK |
49 | testequalpolicy 100 500 -o Test=Automatic |
50 | testequalpolicy 990 500 -o Test=Automatic -t now | |
451ea3d4 | 51 | |
3f732aa6 DK |
52 | sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d' |
53 | } | |
451ea3d4 | 54 | |
3f732aa6 DK |
55 | msgmsg 'Test with not signed archive' |
56 | aptgetupdate() { | |
57 | rm -rf rootdir/var/lib/apt | |
58 | testwarning aptget update --allow-insecure-repositories | |
59 | } | |
60 | testglobalpolicy | |
451ea3d4 | 61 | |
3f732aa6 DK |
62 | msgmsg 'Test with signed but no key in trusted' |
63 | aptgetupdate() { | |
64 | rm -rf rootdir/var/lib/apt | |
65 | signreleasefiles 'Marvin Paranoid' | |
66 | testwarning aptget update --allow-insecure-repositories | |
67 | } | |
68 | testglobalpolicy | |
451ea3d4 | 69 | |
3f732aa6 DK |
70 | # much the same tests will be executed below in more detail again for this one |
71 | msgmsg 'Test with signed and valid key' | |
72 | aptgetupdate() { | |
73 | rm -rf rootdir/var/lib/apt | |
74 | signreleasefiles 'Joe Sixpack' | |
75 | testsuccess aptget update | |
76 | } | |
77 | testglobalpolicy | |
451ea3d4 | 78 | |
3f732aa6 | 79 | msgmsg 'Test with specific packages' |
451ea3d4 | 80 | |
5ed56f93 DK |
81 | buildsimplenativepackage "coolstuff" "all" "1.0" "stable" |
82 | buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports" | |
83 | ||
84 | setupaptarchive | |
85 | ||
27e4c166 DK |
86 | testsuccessequal "coolstuff: |
87 | Installed: (none) | |
88 | Candidate: 2.0~bpo1 | |
89 | Version table: | |
90 | 2.0~bpo1 500 | |
91 | 500 file:${APTARCHIVE} backports/main all Packages | |
92 | 1.0 500 | |
93 | 500 file:${APTARCHIVE} stable/main all Packages" apt policy '^cool.*' | |
94 | ||
5ed56f93 DK |
95 | testequalpolicycoolstuff() { |
96 | local INSTALLED="${1:-(none)}" | |
97 | local CANDIDATE="${2:-(none)}" | |
98 | local AB="$3" | |
99 | local AS="$4" | |
100 | local PB="$5" | |
5ed56f93 DK |
101 | local IS="" |
102 | local IB="" | |
103 | local SB="" | |
104 | local SS="" | |
105 | [ "$1" = "2.0~bpo1" ] && IB="***" && SB=" | |
106 | 100 $STATUS" || IB=" " | |
107 | [ "$1" = "1.0" ] && IS="***" && SS=" | |
108 | 100 $STATUS" || IS=" " | |
109 | local BPO1ARCHIVE="" | |
110 | local BPO2ARCHIVE="" | |
111 | if [ ! "$7" = "2.0~bpo2" ]; then | |
76b004d1 | 112 | BPO1PIN="$AB" |
1dd20368 | 113 | BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main all Packages" |
5ed56f93 DK |
114 | else |
115 | BPO2ARCHIVE=" | |
76b004d1 | 116 | 2.0~bpo2 $AB |
1dd20368 | 117 | $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main all Packages" |
5ed56f93 DK |
118 | SB="$(echo "$SB" | tail -n 1)" |
119 | shift | |
120 | fi | |
121 | shift 6 | |
25b86db1 | 122 | testsuccessequal "coolstuff: |
5ed56f93 DK |
123 | Installed: $INSTALLED |
124 | Candidate: $CANDIDATE | |
bb08e204 | 125 | Version table:${BPO2ARCHIVE} |
5ed56f93 DK |
126 | $IB 2.0~bpo1 $PB |
127 | ${BPO1ARCHIVE}$SB | |
76b004d1 | 128 | $IS 1.0 $AS |
1dd20368 | 129 | $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main all Packages$SS" \ |
5ed56f93 DK |
130 | aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $* |
131 | } | |
132 | ||
76b004d1 JAK |
133 | testequalpolicycoolstuff "" "2.0~bpo1" 500 500 500 "" |
134 | testequalpolicycoolstuff "" "1.0" 500 990 500 "" -t stable | |
135 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -t backports | |
5ed56f93 DK |
136 | echo "Package: * |
137 | Pin: release n=backports | |
138 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
76b004d1 JAK |
139 | testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=GlobalPin |
140 | testequalpolicycoolstuff "" "1.0" 200 990 200 "" -o Test=GlobalPin -t stable | |
141 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=GlobalPin -t backports | |
5ed56f93 DK |
142 | echo "Package: * |
143 | Pin: release n=backports | |
144 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
76b004d1 JAK |
145 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=GlobalPin |
146 | testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=GlobalPin -t stable | |
5ed56f93 DK |
147 | echo "Package: coolstuff |
148 | Pin: release n=backports | |
149 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
150 | #FIXME: policy can't differentiate between two sources where one has a package specific pin in place | |
151 | # testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin | |
152 | # testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports | |
153 | testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable | |
154 | echo "Package: coolstuff | |
155 | Pin: release n=backports | |
156 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
157 | testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin | |
158 | testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable | |
159 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports | |
160 | ||
161 | echo "Package: coolstuff | |
162 | Pin: release n=backports | |
163 | Pin-Priority: -1" > rootdir/etc/apt/preferences | |
164 | # testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin | |
165 | # testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports | |
166 | # testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable | |
167 | ||
168 | rm rootdir/etc/apt/preferences | |
169 | sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" | |
170 | signreleasefiles | |
451ea3d4 | 171 | aptgetupdate |
5ed56f93 | 172 | |
76b004d1 JAK |
173 | testequalpolicycoolstuff "" "1.0" 1 500 1 "" -o Test=NotAutomatic |
174 | testequalpolicycoolstuff "" "1.0" 1 990 1 "" -o Test=NotAutomatic -t stable | |
175 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=NotAutomatic -t backports | |
5ed56f93 DK |
176 | echo "Package: * |
177 | Pin: release n=backports | |
178 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
76b004d1 | 179 | testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=NotAutomatic |
5ed56f93 DK |
180 | echo "Package: * |
181 | Pin: release n=backports | |
182 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
76b004d1 JAK |
183 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=NotAutomatic |
184 | testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=NotAutomatic -t stable | |
5ed56f93 DK |
185 | echo "Package: coolstuff |
186 | Pin: release n=backports | |
187 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
188 | testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic | |
189 | echo "Package: coolstuff | |
190 | Pin: release n=backports | |
191 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
192 | testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic | |
193 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports | |
194 | testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable | |
195 | ||
196 | rm rootdir/etc/apt/preferences | |
197 | sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" | |
198 | signreleasefiles | |
451ea3d4 | 199 | aptgetupdate |
5ed56f93 | 200 | |
76b004d1 JAK |
201 | testequalpolicycoolstuff "" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades |
202 | testequalpolicycoolstuff "" "1.0" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable | |
203 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports | |
5ed56f93 DK |
204 | echo "Package: * |
205 | Pin: release n=backports | |
206 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
76b004d1 | 207 | testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=ButAutomaticUpgrades |
5ed56f93 DK |
208 | echo "Package: * |
209 | Pin: release n=backports | |
210 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
76b004d1 JAK |
211 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=ButAutomaticUpgrades |
212 | testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=ButAutomaticUpgrades -t stable | |
5ed56f93 DK |
213 | echo "Package: coolstuff |
214 | Pin: release n=backports | |
215 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
216 | testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades | |
217 | echo "Package: coolstuff | |
218 | Pin: release n=backports | |
219 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
220 | testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades | |
221 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports | |
222 | testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable | |
223 | ||
224 | rm rootdir/etc/apt/preferences | |
0440d936 | 225 | testsuccess aptget install coolstuff -y |
76b004d1 | 226 | testequalpolicycoolstuff "1.0" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades |
0440d936 | 227 | testsuccess aptget dist-upgrade -y |
76b004d1 JAK |
228 | testequalpolicycoolstuff "1.0" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades |
229 | testequalpolicycoolstuff "1.0" "1.0" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable | |
230 | testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports | |
5ed56f93 | 231 | |
0440d936 | 232 | testsuccess aptget install coolstuff -t backports -y |
76b004d1 | 233 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test=ButAutomaticUpgrades |
0440d936 | 234 | testsuccess aptget dist-upgrade -y |
76b004d1 JAK |
235 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test=ButAutomaticUpgrades |
236 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable | |
237 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports | |
5ed56f93 DK |
238 | |
239 | rm incoming/backports.main.pkglist incoming/backports.main.srclist | |
240 | buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports" | |
241 | setupaptarchive | |
242 | ||
243 | sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" | |
244 | signreleasefiles | |
451ea3d4 | 245 | aptgetupdate |
5ed56f93 | 246 | |
76b004d1 JAK |
247 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 100 "" "2.0~bpo2" -o Test=NotAutomatic |
248 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 100 "" "2.0~bpo2" -o Test=NotAutomatic -t stable | |
249 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test=NotAutomatic -t backports | |
5ed56f93 DK |
250 | |
251 | sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" | |
252 | signreleasefiles | |
451ea3d4 | 253 | aptgetupdate |
5ed56f93 | 254 | |
76b004d1 JAK |
255 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades |
256 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable | |
257 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports | |
e916a815 JAK |
258 | |
259 | ||
260 | tmppath=$(readlink -f .) | |
261 | ||
262 | # Check 16-bit integers | |
263 | echo "Package: coolstuff | |
264 | Pin: release n=backports | |
265 | Pin-Priority: 32767 | |
266 | " > rootdir/etc/apt/preferences | |
267 | ||
268 | testsuccess aptget install -s coolstuff -o PinPriority=32767 | |
269 | ||
270 | echo "Package: coolstuff | |
271 | Pin: release n=backports | |
272 | Pin-Priority: -32768 | |
273 | " > rootdir/etc/apt/preferences | |
274 | testsuccess aptget install -s coolstuff -o PinPriority=-32768 | |
275 | ||
276 | ||
277 | # Check for 32-bit integers | |
278 | echo "Package: coolstuff | |
279 | Pin: release n=backports | |
280 | Pin-Priority: 32768 | |
281 | " > rootdir/etc/apt/preferences | |
282 | ||
283 | testfailureequal "Reading package lists... | |
284 | E: ${tmppath}/rootdir/etc/apt/preferences: Value 32768 is outside the range of valid pin priorities (-32768 to 32767)" \ | |
285 | aptget install -s coolstuff -o PinPriority=32768 | |
286 | ||
287 | ||
288 | echo "Package: coolstuff | |
289 | Pin: release n=backports | |
290 | Pin-Priority: -32769 | |
291 | " > rootdir/etc/apt/preferences | |
292 | ||
293 | testfailureequal "Reading package lists... | |
294 | E: ${tmppath}/rootdir/etc/apt/preferences: Value -32769 is outside the range of valid pin priorities (-32768 to 32767)" \ | |
295 | aptget install -s coolstuff -o PinPriority=-32769 | |
296 | ||
297 | # Check for 64-bit integers | |
298 | ||
299 | echo "Package: coolstuff | |
300 | Pin: release n=backports | |
301 | Pin-Priority: 2147483648 | |
302 | " > rootdir/etc/apt/preferences | |
303 | ||
304 | testfailureequal "Reading package lists... | |
137e8ad4 | 305 | E: Cannot convert 2147483648 to integer: out of range |
e916a815 JAK |
306 | E: ${tmppath}/rootdir/etc/apt/preferences: Value 2147483648 is outside the range of valid pin priorities (-32768 to 32767)" \ |
307 | aptget install -s coolstuff -o PinPriority=2147483648 | |
308 | ||
309 | # Check for 0 | |
310 | echo "Package: coolstuff | |
311 | Pin: release n=backports | |
312 | Pin-Priority: 0 | |
313 | " > rootdir/etc/apt/preferences | |
314 | ||
315 | testfailureequal "Reading package lists... | |
316 | E: No priority (or zero) specified for pin" \ | |
317 | aptget install -s coolstuff -o PinPriority=0 |