Bug 1975773 - Query versioned requires.
Summary: Query versioned requires.
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 38
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-06-24 11:29 UTC by Vít Ondruch
Modified: 2023-08-23 13:22 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-08-23 13:22:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Vít Ondruch 2021-06-24 11:29:18 UTC
Description of problem:
There are versioned BR in some packages [1] such as:

~~~
BuildRequires: rubygem(rspec) < 3
~~~

I'd like to query specifically for the requirement with the version restriction. Trying these two queries:

~~~
$ sudo dnf repoquery -q --disablerepo=* --enablerepo=rawhide-source --arch src --whatrequires "rubygem(rspec) < 3" | wc -l
145

$ sudo dnf repoquery -q --disablerepo=* --enablerepo=rawhide-source --arch src --whatrequires "rubygem(rspec)" | wc -l
159
~~~

The first once certainly provides different output, but it seems it matches also unversioned requires or something. I'd expect that the output would be similar to this grep over Fedora packages:

~~~
$ grep -R -e 'BuildRequires:.*rubygem(rspec).*<.*3'
rubygem-bundler_ext.spec:BuildRequires: rubygem(rspec) < 3
rubygem-cliver.spec:BuildRequires: rubygem(rspec) < 3.0
rubygem-expression_parser.spec:BuildRequires: rubygem(rspec) < 3
rubygem-fssm.spec:BuildRequires: rubygem(rspec) < 3
rubygem-hashie.spec:BuildRequires: rubygem(rspec) < 3.0
rubygem-msgpack.spec:# BuildRequires: rubygem(rspec) < 3
rubygem-RedCloth.spec:#BuildRequires: rubygem(rspec) < 3
rubygem-settingslogic.spec:BuildRequires:  rubygem(rspec) < 3
rubygem-six.spec:BuildRequires: rubygem(rspec) < 3.0
rubygem-stomp.spec:BuildRequires: rubygem(rspec) < 3
~~~

Version-Release number of selected component (if applicable):
$ rpm -q dnf
dnf-4.6.0-1.fc34.noarch


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
It seems there is no way to query dependencies by their version.


Expected results:
It would be nice if versions are respected by repoquery.

Additional info:




[1] https://src.fedoraproject.org/rpms/rubygem-fssm/blob/rawhide/f/rubygem-fssm.spec#_13

Comment 1 amatej 2021-06-28 19:38:26 UTC
I believe you are right, it does also match unversioned requires and I think that is correct.

When something requires just rubygem(rspec) it will be satisfied by any rubygem(rspec) version (including rubygem(rspec) < 3). In other words when you ask what packages require "rubygem(rspec) < 3" then a package that has: requires: rubygem(rspec) should match.


I tried to figure out some way how to do your use case but unfortunately was able to come up only with quite involved solutions.
(Such as doing sed on the output from: dnf repoquery -q --disablerepo=* --enablerepo=rawhide-source --arch src --whatrequires "rubygem(rspec)" --qf "%{name}-%{epoch}:%{version}-%{release}.%{arch}:\n%{requires}\n" or diffing outputs from two dnf runs.)

I can't think of a straightforward way to do this.

Comment 2 Vít Ondruch 2021-06-30 13:53:37 UTC
I think that something like this would be the RPM idiomatic way:

~~~
$ sudo dnf repoquery -q --disablerepo=* --enablerepo=rawhide-source --arch src --whatrequires "rubygem(rspec) >= 0 with rubygem(rspec) < 3"
~~~

Comment 3 amatej 2021-07-01 05:46:45 UTC
Right, I mean here specifically I think we would need a negative form: --whatrequires "rubygem(rspec) >= 0 without rubygem(rspec) >= 3" because your example would still be satisfied by unversioned requires.

But I agree, some way of combining conditions would be required.

Comment 4 Vít Ondruch 2021-07-01 16:39:10 UTC
Would `"rubygem(rspec) < 3 without rubygem(rspec)"` work?

Or maybe we should forget about this kind of syntax and have separate option with some version restrictions?

Alternatively, DNF could modify the querying logic if there was some operator such as '<' and exclude the nonversioned requires - this is my favorite option ATM, because that is what I was actually trying, just copy/paste the require from .spec file.

Sry, just thinking loud O:-)

Comment 5 amatej 2021-07-07 11:04:05 UTC
(In reply to Vít Ondruch from comment #4)
> Would `"rubygem(rspec) < 3 without rubygem(rspec)"` work?
> 
The way I image it it wouldn't work sicne rubygem(rspec) matches all of the versions so after the difference (used because of the "without" keyword) it would end up empty.

I think we can try it for example like this:

#!/usr/bin/python3
import dnf

with dnf.Base() as base:
    repo = dnf.repo.Repo("rawhide-source", base.conf)
    repo.metalink = "https://mirrors.fedoraproject.org/metalink?repo=rawhide-source&arch=$basearch"
    base.repos.add(repo)

    base.fill_sack(load_system_repo=False)

    query = base.sack.query()
    q1 = query.filter(requires__glob="rubygem(rspec) < 3")
    q2 = query.filter(requires__glob="rubygem(rspec)")

    result = q1.difference(q2)

    for pkg in result:
        print(pkg)

It doesn't print anything but changing the queries to:
    q1 = query.filter(requires__glob="rubygem(rspec) >= 0")
    q2 = query.filter(requires__glob="rubygem(rspec) >= 3")
works as expected I think.


> Or maybe we should forget about this kind of syntax and have separate option
> with some version restrictions?
> 
> Alternatively, DNF could modify the querying logic if there was some
> operator such as '<' and exclude the nonversioned requires - this is my
> favorite option ATM, because that is what I was actually trying, just
> copy/paste the require from .spec file.
> 
> Sry, just thinking loud O:-)

yea I am also not sure what is the best approach. I have added the bug to our DNF5 backlog, unfortunately I don't think we can prioritize this right now.

Comment 6 Ben Cotton 2021-08-10 13:08:44 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 35 development cycle.
Changing version to 35.

Comment 7 Ben Cotton 2022-11-29 16:59:04 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 8 Ben Cotton 2023-02-07 14:52:17 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 9 Jaroslav Mracek 2023-08-23 13:22:54 UTC
I am really sorry but the request is too specific with a limited benefit therefore we do not plan to have it on our CLI interface. If you have an interest in a Python code that will deliver the functionality, please ping me.


Note You need to log in before you can comment on or make changes to this bug.