Red Hat Bugzilla – Bug 1288164
RFE: please provide bash function for querying current macros
Last modified: 2016-01-08 04:29:33 EST
Description of problem:
I think there should be mechanism how to query current values of macros (e.g. install time macro values, not build time values). The only solution known to me is to write the whole scriptlet in LUA which is too restrictive. This could be used for e.g. for detection of the state of the _excludedocs macro from %post during the install time.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Try to get the value of %_excludedocs macro from bash from %post
It doesn't seem to be possible (rpm --eval doesn't work if rpm --excludedocs was used).
The mechanism how to query the macro, e.g.
if [ `_expand_macro("_excludedocs")` = 1 ]; then
There was postfix bug 1227824 complaining that postfix installs documentation symlinks in --excludedocs mode. The symlinks are created by 'alternatives' which is called from %post scriptlet. The %post scriptlet is quite complex and written in bash. There is no reliable way known to me how to check that the RPM installs in --excludedocs mode (e.g. that the macro _excludedocs is set to 1) other than usage of LUA for the whole %post scriptlet.
Also just adding some bash alias variable for _excludedocs (e.g. $RPM_EXCLUDEDOCS) would resolve this problem, but I think that more generic approach to this problem would be better.
Well, there is a way how to achieve what you want. You can use option "-e" (expand macros) for your postscript:
if [ "%%_excludedocs" = 1 ]; then
Notice that double "%" is used to disable expansion during build.
Sorry that firstly I told you there is no way how to do this. I didn't know there is something like this in rpm until I found it in rpm code when I was trying to implement it.
Interesting, thanks for info. It shouldn't be hard to fix bug 1227824 now. It seems it's documented, I found: