| Summary: | %ifarch wrapping of definitions inside a macro function does not work | ||
|---|---|---|---|
| Product: | [Fedora] Fedora | Reporter: | Jens Petersen <petersen> |
| Component: | rpm | Assignee: | Fedora Packaging Toolset Team <packaging-team> |
| Status: | CLOSED WONTFIX | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 21 | CC: | ffesti, lkardos, pmatilai, rvokal |
| Target Milestone: | --- | Keywords: | Reopened |
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-07-01 12:48:48 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
Panu explained to me in IRC that %if[n]arch is a spec directive.
So in /usr/lib/rpm/macros does
%debug_package \
%ifnarch noarch\
%global __debug_package 1\
%package debug\
Summary: Debug information for package %{name}\
:
%endif\
%{nil}
work because %debug_package is only invoked late
in the rpmbuild process?
Anyway looks like I will have to make ghc-rpm-macros arch... ?
I have worked around it for now by making ghc-rpm-macros arch. This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component. This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component. This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle. Changing version to '19'. (As we did not run this process for some time, it could affect also pre-Fedora 19 development cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.) More information and reason for this action is here: https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19 This is similar to bug 495658 (or my 3rd report bug 1169111 ;) or NOTABUG anyway I guess (ir "don't use %global inside a macro function def!"). Erm, actually %global set_hello \ %ifarch ppc\ %define __with_hello hello\ %endif gives the same result. The problem is that "%ifarch" is not a real macro but it is a spec directive. So the rpm macro expander doesn't handle it in any special way. For the rpm macro expander "%ifarch" is just an ordinary string.
Rpm macros and directives don't provide a fully featured programming language and not everything is possible by them. But in rpm spec files it is possible to use the lua language that is more complex. You can do what you want in lua language:
%define set_hello \
%{lua:
if rpm.expand("%{_target_cpu}") == "ppc" then
rpm.define("__with_hello hello")
end
}
...
%prep
%set_hello
echo %{?__with_hello}
Be aware that I used "%define" in above code when you replace it with "%global" then the lua code will be executed in time of definition of set_hello and not in time of calling set_hello.
I am closing this as wontfix because purpose of macros and directives is not to be fully featured programming language and for cases like this we have the lua language that is more complex.
|
Description of problem: RPM seems to be evaluating global defines eagerly inside macro definitions with %ifarch/%ifnarch? Sorry if this is a FAQ but not sure how to solve this: the behaviour seems a bit confusing to me. Version-Release number of selected component (if applicable): rpm-4.8.1-5.fc14 also tried 4.9.0 beta in rawhide How reproducible: every time Steps to Reproduce: I try to do the following say in a .spec file (obviously this is just a testcase): %global set_hello \ %ifarch ppc\ %global __with_hello hello\ %endif %prep %set_hello echo %{?__with_hello} Actual results: + echo hello hello Expected results: no hello! Additional info: Actually the result seems to be the same for me with "%ifarch anyblah" or "%ifnarch anyblah blah", etc. How can I make the evaluation less eager? I tried playing with %{expand:...} but that didn't help. Maybe I have to make my macro file arch specific? The context is I am trying to make some macros be only set for ppc since ghc does not support native shared libraries on that arch.