I am creating an RPM package that installs some tools on a system. I want to check some machine state before installing my RPM package. My initial instinct is to just run some commands from within the %pre scriptlet, and "exit 1" if the outcome isn't exactly what I like. But then I encountered this which says:

All scriptlets MUST exit with the zero exit status.

Is there some other way to get RPM to abort the install of a package based on the results of shell commands?

  • You quoted only a part of the text: Basically it says successful scripts must exit with a zero status.
    – U. Windl
    Jun 13, 2022 at 12:21

1 Answer 1


Exiting nonzero in the scriptlet will certainly abort the installation of the pacakge, but this does have side effects. The doc you linked to also discusses the implications of having your scriptlet exit with a nonzero status. You should carefully read and understand this before trying to implement this.

If it is not absolutely necessary to abort the installation in the scriptlet, you should not do so.

For instance, if it wouldn't harm the system to have the package installed but the program in the package simply just wouldn't work, then installation should be allowed to proceed, and the decision to install the package made elsewhere. Your configuration management system is the ideal place for this.

  • Did you mean "decision to uninstall" instead of "decision to install" in the last paragraph?
    – chicks
    Mar 12, 2019 at 13:09
  • @chicks No, I mean it exactly as written. Mar 12, 2019 at 13:51

You must log in to answer this question.

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