This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 1288164 - RFE: please provide bash function for querying current macros
RFE: please provide bash function for querying current macros
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: rpm (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: packaging-team-maint
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  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:
Environment:
Last Closed: 2016-01-07 09:37:50 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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):
rpm-4.12.0.1-13.fc22.x86_64

How reproducible:
Always

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.
%post
if [ `_expand_macro("_excludedocs")` = 1 ]; then
  :
fi

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
   ...
fi

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:
http://www.rpm.org/wiki/PackagerDocs/ScriptletExpansion

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