RPM Community Forums

Mailing List Message of <rpm-users>

Re: How to detect rpm post scriptlet failure

From: Jeff Johnson <n3npq.jbj@gmail.com>
Date: Wed 12 Oct 2011 - 21:22:35 CEST
Message-Id: <CCDD0170-3FBF-4F40-8FF1-424F336BE39F@mac.com>

On Oct 12, 2011, at 11:38 AM, Levon Poghosyan wrote:

> Hello,
> How can I detect if the execution of post scriptlet of the rpm package failed ? 

The simple answer here is:
	You don't.

All I mean by that is that the %post script needs to be written "robustly"
so that the exit code is always 0.

If you need/want to tell whether some specific operation "worked",
then write a test after rpm has run for that specific operation.

Another approach would be to have the %post script register its
state somewhere in /var so that you can easily test whether the script
"worked" or not.

> I've generated the and rpm package which has a test command "lalala" in post install section. So during the installation it prints out information that command lalala was not found but the installation is still successful.
> How do I identify this failure from post install section. 

A %post "scriptlet" (the only difference between script and scriptlet is that a
scriplet is macro expanded and may eventually have some envvar's
prepended instead of having RPM add to the environ directly) is
just a script.

SO use test(1) to test for existence and executability, and write that into
the %post section directly.

Because a %post is part of a package install state machine, the script
SHOULD return 0 for all but catasstrophic faiulures.

There are side-effects of returning failure from %post, the most important
of which is that on an upgrade, the erase will be skipped if/when the install fails.

> Please note I'm not interested in failure in other places, I just need to be informed in post install scriptlet failed.

Personal;ly, I'd just write the %post script to write 1 line into /var/lib/application/state
with the message
	The %post script "succeeded"
or (on failure)
	The %post script "failed".

I'd have to know more about what is implied by a %post success/failure
in order to suggest some other approach.


73 de Jeff
Received on Wed Oct 12 21:54:08 2011
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.