1
votes

Is there a way to exit from %post section in case of a upgrade RPM.

I have simple rpm with following sections. NOTE: here I have exit in %post.

When I run rpm -Uvh package_name, there is an error encountered in %post section. The exit does happen only from %post section. However the rpm then continues with %preun and %postun section.

I just want to exit if there are any error in %post section. Can this be achieved?

  %pre
  perform few checks here

  %post
  perform upgrade steps.
  If there is a error performing upgrade steps. **Then exit**

  %preun
  Perform pre-uninstall checks


  %postun
  Perform un-installation steps of previous package

Can someone clarify on this upgrade rpm package.

2

2 Answers

0
votes

It's somewhat unclear what you mean by exit: RPM exit? %post scriptlet exit?

Presumably, you wish RPM to stop an upgrade if you have a non-zero exit code in %post. That is already implemented: a non-zero return from %post will cancel the erase of the older package being upgraded.

The set of packages being upgraded will continue "best effort" however even if some package in the set fails.

Note that whatever files are installed in the newer package will overwrite paths: that happens before %post is executed, and so an exit in %post cannot stop what has already happened.

0
votes

Atul.

I guess, you cannot abort rpm transaction in %post script let (script let exit codes are ignored by RPM).