centos - Relocated path in a postinstall script -


i'm working on rpm package deploys files /opt , /etc.

in of cases works perfectly, excepted given environment, writing /etc not allowed ....

so used relocations in order deploy /etc files in other location :

relocations : /opt /etc 

by specifying --relocate option can deploy /etc files location :

rpm -ivh --relocate /etc=/my/path/to/etc mypackage.rpm 

now issue in postinstall script, there hard coded references /etc don't replaced when package deployed :

echo `hostname --fqdn` > /etc/myapp/host.conf 

i hope there way (macro, keyword, ... ) use instead of hard coded paths in order perform substitutions during rpm execution.

if have information on i'd appreciate help.

thanks per advance

ps : please note not duplicate of asked (and answered) questions related root path re-locations we're dealing several relocation paths , fact need handle each of them separately during rpm scriptlets

many panu matilainen rpm mailing list answered question. i'll re-produce mail literally in order share knowledge :

i assume mean (the above how rpm -qi shows though):

prefixes: /opt /etc 

the prefixes passed scriptlets via $rpm_install_prefix<n> environment variables, <n> index of supported prefixes starting zero. in above,

/opt $rpm_install_prefix0 /etc $rpm_install_prefix1

so scriptlet example becomes:

echo `hostname --fqdn` > $rpm_install_prefix1/myapp/host.conf 

works charm, thank panu !


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -