3

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?

Ishpeck
  • 204
  • 1
  • 6
  • You quoted only a part of the text: Basically it says *successful* scripts must exit with a zero status. – U. Windl Jun 13 '22 at 12:21

1 Answers1

6

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.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940