Re: Complex conditional %define in .rpmmacros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2012/10/11 Panu Matilainen <pmatilai@xxxxxxxxxxxxxxx>:
> 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 http://pastebin.com/EHKwE59C

Hi Panu, hi everybody.

> 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.

Yes, i know, I used "case" just to better express my idea,
but i didn't knew about %define within conditionals.

>> 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.

Didn't knew about %include , this did the trick.

For the record, here's how i did:

%include set-compiler.inc

Contents of set-compiler.inc
----
%if "%{compiler_name}"  == "intel"
%{!?compiler_version:   %global compiler_version %intel_compiler_version}

%else

%if "%{compiler_name}"  == "pgi"
%{!?compiler_version:   %global compiler_version %pgi_compiler_version}

%endif

%endif

%{!?compiler_name:      %global compiler_name gnu}
%{!?compiler_version:   %global compiler_version %gnu_compiler_version}
----

>> 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 -

The problem must have been me, ;)
and as i fixed it with %include, i'm not going further with lua.

Thank you very much for your help!
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list


[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux