[Fedora-packaging] scriptlets exit status documentation change

Chris Cheney ccheney at redhat.com
Fri May 17 16:50:43 UTC 2013


Currently the documentation for scriptlets says that the exit status should be 0 otherwise it will break installs/upgrades/erases. However on newer versions of rpm this doesn't actually happen, instead rpm ignores the exit status of scriptlets and continues to install packages and returns an exit status 0 from rpm. Previous versions of rpm returned an error exit code if a scriptlet failed but this no longer happens. I think the documentation should probably be rewritten such that it states more clearly that the exit status of scriptlets MUST be 0 and that if one fails rpm will essentially ignore the failure. 

Chris

---

http://fedoraproject.org/wiki/Packaging:ScriptletSnippets

"Except in some really exceptional cases (if any), we want all scriptlets to exit with the zero exit status. Because rpm in its default configuration does not at the moment execute shell scriptlets with the -e argument to the shell, excluding explicit exit calls (frowned upon with a non-zero argument!), the exit status of the last command in a scriptlet determines its exit status. Most commands in the snippets in this document have a "|| :" appended to them, which is a generic trick to force the zero exit status for those commands whether they worked or not. Usually the most important bit is to apply this to the last command executed in a scriptlet, or to add a separate command such as plain ":" or "exit 0" as the last one in a scriptlet. Note that depending on the case, other error checking/prevention measures may be more appropriate, as well as running some commands only if we saw a previous command in the scriptlet which is a must prerequisite to succeed.

Non-zero exit codes from scriptlets break installs/upgrades/erases so that no further actions will be taken for that package in a transaction (see scriptlet ordering below), which may for example prevent an old version of a package from being erased on upgrades, leaving behind duplicate rpmdb entries and possibly stale, unowned files on the filesystem. There are some cases where letting the transaction to proceed when some things in scriptlets failed may result in partially broken setup. It is however often limited to that package only whereas letting a transaction to proceed with some packages dropped out on the fly is more likely to result in broader system wide problems."


More information about the packaging mailing list