I'm trying to build a cross-distro binary RPM package that works under Fedora and openSUSE. I'm using a Require: tag to set the dependencies package names. The problem is that the package names are different in each GNU/Linux distro repo.

Reading: http://goo.gl/3MXSq, and using '%if 0%{?suse_version} ' statements give a cross-distro .spec file. That is, the list of deps will be determined at build-time not install-time.

Is there a way to set a conditional list of deps inside a binary RPM package?

3 Answers 3


Yes, this is certainly possible, as the link to the openSUSE wiki page you linked to explains in detail. Also some vendors do this, e.g. the google-chrome RPM package for Fedora/openSUSE (also works well on other rpm distros) is one example where they only have one rpm package which covers the major rpm distributions.

But you should pay attention to what you require. You have to distinguish between Requires: on normal packages for e.g. binaries that you might require. Those have to be manually added. Also Requires on filenames (e.g. Requires: /usr/bin/sendmail) are disregarded and they're also not portable, as some distros will put their files in slightly different locations.

For unversionned Requires: on common library packages, those are usually always wrong. They are automatically added during rpm build time. There are really rare cases where a certain version needs to be enforced, and where explicit versionned Requires have to be added, mostly on library packages. This is explained e.g. at http://fedoraproject.org/wiki/Packaging:Guidelines#Explicit_Requires


No way. sorry. You couldn't do conditional list of deps inside RPM. The only way to do this is to remove all distro specific deps from your spec file.

  • Ok thanks. I need the list of deps for my app to install without the need for the user to install the deps himself.
    – Saleh
    Apr 15, 2011 at 8:53

No. This isn't how you go about it. You really do need to build separate packages for each distro. This will require a slightly different looking spec file for each distro, and sometimes for different versions of a distro of you are targetting more than the current release.

Your "conditionals" should go one step higher up ... on picking which RPM to use, not inside the RPM itself. If you want you can generate these spec files from a script with conditionals so to automate this process for you, but when you build a package from a spec you will need a distro-specific spec.

  • This is true, but some background might be nice....
    – mattdm
    Apr 13, 2011 at 14:56
  • 2
    Actually the question from the OP was OK - you can build several binary packages for several distributions, all from one .spec. And you can also specify a conditional list of dependencies per distro, which is what you usually need to do when creating packages via the openSUSE buildservice: build.opensuse.org
    – doktor5000
    Dec 11, 2015 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.