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 testequalpolicycoolstuff
() {
87 local INSTALLED
="${1:-(none)}"
88 local CANDIDATE
="${2:-(none)}"
96 [ "$1" = "2.0~bpo1" ] && IB
="***" && SB
="
97 100 $STATUS" || IB
=" "
98 [ "$1" = "1.0" ] && IS
="***" && SS
="
99 100 $STATUS" || IS
=" "
102 if [ ! "$7" = "2.0~bpo2" ]; then
104 BPO1ARCHIVE
=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
108 $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
109 SB
="$(echo "$SB" | tail -n 1)"
113 testsuccessequal
"coolstuff:
114 Installed: $INSTALLED
115 Candidate: $CANDIDATE
116 Version table:${BPO2ARCHIVE}
120 $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main i386 Packages$SS" \
121 aptcache policy coolstuff
-o Policy
=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $
*
124 testequalpolicycoolstuff
"" "2.0~bpo1" 500 500 500 ""
125 testequalpolicycoolstuff
"" "1.0" 500 990 500 "" -t stable
126 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 990 "" -t backports
128 Pin: release n=backports
129 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
130 testequalpolicycoolstuff
"" "1.0" 200 500 200 "" -o Test
=GlobalPin
131 testequalpolicycoolstuff
"" "1.0" 200 990 200 "" -o Test
=GlobalPin
-t stable
132 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 990 "" -o Test
=GlobalPin
-t backports
134 Pin: release n=backports
135 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
136 testequalpolicycoolstuff
"" "2.0~bpo1" 600 500 600 "" -o Test
=GlobalPin
137 testequalpolicycoolstuff
"" "1.0" 600 990 600 "" -o Test
=GlobalPin
-t stable
138 echo "Package: coolstuff
139 Pin: release n=backports
140 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
141 #FIXME: policy can't differentiate between two sources where one has a package specific pin in place
142 # testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
143 # testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
144 testequalpolicycoolstuff
"" "1.0" 500 990 200 "2.0~bpo1" -o Test
=PackagePin
-t stable
145 echo "Package: coolstuff
146 Pin: release n=backports
147 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
148 testequalpolicycoolstuff
"" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test
=PackagePin
149 testequalpolicycoolstuff
"" "1.0" 500 990 600 "2.0~bpo1" -o Test
=PackagePin
-t stable
150 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test
=PackagePin
-t backports
152 echo "Package: coolstuff
153 Pin: release n=backports
154 Pin-Priority: -1" > rootdir
/etc
/apt
/preferences
155 # testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
156 # testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
157 # testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
159 rm rootdir
/etc
/apt
/preferences
160 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"NotAutomatic: yes"
164 testequalpolicycoolstuff
"" "1.0" 1 500 1 "" -o Test
=NotAutomatic
165 testequalpolicycoolstuff
"" "1.0" 1 990 1 "" -o Test
=NotAutomatic
-t stable
166 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 990 "" -o Test
=NotAutomatic
-t backports
168 Pin: release n=backports
169 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
170 testequalpolicycoolstuff
"" "1.0" 200 500 200 "" -o Test
=NotAutomatic
172 Pin: release n=backports
173 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
174 testequalpolicycoolstuff
"" "2.0~bpo1" 600 500 600 "" -o Test
=NotAutomatic
175 testequalpolicycoolstuff
"" "1.0" 600 990 600 "" -o Test
=NotAutomatic
-t stable
176 echo "Package: coolstuff
177 Pin: release n=backports
178 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
179 testequalpolicycoolstuff
"" "1.0" 1 500 200 "2.0~bpo1" -o Test
=NotAutomatic
180 echo "Package: coolstuff
181 Pin: release n=backports
182 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
183 testequalpolicycoolstuff
"" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test
=NotAutomatic
184 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test
=NotAutomatic
-t backports
185 testequalpolicycoolstuff
"" "1.0" 1 990 600 "2.0~bpo1" -o Test
=NotAutomatic
-t stable
187 rm rootdir
/etc
/apt
/preferences
188 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"ButAutomaticUpgrades: yes"
192 testequalpolicycoolstuff
"" "1.0" 100 500 100 "" -o Test
=ButAutomaticUpgrades
193 testequalpolicycoolstuff
"" "1.0" 100 990 100 "" -o Test
=ButAutomaticUpgrades
-t stable
194 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 990 "" -o Test
=ButAutomaticUpgrades
-t backports
196 Pin: release n=backports
197 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
198 testequalpolicycoolstuff
"" "1.0" 200 500 200 "" -o Test
=ButAutomaticUpgrades
200 Pin: release n=backports
201 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
202 testequalpolicycoolstuff
"" "2.0~bpo1" 600 500 600 "" -o Test
=ButAutomaticUpgrades
203 testequalpolicycoolstuff
"" "1.0" 600 990 600 "" -o Test
=ButAutomaticUpgrades
-t stable
204 echo "Package: coolstuff
205 Pin: release n=backports
206 Pin-Priority: 200" > rootdir
/etc
/apt
/preferences
207 testequalpolicycoolstuff
"" "1.0" 100 500 200 "2.0~bpo1" -o Test
=ButAutomaticUpgrades
208 echo "Package: coolstuff
209 Pin: release n=backports
210 Pin-Priority: 600" > rootdir
/etc
/apt
/preferences
211 testequalpolicycoolstuff
"" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test
=ButAutomaticUpgrades
212 testequalpolicycoolstuff
"" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test
=ButAutomaticUpgrades
-t backports
213 testequalpolicycoolstuff
"" "1.0" 100 990 600 "2.0~bpo1" -o Test
=ButAutomaticUpgrades
-t stable
215 rm rootdir
/etc
/apt
/preferences
216 testsuccess aptget
install coolstuff
-y
217 testequalpolicycoolstuff
"1.0" "1.0" 100 500 100 "" -o Test
=ButAutomaticUpgrades
218 testsuccess aptget dist
-upgrade -y
219 testequalpolicycoolstuff
"1.0" "1.0" 100 500 100 "" -o Test
=ButAutomaticUpgrades
220 testequalpolicycoolstuff
"1.0" "1.0" 100 990 100 "" -o Test
=ButAutomaticUpgrades
-t stable
221 testequalpolicycoolstuff
"1.0" "2.0~bpo1" 990 500 990 "" -o Test
=ButAutomaticUpgrades
-t backports
223 testsuccess aptget
install coolstuff
-t backports
-y
224 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test
=ButAutomaticUpgrades
225 testsuccess aptget dist
-upgrade -y
226 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test
=ButAutomaticUpgrades
227 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 100 990 100 "" -o Test
=ButAutomaticUpgrades
-t stable
228 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 990 500 990 "" -o Test
=ButAutomaticUpgrades
-t backports
230 rm incoming
/backports.main.pkglist incoming
/backports.main.srclist
231 buildsimplenativepackage
"coolstuff" "all" "2.0~bpo2" "backports"
234 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"NotAutomatic: yes"
238 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 1 500 100 "" "2.0~bpo2" -o Test
=NotAutomatic
239 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo1" 1 990 100 "" "2.0~bpo2" -o Test
=NotAutomatic
-t stable
240 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test
=NotAutomatic
-t backports
242 sed -i aptarchive
/dists
/backports
/Release
-e 1i
"ButAutomaticUpgrades: yes"
246 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo2" 100 500 100 "" "2.0~bpo2" -o Test
=ButAutomaticUpgrades
247 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo2" 100 990 100 "" "2.0~bpo2" -o Test
=ButAutomaticUpgrades
-t stable
248 testequalpolicycoolstuff
"2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test
=ButAutomaticUpgrades
-t backports
251 tmppath
=$(readlink -f .)
253 # Check 16-bit integers
254 echo "Package: coolstuff
255 Pin: release n=backports
257 " > rootdir
/etc
/apt
/preferences
259 testsuccess aptget
install -s coolstuff
-o PinPriority
=32767
261 echo "Package: coolstuff
262 Pin: release n=backports
264 " > rootdir
/etc
/apt
/preferences
265 testsuccess aptget
install -s coolstuff
-o PinPriority
=-32768
268 # Check for 32-bit integers
269 echo "Package: coolstuff
270 Pin: release n=backports
272 " > rootdir
/etc
/apt
/preferences
274 testfailureequal
"Reading package lists...
275 E: ${tmppath}/rootdir/etc/apt/preferences: Value 32768 is outside the range of valid pin priorities (-32768 to 32767)" \
276 aptget
install -s coolstuff
-o PinPriority
=32768
279 echo "Package: coolstuff
280 Pin: release n=backports
282 " > rootdir
/etc
/apt
/preferences
284 testfailureequal
"Reading package lists...
285 E: ${tmppath}/rootdir/etc/apt/preferences: Value -32769 is outside the range of valid pin priorities (-32768 to 32767)" \
286 aptget
install -s coolstuff
-o PinPriority
=-32769
288 # Check for 64-bit integers
290 echo "Package: coolstuff
291 Pin: release n=backports
292 Pin-Priority: 2147483648
293 " > rootdir
/etc
/apt
/preferences
295 testfailureequal
"Reading package lists...
296 E: Cannot convert 2147483648 to integer - (34: Numerical result out of range)
297 E: ${tmppath}/rootdir/etc/apt/preferences: Value 2147483648 is outside the range of valid pin priorities (-32768 to 32767)" \
298 aptget
install -s coolstuff
-o PinPriority
=2147483648
301 echo "Package: coolstuff
302 Pin: release n=backports
304 " > rootdir
/etc
/apt
/preferences
306 testfailureequal
"Reading package lists...
307 E: No priority (or zero) specified for pin" \
308 aptget
install -s coolstuff
-o PinPriority
=0