Need some help understanding the RPM spec bit operator

Greg_Swift at aotx.uscourts.gov Greg_Swift at aotx.uscourts.gov
Fri Aug 13 13:25:58 UTC 2010


rpm-list-bounces at lists.rpm.org wrote on 08/12/2010 02:12:23 PM:

> I am having some trouble understanding how the RPM spec bit operator
> seems to work. The documentation that I have been able to find confirms
> my understanding of it but, in practice, it doesn't work that way.
>
> In my spec file, I define a variable like this:
> %{!?debug: %global debug 0}
> %if %{debug}
> %define __strip /bin/true
> %endif
>
> Later on I use that same variable like this:
> ./configure --prefix=%{_prefix} %{?debug: --enable-debug}
>
> The rpmbuild command line can be called with "--define 'debug 1'" when
> compiling with debugging enabled of without that "--define" when
> compiling without debugging.
>
> However, no matter what the value of the %{debug} variable is,
> "--enable-debug" is present on the ./configure command line. Why is
> that? I thought that the bit operator tests not only whether a variable
> is defined but also whether it's value is 0 or 1?

In my experience doing %{?debug} is strictly checking to see if that macro
is defined at all, not an IF operation on the contents of the variable.  So
if at the top you are making sure that %{debug} is defined with that global
line, then the --enable-debug line will always get placed.  With that said,
there may be a way to do what you are talking about, because the macro
lines are fairly powerful.  If you haven't read this page, maybe it will
help?

http://www.rpm.org/wiki/PackagerDocs/Macros

Some of that is a bit beyond me, so the way I would have done something
like that would have been:

%{!?debug: %global debug 0}
%if %{debug}
%define __strip /bin/true
%define configure_debug --enable-debug
%endif


./configure --prefix=%{_prefix} %{?configure-debug}


-greg



More information about the Rpm-list mailing list