[Fedora-packaging] Exit status in rpm scriptlets

Miroslav Lichvar mlichvar at redhat.com
Thu May 24 13:40:25 UTC 2007


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

"Most commands in the snippets in this document have a "|| :" appended
to them. This little piece of code causes each such command to exit
with a successful exit status whether or not the command worked. This
is important because the scriptlet as a whole will error the moment it
tries to execute a command that has a non-zero exit status."

That's not quite correct, at least with rpm we have in Fedora.
Scriptlets (contrary to build scripts) are not actually executed
through sh -e, therefore a failed command won't cause the whole
scriptlet to fail. Only the last command executed matters.

Generally we want to have scriptlets that always succeed, so added
"|| :" doesn't break anything, but in case where we want to fail the
installation of the package (as in UsersAndGroups packaging draft that
wants to abort installation if required user isn't available) this
doesn't work as one might expect.

For scriptlets that should always return 0 just add : as the last line
of the script and add "|| exit 1" to a command that should abort the
whole script when failed.

-- 
Miroslav Lichvar




More information about the Fedora-packaging mailing list