RE: %pre scripts with a non-zero exit status.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-----Original Message-----
From: Rpm-list [mailto:rpm-list-bounces@xxxxxxxxxxxxx] On Behalf Of Panu Matilainen
Sent: Wednesday, December 03, 2014 8:48 AM
To: rpm-list@xxxxxxxxxxxxx
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@xxxxxxxxxxxxx] *On Behalf Of *doc
> *Sent:* Tuesday, December 02, 2014 6:52 PM
> *To:* rpm-list@xxxxxxxxxxxxx
> *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
> zypper.

Indeed.

%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@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list





[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux