]> git.saurik.com Git - apt.git/blame - test/integration/test-policy-pinning
Drop the Section field from pkgCache::Package again
[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
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 25Pinned packages:" aptcache policy "$@"
5ed56f93
DK
26}
27
3f732aa6
DK
28testglobalpolicy() {
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
55msgmsg 'Test with not signed archive'
56aptgetupdate() {
57 rm -rf rootdir/var/lib/apt
58 testwarning aptget update --allow-insecure-repositories
59}
60testglobalpolicy
451ea3d4 61
3f732aa6
DK
62msgmsg 'Test with signed but no key in trusted'
63aptgetupdate() {
64 rm -rf rootdir/var/lib/apt
65 signreleasefiles 'Marvin Paranoid'
66 testwarning aptget update --allow-insecure-repositories
67}
68testglobalpolicy
451ea3d4 69
3f732aa6
DK
70# much the same tests will be executed below in more detail again for this one
71msgmsg 'Test with signed and valid key'
72aptgetupdate() {
73 rm -rf rootdir/var/lib/apt
74 signreleasefiles 'Joe Sixpack'
75 testsuccess aptget update
76}
77testglobalpolicy
451ea3d4 78
3f732aa6 79msgmsg 'Test with specific packages'
451ea3d4 80
5ed56f93
DK
81buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
82buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
83
84setupaptarchive
85
86testequalpolicycoolstuff() {
87 local INSTALLED="${1:-(none)}"
88 local CANDIDATE="${2:-(none)}"
89 local AB="$3"
90 local AS="$4"
91 local PB="$5"
92 local PINVERSION="$6"
93 if [ -n "$PINVERSION" ]; then
94 PINVERSION="Package pin: $PINVERSION
95 "
96 fi
97 local IS=""
98 local IB=""
99 local SB=""
100 local SS=""
101 [ "$1" = "2.0~bpo1" ] && IB="***" && SB="
102 100 $STATUS" || IB=" "
103 [ "$1" = "1.0" ] && IS="***" && SS="
104 100 $STATUS" || IS=" "
105 local BPO1ARCHIVE=""
106 local BPO2ARCHIVE=""
107 if [ ! "$7" = "2.0~bpo2" ]; then
76b004d1 108 BPO1PIN="$AB"
1da3b7b8 109 BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
5ed56f93
DK
110 else
111 BPO2ARCHIVE="
76b004d1 112 2.0~bpo2 $AB
1da3b7b8 113 $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
5ed56f93
DK
114 SB="$(echo "$SB" | tail -n 1)"
115 shift
116 fi
117 shift 6
25b86db1 118 testsuccessequal "coolstuff:
5ed56f93
DK
119 Installed: $INSTALLED
120 Candidate: $CANDIDATE
121 ${PINVERSION}Version table:${BPO2ARCHIVE}
122 $IB 2.0~bpo1 $PB
123${BPO1ARCHIVE}$SB
76b004d1 124 $IS 1.0 $AS
1da3b7b8 125 $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main i386 Packages$SS" \
5ed56f93
DK
126 aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
127}
128
76b004d1
JAK
129testequalpolicycoolstuff "" "2.0~bpo1" 500 500 500 ""
130testequalpolicycoolstuff "" "1.0" 500 990 500 "" -t stable
131testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -t backports
5ed56f93
DK
132echo "Package: *
133Pin: release n=backports
134Pin-Priority: 200" > rootdir/etc/apt/preferences
76b004d1
JAK
135testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=GlobalPin
136testequalpolicycoolstuff "" "1.0" 200 990 200 "" -o Test=GlobalPin -t stable
137testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=GlobalPin -t backports
5ed56f93
DK
138echo "Package: *
139Pin: release n=backports
140Pin-Priority: 600" > rootdir/etc/apt/preferences
76b004d1
JAK
141testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=GlobalPin
142testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=GlobalPin -t stable
5ed56f93
DK
143echo "Package: coolstuff
144Pin: release n=backports
145Pin-Priority: 200" > rootdir/etc/apt/preferences
146#FIXME: policy can't differentiate between two sources where one has a package specific pin in place
147# testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
148# testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
149testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
150echo "Package: coolstuff
151Pin: release n=backports
152Pin-Priority: 600" > rootdir/etc/apt/preferences
153testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
154testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
155testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
156
157echo "Package: coolstuff
158Pin: release n=backports
159Pin-Priority: -1" > rootdir/etc/apt/preferences
160# testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
161# testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
162# testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
163
164rm rootdir/etc/apt/preferences
165sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
166signreleasefiles
451ea3d4 167aptgetupdate
5ed56f93 168
76b004d1
JAK
169testequalpolicycoolstuff "" "1.0" 1 500 1 "" -o Test=NotAutomatic
170testequalpolicycoolstuff "" "1.0" 1 990 1 "" -o Test=NotAutomatic -t stable
171testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=NotAutomatic -t backports
5ed56f93
DK
172echo "Package: *
173Pin: release n=backports
174Pin-Priority: 200" > rootdir/etc/apt/preferences
76b004d1 175testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=NotAutomatic
5ed56f93
DK
176echo "Package: *
177Pin: release n=backports
178Pin-Priority: 600" > rootdir/etc/apt/preferences
76b004d1
JAK
179testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=NotAutomatic
180testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=NotAutomatic -t stable
5ed56f93
DK
181echo "Package: coolstuff
182Pin: release n=backports
183Pin-Priority: 200" > rootdir/etc/apt/preferences
184testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
185echo "Package: coolstuff
186Pin: release n=backports
187Pin-Priority: 600" > rootdir/etc/apt/preferences
188testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
189testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
190testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
191
192rm rootdir/etc/apt/preferences
193sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
194signreleasefiles
451ea3d4 195aptgetupdate
5ed56f93 196
76b004d1
JAK
197testequalpolicycoolstuff "" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades
198testequalpolicycoolstuff "" "1.0" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable
199testequalpolicycoolstuff "" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports
5ed56f93
DK
200echo "Package: *
201Pin: release n=backports
202Pin-Priority: 200" > rootdir/etc/apt/preferences
76b004d1 203testequalpolicycoolstuff "" "1.0" 200 500 200 "" -o Test=ButAutomaticUpgrades
5ed56f93
DK
204echo "Package: *
205Pin: release n=backports
206Pin-Priority: 600" > rootdir/etc/apt/preferences
76b004d1
JAK
207testequalpolicycoolstuff "" "2.0~bpo1" 600 500 600 "" -o Test=ButAutomaticUpgrades
208testequalpolicycoolstuff "" "1.0" 600 990 600 "" -o Test=ButAutomaticUpgrades -t stable
5ed56f93
DK
209echo "Package: coolstuff
210Pin: release n=backports
211Pin-Priority: 200" > rootdir/etc/apt/preferences
212testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
213echo "Package: coolstuff
214Pin: release n=backports
215Pin-Priority: 600" > rootdir/etc/apt/preferences
216testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
217testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
218testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
219
220rm rootdir/etc/apt/preferences
0440d936 221testsuccess aptget install coolstuff -y
76b004d1 222testequalpolicycoolstuff "1.0" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades
0440d936 223testsuccess aptget dist-upgrade -y
76b004d1
JAK
224testequalpolicycoolstuff "1.0" "1.0" 100 500 100 "" -o Test=ButAutomaticUpgrades
225testequalpolicycoolstuff "1.0" "1.0" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable
226testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports
5ed56f93 227
0440d936 228testsuccess aptget install coolstuff -t backports -y
76b004d1 229testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test=ButAutomaticUpgrades
0440d936 230testsuccess aptget dist-upgrade -y
76b004d1
JAK
231testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 100 "" -o Test=ButAutomaticUpgrades
232testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 100 "" -o Test=ButAutomaticUpgrades -t stable
233testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 990 "" -o Test=ButAutomaticUpgrades -t backports
5ed56f93
DK
234
235rm incoming/backports.main.pkglist incoming/backports.main.srclist
236buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
237setupaptarchive
238
239sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
240signreleasefiles
451ea3d4 241aptgetupdate
5ed56f93 242
76b004d1
JAK
243testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 100 "" "2.0~bpo2" -o Test=NotAutomatic
244testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 100 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
245testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
5ed56f93
DK
246
247sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
248signreleasefiles
451ea3d4 249aptgetupdate
5ed56f93 250
76b004d1
JAK
251testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
252testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
253testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 100 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports