Re: Helper variables like %{rhel} on CentOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Jan 3, 2011 at 8:01 AM, Santi Saez <santisaez@xxxxxxx> wrote:
> Hello,
>
> I'm trying to use helper variables like %{rhel} in a .SPEC file on
> CentOS (as they are defined in RHEL and Fedora [1]), but it seems they
> are not available.
>
> Is there any way to detect automatically CentOS release from a .SPEC
> file in a RPM build process?
>
> As a workaround, I use this hack:
>
>     %if 0%{?rhel} >= 5
>         (..)
>     %endif
>
> And when calling rpmbuild I use a conditional build, like:
>
>     $ rpmbuild -ba --clean --define "rhel 5"

You may want to look into the srpms of nx/freenx in the CentOS extras
repository. The spec file contains the following:

# centos_ver is a number (2,3,4,5). It can be provided in the build system or
# via the command line with the following define for rpmbuild
# --define "centos_ver 5"
# If centos_ver is not provided the following will find it and should work on
# all current redhat based EL rebuilds, will not work properly on FC though

%{!?centos_ver: %define centos_ver %(Z=`rpm -q --whatprovides
/etc/redhat-release`;A=`rpm -q --qf '%{V}' $Z`; echo ${A:0:1})}


I believe this was originally written by Johnny Hughes and is still in
use for those packages (now including the upcoming version "6").

Akemi
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux