Mailinglist Archive: opensuse-packaging (99 mails)

< Previous Next >
Re: [opensuse-packaging] How to detect package's version in specfile?
  • From: Guido Berhoerster <gber@xxxxxxxxxxxx>
  • Date: Tue, 30 Oct 2012 12:20:09 +0100
  • Message-id: <20121030112007.GA15991@hal.local.invalid>
* Marguerite Su <i@xxxxxxxxxxxxx> [2012-10-30 11:08]:
On Tue, Oct 30, 2012 at 4:38 PM, Guido Berhoerster <gber@xxxxxxxxxxxx> wrote:
%define xulrunner_version %(rpm -q --queryformat '%%{VERSION}'

should work. "%()" is expanded together with the macros before building so
can use the %xulrunner_version for %if blocks, two "%" escape the version
macro. Needless to say that this isn't really pretty.

Hi, Guido

It didn't work...

%if %{xulrunner_version} >= 16 <== line 237
%patch -p1

error: parse error in expression
error: /home/abuild/rpmbuild/SOURCES/gpac.spec:237:
parseExpressionBoolean returns -1

seems "%define xulrunner_version %(rpm -q --queryformat '%%{VERSION}'
xulrunner-devel)" returns 0 or the return is not a number but a
warning string.

Numeric comparisons only work with integers, if you only need to
compare the major version you can get away with:
%define xulrunner_major_ver %(rpm -q --queryformat %'%%{VERSION}\\n'
xulrunner-devel | sed 's|\\..*$||')
%if %xulrunner_major_ver >= 16

If you need a full rpm version string comparison you need a lua
if rpm.vercmp(rpm.expand("%(rpm -q --queryformat '%%{VERSION}'
xulrunner-devel)"), "16.0.0") >= 0 then
rpm.define("xulrunner_ge_16_0_0 1")
rpm.define("xulrunner_ge_16_0_0 0")
%if %xulrunner_ge_16_0_0
Not sure if so much black magic would pass a Factory review...
Guido Berhoerster
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-packaging+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups