4 TESTDIR
="$(readlink -f "$(dirname "$0")")"
8 configarchitecture "i386
"
13 STATUS=$(readlink -f rootdir/var/lib/dpkg/status)
14 APTARCHIVE=$(readlink -f aptarchive)
20 testsuccessequal "Package files
:
21 $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS}
23 $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} Packages
25 Pinned packages
:" aptcache policy "$@
"
31 testequalpolicy 100 500
32 testequalpolicy 990 500 -t now
34 sed -i aptarchive/Release -e 1i"NotAutomatic
: yes"
37 testequalpolicy 100 1 -o Test=NotAutomatic
38 testequalpolicy 990 1 -o Test=NotAutomatic -t now
40 sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades
: yes"
43 testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
44 testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
46 sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
49 testequalpolicy 100 500 -o Test=Automatic
50 testequalpolicy 990 500 -o Test=Automatic -t now
52 sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d'
55 msgmsg 'Test with not signed archive'
57 rm -rf rootdir/var/lib/apt
58 testwarning aptget update --allow-insecure-repositories
62 msgmsg 'Test with signed but no key in trusted'
64 rm -rf rootdir/var/lib/apt
65 signreleasefiles 'Marvin Paranoid'
66 testwarning aptget update --allow-insecure-repositories
70 # much the same tests will be executed below in more detail again for this one
71 msgmsg 'Test with signed and valid key'
73 rm -rf rootdir/var/lib/apt
74 signreleasefiles 'Joe Sixpack'
75 testsuccess aptget update
79 msgmsg 'Test with specific packages'
81 buildsimplenativepackage "coolstuff
" "all
" "1.0" "stable
"
82 buildsimplenativepackage "coolstuff
" "all
" "2.0~bpo1
" "backports
"
86 testsuccessequal "coolstuff
:
91 500 file:${APTARCHIVE} backports
/main all Packages
93 500 file:${APTARCHIVE} stable
/main all Packages
" apt policy '^cool.*'
95 testequalpolicycoolstuff() {
96 local INSTALLED="${1:-(none)}"
97 local CANDIDATE="${2:-(none)}"
105 [ "$1" = "2.0~bpo1
" ] && IB="***" && SB="
106 100 $STATUS" || IB=" "
107 [ "$1" = "1.0" ] && IS="***" && SS="
108 100 $STATUS" || IS=" "
111 if [ ! "$7" = "2.0~bpo2
" ]; then
113 BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main all Packages"
117 $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports
/main all Packages
"
118 SB="$(echo "$SB" | tail -n 1)"
122 testsuccessequal "coolstuff
:
123 Installed
: $INSTALLED
124 Candidate
: $CANDIDATE
125 Version table
:${BPO2ARCHIVE}
129 $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main all Packages$SS" \
130 aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
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
137 Pin: release n=backports
138 Pin-Priority: 200" > rootdir/etc/apt/preferences
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
143 Pin: release n=backports
144 Pin-Priority: 600" > rootdir/etc/apt/preferences
145 testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=GlobalPin
146 testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=GlobalPin -t stable
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
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
168 rm rootdir
/etc
/apt
/preferences
169 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"NotAutomatic: yes"
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
177 Pin: release n=backports
178 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
179 testequalpolicycoolstuff
"" "1.0" 200 500 200 "" -o Test
=NotAutomatic
181 Pin: release n=backports
182 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
183 testequalpolicycoolstuff
"" "2.0~bpo1" 600 500 600 "" -o Test
=NotAutomatic
184 testequalpolicycoolstuff
"" "1.0" 600 990 600 "" -o Test
=NotAutomatic
-t stable
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
196 rm rootdir
/etc
/apt
/preferences
197 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"ButAutomaticUpgrades: yes"
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
205 Pin: release n=backports
206 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
207 testequalpolicycoolstuff
"" "1.0" 200 500 200 "" -o Test
=ButAutomaticUpgrades
209 Pin: release n=backports
210 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
211 testequalpolicycoolstuff
"" "2.0~bpo1" 600 500 600 "" -o Test
=ButAutomaticUpgrades
212 testequalpolicycoolstuff
"" "1.0" 600 990 600 "" -o Test
=ButAutomaticUpgrades
-t stable
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
224 rm rootdir
/etc
/apt
/preferences
225 testsuccess aptget
install coolstuff
-y
226 testequalpolicycoolstuff
"1.0" "1.0" 100 500 100 "" -o Test
=ButAutomaticUpgrades
227 testsuccess aptget dist
-upgrade -y
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
232 testsuccess aptget
install coolstuff
-t backports
-y
233 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test
=ButAutomaticUpgrades
234 testsuccess aptget dist
-upgrade -y
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
239 rm incoming
/backports.main.pkglist incoming
/backports.main.srclist
240 buildsimplenativepackage
"coolstuff" "all" "2.0~bpo2" "backports"
243 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"NotAutomatic: yes"
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
251 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"ButAutomaticUpgrades: yes"
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
260 tmppath
=$(readlink -f .)
262 # Check 16-bit integers
263 echo "Package: coolstuff
264 Pin: release n=backports
266 " > rootdir
/etc
/apt
/preferences
268 testsuccess aptget
install -s coolstuff
-o PinPriority
=32767
270 echo "Package: coolstuff
271 Pin: release n=backports
273 " > rootdir
/etc
/apt
/preferences
274 testsuccess aptget
install -s coolstuff
-o PinPriority
=-32768
276 # Check for 32-bit integers
277 echo "Package: coolstuff
278 Pin: release n=backports
280 " > rootdir
/etc
/apt
/preferences
282 testfailureequal
"Reading package lists...
283 E: ${tmppath}/rootdir/etc/apt/preferences: Value 32768 is outside the range of valid pin priorities (-32768 to 32767)" \
284 aptget
install -s coolstuff
-o PinPriority
=32768
287 echo "Package: coolstuff
288 Pin: release n=backports
290 " > rootdir
/etc
/apt
/preferences
292 testfailureequal
"Reading package lists...
293 E: ${tmppath}/rootdir/etc/apt/preferences: Value -32769 is outside the range of valid pin priorities (-32768 to 32767)" \
294 aptget
install -s coolstuff
-o PinPriority
=-32769
296 # Check for 64-bit integers
298 echo "Package: coolstuff
299 Pin: release n=backports
300 Pin-Priority: 2147483648
301 " > rootdir
/etc
/apt
/preferences
303 testfailureequal
"Reading package lists...
304 E: Cannot convert 2147483648 to integer: out of range
305 E: ${tmppath}/rootdir/etc/apt/preferences: Value 2147483648 is outside the range of valid pin priorities (-32768 to 32767)" \
306 aptget
install -s coolstuff
-o PinPriority
=2147483648
308 # Check that short-max/min is a valid pin
311 Pin: release n=backports
313 " > rootdir
/etc
/apt
/preferences
314 testsuccessequal
"coolstuff:
319 $1 file:${tmppath}/aptarchive backports/main all Packages
321 100 ${tmppath}/rootdir/var/lib/dpkg/status
323 500 file:${tmppath}/aptarchive stable/main all Packages" apt policy coolstuff
325 currentpin
'32767' '2.0~bpo2'
326 currentpin
'-32768' '2.0~bpo1'
329 echo "Package: coolstuff
330 Pin: release n=backports
332 " > rootdir
/etc
/apt
/preferences
334 testfailureequal
"Reading package lists...
335 E: No priority (or zero) specified for pin" \
336 aptget
install -s coolstuff
-o PinPriority
=0
338 # Check with comments
339 echo "#Package: coolstuff
340 #Pin: release n=backports
346 Pin: release n=backports
347 #Pin: release n=unstable
350 #Pin-Priority: 999" > rootdir
/etc
/apt
/preferences
352 testsuccessequal
"coolstuff:
357 100 file:${tmppath}/aptarchive backports/main all Packages
359 100 ${tmppath}/rootdir/var/lib/dpkg/status
361 500 file:${tmppath}/aptarchive stable/main all Packages" aptcache policy coolstuff