Hi,
I tried using %global gccver %(gcc -dumpversion) %if %{gccver} >= 4.6.0 foo here %endif
to conditionalize usage of quadruple precision support in a spec file that ships on multiple distros, but the comparison gives the error
parseExpressionBoolean returns -1
Is there a way to check if the gcc version is sufficient with some rpm macro?
On Sat, Jul 30, 2011 at 11:44 AM, Jussi Lehtola jussilehtola@fedoraproject.org wrote:
Hi,
I tried using %global gccver %(gcc -dumpversion) %if %{gccver} >= 4.6.0 foo here %endif
to conditionalize usage of quadruple precision support in a spec file that ships on multiple distros, but the comparison gives the error
parseExpressionBoolean returns -1
I'm just guessing here, but I think because of the dots it's returning a string instead of a number which makes the >= comparison invalid. Is there another gcc option that will give you a "dotless" version number?
I would try something like:
%global gccver %(gcc -dumpversion | sed "s/.//g") %if %{gccver} >= 460 foo here %endif
Richard
On Sat, 30 Jul 2011 11:50:51 -0500 Richard Shaw hobbes1069@gmail.com wrote:
I'm just guessing here, but I think because of the dots it's returning a string instead of a number which makes the >= comparison invalid. Is there another gcc option that will give you a "dotless" version number?
I would try something like:
%global gccver %(gcc -dumpversion | sed "s/.//g") %if %{gccver} >= 460 foo here %endif
I'm guessing, too, that the issue has to do with strings vs numbers. The above version also fails with "parseExpressionBoolean returns -1".
On 07/30/2011 07:44 PM, Jussi Lehtola wrote:
Is there a way to check if the gcc version is sufficient with some rpm macro?
Do you actually need to have it as a macro? Often cases like this can be handled with plain shell code in %prep, %build, etc. Or by patching the build system to do the check automatically and sending the patch upstream.
On Sat, 30 Jul 2011 20:05:12 +0300 Ville Skyttä ville.skytta@iki.fi wrote:
On 07/30/2011 07:44 PM, Jussi Lehtola wrote:
Is there a way to check if the gcc version is sufficient with some rpm macro?
Do you actually need to have it as a macro? Often cases like this can be handled with plain shell code in %prep, %build, etc. Or by patching the build system to do the check automatically and sending the patch upstream.
Yes, since the existence of some subpackages depends on whether the option is supported or not.
On Sat, 30 Jul 2011 19:44:41 +0300 Jussi Lehtola wrote:
Hi,
I tried using %global gccver %(gcc -dumpversion) %if %{gccver} >= 4.6.0 foo here %endif
to conditionalize usage of quadruple precision support in a spec file that ships on multiple distros, but the comparison gives the error
parseExpressionBoolean returns -1
Is there a way to check if the gcc version is sufficient with some rpm macro?
Using python for parsing seems to work, but it looks a bit weird ;)
%global true_or_false %(python -c "print('%{gccver}' >= '4.6.0')") %if %{true_or_false} == "True" echo "true" %else echo "false" %endif
Hope that helps, Thomsa
On Sat, Jul 30, 2011 at 09:38:29PM +0200, Thomas Spura wrote:
On Sat, 30 Jul 2011 19:44:41 +0300 Jussi Lehtola wrote:
Hi,
I tried using %global gccver %(gcc -dumpversion) %if %{gccver} >= 4.6.0 foo here %endif
to conditionalize usage of quadruple precision support in a spec file that ships on multiple distros, but the comparison gives the error
parseExpressionBoolean returns -1
Is there a way to check if the gcc version is sufficient with some rpm macro?
Using python for parsing seems to work, but it looks a bit weird ;)
%global true_or_false %(python -c "print('%{gccver}' >= '4.6.0')")
Watch out, this is very dangerous! You are comparing strings, not versions:
print '4.6.2' >= '4.6.12'
True
The better way would be to use distutils.version:
from distutils.version import StrictVersion print StrictVersion('4.6.2') >= StrictVersion('4.6.12')
False
It is possible to write this one one line, but that looks reall ugly:
%global true_or_false %(python -c "from distutils.version import StrictVersion as v; print v(%{gccver}) >= v('4.6.0')")
HTH, Niels
%if %{true_or_false} == "True" echo "true" %else echo "false" %endif
Hope that helps, Thomsa -- devel mailing list devel@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/devel
On Sat, 30 Jul 2011 21:39:24 +0100 Niels de Vos wrote:
Watch out, this is very dangerous! You are comparing strings, not versions:
print '4.6.2' >= '4.6.12'
True
Thanks... I was testing with to low numbers... :(
The better way would be to use distutils.version:
from distutils.version import StrictVersion print StrictVersion('4.6.2') >= StrictVersion('4.6.12')
False
It is possible to write this one one line, but that looks reall ugly:
%global true_or_false %(python -c "from distutils.version import StrictVersion as v; print v(%{gccver}) >= v('4.6.0')")
Some '' are missing around gccver.
Thanks, Thomas
On 2011-07-30 9:44, Jussi Lehtola wrote:
I tried using %global gccver %(gcc -dumpversion) %if %{gccver}>= 4.6.0 foo here %endif
to conditionalize usage of quadruple precision support in a spec file that ships on multiple distros, but the comparison gives the error
parseExpressionBoolean returns -1
Is there a way to check if the gcc version is sufficient with some rpm macro?
RPM 4.7 and later let you use a bit of inline Lua to do this:
%if %{lua:rpm.vercmp('%{gccver}', '4.6.0')} > 0
This has the benefit of neither comparing lexically nor dragging in extra build dependencies.
devel@lists.stg.fedoraproject.org