Mailinglist Archive: opensuse-packaging (116 mails)

< Previous Next >
[opensuse-packaging] Re: No %if inside %with?
On 10.12.2017 17:58, Sebastian wrote:

For the package python-termstyle[0] I want to deactivate the tests
because of problems with the default encoding which I can't solve. The
requirement of the project maintainers is to not comment them out but
change the `%bcond_without tests` to `%bcond_with tests`. But now I have
a problem inside %check, which looks like this:

%if %{with tests}
export LANG=C.UTF-8
python2 test -s test2
python3 test -s test3

%ifpython2 / %ifpython3 don't work like this, in the first place.

what you want is instead: %if 0%{?have_python2} / have_python3

difference being:
%ifpython2/3 applies to parts that are different between subpackages. That is:
%description, %files, %pre, %post etc.
it does nothing for parts that are *common*: %prep, %build, %install, %check

that is because %ifpython2 is a rewrite-time check: "should this part of the
spec go into a python2
whereas %have_python2 is asking "is a python2 present in the environment?" (*)

In addition, %ifpython2/3 can't be nested within other ifs, due to the way RPM
parses it. That is
what Neal said, for nested conditions you need to use the longer form, "%if

(*) Which is not even the right question to ask, it should be "is python2 in
the build set?". There
is currently no good way to ask that. I've been working on it but I don't have
a good solution yet.
Also it would be nice if there was a way to do both without the "two spellings"
confusion. I'm not
convinced that it is possible though, without even worse magic that is already

With `%bcond_without tests`, rpm does not complain (the checks fail, but
we know that already), but when I use
`%bcond_with tests` I get:

[ 52s] error: /home/abuild/rpmbuild/SOURCES/python-termstyle.spec:72: Got a
%endif with no %if
Where lne 72 is the last %endif in that section. If I comment out both
%ifpythons, then it works.

Does someone maybe has a clue why this is happening?



< Previous Next >