Bug 1288164 - RFE: please provide bash function for querying current macros
Summary: RFE: please provide bash function for querying current macros
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-12-03 17:29 UTC by Jaroslav Škarvada
Modified: 2016-01-08 09:29 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-01-07 14:37:50 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Jaroslav Škarvada 2015-12-03 17:29:53 UTC
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 14:37:50 UTC
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 09:29:33 UTC
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.