Complex conditional %define in .rpmmacros

Panu Matilainen pmatilai at
Thu Oct 11 08:32:18 UTC 2012

On 10/09/2012 09:20 PM, Fabricio Cannini wrote:
> Hi there
> I have a group of packages that i have to create different versions
> based on the compiler brand and version.
> These variables ( compiler brand and version ) define some features of
> the binary rpms i'm generating,
> like "%_prefix", "%release" , "%optflags" and so on ...
> My idea is to make something like this

Macro files are not shell scripts, that's a no-go. Another problem here 
is the use of %define within conditionals:

{!?compiler_version: %define compiler_version 4.4}

You need to use %global instead of %define there, otherwise you'll 
encounter some bizarre effects sooner or later: technically such a 
nested define falls out of scope immediately, but might not be actually 
"garbage collected" until much later.

> I can do it with a few "%if ... %else ... %endif" , in the package spec file,
> but i'd like to put in ~/.rpmacros to avoid the copy & paste to every
> .spec file. Eeek!

You can avoid copy-paste by putting the common part into a separate file 
and pull it into specs with %include.

> I also tried the lua bindings, but no deal too.

What was the actual problem here? Lua is basically the best/only way to 
get arbitrarily complex things done inside macros.

	- Panu -

More information about the Rpm-list mailing list