[Rpm-maint] [PATCH] Check for undefined macros
Dmitry V. Levin
ldv at altlinux.org
Wed Feb 6 03:09:00 UTC 2013
On Sun, Jan 27, 2013 at 05:27:09AM +0000, Alexey Tourbin wrote:
> This change introduces a generalized routine rpmExpandMacros() to expand
> macros on behalf of user input, with improved diagnostic facilities.
> In particular, one of its arguments is a callback function which is
> called whenever an undefined macro is encountered in user input.
> When specfile parser calls this routine, it supplies a custom function
> to handle undefined macros. This function is keenly aware of specfile
> syntax: valid specfile tokens, such as %prep and %setup, when found in
> the right context, are not treated as undefined macros. Otherwise,
> there are 3 possibilities.
> - Undefined macros in preamble and %pre/%post/... scriptlets raise
> an error, unless a non-build parse is performed; this is to prevent
> malformed packages from being built.
> - In other cases, a warning is issued.
> - Some tokens are permitted beyond their context (e.g. %ghost in
> %changelog), to comply with traditional/sloppy usage. Also, undefined
> macros found in comments normally do not produce a warning.
The idea is certainly not new, it was implemented in ALT Linux in October
of 2005, actually. This feature proved to be useful in catching subtle
specfile bugs caused by undefined macros. Said that, one should
understand that a change that results to some previously acceptable
specfiles being rejected is a policy enforcement. Whether it is a good
idea to impose this specfile check without some grace period during which
newly recognized specfile errors are reported but not yet raise errors
depends on your user base, percentage of specfiles affected by the change,
how long it would take to fix them all, etc. In ALT Linux, we chosen "no
grace period" option and introduced %_allow_undefined_macros macro
allowing users to relax the check. Of course, your mileage may vary.
Finally, I'd like to thank Alexey for bringing this feature to a wider
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
More information about the Rpm-maint