Description of problem: When I define a spec file macro using lua script, I'm seeing that the macro is expanded/executed at definition-time, instead of at invocation time as is preferred. Specifically, the macro is invoked *twice*. The behavior only occurs if the macro is define as '%global'. Other macros with '%define' are not affected. Version-Release number of selected component (if applicable): This was tested on rpm-4.8.1-2 on an f14-x86_64 system. How reproducible: Always Steps to Reproduce: 1. Build the attached spec file 2. 3. Actual results: In the included spec file, each macro should be expanded exactly once. When I run this on my own system, I see that the %global macros are expanded twice: [roth@knut rpms]$ rpmbuild -bb test.spec __fn2: *** before expansion __fn4: hello __fn1: argc is 1 __fn1: arg is expand1 __fn2: argc is 1 __fn2: arg is expand2 __fn3: hello __fn4: hello Am I missing something about the semantics of '%global' macros? Expected results: Additional info:
Created attachment 458496 [details] SPEC file to illustrate macro behavior
(In reply to comment #0) > Am I missing something about the semantics of '%global' macros? Yes: the body of %global is expanded at definition time, whereas %define body is only expanded at the time of use. This is to support the intended use of %global, ie inside "function" blocks where the macro body could refer to other macros such as macro arguments that are only defined inside the {} block scope. The bug here is Fedora's packaging guidelines claiming %global and %define being equivalent and recommending %global everywhere. %global and %define, even at toplevel, are only equivalent when the macro body is constant. For function-style macros you'll practically always want to use %define.
*** Bug 650687 has been marked as a duplicate of this bug. ***