[Fedora-packaging] Are brackets around macros required?

Ralf Corsepius rc040203 at freenet.de
Sat Aug 20 05:16:25 UTC 2011


On 08/19/2011 11:45 PM, Göran Uddeborg wrote:
> Michael Schwendt:
>> Do you parse them all without testing?

I sense a misunderstanding.

People seem to presume rpm.specs to be written in a "well defined 
programming language" using a lexical scanner and parser underneath.

This does not apply, the "rpm.spec language" is a "macro language", 
similar to regexes and m4, using macro sets underneath, similar to 
autoconf or sendmail, with all kind of ambiguities and "historic 
heritage and historic heuristics" underneath.

I.e. rpm doesn't actually "parse" spec files in the sense 
compilers/interpreters would parse/interpret a well "defined language", 
it expands macros and passes the results to other parties.

>> From your question I was kind of expecting some surprising exception.
> But when I tested they all behaved the way I would have thought.
>
> But it doesn't matter.  I understand I'm not convincing anyone, and
> I'll change my package to follow this rule.
>
> One more detail before I go away.  Spec files do contain small scripts
> (%build, %post, etc.)  These scripts can use both spec file macros and
> shell variables.  The exchangable %{buildroot} and ${RPM_BUILD_ROOT}
> for example.  Does the rule to to always use brackets apply to both,
> or only to the spec macros?

They are supposed to be complete independent.

Actually, rpmbuild first expands the macros inside of spec's scriptlet 
and then hands the results over to the shell.

I.e. rpm itself is supposed not even to touch to let it pass through as 
"arbitrary text".

Ralf


More information about the packaging mailing list