Wednesday, April 20, 2022

[SOLVED] Strange behaviour of rpm command on error in %pre section of a rpm package

Issue

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 -Uhv 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 all the packages at once:

rpm -Uhv mypak-0.0.1-*                
warning: package mypak = 0.0.1-1.el6 was already added, replacing with mypak > 0.0.1-2.el6
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 install my packages one after another, I don't have that problem. In this case installation of the third package fails and that's all. The previous version of my package is still in place.

I think this is really a strange behaviour. Is it a bug in rpm or am I missing something?

I use rpm 4.8.0 on Centos 6.5.


Solution

I wrote about this behaviour to the RPM mailing list and Lubos Kardos answered that this is a bug and now it is fixed.

Mailing list thread: http://lists.rpm.org/pipermail/rpm-list/2015-April/001740.html

Commit: https://github.com/rpm-software-management/rpm/commit/c7fa7b2fd7205b73c833831ab9f8c311f40b2ff1



Answered By - hank
Answer Checked By - Dawn Plyler (WPSolving Volunteer)