Cancel rpm install on% post failed
You cannot and should not.
You have to assert everything you can through the `Requires: lines in your spec file so you don't even get to that.
%post
too late to cancel. All your files have already been placed on the / etc drive.
You can disable yourself to not run, but that's about it.
If this is something that you really cannot afford to dump, then the best you can do is check in time %pre
and interrupt there (but even that is evil).
source to share
This is the hack I used %post
to rollback:
if [ ! -d %{basedeploymentpath} ]; then
echo "ERROR: %{basedeploymentpath} does not exist or is inaccessible. I will uninstall myself."
rpm -ev ${APP_NAME} &
exit 1
fi
In the above snippet, if the variable %{basedeploymentpath}
representing the directory is not found, then call rpm -ev
on the package name using &
to develop the process. %post
The script exits with code 1
under the mentioned condition.
If the installation process is started at the command line ( rpm -ivh
) and an error condition exists after installation, this result appears:warning: %post(...) scriptlet failed, exit status 1
This is an ugly hack, but it works. NOTE : The exit status of the command rpm -ivh
will still appear to be successful (exit 0
) if you execute echo $?
after starting the operation rpm -ivh
.
source to share