There are several problems with your spec file:
- your
%files
section is empty, your RPM contains no files at all (try and rpm -ql packagename
);
- you do all of your work in
%pre
and %post
;
- your
%post
is too complicated.
As there are no files at all in your RPM, it will not remove anything when you uninstall it, which is logical. As to the other problems, it would be much better if your %post
script is a file provided by the RPM, and that another script is provided for cleaning up. Then, your pre, post, preun and postun section would look like:
#no %pre
%post
/path/to/install.sh
%preun
# Only if package completely removed!
[ "$1" = "0" ] && /path/to/cleanup.sh
#no %postun
But given what you do here, you are probably better off using a tool like Puppet or such.