[Rpm-maint] [PATCH] Check for undefined macros
Alexey Tourbin
alexey.tourbin at gmail.com
Wed Feb 13 06:07:40 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.
This is actually the most important patch, because it unveils many
typos/thikos in specfiles, and it can be instrumental in improving
package base (as opposed to improving rpm code base proper, with no
overt impact on the packages).
Since Fedora 19 is in its early stage of development, and since RHEL7
probably won't be using rpm-4.11+ anyway, I wonder whether this is the
right time and otherwise a good idea to make a release with this patch
applied (along with a few other patches related to syntax). If it turns
out to be a good idea, I'm willing to spend more time and come up with
"full coverage" results for Fedora 18 specfiles (I have already posted a
rather detailed if preliminary analysis of some common errors).
> 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.
> ---
> build/files.c | 66 ++++++++++++++++++--
> build/pack.c | 11 ++--
> build/parseSpec.c | 154 +++++++++++++++++++++++++++++++++++++++++++---
> build/rpmbuild_internal.h | 11 ++++
> build/spec.c | 3 +
> rpmio/macro.c | 67 +++++++++++---------
> rpmio/rpmmacro.h | 28 ++++++---
> 7 files changed, 287 insertions(+), 53 deletions(-)
More information about the Rpm-maint
mailing list