* doc/apt-get.8.xml:
[ntk/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
28aptget update -qq
29testequalpolicy 100 500
30testequalpolicy 990 500 -t now
31
32sed -i aptarchive/Release -e 1i"NotAutomatic: yes"
5ed56f93
DK
33aptget update -qq
34
35testequalpolicy 100 1 -o Test=NotAutomatic
36testequalpolicy 990 1 -o Test=NotAutomatic -t now
37
38sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
5ed56f93
DK
39aptget update -qq
40
41testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
42testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
43
44sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
5ed56f93
DK
45aptget update -qq
46
47testequalpolicy 100 500 -o Test=Automatic
48testequalpolicy 990 500 -o Test=Automatic -t now
49
50buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
51buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
52
53setupaptarchive
54
55testequalpolicycoolstuff() {
56 local INSTALLED="${1:-(none)}"
57 local CANDIDATE="${2:-(none)}"
58 local AB="$3"
59 local AS="$4"
60 local PB="$5"
61 local PINVERSION="$6"
62 if [ -n "$PINVERSION" ]; then
63 PINVERSION="Package pin: $PINVERSION
64 "
65 fi
66 local IS=""
67 local IB=""
68 local SB=""
69 local SS=""
70 [ "$1" = "2.0~bpo1" ] && IB="***" && SB="
71 100 $STATUS" || IB=" "
72 [ "$1" = "1.0" ] && IS="***" && SS="
73 100 $STATUS" || IS=" "
74 local BPO1ARCHIVE=""
75 local BPO2ARCHIVE=""
76 if [ ! "$7" = "2.0~bpo2" ]; then
77 BPO1ARCHIVE=" $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
78 else
79 BPO2ARCHIVE="
80 2.0~bpo2 $PB
81 $(echo "$AB" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ backports/main i386 Packages"
82 SB="$(echo "$SB" | tail -n 1)"
83 shift
84 fi
85 shift 6
86 testequal "coolstuff:
87 Installed: $INSTALLED
88 Candidate: $CANDIDATE
89 ${PINVERSION}Version table:${BPO2ARCHIVE}
90 $IB 2.0~bpo1 $PB
91${BPO1ARCHIVE}$SB
92 $IS 1.0 $PB
93 $(echo "$AS" | awk '{ printf("%3s\n",$0) }') file:${APTARCHIVE}/ stable/main i386 Packages$SS" \
94 aptcache policy coolstuff -o Policy=${INSTALLED}-${CANDIDATE}-${AB}-${AS}-${PB} $*
95}
96
97testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
98testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
99testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
100echo "Package: *
101Pin: release n=backports
102Pin-Priority: 200" > rootdir/etc/apt/preferences
103testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
104testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
105testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
106echo "Package: *
107Pin: release n=backports
108Pin-Priority: 600" > rootdir/etc/apt/preferences
109testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
110testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
111echo "Package: coolstuff
112Pin: release n=backports
113Pin-Priority: 200" > rootdir/etc/apt/preferences
114#FIXME: policy can't differentiate between two sources where one has a package specific pin in place
115# testequalpolicycoolstuff "" "1.0" 500 500 200 "2.0~bpo1" -o Test=PackagePin
116# testequalpolicycoolstuff "" "1.0" 990 500 200 "2.0~bpo1" -o Test=PackagePin -t backports
117testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
118echo "Package: coolstuff
119Pin: release n=backports
120Pin-Priority: 600" > rootdir/etc/apt/preferences
121testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
122testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
123testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
124
125echo "Package: coolstuff
126Pin: release n=backports
127Pin-Priority: -1" > rootdir/etc/apt/preferences
128# testequalpolicycoolstuff "" "1.0" 500 500 -1 "2.0~bpo1" -o Test=PackagePin
129# testequalpolicycoolstuff "" "1.0" 990 500 -1 "2.0~bpo1" -o Test=PackagePin -t backports
130# testequalpolicycoolstuff "" "1.0" 500 990 -1 "2.0~bpo1" -o Test=PackagePin -t stable
131
132rm rootdir/etc/apt/preferences
133sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
134signreleasefiles
5ed56f93
DK
135aptget update -qq
136
137testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
138testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
139testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
140echo "Package: *
141Pin: release n=backports
142Pin-Priority: 200" > rootdir/etc/apt/preferences
143testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
144echo "Package: *
145Pin: release n=backports
146Pin-Priority: 600" > rootdir/etc/apt/preferences
147testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
148testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
149echo "Package: coolstuff
150Pin: release n=backports
151Pin-Priority: 200" > rootdir/etc/apt/preferences
152testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
153echo "Package: coolstuff
154Pin: release n=backports
155Pin-Priority: 600" > rootdir/etc/apt/preferences
156testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
157testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
158testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
159
160rm rootdir/etc/apt/preferences
161sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
162signreleasefiles
5ed56f93
DK
163aptget update -qq
164
165testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
166testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
167testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
168echo "Package: *
169Pin: release n=backports
170Pin-Priority: 200" > rootdir/etc/apt/preferences
171testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
172echo "Package: *
173Pin: release n=backports
174Pin-Priority: 600" > rootdir/etc/apt/preferences
175testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
176testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
177echo "Package: coolstuff
178Pin: release n=backports
179Pin-Priority: 200" > rootdir/etc/apt/preferences
180testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
181echo "Package: coolstuff
182Pin: release n=backports
183Pin-Priority: 600" > rootdir/etc/apt/preferences
184testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
185testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
186testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
187
188rm rootdir/etc/apt/preferences
189aptget install coolstuff -qq > /dev/null 2> /dev/null
190testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
191aptget dist-upgrade -qq > /dev/null 2> /dev/null
192testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
193testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
194testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
195
196aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null
197testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
198aptget dist-upgrade -qq > /dev/null 2> /dev/null
199testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
200testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
201testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
202
203rm incoming/backports.main.pkglist incoming/backports.main.srclist
204buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
205setupaptarchive
206
207sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
208signreleasefiles
5ed56f93
DK
209aptget update -qq
210
211testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
212testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
213testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
214
215sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
216signreleasefiles
5ed56f93
DK
217aptget update -qq
218
219testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
220testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
221testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports