Mailinglist Archive: opensuse-factory (914 mails)

< Previous Next >
Re: [opensuse-factory] New rpm macros to test package versions in spec files


On May 31 12:23 Antonio Larrosa wrote (excerpt):
Consider you have a patch that has to be applied only with gcc 7. You'd
propably do something like:

%if 0%{?suse_version} > 1320
%patch0 -p1

That makes sense only once you know suse_version is a number that somehow
relates to the distribution version, once you know >1320 means Tumbleweed
and once you know that Tumbleweed currently has gcc 7 (which only happens
during a timeframe). It works, it's useful, but it's not nice. This is
just an example but for other cases you'd probably have to mix it with
checks for 0%{?leap_version}, 0%{?sle_version} and maybe also

With the new macros I just submitted you can do:

%if %{pkg_version_at_least gcc 7}
%patch0 -p1

Which is actually what you want to do: apply your patch when the gcc version
is 7.0 or newer. I think this makes spec files more readable and require
less maintenance work when any distribution changes other package versions
(think Leap 15 changing to gcc 7 in that example above) since it allows you
not to think about what package versions a distribution has, but about the
package versions themselves.


So, any opinion/suggestion about these macros?


I do very much appreciate such kind of test macros!

cf. what I had written about
"... using product version tests in spec files
is fundamentally inappropriate because such tests
do not test for the actual requirement.
Therefore the plain test is meaningless ..."

In general I think any version test is fundamentally inappropriate
because because it does not test for the actual requirement
(assuming the plain version is not what is actually needed).

Therefore - strictly speaking - even a test like
%if %{pkg_version_at_least gcc 7}
does not test for the actual final requirement
but is it a big step forward into the right direction.

Furthermore in practice a package version string is probably
often the only thing that is directly available for testing
with reasonable effort so that I think in practice a test like
%if %{pkg_version_at_least gcc 7}
is probably fully sufficient for the next 10 years or so :-)

Kind Regards
Johannes Meixner
SUSE LINUX GmbH - GF: Felix Imendoerffer, Jane Smithard,
Graham Norton - HRB 21284 (AG Nuernberg)

To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >