Bug 175727 - RPM %pre failure causes installaed package to uninstall
Summary: RPM %pre failure causes installaed package to uninstall
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: rpm
Version: 4.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Paul Nasrat
QA Contact: Mike McLean
Depends On:
TreeView+ depends on / blocked
Reported: 2005-12-14 11:50 UTC by Ritesh Raj Sarraf
Modified: 2007-11-30 22:07 UTC (History)
3 users (show)

Clone Of:
Last Closed: 2005-12-15 19:18:36 UTC

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

Description Ritesh Raj Sarraf 2005-12-14 11:50:11 UTC
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 13:20:02 UTC
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 15:04:19 UTC
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 17:05:47 UTC
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 10:28:58 UTC
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 10:29:46 UTC
Created attachment 122271 [details]
Dummy Package b.rpm

Dummy Package b.rpm

Comment 6 Ritesh Raj Sarraf 2005-12-15 10:30:18 UTC
Created attachment 122272 [details]
Package a's spec file

spec file

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

Package b's spec file

Comment 8 Ritesh Raj Sarraf 2005-12-15 10:32:48 UTC
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 19:18:36 UTC
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.