How to create an RPM post script that can be relocated?
Hi,
I am trying to create an RPM package where the post script is able to figure out if the package get relocated. I need that because the RPM is installing some *.so links into /usr/lib and they need to point to the right location. Thanks |
If %post has access to any args given to rpm (dunno), maybe you could parse $@ for the arg thats shift 1 at --relocate?
|
Accessing relocatable rpm install directory prefix from %post script
I found similar questions in several forums (none with answers). So I'm resurrecting this thread with the answer.
Problem: The default prefix is %{_prefix} but the %post section of the spec file can only use it when the rpm is being built, we need to know the prefix when the rpm is being installed. Solution: Use the environment variable $RPM_INSTALL_PREFIX to determine where the package prefix is at install time. e.g. Prefix: /usr %post #Soft link example ln -s %{_prefix}/lib/mylib.so $RPM_INSTALL_PREFIX/lib/mylib.so #Echo example if [ $RPM_INSTALL_PREFIX == %{_prefix} ] then echo "package installed in default location: %{_prefix}" else echo "package installed in user-defined location: $RPM_INSTALL_PREFIX" fi In the above example %{_prefix} is changed to the default prefix "/usr" when the script is written and the environment variable $RPM_INSTALL_PREFIX is replaced with the one given on the commandline at install time. i.e. rpm -i --prefix /usr/local package.rpm |
All times are GMT -5. The time now is 11:25 AM. |