From Fedora Project Wiki
fp-wiki>ImportUser
(Imported from MoinMoin)
 
 
(3 intermediate revisions by 3 users not shown)
Line 3: Line 3:
== current usage of %define beneath Packaging ==
== current usage of %define beneath Packaging ==


* ["Packaging/KernelModules"]
* [[Packaging/Perl]]  
* ["Packaging/Perl"]  
* [[Packaging/Ruby]]  
* ["Packaging/Ruby"]  
* [[Packaging/Python]]  
* ["Packaging/Python"]  
* [[Packaging/DistTag]]  
* ["Packaging/DistTag"]  


all uses are for either
all uses are for either


* <code>%{!?foo:%define foo ...} </code> usage, or
* <code>%{!?foo:%define foo ...} </code> usage, or
* global top level macor definitions.
* global top level macro definitions.


So both can be simply <code>s/%define/%global/g</code>.
So both can be simply <code>s/%define/%global/g</code>.
Line 27: Line 26:


The reason this hasn't bitten us as often is that due to a minor bug in rpm the invalidated local macro definition is not garbage collected unless other events force rpm to. So the bug is seldomly triggered, but when it is, it is difficult to diagnose the issue. That's why we'd like to keep away from <code>%define</code>s and educate packagers to use <code>%global</code> by default to avoid creation of new latent bugs.
The reason this hasn't bitten us as often is that due to a minor bug in rpm the invalidated local macro definition is not garbage collected unless other events force rpm to. So the bug is seldomly triggered, but when it is, it is difficult to diagnose the issue. That's why we'd like to keep away from <code>%define</code>s and educate packagers to use <code>%global</code> by default to avoid creation of new latent bugs.
[[Category:Packaging guidelines drafts]]

Latest revision as of 23:28, 22 February 2009

%global preferred over %define

current usage of %define beneath Packaging

all uses are for either

  • %{!?foo:%define foo ...} usage, or
  • global top level macro definitions.

So both can be simply s/%define/%global/g.

Proposal for addition into the guidelines

%global preferred over %define

Use %global instead of %define, unless you really need only locally defined submacros within other macro definitions (a very rare case).

Rationale: The two macro defining statements behave the same when they are a the top level of rpm's nesting level.

But when they are used in nested macro expansions (like in  %{!?foo: ... } constructs, %define theoretically only lasts until the end brace (local scope), while %global definitions have global scope.

The reason this hasn't bitten us as often is that due to a minor bug in rpm the invalidated local macro definition is not garbage collected unless other events force rpm to. So the bug is seldomly triggered, but when it is, it is difficult to diagnose the issue. That's why we'd like to keep away from %defines and educate packagers to use %global by default to avoid creation of new latent bugs.