]> git.saurik.com Git - apt.git/blame - test/integration/test-policy-pinning
merged lp:~donkult/apt/sid
[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"
33rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
34aptget update -qq
35
36testequalpolicy 100 1 -o Test=NotAutomatic
37testequalpolicy 990 1 -o Test=NotAutomatic -t now
38
39sed -i aptarchive/Release -e 1i"ButAutomaticUpgrades: yes"
40rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
41aptget update -qq
42
43testequalpolicy 100 100 -o Test=ButAutomaticUpgrades
44testequalpolicy 990 100 -o Test=ButAutomaticUpgrades -t now
45
46sed -i aptarchive/Release -e 's#NotAutomatic: yes#NotAutomatic: no#' -e '/ButAutomaticUpgrades: / d'
47rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
48aptget update -qq
49
50testequalpolicy 100 500 -o Test=Automatic
51testequalpolicy 990 500 -o Test=Automatic -t now
52
53buildsimplenativepackage "coolstuff" "all" "1.0" "stable"
54buildsimplenativepackage "coolstuff" "all" "2.0~bpo1" "backports"
55
56setupaptarchive
57
58testequalpolicycoolstuff() {
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
100testequalpolicycoolstuff "" "2.0~bpo1" 500 500 0 ""
101testequalpolicycoolstuff "" "1.0" 500 990 0 "" -t stable
102testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -t backports
103echo "Package: *
104Pin: release n=backports
105Pin-Priority: 200" > rootdir/etc/apt/preferences
106testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=GlobalPin
107testequalpolicycoolstuff "" "1.0" 200 990 0 "" -o Test=GlobalPin -t stable
108testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=GlobalPin -t backports
109echo "Package: *
110Pin: release n=backports
111Pin-Priority: 600" > rootdir/etc/apt/preferences
112testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=GlobalPin
113testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=GlobalPin -t stable
114echo "Package: coolstuff
115Pin: release n=backports
116Pin-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
120testequalpolicycoolstuff "" "1.0" 500 990 200 "2.0~bpo1" -o Test=PackagePin -t stable
121echo "Package: coolstuff
122Pin: release n=backports
123Pin-Priority: 600" > rootdir/etc/apt/preferences
124testequalpolicycoolstuff "" "2.0~bpo1" 500 500 600 "2.0~bpo1" -o Test=PackagePin
125testequalpolicycoolstuff "" "1.0" 500 990 600 "2.0~bpo1" -o Test=PackagePin -t stable
126testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=PackagePin -t backports
127
128echo "Package: coolstuff
129Pin: release n=backports
130Pin-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
135rm rootdir/etc/apt/preferences
136sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
137signreleasefiles
138rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
139aptget update -qq
140
141testequalpolicycoolstuff "" "1.0" 1 500 0 "" -o Test=NotAutomatic
142testequalpolicycoolstuff "" "1.0" 1 990 0 "" -o Test=NotAutomatic -t stable
143testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=NotAutomatic -t backports
144echo "Package: *
145Pin: release n=backports
146Pin-Priority: 200" > rootdir/etc/apt/preferences
147testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=NotAutomatic
148echo "Package: *
149Pin: release n=backports
150Pin-Priority: 600" > rootdir/etc/apt/preferences
151testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=NotAutomatic
152testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=NotAutomatic -t stable
153echo "Package: coolstuff
154Pin: release n=backports
155Pin-Priority: 200" > rootdir/etc/apt/preferences
156testequalpolicycoolstuff "" "1.0" 1 500 200 "2.0~bpo1" -o Test=NotAutomatic
157echo "Package: coolstuff
158Pin: release n=backports
159Pin-Priority: 600" > rootdir/etc/apt/preferences
160testequalpolicycoolstuff "" "2.0~bpo1" 1 500 600 "2.0~bpo1" -o Test=NotAutomatic
161testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=NotAutomatic -t backports
162testequalpolicycoolstuff "" "1.0" 1 990 600 "2.0~bpo1" -o Test=NotAutomatic -t stable
163
164rm rootdir/etc/apt/preferences
165sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
166signreleasefiles
167rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
168aptget update -qq
169
170testequalpolicycoolstuff "" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
171testequalpolicycoolstuff "" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
172testequalpolicycoolstuff "" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
173echo "Package: *
174Pin: release n=backports
175Pin-Priority: 200" > rootdir/etc/apt/preferences
176testequalpolicycoolstuff "" "1.0" 200 500 0 "" -o Test=ButAutomaticUpgrades
177echo "Package: *
178Pin: release n=backports
179Pin-Priority: 600" > rootdir/etc/apt/preferences
180testequalpolicycoolstuff "" "2.0~bpo1" 600 500 0 "" -o Test=ButAutomaticUpgrades
181testequalpolicycoolstuff "" "1.0" 600 990 0 "" -o Test=ButAutomaticUpgrades -t stable
182echo "Package: coolstuff
183Pin: release n=backports
184Pin-Priority: 200" > rootdir/etc/apt/preferences
185testequalpolicycoolstuff "" "1.0" 100 500 200 "2.0~bpo1" -o Test=ButAutomaticUpgrades
186echo "Package: coolstuff
187Pin: release n=backports
188Pin-Priority: 600" > rootdir/etc/apt/preferences
189testequalpolicycoolstuff "" "2.0~bpo1" 100 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades
190testequalpolicycoolstuff "" "2.0~bpo1" 990 500 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t backports
191testequalpolicycoolstuff "" "1.0" 100 990 600 "2.0~bpo1" -o Test=ButAutomaticUpgrades -t stable
192
193rm rootdir/etc/apt/preferences
194aptget install coolstuff -qq > /dev/null 2> /dev/null
195testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
196aptget dist-upgrade -qq > /dev/null 2> /dev/null
197testequalpolicycoolstuff "1.0" "1.0" 100 500 0 "" -o Test=ButAutomaticUpgrades
198testequalpolicycoolstuff "1.0" "1.0" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
199testequalpolicycoolstuff "1.0" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
200
201aptget install coolstuff -t backports -qq > /dev/null 2> /dev/null
202testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
203aptget dist-upgrade -qq > /dev/null 2> /dev/null
204testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 500 0 "" -o Test=ButAutomaticUpgrades
205testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 100 990 0 "" -o Test=ButAutomaticUpgrades -t stable
206testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 990 500 0 "" -o Test=ButAutomaticUpgrades -t backports
207
208rm incoming/backports.main.pkglist incoming/backports.main.srclist
209buildsimplenativepackage "coolstuff" "all" "2.0~bpo2" "backports"
210setupaptarchive
211
212sed -i aptarchive/dists/backports/Release -e 1i"NotAutomatic: yes"
213signreleasefiles
214rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
215aptget update -qq
216
217testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 500 0 "" "2.0~bpo2" -o Test=NotAutomatic
218testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo1" 1 990 0 "" "2.0~bpo2" -o Test=NotAutomatic -t stable
219testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=NotAutomatic -t backports
220
221sed -i aptarchive/dists/backports/Release -e 1i"ButAutomaticUpgrades: yes"
222signreleasefiles
223rm rootdir/var/cache/apt/srcpkgcache.bin rootdir/var/cache/apt/pkgcache.bin
224aptget update -qq
225
226testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades
227testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 100 990 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t stable
228testequalpolicycoolstuff "2.0~bpo1" "2.0~bpo2" 990 500 0 "" "2.0~bpo2" -o Test=ButAutomaticUpgrades -t backports