bcond and defaults

Posted on Nov 14, 2025

A while ago we looked at conditional building in rpm. One point we did not cover yet was how we can control build conditionals within the open buildservice.

Back in the good old days

When using osc build --with=build_docs --without=run_tests rpm internally defines 2 variables:

_with_build_docs
_without_run_tests

Which is also something we used when integrate it with the buildservice:

%define _with_ruby34 1
%define _without_apparmor 1
Macros:
%_with_ruby34 1
%_without_apparmor 1
:Macros

This was working mostly well. We could have one spec file which then had features turned on and off depending on the _with(out)_something defines. But it completely failed if an user later wanted to toggle the decision made on the base distro.

You could not really undefine any of those with/without defines. The number at the end? Does not matter. Setting it from 0 to 1. The defines remained.

Into a brighter future

Back in 2023 Michael Schröder added a nice new feature in rpm:

%bcond_default_something 1

Since 2025-10-22 the feature is now also implemented in obs-build and deployed on https://build.opensuse.org/. Woohoo!

So now we can add this to our project config:

#
# https://github.com/rpm-software-management/rpm/pull/2405
#
%if 0%{?suse_version} >= 1600
Macros:
%bcond_default_apparmor 1
:Macros
%endif

This will take precedence over the %_without_apparmor 1 in the SLFO/Leap project config. Now packages like php8 can be rebuilt for Leap 16.0 and have their AppArmor features turned back on.

Now what?

I spoke to Michael and he recommends to move all the _with(out)_something in Leap/SLFO/SLES 16 and openSUSE Tumbleweed the new syntax.

But what about SLES 15 and Leap 15? Or even older distros? There you have no other options at the moment than the old _with(out)_something defines. At least for now.