Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Checking version of a required package

  1. #1
    Join Date
    Jun 2008
    Location
    Düsseldorf/Germany
    Posts
    244

    Default 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

  2. #2
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    9,908
    Blog Entries
    1

    Default Re: Checking version of a required package

    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
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  3. #3
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,472
    Blog Entries
    15

    Default Re: Checking version of a required package

    Quote Originally Posted by DocB View Post
    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
    Hi
    Just query the package....

    Code:
    %define foo_version %(rpm -q --qf '%{VERSION}' foo)
    
    MY_VAR=%{foo_version}
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  4. #4
    Join Date
    Jun 2008
    Location
    Düsseldorf/Germany
    Posts
    244

    Default Re: Checking version of a required package

    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...

  5. #5
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,472
    Blog Entries
    15

    Default Re: Checking version of a required package

    Quote Originally Posted by DocB View Post
    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...?
    https://build.opensuse.org/package/v....spec?expand=1
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  6. #6
    Join Date
    Jun 2008
    Location
    Düsseldorf/Germany
    Posts
    244

    Default Re: Checking version of a required package

    Sure:
    https://build.opensuse.org/package/v....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?

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,472
    Blog Entries
    15

    Default Re: Checking version of a required package

    Quote Originally Posted by DocB View Post
    Sure:
    https://build.opensuse.org/package/v....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.

    Code:
    %{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....
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  8. #8
    Join Date
    Jun 2008
    Location
    Düsseldorf/Germany
    Posts
    244

    Default Re: Checking version of a required package

    Quote Originally Posted by malcolmlewis View Post
    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

    Quote Originally Posted by malcolmlewis View Post
    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)

    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...

  9. #9
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,472
    Blog Entries
    15

    Default Re: Checking version of a required package

    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!


  10. #10
    Join Date
    Jun 2008
    Location
    Düsseldorf/Germany
    Posts
    244

    Default Re: Checking version of a required package

    Quote Originally Posted by malcolmlewis View Post
    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....
    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!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •