Discussion:
How to run a tool stored in RPM package upon uninstallation?
s***@free.fr
2007-10-05 13:57:11 UTC
Permalink
Hi all,

I am new to RPM development and so far I have been figuring out many things just
by looking at the documentation but now I am stuck with a new issue.

I basically want a small tool to be executed when my rpm is being uninstalled by
the user. This tool should be embedded in the RPM package but should be
extracted only upon uninstallation, and should be removed after being run. I can
not use the %file directive to include this tool in my package since I do not
want this file to actually be "installed" or stored on the user's system.

If you are familiar with InstallShield on Windows, it is possible to run upon
uninstallation a custom action which uses an executable stored in the binary
table. That's basically what I want to do with RPM.

Any ideas on how to do that?

Thanks in advance.

Ben
Bob Proulx
2007-10-05 15:05:54 UTC
Permalink
Post by s***@free.fr
I basically want a small tool to be executed when my rpm is being
uninstalled by the user. This tool should be embedded in the RPM
package but should be extracted only upon uninstallation, and should
be removed after being run. I can not use the %file directive to
include this tool in my package since I do not want this file to
actually be "installed" or stored on the user's system.
First you do need to install it using a %file location someplace on
the system and it will live there while the package is installed. But
put it someplace out of the way. If the program is architecture
independent (that is, a script) then I would install it in
/usr/share/<pkgname>/postun/scriptfile, or just embed the actions in
the rpm %preun script. If the program is a binary executable then I
would install it in /usr/lib/<pkgname>/postun/progfile or some such
locations. They will be on the system but out of the way. Then upon
uninstall, in the %preun script section, invoke your special uninstall
program.

The ordering is that the %preun actions run, %files are uninstalled,
the %postun actions run. If you need to have this run in the %postun
section after the %files have been removed then I think you would need
to copy the special uninstall program to /tmp/<pkgname>/prog in a
secured subdirectory to save it from the %files removal and then in
the %postun call the program. After the run in the %postun
continuation you can remove the /tmp/<pkgname> directory to clean up.

Test and verify everything.

Bob

Loading...