1

According to the RPM documentation, the %pre, %post, %preun and %postun scriptlets must return 0 for the (un)installation proceeds.

(1) But what is the effect of one of those scriptlets returning a non zero value?

(2) Will the operation made so far be undone, leaving the system as it was before invoking the RPM (un)installation?

(3) Is the transaction mechanism involved?

I went through the documentation (on many pages including Fedora’s official doc) but I haven’t found any clue (at least nothing 'black-on-white' to my understanding).

2 Answers 2

1

The information I have found comes from Redhat Bug 216221 from November 2006. I don't know if the following text is still valid.

The last entry of the post says:

  • %pre and %preun scriptlets exiting with non-zero code cause install/erase to fail just like before. This behavior needs to be preserved as various packages use that to prevent install/uninstall on some conditions.
  • non-zero exit code from other scriptlets is treated as a warning only (ie %postun failing will log a warning but the package will get removed anyway)
  • scriptlets dying on signals and other "abnormal" ways are still treated as errors
  • for all scriptlet errors, RPMCALLBACK_SCRIPT_ERROR notification is issued to the callback, with the tag of the failing script passed in the "amount" parameter and "total" parameter containing RPMRC_OK / RPMRC_FAIL to signal whether rpm treated it as a warning or error
1
  • "This behavior needs to be preserved as various packages use that to prevent install/uninstall on some conditions." is good information. This is from prehistoric age (2006!) but it is, most probably, still valid because the need still exist.
    – Algiz
    Sep 25, 2019 at 9:50
0

I only have partial answers, but I hope it helps you on the way...

  1. the installation will be considered failed, but afaik there is no real impact: the files will still be present on your system etc. I have had trouble removing a package where the %preun scriptlet failed however.
  2. No operations are undone. rpm cannot magically know how to undo the commands that you put in your scriptlets.
  3. I don't really know if the transaction mechanism is involved. You could run some tests for that: installing a good rpm and one with a broken %post script...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .