rpm-software-management / dnf5

Next-generation RPM package management system
Other
239 stars 81 forks source link

Add support for using regular expressions for queries (repoquery) #1156

Open Conan-Kudo opened 9 months ago

Conan-Kudo commented 9 months ago

Today, DNF has support for queries using simple globs, but I would like to also request support for being able to use regular expressions too.

This feature exists in urpmf(8) and it can be useful when globs aren't quite sufficient, and especially if I want to have a chance to reimplement it in dnf-URPM.

It is also needed for dnfdragora through dnf5daemon.

Conan-Kudo commented 9 months ago

cc: @anaselli @soig

ppisar commented 9 months ago

Regular expressions are a logical enhancement. Though, I have few remarks:

Your request has large impact. I'd like to hear others' opinions.

ppisar commented 9 months ago

Based on the complexity and that the team now focuses on polishing DNF5 for Fedora 41, I set it a low priority for now.

Conan-Kudo commented 9 months ago

I think adding another option to trigger it makes sense and should not be default behavior. A --regexp global option works for that. From the API side, this could be handled either by new functions or we can just make it part of the ABI break with #1091.

I would prefer using PCRE2 for the regular expressions, since that matches the "expected" regular expression flavor.

As for libsolv, there is a SEARCH_REGEX mode defined in dataiterator.h, though I'm not sure what it means. @mlschroe could speak more on it.

anaselli commented 9 months ago

I developed something like that in dnfdragora using its internal cached data here. I added myself to this issue so that i'm informed on the changes.

j-mracek commented 9 months ago

@Conan-Kudo May I ask you for which RPM/ Repo, Comps attribute you want to enable the regex search pattern?

Conan-Kudo commented 9 months ago

Well, the idea is to enable this for searching everything dnf has... So being able to search package/group names, summaries, descriptions, dependencies, etc.

j-mracek commented 9 months ago

Thank you it means huge scope.

Conan-Kudo commented 9 months ago

To make it clearer, anywhere we can use a glob based query, we should be able to use a regexp based query.

keithbowes commented 1 month ago

Definitely. This is the reason I still use urpmf to search for packages, though I've switched to DNF for everything else. I don't know how that would be done exactly. One suggestion would be to use --regex, so perhaps you do alias dnf="dnf5 --regex" so that dnf would always use regex searches. Another suggestion would be to add a key to dnf.conf (of course, the two aren't mutually exclusive; most things in dnf.conf can also be provided/overridden on the command line).