0

I'm currently trying to assure that some specific files and folders get deleted once I remove an rpm package for good. So, to make things simple, I just created a file ~/sample.txt to be deleted on a post-uninstall script. So I have this section on my spec file:

%postun

if [ "$1" = 0 ];
    then
    rm -f ~/sample.txt
fi

The thing compiles, given that typos got warned once I've tried to delete the package but, even when fixed, the postun script seems to not run at all. My suspicion is that since the rpm didn't create the ~/sample.txt file, it wouldn't be able to delete it either.

Note: the conditional if [ "$1" = 0 ]; follows a suggestion from here to avoid deletion on upgrades.

Evandro Teixeira
  • 321
  • 3
  • 18

1 Answers1

2

When installing or removing a rpm package, the root user is executing the commands, so ~/sample.txt will be expanded to /root/sample.txt

PS: a very nice overview for the arguments you get in the pre/post/preun/postun scripts: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/

Chris Maes
  • 35,025
  • 12
  • 111
  • 136