Re: Check whether a macro is undefined or has a specific value

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

 



2011/8/16 Daniel Neuberger <daniel.neuberger@xxxxxxxxx>:
> On 08/16/2011 07:22 AM, Marco wrote:
>>
>> as the subject says: If macro %{__foo} is defined and has value 1, I'd
>> like to do something; otherwise (undefined or value != 1), skip.
>
> See the section about defining conditional macros:
> http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch10s06.html#id508811
>
> Here's an example that's similar to what you're talking about:
>
> %define  _default_release 1
> %define  _release
> %{!?_svn_last_rev:%{_default_release}}%{?_svn_last_rev:%{_svn_last_rev}}
>
> I only know how to check for definition, not equality, but it shouldn't be
> too hard to make that work for you.

Thanks. I don't need to define another macro based on the value of
%{__foo}. However based on your suggestion, I think I can do this,
which seems to work:

%if %{?__foo:1}%{!?__foo:0}
%if "%{__foo}" == "1"
  echo "foo is defined and is 1"
%else
  echo "foo is defined, but has some other value: %{__foo}"
%endif
%else
  echo "foo is not defined"
%endif

Does this look correct/reliable enough or is there a better way to do
what I'm trying to do? Thanks.
_______________________________________________
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