Bug 722933

Summary: It's *NOT* possible to use %%-escaping to force lazy expansion of %global.
Product: [Fedora] Fedora Reporter: Vít Ondruch <vondruch>
Component: rpmAssignee: Panu Matilainen <pmatilai>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ffesti, jnovy, pmatilai
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-19 08:38:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Vít Ondruch 2011-07-18 14:18:36 UTC
Description of problem:
RPM wiki [1] as well as [2] Fedora packaging guidelines state that "It's possible to use %%-escaping to force lazy expansion of %global.". However, trying to use "%%global foo bar" on first line of my spec file throws an error "error: line 1: Unknown tag: %global foo bar". So I suspect that the statement is not true. If it is true, then please update the documentation to be more descriptive.


Version-Release number of selected component (if applicable):
$ rpm -q rpm
rpm-4.9.0-9.fc15.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Insert "%%global foo bar" on the first line of spec file.
2. $ rpmbuild -bi mypackage.spec
3.
  
Actual results:
error: line 1: Unknown tag: %global foo bar

Expected results:
The variable will be lazily evaluated when needed.

Additional info:

[1] http://rpm.org/wiki/PackagerDocs/Macros
[2] http://fedoraproject.org/wiki/Packaging:Guidelines#.25global_preferred_over_.25define

Comment 1 Panu Matilainen 2011-07-19 08:38:44 UTC
The guideline explanation is a bit misleading or unclear at least.

%global is always expanded once at the time of "declaration", no %-escaping changes that. What I suppose the guideline comment means is that you can use
"%global foo %%{bar}" which will leave foo defined as literal "%{bar}", which will then have the effect of lazy expansion when you use %{foo}.

Comment 2 Vít Ondruch 2011-07-19 08:52:47 UTC
Thank you for explanation. That makes sense. Could you please manage to clarify the documentation (both places I liked above)?