]> git.saurik.com Git - apt.git/blame - test/integration/test-policy-pinning
Merge remote-tracking branch 'mvo/debian/sid' into debian/sid
[apt.git] / test / integration / test-policy-pinning
CommitLineData
5ed56f93
DK
1#!/bin/sh
2set -e
3
9962ae93 4TESTDIR=$(readlink -f $(dirname $0))
5ed56f93
DK
5. $TESTDIR/framework
6
7setupenvironment
8configarchitecture "i386"
9
10buildaptarchive
11setupflataptarchive
12
13STATUS=$(readlink -f rootdir/var/lib/dpkg/status)
14APTARCHIVE=$(readlink -f aptarchive)
15
16testequalpolicy() {
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=
25Pinned packages:" aptcache policy $*
26}
27
451ea3d4
DK
28aptgetupdate() {
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
38aptgetupdate
5ed56f93
DK
39testequalpolicy 100 500
40testequalpolicy 990 500 -t now
41
42sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
451ea3d4 43aptgetupdate
5ed56f93
DK
44
45testequalpolicy 100 1 -o Test=NotAutomatic
46testequalpolicy 990 1 -o Test=NotAutomatic -t now
47
48sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
451ea3d4 49aptgetupdate
5ed56f93
DK
50
51testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
52testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
53
54sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
451ea3d4 55aptgetupdate
5ed56f93
DK
56
57testequalpolicy 100 500 -o Test=Automatic
58testequalpolicy 990 500 -o Test=Automatic -t now
59
451ea3d4
DK
60sed -i aptarchive/Release -e '/NotAutomatic: / d' -e '/ButAutomaticUpgrades: / d'
61
62### signed but no key in trusted
63
64signreleasefiles 'Marvin Paranoid'
65aptgetupdate
66testequalpolicy 100 500
67testequalpolicy 990 500 -t now
68
69sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
70signreleasefiles 'Marvin Paranoid'
71aptgetupdate
72
73testequalpolicy 100 1 -o Test=NotAutomatic
74testequalpolicy 990 1 -o Test=NotAutomatic -t now
75
76sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
77signreleasefiles 'Marvin Paranoid'
78aptgetupdate
79
80testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
81testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
82
83sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
84signreleasefiles 'Marvin Paranoid'
85aptgetupdate
86
87testequalpolicy 100 500 -o Test=Automatic
88testequalpolicy 990 500 -o Test=Automatic -t now
89
90### signed and valid key
91
5ed56f93
DK
92buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
93buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
94
95setupaptarchive
96
97testequalpolicycoolstuff() {
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
139testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
140testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
141testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
142echo "Package: *
143Pin: release n=backports
144Pin-Priority: 200" > rootdir/etc/apt/preferences
145testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
146testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
147testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
148echo "Package: *
149Pin: release n=backports
150Pin-Priority: 600" > rootdir/etc/apt/preferences
151testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
152testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
153echo "Package: coolstuff
154Pin: release n=backports
155Pin-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
159testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
160echo "Package: coolstuff
161Pin: release n=backports
162Pin-Priority: 600" > rootdir/etc/apt/preferences
163testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
164testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
165testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
166
167echo "Package: coolstuff
168Pin: release n=backports
169Pin-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
174rm rootdir/etc/apt/preferences
175sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
176signreleasefiles
451ea3d4 177aptgetupdate
5ed56f93
DK
178
179testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
180testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
181testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
182echo "Package: *
183Pin: release n=backports
184Pin-Priority: 200" > rootdir/etc/apt/preferences
185testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
186echo "Package: *
187Pin: release n=backports
188Pin-Priority: 600" > rootdir/etc/apt/preferences
189testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
190testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
191echo "Package: coolstuff
192Pin: release n=backports
193Pin-Priority: 200" > rootdir/etc/apt/preferences
194testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
195echo "Package: coolstuff
196Pin: release n=backports
197Pin-Priority: 600" > rootdir/etc/apt/preferences
198testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
199testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
200testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
201
202rm rootdir/etc/apt/preferences
203sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
204signreleasefiles
451ea3d4 205aptgetupdate
5ed56f93
DK
206
207testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
208testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
209testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
210echo "Package: *
211Pin: release n=backports
212Pin-Priority: 200" > rootdir/etc/apt/preferences
213testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
214echo "Package: *
215Pin: release n=backports
216Pin-Priority: 600" > rootdir/etc/apt/preferences
217testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
218testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
219echo "Package: coolstuff
220Pin: release n=backports
221Pin-Priority: 200" > rootdir/etc/apt/preferences
222testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
223echo "Package: coolstuff
224Pin: release n=backports
225Pin-Priority: 600" > rootdir/etc/apt/preferences
226testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
227testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
228testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
229
230rm rootdir/etc/apt/preferences
0440d936 231testsuccess aptget install coolstuff -y
5ed56f93 232testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
0440d936 233testsuccess aptget dist-upgrade -y
5ed56f93
DK
234testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
235testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
236testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
237
0440d936 238testsuccess aptget install coolstuff -t backports -y
5ed56f93 239testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
0440d936 240testsuccess aptget dist-upgrade -y
5ed56f93
DK
241testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
242testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
243testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
244
245rm incoming/backports.main.pkglist incoming/backports.main.srclist
246buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
247setupaptarchive
248
249sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
250signreleasefiles
451ea3d4 251aptgetupdate
5ed56f93
DK
252
253testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
254testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
255testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
256
257sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
258signreleasefiles
451ea3d4 259aptgetupdate
5ed56f93
DK
260
261testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
262testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
263testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports