Bug 1288164 - RFE: please provide bash function for querying current macros
RFE: please provide bash function for querying current macros
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2015-12-03 12:29 EST by Jaroslav Škarvada
Modified: 2016-01-08 04:29 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-01-07 09:37:50 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jaroslav Škarvada 2015-12-03 12:29:53 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):

How reproducible:

Steps to Reproduce:
1. Try to get the value of %_excludedocs macro from bash from %post

Actual results:
It doesn't seem to be possible (rpm --eval doesn't work if rpm --excludedocs was used).

Expected results:
The mechanism how to query the macro, e.g.
if [ `_expand_macro("_excludedocs")` = 1 ]; then

Additional info:
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.
Comment 1 Ľuboš Kardoš 2016-01-07 09:37:50 EST
Well, there is a way how to achieve what you want. You can use option "-e" (expand macros) for your postscript:

%post -e
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.
Comment 2 Jaroslav Škarvada 2016-01-08 04:29:33 EST
Interesting, thanks for info. It shouldn't be hard to fix bug 1227824 now. It seems it's documented, I found:

Note You need to log in before you can comment on or make changes to this bug.