How bcond_without is supposed to work?

I’m a bit confused.
Using rust2rpm I obtain a spec file

...
%bcond_without check
...
%if %{with check}
%check
%cargo_test
%endif

In this way, using rpmbuild, the %check and %cargo_test macros are executed.
While setting %bcond_with check, such macros aren’t executed.

Sorry, but I was expecting the opposite! Where I’m wrong?

Yes, it is kind of backwards. When you write %bcond_without, that’s an option to turn it off but it will be %with by default, and vice versa for %bcond_with.

See also: rpm.org - Conditional Builds

1 Like

Yes. A useful mnemonic is that %bcond_without allows to optionally build without, and %bcond_with allows to optionally build with. This is confusing as hell. Just don’t use those.

The modern replacement is %bcond <name> <default>, in your case e.g.%bcond check 1, that will do tests by default.

1 Like

Seems like an improvement to the rust2rpm tool would be nice.
@alciregi You could raise an issue on its git repo.
I think its this one Issues - fedora-rust/rust2rpm - Pagure.io

1 Like