On Thu, Oct 13, 2011 at 9:15 AM, Levon Poghosyan <deimusmeis...@gmail.com>wrote:
> Thanks for the reply. > > The situation is following. I've got an application which installs bunch of > rpm packages. > Some of those packages have post scriptlet failing, so I need to > know/figure out which are failing. > Those packages are many, so I think it wont be the best solution to modify > all off them to store their post install scriptlet execution status in /var, > any other solution for this case ? > > Regards, > Levon > > FWIW, there is a related bugzilla for @rpm.org https://bugzilla.redhat.com/show_bug.cgi?id=569930 (rpm exit 0 always on scriptlet execution) In other package management system exists state as "half installed" or so. But here are two issue relevant i think : - Should be failing script relevant or not (see the bugzilla for a discussion on this, in particular for %post) ? @rpm.org choose to exit always with 0 - How should applications or users know that there is some errors ? In any case @rpm5.org add the scriplets exit code to the header registrated in a rpmdb and also to the source rpm (for detecting a wrong use of --short-circuit). rpm -q --yaml arbitrarytags (snip) ..... Scriptstates: - 0 - 0 - 0 - 131072 <---- %post exit code : this number mean exit 0 ................ you can also use rpm -q --qf '[%{SCRIPTSTATES}]\n' arbitrarytag 000*131072*0000000000000000000000000000 -------- ^ | Hope this help Best Regards here are two issues relevant (imho Should failing scripts be permitted? and a obscurely related general design issue How should applications and users and ... be notified of errors? > > On 12 October 2011 21:22, Jeff Johnson <n3npq....@gmail.com> wrote: > >> >> 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. >> >> hth >> >> 73 de Jeff >> >> ______________________________________________________________________ >> RPM Package Manager http://rpm5.org >> User Communication List rpm-users@rpm5.org >> > > > > -- > Address Yerevan, Baghramyan 70/75 >