%pre scripts with a non-zero exit status.
Eran Ben Natan
eranb at celltick.com
Wed Dec 3 07:57:06 UTC 2014
Look at the following scenario: A requires B. B, in the %post, runs an activity that is essential for A. If you install A with YUM, and that activity of B fails, YUM will install A anyway, but A will not be functional because the %post of B failed.
Checking that the %post of B completed successfully in %pre of A will prevent that situation.
From: Rpm-list [mailto:rpm-list-bounces at lists.rpm.org] On Behalf Of Panu Matilainen
Sent: Wednesday, December 03, 2014 8:48 AM
To: rpm-list at lists.rpm.org
Subject: Re: %pre scripts with a non-zero exit status.
On 12/02/2014 06:55 PM, Eran Ben Natan wrote:
> That is exactly the purpose of the %pre – to verify that all
> prerequisites are met, so, yes, this is a good idea.
That is what dependencies are for. Doing such checks in %pre is generally speaking a bad idea. And no, that is not what %pre exists for. Not at all!
> *From:*Rpm-list [mailto:rpm-list-bounces at lists.rpm.org] *On Behalf Of *doc
> *Sent:* Tuesday, December 02, 2014 6:52 PM
> *To:* rpm-list at lists.rpm.org
> *Subject:* %pre scripts with a non-zero exit status.
> I'm being asked to create a %pre scriptlet which if certain
> configuration conditions are not met will not install the rpm package.
> Is this a good idea?
> My understanding of rpm scriptlets is that they should always (except
> under extreme conditions) exit with a status of 0. Needless to say,
> these rpms with the %pre failures would be installed by rpm, yum and
%pre (and %pretrans in newer rpm versions) has the capability to cancel
out package installation, %preun similarly can cancel uninstall. Doing
so is almost always a terrible idea however, because the scriptlets are
executed at a point where its not possible to cancel other packages. So
when you're using %pre to cancel package installation, you're pulling
the carpet underneath everything else in the same transaction: your
package does not know what other packages might depend on it.
Non-zero exit from %pre/%preun should be a last-gasp measure for
preventing install. Its basically okay if you know the package will
ALWAYS be installed alone in a transaction, but there's usually no way
to guarantee such a thing.
- Panu -
Rpm-list mailing list
Rpm-list at lists.rpm.org
More information about the Rpm-list