Conditionally applying a patch based on a program's EVR

2009-07-09 Thread Alan Dunn
I want to conditionally apply a patch in a spec file based upon the
version of a package. (There's an emacs package that needs a patch to
work with the latest version of xemacs, but this patch shouldn't be
applied for previous versions of xemacs.) I know that for checking
something like Fedora version numbers I can use

%if 0%{?fedora}  9
...
%endif

but is there an easy way to do this for a version number in say, EVR
form? That is, something like

%if %{program_version}  1.2.3
...
%endif

(%{program_version} will always be defined)

RPM doesn't seem to support a mechanism like this in %if conditionals
(I believe having a digit first causes rpmbuild to try and interpret
the result as a number), though clearly there is a mechanism for
examining EVRs of this form for other parts of rpmbuild.

One could try something like

%if %{prorgram_version}  1.2.3

which does string comparison, but this doesn't work for some version
combinations, since, for example, we would want 1.10.1  1.9.1

- Alan

-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Conditionally applying a patch based on a program's EVR

2009-07-09 Thread Jochen Schmitt
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Am 09.07.2009 21:59, schrieb Alan Dunn:
 I want to conditionally apply a patch in a spec file based upon the
 version of a package. (There's an emacs package that needs a patch to
 work with the latest version of xemacs, but this patch shouldn't be
 applied for previous versions of xemacs.) I know that for checking
 something like Fedora version numbers I can use

 %if 0%{?fedora}  9
 ...
 %endif

 but is there an easy way to do this for a version number in say, EVR
 form? That is, something like

I assume, that your match may fixed a issue caused by xemacs.

So, I would to prefer, that the user should make a update to the specific
release of xemacs on which the issue doesn't occurs.

You may write someting link

# You need xemacs = required release to
# fix the following issue ...
Requires:xemacs = required release


Of corse, if the required release may not available on older
distribution, you may embrace the Requires statement into
a condition.

Best Regards:

Jochen Schmitt
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkpWTd8ACgkQT2AHK6txfgyL+ACfYmujoW+Grc46ngj7gFSH1GER
MGgAoMI7fLQnLjin2dJ8HNFFGCDQKy0Z
=WR+q
-END PGP SIGNATURE-

-- 
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list


Re: Conditionally applying a patch based on a program's EVR

2009-07-09 Thread Panu Matilainen

On Thu, 9 Jul 2009, Alan Dunn wrote:


I want to conditionally apply a patch in a spec file based upon the
version of a package. (There's an emacs package that needs a patch to
work with the latest version of xemacs, but this patch shouldn't be
applied for previous versions of xemacs.) I know that for checking
something like Fedora version numbers I can use

%if 0%{?fedora}  9
...
%endif

but is there an easy way to do this for a version number in say, EVR
form? That is, something like

%if %{program_version}  1.2.3
...
%endif

(%{program_version} will always be defined)

RPM doesn't seem to support a mechanism like this in %if conditionals
(I believe having a digit first causes rpmbuild to try and interpret
the result as a number), though clearly there is a mechanism for
examining EVRs of this form for other parts of rpmbuild.

One could try something like

%if %{prorgram_version}  1.2.3

which does string comparison, but this doesn't work for some version
combinations, since, for example, we would want 1.10.1  1.9.1


In rpm = 4.7.0 the real rpm version comparison algorithm is available to 
the embedded Lua interpreter as rpm.vercmp(), eg:
[pmati...@localhost ~]$ rpm --eval %{lua:print(rpm.vercmp('1.2.3-1', 
'1.1.1-1'))}

1
[pmati...@localhost ~]$ rpm --eval %{lua:print(rpm.vercmp('1.2.3-1', 
'5:1.1.1-1'))}

-1

With older rpm versions you need to do something else, such as call 
rpmdev-vercmp.


- Panu -

--
fedora-devel-list mailing list
fedora-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list