Re: What does "%if 0%{?..." mean

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

 



On Jan 18, 2009, at 1:42 AM, Jonathan Ryshpan wrote:

> On Sat, 2009-01-17 at 23:20 +0100, Jos Vos wrote:
>> On Sat, Jan 17, 2009 at 02:09:31PM -0800, Jonathan Ryshpan wrote:
>>
>>> I have a spec file with this text.
>>>        %if 0%{?build_jack_svn}
>>>        %define jack_revision 3190
>>>        %define jack_version 0.116.1
>>>        %define jack_svndate 20081206.171018
>>>        %else
>>>        %define jack_version 0.116.1
>>>        %endif
>>>
>>> What does all this do?  I can't find the form "%if 0%{?mac}" defined
>>> anywhere.  I assume it means the macro mac exists and has the  
>>> value 0
>>> -- is this correct?
>> 0%{?build_jack_svn}0%{?build_jack_svn}
>> No.
>>
>> The "0%{?build_jack_svn}" expands to "0X" where "X" is the value of
>> the %{build_jack_svn} macro if this macro is defined, or it expands
>> to "0" if the %{build_jack_svn} macro is not defined.
>
> I surmise from this that
> 	%if 0%{?build_jack_svn}
> is *always* true, since
> 	0%{?build_jack_svn}
> always has a value.
>

No.

After expansion, there will be
	%if 0
or
	%if 01
depending on whether the macro is undefined or defined to "1".

Macro expansion will be attempted on anything within %{...}
before the %if is tested.

The truth value is determined by converting the integer, 0 == false,  
01 == true.

> If so, the "%if" statement above is has no effect, since it is always
> true, and the spec file fragment is probably buggy.
>
> Please pardon my ignorance.  My experience with RPMs up to now has  
> been
> entirely limited to installing and sometimes building them.
>

np. %if blended with macro expansions is a bit wonky; the pieces
don't fit together very well, and its certainly a strange looking
syntax.

73 de Jeff
_______________________________________________
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