RPM auto relocate directory


I create a RPM with “Prefix” in the spec file.
When I install the RPM with the “–relocate” option, the files are good relocated :).

I want relocate the files during the installation according to tests (ex: personal directory of a user, java home), but I did not find how to do it :(.
I saw that there was an environment variable RPM_INSTALL_PREFIX, but changing its value has no effect.

Can you tell me how to do.


It is set by RPM itself during installation for use in scriptlets.

Can you tell me how to do.

Not sure I understand the question. You can call rpm with different values of --relocate or --prefix if you want to install it in different places. But you already know it. Please explain what you are trying to do.

I want to make an RPM that puts files in the personal directory of a service account.
If the account does not exist, I do not have a pb because I create the account with for his home directory the default path.
But if the account exits, I wish that the files present in my source goes in the directory of the existing account. And I would like to take into account the fact that his personal directory is not necessarily the default path.

I tried to change the variable RPM_INSTALL_PREFIX in the parts “% prep” and “% install” but that does not change anything.

Thanks for your help

You explained why you want to install in different locations. You did not explain why you cannot use “rpm --relocate” for it.

I wish it could be automatic and if I install the RPM through Yast I can not pass the --relocate parameter

I am not aware of possibility to control relocation (or any other rpm option for that matter) using environment variable. Nor is it necessary for your use case - just always install in standard location and use links/alternatives/bind mounts to point to it as needed.

OK, thank you for your return