-1

All,

I created a RPM package using rpm.spec file. The package installed succesfully. When i remove the package using rpm -e it removed from RPM database

But directory structure that the pkg created was not removed.

Please help me to resolve this issue.

baluchen
  • 749
  • 3
  • 11
  • 18

1 Answers1

3

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.

fge
  • 119,121
  • 33
  • 254
  • 329