[opensuse-packaging] How to detect package's version in specfile?
Hi, all I have to detect xulrunner-devel version in specfile. but I got a problem: the version in `rpm -q --qf='%{version}' xulrunner-devel` will be overridden by the "Version: " in specfile itself. any ideas? or has anybody successfully detected a Tumbleweed? I know it's not possible so that I have to detect xulrunner version. Marguerite -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
* Marguerite Su <i@marguerite.su> [2012-10-30 09:10]:
Hi, all
I have to detect xulrunner-devel version in specfile.
but I got a problem:
the version in `rpm -q --qf='%{version}' xulrunner-devel` will be overridden by the "Version: " in specfile itself.
any ideas?
%define xulrunner_version %(rpm -q --queryformat '%%{VERSION}' xulrunner-devel) should work. "%()" is expanded together with the macros before building so you can use the %xulrunner_version for %if blocks, two "%" escape the version macro. Needless to say that this isn't really pretty. -- Guido Berhoerster -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Tue, Oct 30, 2012 at 4:38 PM, Guido Berhoerster <gber@opensuse.org> wrote:
%define xulrunner_version %(rpm -q --queryformat '%%{VERSION}' xulrunner-devel)
should work. "%()" is expanded together with the macros before building so you 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 %endif 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. Marguerite -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
* Marguerite Su <i@marguerite.su> [2012-10-30 11:08]:
On Tue, Oct 30, 2012 at 4:38 PM, Guido Berhoerster <gber@opensuse.org> wrote:
%define xulrunner_version %(rpm -q --queryformat '%%{VERSION}' xulrunner-devel)
should work. "%()" is expanded together with the macros before building so you 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 %endif
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 [...] %endif If you need a full rpm version string comparison you need a lua macro: %{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") else rpm.define("xulrunner_ge_16_0_0 0") end } %if %xulrunner_ge_16_0_0 [...] %endif Not sure if so much black magic would pass a Factory review... -- Guido Berhoerster -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
On Tue, Oct 30, 2012 at 7:20 PM, Guido Berhoerster <gber@opensuse.org> 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 [...] %endif
If you need a full rpm version string comparison you need a lua macro: %{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") else rpm.define("xulrunner_ge_16_0_0 0") end } %if %xulrunner_ge_16_0_0 [...] %endif
Thanks! That's it!
Not sure if so much black magic would pass a Factory review...
Don't worry...I used it to detect Tumbleweed in Packman... Marguerite -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
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@opensuse.org> 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 [...] %endif
If you need a full rpm version string comparison you need a lua macro: %{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") else rpm.define("xulrunner_ge_16_0_0 0") end } %if %xulrunner_ge_16_0_0 [...] %endif
Thanks! That's it!
Not sure if so much black magic would pass a Factory review...
Hi! 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 Regards Michal Vyskocil
On Thu, Nov 1, 2012 at 10:48 PM, Michal Vyskocil <mvyskocil@suse.cz> wrote:
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.
I still think it might be a good idea to give Tumbleweed a valid rolling version number like 1225 (1220 < Tumbleweed < Factory = 1230) in /usr/lib/rpm/suse_macros. or just add a new macro like sles. But since it's not possible (seems), we can use specific package version to do the trick. eg: xulrunner-devel is not available in <=1210. and Tumbleweed is the only one have 14.0.1 version. (12.2 is 16.0.1 and Factory is 16.0.2) so: %if 0%{?suse_version} >= 1220 %if 0%{?xulrunner_version} < 15 // Now you're in Tumbleweed env %endif %endif the shortcoming is if Tumbleweed updates this package, we need to find new unique package. or we can submit a fake package into Tumbleweed to do the job solely. PS: Guido, is "s|\\..*$||" regression? I asked around on gtalk, but no one knows such regex style...can you explain it a little bit? Marguerite -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
* Marguerite Su <i@marguerite.su> [2012-11-01 16:17]:
On Thu, Nov 1, 2012 at 10:48 PM, Michal Vyskocil <mvyskocil@suse.cz> wrote:
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.
I still think it might be a good idea to give Tumbleweed a valid rolling version number like 1225 (1220 < Tumbleweed < Factory = 1230) in /usr/lib/rpm/suse_macros. or just add a new macro like sles.
But since it's not possible (seems), we can use specific package version to do the trick.
eg: xulrunner-devel is not available in <=1210. and Tumbleweed is the only one have 14.0.1 version. (12.2 is 16.0.1 and Factory is 16.0.2)
so:
%if 0%{?suse_version} >= 1220 %if 0%{?xulrunner_version} < 15 // Now you're in Tumbleweed env %endif %endif
the shortcoming is if Tumbleweed updates this package, we need to find new unique package. or we can submit a fake package into Tumbleweed to do the job solely.
A suse_version number only really makes sense for stable releases (that is the version number corresponds to a mostly static set of packages), for Tumbleweed and Factory they do not have much meaning.
PS: Guido, is "s|\\..*$||" regression? I asked around on gtalk, but no one knows such regex style...can you explain it a little bit?
Not sure what you mean, it's just a BRE, the double backslash is needed there because rpmbuild also interprets backslashes. -- Guido Berhoerster -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hi, I've missed that thread but just noticed something about xulrunner and Tumbleweed. Am 01.11.2012 16:17, schrieb Marguerite Su:
eg: xulrunner-devel is not available in <=1210. and Tumbleweed is the only one have 14.0.1 version. (12.2 is 16.0.1 and Factory is 16.0.2)
Tumbleweed has the xulrunner version inherited from 12.2 and the only reason why Tumbleweed has no update in itself is that Tumbleweed users are meant to have the 12.2 update repo enabled. xulrunner > 10.0.10 and < 16.0.2 is not supported and contain security issues.
so:
%if 0%{?suse_version} >= 1220 %if 0%{?xulrunner_version} < 15 // Now you're in Tumbleweed env %endif %endif
That can also be 12.2 if you build against 12.2 and not against the 12.2 update repository. Therefore I do not think this is the right package to check for. I also have no good idea how to detect Tumbleweed btw. Wolfgang -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (4)
-
Guido Berhoerster
-
Marguerite Su
-
Michal Vyskocil
-
Wolfgang Rosenauer