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?
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.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.