Server Fault is a question and answer site for system and network administrators. 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 write a single rpm spec for RHEL/CentOS/SL 5 and 6. This spec is for python app, so there is no differences in build process. But on RHEL/CentOS5 I need to add one additional dependency.

How would I define dependency only for el5? I've tried following:

%if 0%{?redhat} == 5 || 0%{?centos} == 5
Requires:   kmod-coretemp

Does not work (build on CentOS5 does not adds kmod-coretemp dependency).

I've tried also following:

%if %{?dist} == "el5"

It reports with syntax error. I'm sure dist macro is set and contains 'el5'. But I'm not sure what is the syntax of if conditionals in rpm? rpmguide does not have detailed answer.

share|improve this question

The Fedora wiki, as usual, provides the best guidelines about packaging. Take a look at the Packaging:DistTag page. You can use the %{el5} variable and a shorthand conditional to ensure that the relevent Require line is used when building packages for EL5.

%{?el5:Requires: kmod-coretemp}

You'll probably want to label the resulting binary RPMs as .el5 and .el6 to avoid later confusion.

share|improve this answer
Thanks! Well, my system does not have this for some reason, but I've defined macro manually. Sorry, marking Ignacio answer as accepted, as it was first one. – rvs Jun 23 '11 at 11:28
If they're not present then you may need to install the package redhat-rpm-config from Yum. – Dan Carley Jun 23 '11 at 12:03
It's installed, but still no macros. I believe it's centos-specific, as on another rhel5 machines they are in place. – rvs Jun 23 '11 at 14:08

Your Answer


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.