substitutions in pkg-plist
Ricardo Nabinger Sanchez
rnsanchez at wait4.org
Tue Oct 30 13:29:06 PDT 2007
While working on an non-public port, I noticed that when I used macros like
%%ETCDIR%%, %%EXAMPLESDIR%%, inside @exec, @unexec and @dirrm/@dirrmtry,
the terminal output was as expected, but the commands would fail silently.
For instance, I tried this (pkg-plist):
@exec [ -d %%ETCDIR%%/socksarmor ] || mkdir -v %%ETCDIR%%/socksarmor
@unexec if cmp -s %%EXAMPLESDIR%%/socksarmor.config %%ETCDIR%%/socksarmor.config; then rm -f %%ETCDIR%%/socksarmor.config; fi
@unexec if cmp -s %%EXAMPLESDIR%%/socksarmor.xml %%ETCDIR%%/socksarmor.xml; then rm -f %%ETCDIR%%/socksarmor.xml; fi
When executing pkg_add or pkg_delete (both with -v), the terminal output
was fine, but things were not being executed. In this very case, I could
confirm with ls that %%ETCDIR%%/socksarmor, for instance, was not being
created. I copy-pasted the commands pkg_add printed, verbatim, and they
worked as expected.
After lots of googling and Mk browsing, I finally decided to partially
hardcode things and use %D whenever possible, getting this:
@exec [ -d %D/etc/socksarmor ] || mkdir -v %D/etc/socksarmor
@unexec if cmp -s %D/share/examples/socksarmor/socksarmor.config %D/etc/socksarmor/socksarmor.config; then rm -f %D/etc/socksarmor/socksarmor.config; fi
@unexec if cmp -s %D/share/examples/socksarmor/socksarmor.xml %D/etc/socksarmor/socksarmor.xml; then rm -f %D/etc/socksarmor/socksarmor.xml; fi
This works, but it is not clear why %%whatever%% macros fail silently. I
couldn't find useful docs, perhaps because google strip %s off my queries.
Comments are appreciated. :)
Ricardo Nabinger Sanchez rnsanchez at wait4.org
Powered by FreeBSD
"Left to themselves, things tend to go from bad to worse."
More information about the freebsd-ports