]> git.saurik.com Git - apt.git/blame - test/integration/test-policy-pinning
show URI.Path in all acquire item descriptions
[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
DK
24 release c=
25Pinned packages:" aptcache policy $*
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
1da3b7b8 108 BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
5ed56f93
DK
109 else
110 BPO2ARCHIVE="
111 2.0~bpo2 $PB
1da3b7b8 112 $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} backports/main i386 Packages"
5ed56f93
DK
113 SB="$(echo "$SB" | tail -n 1)"
114 shift
115 fi
116 shift 6
25b86db1 117 testsuccessequal "coolstuff:
5ed56f93
DK
118 Installed: $INSTALLED
119 Candidate: $CANDIDATE
120 ${PINVERSION}Version table:${BPO2ARCHIVE}
121 $IB 2.0~bpo1 $PB
122${BPO1ARCHIVE}$SB
123 $IS 1.0 $PB
1da3b7b8 124 $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE} stable/main i386 Packages$SS" \
5ed56f93
DK
125 aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
126}
127
128testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
129testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
130testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
131echo "Package: *
132Pin: release n=backports
133Pin-Priority: 200" > rootdir/etc/apt/preferences
134testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
135testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
136testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
137echo "Package: *
138Pin: release n=backports
139Pin-Priority: 600" > rootdir/etc/apt/preferences
140testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
141testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
142echo "Package: coolstuff
143Pin: release n=backports
144Pin-Priority: 200" > rootdir/etc/apt/preferences
145#FIXME: policy can't differentiate between two sources where one has a package specific pin in place
146# testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
147# testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
148testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
149echo "Package: coolstuff
150Pin: release n=backports
151Pin-Priority: 600" > rootdir/etc/apt/preferences
152testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
153testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
154testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
155
156echo "Package: coolstuff
157Pin: release n=backports
158Pin-Priority: -1" > rootdir/etc/apt/preferences
159# testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
160# testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
161# testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
162
163rm rootdir/etc/apt/preferences
164sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
165signreleasefiles
451ea3d4 166aptgetupdate
5ed56f93
DK
167
168testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
169testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
170testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
171echo "Package: *
172Pin: release n=backports
173Pin-Priority: 200" > rootdir/etc/apt/preferences
174testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
175echo "Package: *
176Pin: release n=backports
177Pin-Priority: 600" > rootdir/etc/apt/preferences
178testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
179testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
180echo "Package: coolstuff
181Pin: release n=backports
182Pin-Priority: 200" > rootdir/etc/apt/preferences
183testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
184echo "Package: coolstuff
185Pin: release n=backports
186Pin-Priority: 600" > rootdir/etc/apt/preferences
187testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
188testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
189testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
190
191rm rootdir/etc/apt/preferences
192sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
193signreleasefiles
451ea3d4 194aptgetupdate
5ed56f93
DK
195
196testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
197testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
198testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
199echo "Package: *
200Pin: release n=backports
201Pin-Priority: 200" > rootdir/etc/apt/preferences
202testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
203echo "Package: *
204Pin: release n=backports
205Pin-Priority: 600" > rootdir/etc/apt/preferences
206testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
207testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
208echo "Package: coolstuff
209Pin: release n=backports
210Pin-Priority: 200" > rootdir/etc/apt/preferences
211testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
212echo "Package: coolstuff
213Pin: release n=backports
214Pin-Priority: 600" > rootdir/etc/apt/preferences
215testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
216testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
217testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
218
219rm rootdir/etc/apt/preferences
0440d936 220testsuccess aptget install coolstuff -y
5ed56f93 221testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
0440d936 222testsuccess aptget dist-upgrade -y
5ed56f93
DK
223testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
224testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
225testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
226
0440d936 227testsuccess aptget install coolstuff -t backports -y
5ed56f93 228testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
0440d936 229testsuccess aptget dist-upgrade -y
5ed56f93
DK
230testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
231testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
232testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
233
234rm incoming/backports.main.pkglist incoming/backports.main.srclist
235buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
236setupaptarchive
237
238sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
239signreleasefiles
451ea3d4 240aptgetupdate
5ed56f93
DK
241
242testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
243testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
244testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
245
246sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
247signreleasefiles
451ea3d4 248aptgetupdate
5ed56f93
DK
249
250testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
251testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
252testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports