Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
    
This is true, but some background might be nice.... – mattdm Apr 13 '11 at 14:56
    
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 '15 at 13:56

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.

share|improve this answer
    
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 '11 at 8:53

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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