Checking version of a required package

Hi,
Is there a macro to check the version of a package listed in
BuildRequires: foo
in that way, that I get a variable filled with the version number of foo?
Thanks

You can try something like what I posted in my Wiki that reads distro versions and auto configures the correct repository URI… And now that I’m looking at it, the code is out-dated and won’t work because nowadays different variables are used but the statement structure logic should still work. If you can’t get it to work, I should have some working code posted within the next couple days when I get some time…

https://en.opensuse.org/User:Tsu2/BASH_zypper

TSU

Hi
Just query the package…


%define foo_version %(rpm -q --qf '%{VERSION}' foo)

MY_VAR=%{foo_version}

Thank you both for your input!

Unfortunately, quering the version works on the command line, but not in OBS
I’m building the package bar with the version
%define majorver 3.4
Version: %{majorver}.0

The build requirement is foo.
If I now define
%define foo_version %(rpm -q --qf ‘%{VERSION}’ foo)
MY_VAR=%{foo_version}
The result is the same in %{version} and %{foo_version} - 3.4.0
A different variable instead of %{version} in the rpm query does not work either…

Hi
Can you point to the package?

Here’s an example here that I use all the time for the kernel version…?

Sure:
https://build.opensuse.org/package/view_file/Application:ERP:GNUHealth:3.4/gnuhealth/gnuhealth.spec?expand=1

another idea would be to move TRYTON_VERSION to the respective trytond-package. By chance, do you know if the the file (/etc/tryton/gnuhealthrc) is overwritten or appended?

Hi
The define needs to be VERSION not version (it’s case sensitive) in the spec file to get the correct variable.

You should create /etc/tryton/gnuhealthrc as a file and install, then mark %config in %files then it would be overwritten, if you don’t want a config file overwritten use the (noreplace) option in %files.


%{config} %{_sysconfdir}/%{base_name}/gnuhealthrc

or

%{config}(noreplace) %{_sysconfdir}/%{base_name}/gnuhealthrc

You also need to look at removal of %defattr as this is deprecated, set permissions on install if required…

You mean


%define t_version %(rpm -q --qf '%{VERSION}' trytond) 

? I tried all variants, no success

Yes, I know of this option.
The question was more if the config file gets updates from two different packages (with just a subset of the variables)

You also need to look at removal of %defattr as this is deprecated, set permissions on install if required…

Uh, did not know this. %defattr is still widely used I think…

On Mon 17 Dec 2018 05:36:03 PM CST, DocB wrote:

malcolmlewis;2889116 Wrote:
>
> The define needs to be VERSION not version (it’s case sensitive) in
> the spec file to get the correct variable.
>
You mean

Code:

%define t_version %(rpm -q --qf ‘%{VERSION}’ trytond)


? I tried all variants, no success

malcolmlewis;2889116 Wrote:
> Hi
> You should create /etc/tryton/gnuhealthrc as a file and install, then
> mark %config in %files then it would be overwritten, if you don’t
> want a config file overwritten use the (noreplace) option in %files.
>
Yes, I know of this option.
The question was more if the config file gets updates from two different
packages (with just a subset of the variables)

Hi
When installing the user will get a zypper warning asking do you want
to over-write config1 with the config1 from package2, their call from
that point on…


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
SLES 15 | GNOME Shell 3.26.2 | 4.12.14-25.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Ah, thanks!. Unfortunately this is not the solution either!
The quering of the other package looks more promising (if it works…). I think I’ll ask in the packaging list!
Have a great xmas and thanks for your help!

Solution: %{VERSION} gets expanded by rpm as spec macro. You need to use %%{VERSION} to quote it.

So
%define t_version %(rpm -q --qf ‘%%{VERSION}’ trytond)
gives the desired result.
Thanks to all of you for solving this!