Search code examples
rpmrpmbuildrpm-spec

rpm package failure, package still installed


I'm working on building an rpm pacakge however I noticed this scenario. When my rpm scripts fails, the rpm is still considered installed in my system. I was thinking of adding in the clean up logic where if an error is detected in my rpm scripts, I can call an 'rpm -e' in my code and uninstall the script. However it seems a bit kludgy. Is there a cleaner way of making sure the rpm is uninstalled if the script fails?

Thanks!


Solution

  • You can't. Either %pre fails and it is not installed, or you're installed. You cannot call rpm -e because the RPM DB is locked for your transaction.

    If something fails, I recommend you write out to STDERR and make sure that you [re]run chkconfig to turn your service off so it won't try to launch next time they reboot.