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