Strange behaviour of rpm command on error in %pre section of a rpm pakage

Viktor Shitkovskiy hanksmail at gmail.com
Mon Apr 13 07:23:39 UTC 2015


I've got several versions of some package. The last of it has an error in
%pre section that terminates the install script:

mypak-0.0.1-1.el6.noarch.rpm
mypak-0.0.1-2.el6.noarch.rpm
mypak-0.0.1-3.el6.noarch.rpm <-- bad package

All of my packages have debug output in pre, post, preun and postun
sections.

I install the first package:

rpm -ihv mypak-0.0.1-1.el6.noarch.rpm

Output (param is the parameter passed to script sections) is:

Preparing...                ###########################################
[100%]
pre: 0.0.1-1.el6 ; param = 1
   1:mypak                  ###########################################
[100%]
post: 0.0.1-1.el6 ; param = 1

Then I try to update my package and (accidentally) launch rpm command with
v2 and v3 packages at once:

rpm -Uhv mypak-0.0.1-2.el6.noarch.rpm mypak-0.0.1-3.el6.noarch.rpm

warning: package mypak = 0.0.1-2.el6 was already added, replacing with
mypak > 0.0.1-3.el6
Preparing...                ###########################################
[100%]
pre: 0.0.1-3.el6 ; param = 2
!!!version 3 is bad!!!
error: %pre(mypak-0.0.1-3.el6.noarch) scriptlet failed, exit status 1
error:   install: %pre scriptlet failed (2), skipping mypak-0.0.1-3.el6
preun: 0.0.1-1.el6 ; param = 0
postun: 0.0.1-1.el6 ; param = 0

As you can see, my package was removed in the end. Moreover, the package is
removed even if other packages depend on it. I don't even get any warnings
about corrupted dependencies!

If I update my packages one after another, I don't have that problem. In
this case update to the third version fails and that's all. My package of
previous version is still in place.

So my questions are:
1. Why do I get different behaviour when I update my package using 'rpm
-Uhv 3' and 'rpm -Uhv 2 3'? In the first case only the update fails and my
package is not removed. In the second one, the update fails and the package
**is** removed.
2. How can my package be removed in that corrupted update transaction if
other packages depend on it? If I launch 'rpm -e mypak' it fails as it
should:
rpm -e mypak
error: Failed dependencies:
mypak is needed by (installed) mypak-dep-0.0.1-1.el6.noarch

I use rpm 4.8.0 on Centos 6.5.
Originally I posted this question on SO:
http://stackoverflow.com/questions/29565224/strange-behaviour-of-rpm-command-on-error-in-pre-section-of-a-rpm-pakage
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20150413/35960d13/attachment.html>


More information about the Rpm-list mailing list