To leave the system in a cleaner state, I am trying to remove entries from the PATH in the %preun section of my rpm spec file.
I found couple of threads on stackoverflow that I tried
Answers in both these links work perfectly when I manually run them on a terminal. But, they don't work when I run the rpm -e xx command. If my PATH looked like this after successful installation:
and I am trying to remove /usr/lpp/mmfs/bin,
After the rpm uninstall the PATH looks like:
Questions: 1) Do I need to do something different when the commands mentioned in the earlier links are run from the spec file?
2) What are some recommended ways to remove PATH entries during rpm uninstalls?
Note Commands I have tried in spec file are:
PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')
%preun script cannot affect the
PATH variable of any running shells. That isn't possible.
It can't (directly) affect the
PATH variable of any new shells either.
The only thing it can do is remove whatever changes it made to the system (or user shudder) shell startup files that caused the
PATH variable additions to be made.
Removing those changes will cause any new shells not to have those changes made and therefore not to have those additional
PATH entries in them.
$PATHmodifications during install then yes, removing them would be potentially appropriate. Though, as I just said in a comment on the OP, an RPM that modifies
$PATHis a bad idea as far as I'm concerned. — Jan 18, 2015 at 13:40
Local articles referenced by this article: