Bug 175727 - RPM %pre failure causes installaed package to uninstall
RPM %pre failure causes installaed package to uninstall
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: rpm (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: Paul Nasrat
Mike McLean
Depends On:
  Show dependency treegraph
Reported: 2005-12-14 06:50 EST by Ritesh Raj Sarraf
Modified: 2007-11-30 17:07 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-12-15 14:18:36 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Dummy Package a.rpm (1.97 KB, application/x-redhat-package-manager)
2005-12-15 05:28 EST, Ritesh Raj Sarraf
no flags Details
Dummy Package b.rpm (2.07 KB, application/x-redhat-package-manager)
2005-12-15 05:29 EST, Ritesh Raj Sarraf
no flags Details
Package a's spec file (632 bytes, application/octet-stream)
2005-12-15 05:30 EST, Ritesh Raj Sarraf
no flags Details
spec file (719 bytes, application/octet-stream)
2005-12-15 05:30 EST, Ritesh Raj Sarraf
no flags Details

  None (edit)
Description Ritesh Raj Sarraf 2005-12-14 06:50:11 EST
Description of problem:
Dependency checks are done before %pre scripts are called. When a %pre script
fails due to an "internal" check failure  and exits with an error code, the RPM
data base and/or operating information is not updated for the remainder of the
*.rpm operation.

This causes RPM's, for example foo,  "Requires: %{ld_bar} = {ld_version}", to
install even if foo did not.

In simple: If A requires B and B's %pre fails, A still gets installed.

Version-Release number of selected component (if applicable):
All RPM Versions

How reproducible:

Steps to Reproduce:
1. Install package "a" which depends on package "b" with the following command
`rpm -Uvh *.rpm (both the RPM's are in the pwd).

2. If "b" fails because it requires some libraries, still "a" gets isntalled.

Actual results:
Package "a" gets installed even if "b" fails.

Expected results:
If "b" fails, "a" should stop. It shouldn't get installed

Additional info:
Comment 1 Paul Nasrat 2005-12-14 08:20:02 EST
rpm is behaving as intended - rpm has performed a best effort install.  To
satisfy the requirements the packages need to be installed first, and thus are.
Comment 2 Ritesh Raj Sarraf 2005-12-14 10:04:19 EST
There is no use for package "a" if the package on which it is dependent fails to
get installed i.e. package "b".

For example:
bash depends on package glibc. glibc is a meta-package which further depends on
glibc-i386. Now in a directory where only packages bash and glibc are present,
the command `rpm -Uvh *.rpm` should abort because the dependency isn't resolved. 

To comment your last line, the dependency needs to be installed first which as
per my example is glibc-i386 and _not_ package bash. I'm sure this dependency
handling mechanism should be well implemented in "yum" but rpm, unless given
with the force option, should simply abort such installations.

This is well implemented in dpkg and apt.
Comment 3 Bill Nottingham 2005-12-14 12:05:47 EST
The package set is done as an entire transaction; they are not independent
events that can be cancelled based on the failure of earlier packages.
Comment 4 Ritesh Raj Sarraf 2005-12-15 05:28:58 EST
Created attachment 122270 [details]
Dummy Package a.rpm

This is a Dummy Package a.rpm.
This will try to clarify the bug
Comment 5 Ritesh Raj Sarraf 2005-12-15 05:29:46 EST
Created attachment 122271 [details]
Dummy Package b.rpm

Dummy Package b.rpm
Comment 6 Ritesh Raj Sarraf 2005-12-15 05:30:18 EST
Created attachment 122272 [details]
Package a's spec file

spec file
Comment 7 Ritesh Raj Sarraf 2005-12-15 05:30:43 EST
Created attachment 122273 [details]
spec file

Package b's spec file
Comment 8 Ritesh Raj Sarraf 2005-12-15 05:32:48 EST
Sorry for the confusing explanation in Comment #2.

Here's the real problem. Package a depends on Package b. Package b fails to
install because its %pre is not successful, hence Package b isn't installed and
exits with a bad status. But still Package a gets installed. 
Now shouldn't the whole installation get aborted because hitting `rpm -Uvh
*.rpm` would include both Packages' successes and failures into "one single
transaction" ?

I've attached two dummy rpm's (a and b) and the spec files for explanation.
Try the steps mentioned in the Bug Comment to reproduce it.
Comment 10 Jeff Johnson 2005-12-15 14:18:36 EST
Dependency checking and %pre running are different.

The running of %pre is way too late to prevent installation
of an entire set of packages chained through dependencies.
Simply doesn't "work", and the change to rpm is highly unlikely.

Either add dependencies that achieve the same goal as whatever
you are doing in %pre (that's probably the best solution), or run
your %pre script before executing rpm.

Alternatively, it's now possible in rpm-4.4.3 and later to run a script
during dependency checking. 

Note You need to log in before you can comment on or make changes to this bug.