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"
Regards,
On Mon, Jan 3, 2011 at 8:01 AM, Santi Saez santisaez@woop.es 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
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
On Tue, Jan 4, 2011 at 12:19 PM, Santi Saez santisaez@woop.es wrote:
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)
Hmmm.. You might befit from the portability of this approach
%rhel 0%(/bin/rpm -q --f /etc/redhat-release -qf '%{VERSION}\n' )
Notice that this now works with RHEL and CentOS, and the "\n" keeps certain programs historically happier with the commands having an EOL.
On Tue, Jan 4, 2011 at 4:38 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
Hmmm.. You might befit from the portability of this approach
%rhel 0%(/bin/rpm -q --f /etc/redhat-release -qf '%{VERSION}\n' )
Notice that this now works with RHEL and CentOS, and the "\n" keeps certain programs historically happier with the commands having an EOL.
Nice. Minor corrections needed:
-f => --f -qf => --qf
Akemi
On Wed, Jan 5, 2011 at 10:07 AM, Akemi Yagi amyagi@gmail.com wrote:
On Tue, Jan 4, 2011 at 4:38 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
Hmmm.. You might befit from the portability of this approach
%rhel 0%(/bin/rpm -q --f /etc/redhat-release -qf '%{VERSION}\n' )
Notice that this now works with RHEL and CentOS, and the "\n" keeps certain programs historically happier with the commands having an EOL.
Nice. Minor corrections needed:
-f => --f -qf => --qf
Sorry to spam the list again ... a correction of the correction needed :-)
--f => -f
So, it will be:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Akemi
On Wed, Jan 5, 2011 at 2:05 PM, Akemi Yagi amyagi@gmail.com wrote:
On Wed, Jan 5, 2011 at 10:07 AM, Akemi Yagi amyagi@gmail.com wrote:
On Tue, Jan 4, 2011 at 4:38 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
Hmmm.. You might befit from the portability of this approach
%rhel 0%(/bin/rpm -q --f /etc/redhat-release -qf '%{VERSION}\n' )
Notice that this now works with RHEL and CentOS, and the "\n" keeps certain programs historically happier with the commands having an EOL.
Nice. Minor corrections needed:
-f => --f -qf => --qf
Sorry to spam the list again ... a correction of the correction needed :-)
--f => -f
So, it will be:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Akemi
Gahhh. Proportional fonts in this mail interfaces. We hates it, yes, we hates it!!!!
Good catch, though. But why use '%{VERSION}' when '%{version}' will serve?
On Wed, Jan 5, 2011 at 9:06 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
On Wed, Jan 5, 2011 at 2:05 PM, Akemi Yagi amyagi@gmail.com wrote:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Gahhh. Proportional fonts in this mail interfaces. We hates it, yes, we hates it!!!!
Good catch, though. But why use '%{VERSION}' when '%{version}' will serve?
Well then, you can save even more ... '%{v}'
:-)
Akemi
On Thu, Jan 6, 2011 at 3:34 AM, Akemi Yagi amyagi@gmail.com wrote:
On Wed, Jan 5, 2011 at 9:06 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
On Wed, Jan 5, 2011 at 2:05 PM, Akemi Yagi amyagi@gmail.com wrote:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Gahhh. Proportional fonts in this mail interfaces. We hates it, yes, we hates it!!!!
Good catch, though. But why use '%{VERSION}' when '%{version}' will serve?
Well then, you can save even more ... '%{v}'
:-)
I'd prefer not to "save" myself out of legibility.....
Nico Kadel-Garcia wrote:
On Thu, Jan 6, 2011 at 3:34 AM, Akemi Yagi amyagi@gmail.com wrote:
On Wed, Jan 5, 2011 at 9:06 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
On Wed, Jan 5, 2011 at 2:05 PM, Akemi Yagi amyagi@gmail.com wrote:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Gahhh. Proportional fonts in this mail interfaces. We hates it, yes, we hates it!!!!
Into Mount Doom with HTML email!
Good catch, though. But why use '%{VERSION}' when '%{version}' will serve?
Well then, you can save even more ... '%{v}'
:-)
I'd prefer not to "save" myself out of legibility.....
What, there's no Obfuscaed Kickstart competition?
mark
On Thu, Jan 6, 2011 at 9:29 AM, m.roth@5-cent.us wrote:
Nico Kadel-Garcia wrote:
On Thu, Jan 6, 2011 at 3:34 AM, Akemi Yagi amyagi@gmail.com wrote:
On Wed, Jan 5, 2011 at 9:06 PM, Nico Kadel-Garcia nkadel@gmail.com wrote:
On Wed, Jan 5, 2011 at 2:05 PM, Akemi Yagi amyagi@gmail.com wrote:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n' )
Gahhh. Proportional fonts in this mail interfaces. We hates it, yes, we hates it!!!!
Into Mount Doom with HTML email!
Good catch, though. But why use '%{VERSION}' when '%{version}' will serve?
Well then, you can save even more ... '%{v}'
:-)
I'd prefer not to "save" myself out of legibility.....
What, there's no Obfuscaed Kickstart competition?
Can I give my award to the winner of that in person? Please? I have something very, very, very special for them. And a few candidates from companies that include their own "we'll build a kickstart file with our GUI" applications....
El 05/01/2011 20:05, Akemi Yagi escribió:
(..) So, it will be:
%rhel 0%(/bin/rpm -q -f /etc/redhat-release --qf '%{VERSION}\n')
Akemi and Nico, thank you very much for those tips!
Finally I will use the last version proposed by Akemi, thanks!
Regards,
-- Santi Saez http://woop.es