Nadia Solovyeva
Nadia Solovyeva

Reputation: 207

How to roll back RPM installation if %pre section of SPEC file script return false

I'm a newby in RPM building. I have to build RPM which would install a package only if file /etc/i-am-a-requirement exists on target machine. So I wrote

%pre
if test -f "/etc/i-am-a-requirement"; then 
echo "I'm OK to continue"
else
echo "The file is not found, the RPM won't be installed"
-- How to add failure here? --
fi

I know that normally we expect RPM to have dependency packages, but in this case "/etc/i-am-a-requirement" is distributed as binary, so it does not have a package at all.

Upvotes: 0

Views: 1355

Answers (1)

Chris Maes
Chris Maes

Reputation: 37742

the %pre, %post and other scripts cannot stop the installation of an rpm. Once you are inside the scriptlets; installation will continue nomatter the exit code of your scriptlets.

You should use Requires:

Requires: /etc/i-am-a-requirement

Upvotes: 1

Related Questions