What does "%if 0%{?..." mean
Jeff Johnson
n3npq at mac.com
Sun Jan 18 07:02:28 UTC 2009
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
More information about the Rpm-list
mailing list