Conditional macros are defined for true else must be 0 for false.

The RPM spec file will return value for %{?macro:value} if the
macro is defined. This means you need to:

%if %something
 %define macro 1
%else
 %undefine macro
%endif

which means you have to have more complex tests to check for the macro
and its value. Therefore we support defined as true and defined and
0 as false.
This commit is contained in:
Chris Johns 2013-03-02 16:08:05 +11:00
parent a18e76bd85
commit 45ca8cf134

View File

@ -380,9 +380,10 @@ class file:
if m.startswith('%{?'):
istrue = False
if mn in self.defines:
# If defined and 0 then it is false.
istrue = _check_bool(self.defines[mn])
if istrue is None:
istrue = False
istrue = True
if colon >= 0 and istrue:
s = s.replace(m, m[start + colon + 1:-1])
expanded = True
@ -393,7 +394,7 @@ class file:
isfalse = True
if mn in self.defines:
istrue = _check_bool(self.defines[mn])
if istrue is not None and istrue == True:
if istrue is None or istrue == True:
isfalse = False
if colon >= 0 and isfalse:
s = s.replace(m, m[start + colon + 1:-1])