The wikis are now using the new authentication system.
If you did not migrate your account yet, visit

RPM Boolean Dependencies

Jump to: navigation, search

One of the great features of rpm 4.13 are boolean dependencies. Those dependencies work with all soft and hard requires and also build dependencies. For the basics see the official documentation above.


Avoid Recommends to install unwanted dependencies

# nginx.spec main package:
Recommends:  nginx-vim

On a system where recommends are enabled and vim is not installed, installing nginx would trigger installing vim. In the past a solution via packageand() could have been used. But a more portable solution is:

# nginx.spec main package:
Recommends:  (nginx-vim if vim_client)

Same can be done with the reverse dependency.

# nginx.spec nginx-vim subpackage:
Supplements:  (nginx and vim_client)

Both solutions are valid and it depends on where you want to express the dependency.

Ranged dependencies

In the old days we had a little %py_requires macro, which boiled down to something like

Requires: python >= 3.7.0
Requires: python < 4.0

If you now have a package installed that provides python=3.5.0 and python=4.1.0 you technically fulfilled the require statements but did not actually achieve what you wanted. And more and more languages adopt similar range dependencies. In Ruby you have the ~> operator e.g. So to solve the problem in a correct way:

Requires (python >= 3.7 with python < 4)

For rubygems

# rails ~> 6.1.0
Requires: (rubygem(%{rb_default_ruby_abi}:rails) >= 6.1.0 with rubygem(%{rb_default_ruby_abi}:rails) < 6.2)
# rails ~> 6.1
Requires: (rubygem(%{rb_default_ruby_abi}:rails) >= 6.1  with rubygem(%{rb_default_ruby_abi}:rails) < 7)

Optional (build)requires

BuildRequires: (pkgconfig(libfoo) or libfoo-devel)

While the first example was straight forward, we prefer the pkgconfig provides and fallback to the pkgname. The next example is a double edged sword but it might make spec files more readable. Use wisely:

BuildRequires: (pkgconfig(libfoo) if pkgconfig(libfoo) >= 1.2.3)

Only add a BuildRequires if the library is new enough.

WARNING: While this is easier to read than the explicit %if %suse_version .... constructs currently used, this very quickly leads to problems with unreproducible builds and should therefore be avoided.