[Rpm-maint] [PATCH] Stricter macro substitution syntax

Panu Matilainen pmatilai at laiskiainen.org
Wed Feb 13 11:15:28 UTC 2013


Moving this to rpm-maint, for those who missed the initial discussion on 
rpm-list the start of the thread is here:
http://lists.rpm.org/pipermail/rpm-list/2013-January/001358.html

On 01/21/2013 10:14 PM, Alexey Tourbin wrote:
> This change introduces a separate routine to parse for valid macro
> names.  Valid macro names are either regular 3+ character identifiers,
> or special names: "S", "P", "0", "#", "*", "**", macro options such as
> "-o" and "-o*", and macro arguments such as "1".  Other names are not
> valid.  This fixes a number of bugs seen earlier due to sloppy name
> parsing: "%_libdir*" and "%01" were not expanded (these are now expanded
> to e.g. "/usr/lib64*" and "<name>1", as expected).  This also fixes
> bugs in as-is substitution: "%!foo" was expanded to "%foo", and likewise
> "%!!!" was expanded to "%" (and to "%<garbage>" at EOL).
>
> Also, bad names in %name and %{name...} substitutions are now handled
> differently.  In %name form, the name is parsed tentatively; a silent
> fall-back to as-is substitution is provisioned when no valid name can
> be obtain.  In %{name...} form, a failure to obtain a valid name is now
> a syntax error.  Furthermore, only 3 variants are syntactically valid:
> %{name} proper, %{name:...}, and %{name ...}.  This renders invalid
> ambiguous macro substitutions such as the one found in FC18 lvm2.spec:
>
> Requires: util-linux >= %{util-linux_version}
> error: Invalid macro syntax: %{util-linux_version}

After far too much time spent pondering... applied.

Not only is this highly useful in spotting typos and the like in specs, 
it also helps cleaning up the expandMacro() monster by splitting the 
macro name and flag parsing into separate and obvious functions.

Thanks for the patch!

	- Panu -


More information about the Rpm-maint mailing list