msm: consistency for equally ranked keys
[platform/upstream/rpm.git] / tests / rpmi.at
1 #    rpmi.at: test various aspects of rpm install
2 #
3 #    Copyright (C) 2007  Ralf Corsépius <corsepiu@fedoraproject.org>
4 #
5 #    This program is free software; you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation; either version 2 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program; if not, write to the Free Software
17 #    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 AT_BANNER([RPM install tests])
20
21 # ------------------------------
22 # Check if rpm -U *.src.rpm works
23 AT_SETUP([rpm -U *.src.rpm])
24 AT_KEYWORDS([install])
25 AT_CHECK([
26 rm -rf ${TOPDIR}
27
28 runroot rpm \
29   -U /data/SRPMS/hello-1.0-1.src.rpm
30 ],
31 [0],
32 [ignore],
33 [ignore])
34 AT_CLEANUP
35
36 # ------------------------------
37 # Check if rpm -i *.src.rpm works
38 AT_SETUP([rpm -i *.src.rpm])
39 AT_KEYWORDS([install])
40 AT_CHECK([
41 rm -rf ${TOPDIR}
42
43 runroot rpm \
44   -i /data/SRPMS/hello-1.0-1.src.rpm
45 ],
46 [0],
47 [ignore],
48 [ignore])
49 AT_CLEANUP
50
51 # ------------------------------
52 # Various error behavior tests
53 #
54 AT_SETUP([rpm -i <nonexistent file>])
55 AT_KEYWORDS([install])
56 AT_CHECK([
57 runroot rpm \
58   -i no_such_file
59 ],
60 [1],
61 [ignore],
62 [ignore])
63 AT_CLEANUP
64
65 # XXX hmm, --nomanifest seems broken atm...
66 AT_SETUP([rpm -i --nomanifest <garbage text file>])
67 AT_KEYWORDS([install])
68 AT_CHECK([
69 junk="${RPMTEST}/textfile"
70 cat << EOF > "${junk}"
71 no_such.file
72 not_an.rpm
73 EOF
74
75 runroot rpm \
76   -Uvv --nomanifest /textfile
77 ],
78 [1],
79 [ignore],
80 [ignore])
81 AT_CLEANUP
82
83 AT_SETUP([rpm -i <garbage text file])
84 AT_KEYWORDS([install])
85 AT_CHECK([
86 junk="${RPMTEST}/not_an.rpm"
87 cat << EOF > "${junk}"
88 no_such.file
89 not_pkg.rpm
90 EOF
91
92 runroot rpm \
93   -Uvv /not_an.rpm
94 ],
95 [2],
96 [ignore],
97 [ignore])
98 AT_CLEANUP
99
100 # ------------------------------
101 # Test normal upgrade
102 AT_SETUP([rpm -U upgrade to newer])
103 AT_CHECK([
104 RPMDB_CLEAR
105 RPMDB_INIT
106 rm -rf "${TOPDIR}"
107
108 for v in "1.0" "2.0"; do
109     runroot rpmbuild --quiet -bb \
110         --define "ver $v" \
111           /data/SPECS/versiontest.spec
112 done
113
114 runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
115 runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
116 runroot rpm -q versiontest
117 ],
118 [0],
119 [versiontest-2.0-1.noarch
120 ],
121 [])
122 AT_CLEANUP
123
124 # Test upgrading to older package (should fail)
125 AT_SETUP([rpm -U upgrade to older])
126 AT_CHECK([
127 RPMDB_CLEAR
128 RPMDB_INIT
129
130 runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
131 runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
132 ],
133 [2],
134 [],
135 [       package versiontest-2.0-1.noarch (which is newer than versiontest-1.0-1.noarch) is already installed
136 ])
137 AT_CLEANUP
138
139 # Test downgrading to older package with --oldpackage
140 AT_SETUP([rpm -U --oldpackage downgrade])
141 AT_CHECK([
142 RPMDB_CLEAR
143 RPMDB_INIT
144
145 runroot rpm -U "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
146 runroot rpm -U --oldpackage "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
147 runroot rpm -q versiontest
148 ],
149 [0],
150 [versiontest-1.0-1.noarch
151 ],
152 [ignore])
153 AT_CLEANUP
154
155 # Test upgrade of different versions in same transaction
156 AT_SETUP([rpm -U two versions of same package 1])
157 AT_CHECK([
158 RPMDB_CLEAR
159 RPMDB_INIT
160
161 runroot rpm -Uv \
162   "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
163   "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
164 runroot rpm -q versiontest
165 ],
166 [0],
167 [Preparing packages...
168 versiontest-2.0-1.noarch
169 versiontest-2.0-1.noarch
170 ],
171 [warning: package versiontest-1.0-1.noarch was already added, replacing with versiontest-2.0-1.noarch
172 ])
173 AT_CLEANUP
174
175 # Test upgrade of different versions in same transaction
176 AT_SETUP([rpm -U two versions of same package 2])
177 AT_CHECK([
178 RPMDB_CLEAR
179 RPMDB_INIT
180
181 runroot rpm -Uv \
182   "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm \
183   "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
184 runroot rpm -q versiontest
185 ],
186 [0],
187 [Preparing packages...
188 versiontest-2.0-1.noarch
189 versiontest-2.0-1.noarch
190 ],
191 [warning: package versiontest-2.0-1.noarch was already added, skipping versiontest-1.0-1.noarch
192 ])
193 AT_CLEANUP
194
195 # Test upgrade of obsoleted package in same transaction
196 AT_SETUP([rpm -U obsoleted package 1])
197 AT_CHECK([
198 RPMDB_CLEAR
199 RPMDB_INIT
200
201 runroot rpmbuild --quiet -bb \
202         --define "pkg one" \
203         --define "obs deptest-two" \
204         /data/SPECS/deptest.spec
205 runroot rpmbuild --quiet -bb \
206         --define "pkg two" \
207         /data/SPECS/deptest.spec
208
209
210 runroot rpm -Uv \
211   "${TOPDIR}"/RPMS/noarch/deptest-two-1.0-1.noarch.rpm \
212   "${TOPDIR}"/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
213 runroot rpm -q deptest-one
214 ],
215 [0],
216 [Preparing packages...
217 deptest-one-1.0-1.noarch
218 deptest-one-1.0-1.noarch
219 ],
220 [warning: package deptest-two-1.0-1.noarch was already added, replacing with deptest-one-1.0-1.noarch
221 ])
222 AT_CLEANUP
223
224 # Test upgrade of obsoleted package in same transaction
225 AT_SETUP([rpm -U obsoleted package 2])
226 AT_CHECK([
227 RPMDB_CLEAR
228 RPMDB_INIT
229
230 runroot rpmbuild --quiet -bb \
231         --define "pkg one" \
232         --define "obs deptest-two" \
233         /data/SPECS/deptest.spec
234 runroot rpmbuild --quiet -bb \
235         --define "pkg two" \
236         /data/SPECS/deptest.spec
237
238
239 runroot rpm -Uv \
240   "${TOPDIR}"/RPMS/noarch/deptest-one-1.0-1.noarch.rpm \
241   "${TOPDIR}"/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
242 runroot rpm -q deptest-one
243 ],
244 [0],
245 [Preparing packages...
246 deptest-one-1.0-1.noarch
247 deptest-one-1.0-1.noarch
248 ],
249 [warning: package deptest-one-1.0-1.noarch was already added, skipping deptest-two-1.0-1.noarch
250 ])
251 AT_CLEANUP
252
253 # Test install of two different versions in same transaction
254 AT_SETUP([rpm -i two versions of same package])
255 AT_CHECK([
256 RPMDB_CLEAR
257 RPMDB_INIT
258
259 runroot rpm -i \
260   "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
261   "${TOPDIR}"/RPMS/noarch/versiontest-2.0-1.noarch.rpm
262 runroot rpm -q versiontest
263 ],
264 [0],
265 [versiontest-2.0-1.noarch
266 versiontest-1.0-1.noarch
267 ],
268 [])
269 AT_CLEANUP
270
271 # Test install of two different versions in same transaction
272 # TODO: test only one was installed
273 AT_SETUP([rpm -i identical versions of same package])
274 AT_CHECK([
275 RPMDB_CLEAR
276 RPMDB_INIT
277
278 runroot rpm -i \
279   "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
280   "${TOPDIR}"/RPMS/noarch/versiontest-1.0-1.noarch.rpm
281 runroot rpm -q versiontest
282 ],
283 [0],
284 [versiontest-1.0-1.noarch
285 ],
286 [])
287 AT_CLEANUP
288
289 # TODO: the same with epoch vs no epoch
290
291 AT_SETUP([rpm -U with invalid --relocate])
292 AT_KEYWORDS([install relocate])
293 AT_CHECK([
294 RPMDB_CLEAR
295 RPMDB_INIT
296
297 runroot rpmbuild --quiet -bb /data/SPECS/hello-script.spec
298
299 runroot rpm -U --test --ignoreos --relocate /usr=/opt \
300   "${TOPDIR}"/RPMS/noarch/hello-script-1.0-1.noarch.rpm
301 ],
302 [1],
303 [],
304 [       path /usr in package hello-script-1.0-1.noarch is not relocatable
305 ])
306 AT_CLEANUP
307
308 AT_SETUP([rpm -U --badreloc with invalid --relocate])
309 AT_KEYWORDS([install relocate])
310 AT_CHECK([
311 RPMDB_CLEAR
312 RPMDB_INIT
313
314 runroot rpmbuild --quiet -bb /data/SPECS/hello-script.spec
315
316 runroot rpm -U --test --ignoreos --badreloc --relocate /usr=/opt \
317   "${TOPDIR}"/RPMS/noarch/hello-script-1.0-1.noarch.rpm
318 ],
319 [0],
320 [],
321 [])
322 AT_CLEANUP