Created attachment 339452 [details] testcase.spec Description of problem: I recently switched one of my packages to using %global instead of %define as had been recommended to us. Today I discovered that %global does not expand %{?2:...} like %define does, causing missing requires in a bunch of the subpackages. Version-Release number of selected component (if applicable): 4.7.0.rc1 How reproducible: every time Steps to Reproduce: 1. rpmbuild -bb testcase.spec 2. rpm -qp --requires ~/rpmbuild/RPMS/noarch/testcase-0-1.noarch.rpm Actual results: 1. %define expands %{?2:...} but %global seems to ignore it. Expected results: %define and %global to behave the expand %{?2:...} the same way.
So use %define instead of %global. Adding an RFE in bugzilla to state an expectation that %global should work like %define so that Fedora packaging policy recommendations can be accurately stated as Always use %global. makes very little sense to me. Have fun!
That is fine but are the expected behaviours of the two documented somewhere?
There's not much to document. Macro expansion proceeds through levels of recursion. %define is wrto whatever recursion level is active, with automatic garbage collection and %undefine upon return. %global is just a macro defined at the top level, i.e. level 0. The problem is that lusers are surprised when %define not at level 0 disappears. This is exactly the behavior implemented and intended, just not what lusers expect. Are luser expected behaviors of RPM documented anywhere? ;-)
Thanks for that explanation. Given that my testcase is for level 0 %define, what is the difference in this base between %define and %global? (Docs, muahaha;)
The difference is that %define "works" and %global does not.
The difference is that %global expands the body at definition time whereas %define doesn't. Fedora recommendation of %global over %define completely misses this point. You can force %global to be lazily expanded with %%-escapes though: %global globalrequires()\ Requires: %%1, %%{?2:%%2-devel}