Bug 650688 - global spec macros with lua are expanded too early/too often
Summary: global spec macros with lua are expanded too early/too often
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 13
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 650687 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-11-07 18:57 UTC by Carl Roth
Modified: 2010-11-09 15:54 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-11-08 06:40:31 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
SPEC file to illustrate macro behavior (1020 bytes, text/plain)
2010-11-07 18:57 UTC, Carl Roth
no flags Details

Description Carl Roth 2010-11-07 18:57:10 UTC
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:

Comment 1 Carl Roth 2010-11-07 18:57:39 UTC
Created attachment 458496 [details]
SPEC file to illustrate macro behavior

Comment 2 Panu Matilainen 2010-11-08 06:40:31 UTC
(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.

Comment 3 Panu Matilainen 2010-11-09 15:54:07 UTC
*** Bug 650687 has been marked as a duplicate of this bug. ***


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