[CentOS] Helper variables like %{rhel} on CentOS

Santi Saez santisaez at woop.es
Tue Jan 4 17:19:42 UTC 2011


El 03/01/2011 20:15, Akemi Yagi escribió:
> 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})}

Hi Akemi,

Thanks for the tip :)

If I put Johnny's code in my .rpmmacros it works, but I get this warning:

     error: Macro % has illegal name (%define)

I have solved with this change:

# Helper variable that defines CentOS release number, http://goo.gl/dkGUg
# This macro is based on Johnny Hughes's freenx.spec, from "extras" repo
%rhel           %(/bin/rpm -q --qf '%{VERSION}' centos-release)

Regards,

--
Santi Saez
http://woop.es



More information about the CentOS mailing list