rpm-software-management / dnf5

Next-generation RPM package management system
Other
222 stars 74 forks source link

dnf5daemon search (org.rpm.dnf.v0.rpm.Rpm List) explanation #1138

Open anaselli opened 6 months ago

anaselli commented 6 months ago

It isn't clear to me how a search of a package works. using the following options:

options = {
"package_attrs": [
                "full_nevra",
            ],
            "scope": "all",            
            "patterns": ["dnf"]
        }

I'd expect to have all the packages containing dnf. But the result is dnf-0:4.14.0-1.mga9.noarch twice (one is the installed and the latter i don't know from which list of packages is got (it should not be from available, and neither from updates).

The first question is where the pattern should match. I mean according to documentation "with_binaries", "with_filenames", "with_nevra", "with_provides", "with_src" are all True at default. And that seems to say that the pattern should match (i guess "be contained") every where. But as said above it does not.

Let's try to see filenames, according to documentation options should be:

options = {
"package_attrs": [
                "full_nevra",
            ],
            "scope": "all", 
           "with_binaries": False,
            "with_filenames": True,
            "with_nevra" : False,
            "with_provides" : False,
            "with_src" : False,
            "patterns": ["dnf"]
        }

But that produces no output. Let's try with binaries:

options = {
"package_attrs": [
                "full_nevra",
            ],
            "scope": "all", 
           "with_binaries": True,
            "with_filenames": False,
            "with_nevra" : False,
            "with_provides" : False,
            "with_src" : False,
            "patterns": ["dnf"]
        }

And again dnf-0:4.14.0-1.mga9.noarch twice. Trying setting "with_src" produces nothing again.

Could you explain better how the pattern should be written and if i'm wrong in something?

m-blaha commented 6 months ago

Imagine the List() method as an alternative to the dnf repoquery command, rather than dnf search command.

Matching in this context is akin to matching files with glob patterns in the shell. To obtain a list of packages with names containing dnf you need to add wildcards to the pattern, such as *dnf*.

To find out what repository each returned package comes from, consider adding repo_id to the package_attrs list.