Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failing an RPM install programmatically in a spec step

Tags:

fedora

rpm

I'm making an RPM. This particular RPM has requirements that can't be expressed as RPM prerequisites, lets call them a particular filesystem/disk configuration. Currently the failure happens after install, at runtime, when the requirements aren't met.

I can check for the required prerequisites in the %install, section of my script. However, I can't figure out how to fail the install if certain criteria are met. Is it possible to fail an rpm install at runtime via some trigger in the %install (or some other) section?

An example would look something like so, in a .spec file:

%install
if [ -f /some/file ]
then
    FAIL_RPM_INSTALL ## What is this command?
fi
like image 385
Paul Rubel Avatar asked Oct 27 '10 20:10

Paul Rubel


People also ask

What is a RPM error?

This error generally occurs due to conflicts that exist between the RPMs and a third-party repository. An RPM installation may fail if the system classifies a package as obsolete.


1 Answers

It turns out that if you exit in the %pre stage the rpm install will fail.

%pre
if [ -f /some/file ]
then
    echo "/some/file exists, it shouldn't"
    exit 1
fi

Reference: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets

like image 189
Paul Rubel Avatar answered Oct 03 '22 20:10

Paul Rubel