Bug 754727 - RPM transaction ignores %pre scriptlet failure
Summary: RPM transaction ignores %pre scriptlet failure
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 15
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-17 15:14 UTC by Grigory Batalov
Modified: 2012-08-07 18:05 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-07 18:05:52 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
specfile for the first package (402 bytes, text/x-rpm-spec)
2011-11-17 15:14 UTC, Grigory Batalov
no flags Details
specfile for the second package (418 bytes, text/x-rpm-spec)
2011-11-17 15:14 UTC, Grigory Batalov
no flags Details

Description Grigory Batalov 2011-11-17 15:14:05 UTC
Created attachment 534207 [details]
specfile for the first package

Description of problem:
1) Package2 requires Package1
2) Package1 has an error in the %pre scriptlet
3) Installation of the pair of packages should fail (I believe), but it just ignores an error in pkg1 and installs pkg2

Version-Release number of selected component (if applicable):
rpm-4.9.1.2-1.fc15.x86_64

How reproducible:
always

Steps to Reproduce:
$ cd ~/rpmbuild/SPECS/
$ rpmbuild -ba pkg1.spec pkg2.spec
$ sudo rpm -ihv ../RPMS/noarch/{pkg2-2-2,pkg1-1-1}.noarch.rpm                    
Preparing...                ########################################### [100%]
error: %pre(pkg1-1-1.noarch) scriptlet failed, exit status 1
error: pkg1-1-1.noarch: install failed
   1:pkg2                   ########################################### [ 50%]
$ rpm -q pkg1 pkg2
package pkg1 is not installed
pkg2-2-2.noarch
$ rpm -q --requires pkg2
pkg1  
  
Actual results:
Package2 is installed

Expected results:
Installation of Package2 failed

Additional info:
The same is in CentOS-5.7 (rpm-4.4.2.3-22.el5_7.2).

Comment 1 Grigory Batalov 2011-11-17 15:14:59 UTC
Created attachment 534208 [details]
specfile for the second package

Comment 2 Panu Matilainen 2011-11-18 06:54:45 UTC
Yes, this is expected and has always been the case, rpm doesn't even try to track dependencies during the transaction. There must be a dozen duplicates of this around bugzilla :)

While the "right thing to do" looks (and would be) easyish to achieve in a trivial case like the example here, things get ugly real fast when the transactions become more complex. Such as packages with dependency loops, eg pkg1 and pkg2 that depend on each other, installation of first one succeeds but the latter fails -> there's no way to truly undo what the installation of the first one might have done (through scripts etc). And then consider dependency loops consisting of large number of packages (IIRC Centos 5.x has dep loops involving > 20 packages in the core package set) and what should happen if one of them fails... etc.

"Right thing" being not always achievable doesn't have to mean we couldn't do it when it's possible though.

Comment 3 Akira TAGOH 2011-11-18 08:50:46 UTC
I'm facing same issue at the summary but not on f15 nor f16. it works fine for me, but not on rawhide. it doesn't explicitly say any failure because it has "exit 0" at the end according to https://fedoraproject.org/wiki/Packaging/UsersAndGroups

Version-Release number of selected component (if applicable):
rpm-4.9.1.2-3.fc17.x86_64

How reproducible:
always

Steps to Reproduce:
1. yum install Canna

Actual results:
many warnings like:

warning: user canna does not exist - using root

appears.

Expected results:
no warnings

Additional info:
As I said, it works on f16 and the issue happens on rawhide only with the same package. for reference, the spec file is:
http://pkgs.fedoraproject.org/gitweb/?p=Canna.git;a=blob;f=Canna.spec;h=cda2111032f5996552c8e411e31cb57c7f682438;hb=HEAD#l269

Also just tried to get rid of "exit 0" didn't help. no errors. so it looks like rpm just ignores %pre script in rawhide.

Comment 4 Akira TAGOH 2011-11-18 09:00:15 UTC
Hmm, guess I better file a new one...

Comment 5 Panu Matilainen 2011-11-18 09:06:15 UTC
Yes that Canna thing is a totally different issue. Such issues are typically missing %pre dependencies in the package in question, OR some other breakage. For example in this case, if getent/groupadd/useradd happened to be broken in rawhide (I dunno, but its one possibility), there's *zero* rpm can do about it.

Comment 6 Grigory Batalov 2011-11-18 12:13:58 UTC
Panu, thank you for the explanation.
What if I use "rpm -q pkg1" in pkg2's %pre scriptlet? It seems to work, i.e. aborts installation on the pkg1 failure (excluding failure of upgrading of pkg1).

Comment 7 Panu Matilainen 2011-11-18 12:32:52 UTC
Rpm queries (or other uses) from within scriptlets is not a good idea. It works most of the time, but there are situations where it WILL break and there's no way for the package to know when that happens.

A much safer choice is to for example test for file existence: if a file from pkg1 doesn't exist at pkg2's %pre, pkg1 quite obviously isn't installed at that point.

Comment 8 Grigory Batalov 2011-11-18 12:58:29 UTC
(In reply to comment #7)
> A much safer choice is to for example test for file existence: if a file from
> pkg1 doesn't exist at pkg2's %pre, pkg1 quite obviously isn't installed at that
> point.

Right! Thanks again.

Comment 9 Fedora End Of Life 2012-08-07 18:05:54 UTC
This message is a notice that Fedora 15 is now at end of life. Fedora
has stopped maintaining and issuing updates for Fedora 15. It is
Fedora's policy to close all bug reports from releases that are no
longer maintained. At this time, all open bugs with a Fedora 'version'
of '15' have been closed as WONTFIX.

(Please note: Our normal process is to give advanced warning of this
occurring, but we forgot to do that. A thousand apologies.)

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, feel free to reopen
this bug and simply change the 'version' to a later Fedora version.

Bug Reporter: Thank you for reporting this issue and we are sorry that
we were unable to fix it before Fedora 15 reached end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged to click on
"Clone This Bug" (top right of this page) and open it against that
version of Fedora.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

The process we are following is described here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping


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