I have tried to replace an expression in a file by $RPM_INSTALL_PREFIX in %post part of SPEC file. I used below command
sed -i "s/opt/$RPM_INSTALL_PREFIX/" /etc/mersad.conf
as I have respected it should change opt by the prefix which I use at installation. Unfortunately, it shows an error and doesn't do it. it just goes wrong in sed command and when I echo $RPM_INSTALL_PREFIX it shows the correct value.
Use a different find-replace separator than '/' in the sed command option. Try using '|' as that is unlikely to be found in $RPM_INSTALL_PREFIX paths.
Note that you will likely encounter other problems (on upgrade in particular) if attempting to use --relocate: relocations are not persistent through upgrades.