Redhat – rpm spec: conditional require based of distro version

centos5redhatrpm

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
%endif

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.

Related Topic