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