Mailinglist Archive: opensuse-packaging (267 mails)

< Previous Next >
Re: [opensuse-packaging] How to detect package's version in specfile?
On Thu, Nov 01, 2012 at 03:15:14AM +0800, Marguerite Su wrote:
On Tue, Oct 30, 2012 at 7:20 PM, Guido Berhoerster <gber@xxxxxxxxxxxx> wrote:
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

Thanks! That's it!

Not sure if so much black magic would pass a Factory review...


Wearing my review-team-membership hat*

1.) it is perfectly valid to check package version in a spec calling
rpm -q $PACKAGE - Rudi pointed it makes more sense to do that, that
missusing %suse_version macro.

2.) usage of rpm in %scripplets is strictly prohibited

* I know it, because I've asked on a team ML recently

Michal Vyskocil
< Previous Next >
List Navigation
Follow Ups