1 # rpmi.at: test various aspects of rpm install
3 # Copyright (C) 2007 Ralf Corsépius <corsepiu@fedoraproject.org>
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.
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.
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
19 AT_BANNER([RPM install tests])
21 AT_SETUP([rpm -U <manifest>])
22 AT_KEYWORDS([install])
27 echo /data/RPMS/hello-2.0-1.x86_64.rpm > ${RPMTEST}/tmp/test.mft
28 runroot rpm -U --ignorearch --ignoreos --nodeps \
36 AT_SETUP([rpm -U <manifest notfound 1>])
37 AT_KEYWORDS([install])
42 echo /data/RPMS/hello-2.0-1.x86_64.rpm > ${RPMTEST}/tmp/test.mft
43 runroot rpm -U --ignorearch --ignoreos --nodeps \
44 /tmp/test-not-there.mft
48 [error: open of /tmp/test-not-there.mft failed: No such file or directory
52 AT_SETUP([rpm -U <manifest notfound 2>])
53 AT_KEYWORDS([install])
58 echo /data/RPMS/hello-not-there-2.0-1.x86_64.rpm > ${RPMTEST}/tmp/test.mft
59 runroot rpm -U --ignorearch --ignoreos --nodeps \
64 [error: open of /data/RPMS/hello-not-there-2.0-1.x86_64.rpm failed: No such file or directory
68 AT_SETUP([rpm -U <notfound>])
69 AT_KEYWORDS([install])
74 runroot rpm -U --ignorearch --ignoreos --nodeps \
75 /data/RPMS/hello-not-there-2.0-1.x86_64.rpm
79 [error: open of /data/RPMS/hello-not-there-2.0-1.x86_64.rpm failed: No such file or directory
83 AT_SETUP([rpm -U <unsigned>])
84 AT_KEYWORDS([install])
89 runroot rpm -U --ignorearch --ignoreos --nodeps \
90 /data/RPMS/hello-2.0-1.x86_64.rpm
97 AT_SETUP([rpm -U <signed nokey>])
98 AT_KEYWORDS([install])
103 runroot rpm -U --ignorearch --ignoreos --nodeps \
104 /data/RPMS/hello-2.0-1.x86_64-signed.rpm
108 [warning: /data/RPMS/hello-2.0-1.x86_64-signed.rpm: Header V4 RSA/SHA256 Signature, key ID 1964c5fc: NOKEY
112 AT_SETUP([rpm -U <signed>])
113 AT_KEYWORDS([install])
118 runroot rpmkeys --import /data/keys/rpm.org-rsa-2048-test.pub
119 runroot rpm -U --ignorearch --ignoreos --nodeps \
120 /data/RPMS/hello-2.0-1.x86_64-signed.rpm
127 AT_SETUP([rpm -U <corrupted signed 1>])
128 AT_KEYWORDS([install])
133 pkg="hello-2.0-1.x86_64-signed.rpm"
134 cp "${RPMTEST}"/data/RPMS/${pkg} "${RPMTEST}"/tmp/${pkg}
135 dd if=/dev/zero of="${RPMTEST}"/tmp/${pkg} \
136 conv=notrunc bs=1 seek=264 count=2 2> /dev/null
138 runroot rpm -U --ignorearch --ignoreos --nodeps \
143 [error: /tmp/hello-2.0-1.x86_64-signed.rpm: Header signature: BAD (package tag 268: invalid OpenPGP signature)
144 error: /tmp/hello-2.0-1.x86_64-signed.rpm cannot be installed
148 AT_SETUP([rpm -U <corrupted signed 2>])
149 AT_KEYWORDS([install])
154 pkg="hello-2.0-1.x86_64-signed.rpm"
155 cp "${RPMTEST}"/data/RPMS/${pkg} "${RPMTEST}"/tmp/${pkg}
156 dd if=/dev/zero of="${RPMTEST}"/tmp/${pkg} \
157 conv=notrunc bs=1 seek=5555 count=6 2> /dev/null
159 runroot rpm -U --ignorearch --ignoreos --nodeps \
164 [error: /tmp/hello-2.0-1.x86_64-signed.rpm: Header V4 RSA/SHA256 Signature, key ID 1964c5fc: BAD
165 error: /tmp/hello-2.0-1.x86_64-signed.rpm: Header SHA1 digest: BAD (Expected 5cd9874c510b67b44483f9e382a1649ef7743bac != 4261b2c1eb861a4152c2239bce20bfbcaa8971ba)
166 error: /tmp/hello-2.0-1.x86_64-signed.rpm: Header SHA256 digest: BAD (Expected ef920781af3bf072ae9888eec3de1c589143101dff9cc0b561468d395fb766d9 != 29fdfe92782fb0470a9a164a6c94af87d3b138c63b39d4c30e0223ca1202ba82)
167 error: /tmp/hello-2.0-1.x86_64-signed.rpm cannot be installed
171 # This is more about documenting current behavior than what it *should* do
172 # when encountering corrupted payload.
173 AT_SETUP([rpm -U <corrupted signed 3>])
174 AT_KEYWORDS([install])
179 pkg="hello-2.0-1.x86_64-signed.rpm"
180 cp "${RPMTEST}"/data/RPMS/${pkg} "${RPMTEST}"/tmp/${pkg}
181 dd if=/dev/zero of="${RPMTEST}"/tmp/${pkg} \
182 conv=notrunc bs=1 seek=7788 count=6 2> /dev/null
184 runroot rpm -U --ignorearch --ignoreos --nodeps \
189 [warning: /tmp/hello-2.0-1.x86_64-signed.rpm: Header V4 RSA/SHA256 Signature, key ID 1964c5fc: NOKEY
190 error: unpacking of archive failed: cpio: Bad magic
191 error: hello-2.0-1.x86_64: install failed
195 # ------------------------------
196 # Check if rpm -U *.src.rpm works
197 AT_SETUP([rpm -U *.src.rpm])
198 AT_KEYWORDS([install])
203 -U /data/SRPMS/hello-1.0-1.src.rpm
210 # ------------------------------
211 # Check if rpm -i *.src.rpm works
212 AT_SETUP([rpm -i *.src.rpm])
213 AT_KEYWORDS([install])
218 -i /data/SRPMS/hello-1.0-1.src.rpm
225 # ------------------------------
226 # Various error behavior tests
228 AT_SETUP([rpm -i <nonexistent file>])
229 AT_KEYWORDS([install])
239 # XXX hmm, --nomanifest seems broken atm...
240 AT_SETUP([rpm -i --nomanifest <garbage text file>])
241 AT_KEYWORDS([install])
243 junk="${RPMTEST}/textfile"
244 cat << EOF > "${junk}"
250 -Uvv --nomanifest /textfile
257 AT_SETUP([rpm -i <garbage text file])
258 AT_KEYWORDS([install])
260 junk="${RPMTEST}/not_an.rpm"
261 cat << EOF > "${junk}"
274 # ------------------------------
275 # Test normal upgrade
276 AT_SETUP([rpm -U upgrade to newer])
282 for v in "1.0" "2.0"; do
283 runroot rpmbuild --quiet -bb \
285 /data/SPECS/versiontest.spec
288 runroot rpm -U /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm
289 runroot rpm -U /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm
290 runroot rpm -q versiontest
293 [versiontest-2.0-1.noarch
298 # Test upgrading to older package (should fail)
299 AT_SETUP([rpm -U upgrade to older])
304 runroot rpm -U /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm
305 runroot rpm -U /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm
309 [ package versiontest-2.0-1.noarch (which is newer than versiontest-1.0-1.noarch) is already installed
313 # Test downgrading to older package with --oldpackage
314 AT_SETUP([rpm -U --oldpackage downgrade])
319 runroot rpm -U /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm
320 runroot rpm -U --oldpackage /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm
321 runroot rpm -q versiontest
324 [versiontest-1.0-1.noarch
329 # Test upgrade of different versions in same transaction
330 AT_SETUP([rpm -U two versions of same package 1])
336 /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
337 /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm
338 runroot rpm -q versiontest
341 [Preparing packages...
342 versiontest-2.0-1.noarch
343 versiontest-2.0-1.noarch
345 [warning: package versiontest-1.0-1.noarch was already added, replacing with versiontest-2.0-1.noarch
349 # Test upgrade of different versions in same transaction
350 AT_SETUP([rpm -U two versions of same package 2])
356 /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm \
357 /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm
358 runroot rpm -q versiontest
361 [Preparing packages...
362 versiontest-2.0-1.noarch
363 versiontest-2.0-1.noarch
365 [warning: package versiontest-2.0-1.noarch was already added, skipping versiontest-1.0-1.noarch
369 # Test upgrade of obsoleted package in same transaction
370 AT_SETUP([rpm -U obsoleted package 1])
375 runroot rpmbuild --quiet -bb \
377 --define "obs deptest-two" \
378 /data/SPECS/deptest.spec
379 runroot rpmbuild --quiet -bb \
381 /data/SPECS/deptest.spec
385 /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm \
386 /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm
387 runroot rpm -q deptest-one
390 [Preparing packages...
391 deptest-one-1.0-1.noarch
392 deptest-one-1.0-1.noarch
394 [warning: package deptest-two-1.0-1.noarch was already added, replacing with deptest-one-1.0-1.noarch
398 # Test upgrade of obsoleted package in same transaction
399 AT_SETUP([rpm -U obsoleted package 2])
404 runroot rpmbuild --quiet -bb \
406 --define "obs deptest-two" \
407 /data/SPECS/deptest.spec
408 runroot rpmbuild --quiet -bb \
410 /data/SPECS/deptest.spec
414 /build/RPMS/noarch/deptest-one-1.0-1.noarch.rpm \
415 /build/RPMS/noarch/deptest-two-1.0-1.noarch.rpm
416 runroot rpm -q deptest-one
419 [Preparing packages...
420 deptest-one-1.0-1.noarch
421 deptest-one-1.0-1.noarch
423 [warning: package deptest-one-1.0-1.noarch was already added, skipping deptest-two-1.0-1.noarch
427 # Test install of two different versions in same transaction
428 AT_SETUP([rpm -i two versions of same package])
434 /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
435 /build/RPMS/noarch/versiontest-2.0-1.noarch.rpm
436 runroot rpm -q versiontest
439 [versiontest-2.0-1.noarch
440 versiontest-1.0-1.noarch
445 # Test install of two different versions in same transaction
446 # TODO: test only one was installed
447 AT_SETUP([rpm -i identical versions of same package])
453 /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm \
454 /build/RPMS/noarch/versiontest-1.0-1.noarch.rpm
455 runroot rpm -q versiontest
458 [versiontest-1.0-1.noarch
463 # TODO: the same with epoch vs no epoch
465 AT_SETUP([rpm -U with invalid --relocate])
466 AT_KEYWORDS([install relocate])
471 runroot rpmbuild --quiet -bb /data/SPECS/hello-script.spec
473 runroot rpm -U --test --ignoreos --relocate /usr=/opt \
474 /build/RPMS/noarch/hello-script-1.0-1.noarch.rpm
478 [ path /usr in package hello-script-1.0-1.noarch is not relocatable
482 AT_SETUP([rpm -U --badreloc with invalid --relocate])
483 AT_KEYWORDS([install relocate])
488 runroot rpmbuild --quiet -bb /data/SPECS/hello-script.spec
490 runroot rpm -U --test --ignoreos --badreloc --relocate /usr=/opt \
491 /build/RPMS/noarch/hello-script-1.0-1.noarch.rpm
498 AT_SETUP([rpm -i with/without --excludedocs])
499 AT_KEYWORDS([install excludedocs])
504 runroot rpmbuild --quiet -bb /data/SPECS/testdoc.spec
506 runroot rpm -i --excludedocs \
507 /build/RPMS/noarch/testdoc-1.0-1.noarch.rpm
509 RPM_DOCDIR=$(runroot rpm --eval '%_defaultdocdir')
510 RPM_DATADIR=$(runroot rpm --eval '%_datadir')
512 test ! -e ${RPMTEST}${RPM_DOCDIR}/testdoc || exit 1
513 test -e ${RPMTEST}${RPM_DATADIR}/testdoc/nodoc || exit 1
515 runroot rpm -e testdoc
518 /build/RPMS/noarch/testdoc-1.0-1.noarch.rpm
519 test -e ${RPMTEST}${RPM_DOCDIR}/testdoc/documentation1 || exit 1
520 test -e ${RPMTEST}${RPM_DOCDIR}/testdoc/documentation2 || exit 1
521 test -e ${RPMTEST}${RPM_DOCDIR}/testdoc/examples/example1 || exit 1
522 test -e ${RPMTEST}${RPM_DOCDIR}/testdoc/examples/example2 || exit 1
523 test -e ${RPMTEST}${RPM_DATADIR}/testdoc/nodoc || exit 1
525 runroot rpm -e testdoc