I have created a rpm build which will extract files as part of rpm installation then run custom scripts to install the package. But when i do rpm -e option it will remove only the rpm extracted files which is not good enough. How can i write rpm -e option to run my custom uninstall script?
2 Answers
You can write a custom %preun
or %postun
scriptlet.
That being said, what you are doing is wrong and not following the philosophy of what RPMs are supposed to do. You've made it nearly impossible for an admin to verify the integrity of the files on the system (rpm -V
), find out what installed the files on the system (rpm -q --whatprovides
), etc. Please reconsider.

- 6,506
- 3
- 26
- 39
In a normal scenario, where files are created as a by-product of your package life-cycle (i.e. log files, temporary files), you can have these removed during uninstallation using the %ghost
directive. See Directives For the %files list .
In your %files
section you would %ghost
own these additional files. Packaging would not attempt to include these files in the rpm, but upon uninstallation of your package, it would recognize ownership, and remove them accordingly.
%files
%ghost /var/log/mylogfile.log

- 157
- 8