]>
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 | |
20 | testequal "Package files: | |
21 | $(echo "$SP" | awk '{ printf("%3s\n",$0) }') ${STATUS} | |
22 | release a=now | |
23 | $(echo "$AP" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ Packages | |
24 | release c= | |
25 | Pinned packages:" aptcache policy $* | |
26 | } | |
27 | ||
451ea3d4 DK |
28 | aptgetupdate() { |
29 | # just to be sure that no old files are used | |
30 | rm -rf rootdir/var/lib/apt | |
31 | if aptget update -qq 2>&1 | grep '^E: '; then | |
32 | msgwarn 'apt-get update failed with an error' | |
33 | fi | |
34 | } | |
35 | ||
36 | ### not signed archive | |
37 | ||
38 | aptgetupdate | |
5ed56f93 DK |
39 | testequalpolicy 100 500 |
40 | testequalpolicy 990 500 -t now | |
41 | ||
42 | sed -i aptarchive/Release -e 1i"NotAutomatic: yes" | |
451ea3d4 | 43 | aptgetupdate |
5ed56f93 DK |
44 | |
45 | testequalpolicy 100 1 -o Test=NotAutomatic | |
46 | testequalpolicy 990 1 -o Test=NotAutomatic -t now | |
47 | ||
48 | sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes" | |
451ea3d4 | 49 | aptgetupdate |
5ed56f93 DK |
50 | |
51 | testequalpolicy 100 100 -o Test=ButAutomaticUpgrades | |
52 | testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now | |
53 | ||
54 | sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d' | |
451ea3d4 | 55 | aptgetupdate |
5ed56f93 DK |
56 | |
57 | testequalpolicy 100 500 -o Test=Automatic | |
58 | testequalpolicy 990 500 -o Test=Automatic -t now | |
59 | ||
451ea3d4 DK |
60 | sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d' |
61 | ||
62 | ### signed but no key in trusted | |
63 | ||
64 | signreleasefiles 'Marvin Paranoid' | |
65 | aptgetupdate | |
66 | testequalpolicy 100 500 | |
67 | testequalpolicy 990 500 -t now | |
68 | ||
69 | sed -i aptarchive/Release -e 1i"NotAutomatic: yes" | |
70 | signreleasefiles 'Marvin Paranoid' | |
71 | aptgetupdate | |
72 | ||
73 | testequalpolicy 100 1 -o Test=NotAutomatic | |
74 | testequalpolicy 990 1 -o Test=NotAutomatic -t now | |
75 | ||
76 | sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes" | |
77 | signreleasefiles 'Marvin Paranoid' | |
78 | aptgetupdate | |
79 | ||
80 | testequalpolicy 100 100 -o Test=ButAutomaticUpgrades | |
81 | testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now | |
82 | ||
83 | sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d' | |
84 | signreleasefiles 'Marvin Paranoid' | |
85 | aptgetupdate | |
86 | ||
87 | testequalpolicy 100 500 -o Test=Automatic | |
88 | testequalpolicy 990 500 -o Test=Automatic -t now | |
89 | ||
90 | ### signed and valid key | |
91 | ||
5ed56f93 DK |
92 | buildsimplenativepackage "coolstuff" "all" "1.0" "stable" |
93 | buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports" | |
94 | ||
95 | setupaptarchive | |
96 | ||
97 | testequalpolicycoolstuff() { | |
98 | local INSTALLED="${1:-(none)}" | |
99 | local CANDIDATE="${2:-(none)}" | |
100 | local AB="$3" | |
101 | local AS="$4" | |
102 | local PB="$5" | |
103 | local PINVERSION="$6" | |
104 | if [ -n "$PINVERSION" ]; then | |
105 | PINVERSION="Package pin: $PINVERSION | |
106 | " | |
107 | fi | |
108 | local IS="" | |
109 | local IB="" | |
110 | local SB="" | |
111 | local SS="" | |
112 | [ "$1" = "2.0~bpo1" ] && IB="***" && SB=" | |
113 | 100 $STATUS" || IB=" " | |
114 | [ "$1" = "1.0" ] && IS="***" && SS=" | |
115 | 100 $STATUS" || IS=" " | |
116 | local BPO1ARCHIVE="" | |
117 | local BPO2ARCHIVE="" | |
118 | if [ ! "$7" = "2.0~bpo2" ]; then | |
119 | BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages" | |
120 | else | |
121 | BPO2ARCHIVE=" | |
122 | 2.0~bpo2 $PB | |
123 | $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages" | |
124 | SB="$(echo "$SB" | tail -n 1)" | |
125 | shift | |
126 | fi | |
127 | shift 6 | |
128 | testequal "coolstuff: | |
129 | Installed: $INSTALLED | |
130 | Candidate: $CANDIDATE | |
131 | ${PINVERSION}Version table:${BPO2ARCHIVE} | |
132 | $IB 2.0~bpo1 $PB | |
133 | ${BPO1ARCHIVE}$SB | |
134 | $IS 1.0 $PB | |
135 | $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ stable/main i386 Packages$SS" \ | |
136 | aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $* | |
137 | } | |
138 | ||
139 | testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 "" | |
140 | testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable | |
141 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports | |
142 | echo "Package: * | |
143 | Pin: release n=backports | |
144 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
145 | testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin | |
146 | testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable | |
147 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports | |
148 | echo "Package: * | |
149 | Pin: release n=backports | |
150 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
151 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin | |
152 | testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable | |
153 | echo "Package: coolstuff | |
154 | Pin: release n=backports | |
155 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
156 | #FIXME: policy can't differentiate between two sources where one has a package specific pin in place | |
157 | # testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin | |
158 | # testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports | |
159 | testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable | |
160 | echo "Package: coolstuff | |
161 | Pin: release n=backports | |
162 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
163 | testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin | |
164 | testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable | |
165 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports | |
166 | ||
167 | echo "Package: coolstuff | |
168 | Pin: release n=backports | |
169 | Pin-Priority: -1" > rootdir/etc/apt/preferences | |
170 | # testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin | |
171 | # testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports | |
172 | # testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable | |
173 | ||
174 | rm rootdir/etc/apt/preferences | |
175 | sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" | |
176 | signreleasefiles | |
451ea3d4 | 177 | aptgetupdate |
5ed56f93 DK |
178 | |
179 | testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic | |
180 | testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable | |
181 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports | |
182 | echo "Package: * | |
183 | Pin: release n=backports | |
184 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
185 | testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic | |
186 | echo "Package: * | |
187 | Pin: release n=backports | |
188 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
189 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic | |
190 | testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable | |
191 | echo "Package: coolstuff | |
192 | Pin: release n=backports | |
193 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
194 | testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic | |
195 | echo "Package: coolstuff | |
196 | Pin: release n=backports | |
197 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
198 | testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic | |
199 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports | |
200 | testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable | |
201 | ||
202 | rm rootdir/etc/apt/preferences | |
203 | sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" | |
204 | signreleasefiles | |
451ea3d4 | 205 | aptgetupdate |
5ed56f93 DK |
206 | |
207 | testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades | |
208 | testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable | |
209 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports | |
210 | echo "Package: * | |
211 | Pin: release n=backports | |
212 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
213 | testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades | |
214 | echo "Package: * | |
215 | Pin: release n=backports | |
216 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
217 | testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades | |
218 | testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable | |
219 | echo "Package: coolstuff | |
220 | Pin: release n=backports | |
221 | Pin-Priority: 200" > rootdir/etc/apt/preferences | |
222 | testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades | |
223 | echo "Package: coolstuff | |
224 | Pin: release n=backports | |
225 | Pin-Priority: 600" > rootdir/etc/apt/preferences | |
226 | testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades | |
227 | testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports | |
228 | testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable | |
229 | ||
230 | rm rootdir/etc/apt/preferences | |
231 | aptget install coolstuff -qq > /dev/null 2> /dev/null | |
232 | testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades | |
233 | aptget dist-upgrade -qq > /dev/null 2> /dev/null | |
234 | testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades | |
235 | testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable | |
236 | testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports | |
237 | ||
238 | aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null | |
239 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades | |
240 | aptget dist-upgrade -qq > /dev/null 2> /dev/null | |
241 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades | |
242 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable | |
243 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports | |
244 | ||
245 | rm incoming/backports.main.pkglist incoming/backports.main.srclist | |
246 | buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports" | |
247 | setupaptarchive | |
248 | ||
249 | sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes" | |
250 | signreleasefiles | |
451ea3d4 | 251 | aptgetupdate |
5ed56f93 DK |
252 | |
253 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic | |
254 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable | |
255 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports | |
256 | ||
257 | sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes" | |
258 | signreleasefiles | |
451ea3d4 | 259 | aptgetupdate |
5ed56f93 DK |
260 | |
261 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades | |
262 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable | |
263 | testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports |