0
votes

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.

2

2 Answers

1
votes

RPM will ignore (by substituting newer version) older versions of identically named packages when installing. Either rename some of the packages, or don't install multiple versions of an identically named package in the same transactio

%pre failures when upgrading are tricky. The newer package will not install if %pre fails. and (on upgrade when there is an older version already installed) will remove the already installed package. The best answer here is don't rely on %pre failures in packaging while installing. Instead add Provides:/Requires: so that the package (and transaction) failure occurs during dependency checking, or design a different means for testing a dynamic property than %pre, either in configuration, or in documentation, or by renaming and obsoleteing the previous package to get a more reliable packaging.

0
votes

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