Open Conan-Kudo opened 9 months ago
cc: @anaselli @soig
Regular expressions are a logical enhancement. Though, I have few remarks:
We cannot blindly interpret queries as regexps because that would change semantics of the queries (from a literal or from a glob). There needs to be a new option for command-line interface and for D-Bus interface, as well as in library APIs. I don't think duplicating all query fields (e.g. dnf repoquery --whatprovides 'perl(*)'
to dnf repoquery --whatprovides-regexp 'perl\(.*\)'
) is a productive way. Either a single new option would be better (e.g. (dnf --regexp repoquery --whatprovides 'perl\(.*\)'
). A global option in dnf.conf would of course affect D-Bus and library API. That's maybe too big hammer. However, injecting the regexp switch into C API can be difficult because adding a new argument to a function breaks API and ABI. In D-Bus, we could inject it into a session state. Ideally the new queries should be typed like --whatprovides 'regexp:perl\(.*\)
, but that's again incompatible change.
We need to pick up a regular expression variant: basic, extended, posix, perl, ...
Question is how the globs are implemented now. If they rely on libsolv and if libsolv does not support regexps, then having two code paths does not seem appealing.
libdnf5 now uses regular expressions implemented by standard C++ library. In case of GNU implementation, those are recursive and stack-based and lead easily to segfaults with "complex" expressions. If libdnf5 should support regexps, mature implementation would be required. E.g. PCRE2.
Your request has large impact. I'd like to hear others' opinions.
Based on the complexity and that the team now focuses on polishing DNF5 for Fedora 41, I set it a low priority for now.
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.
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.
@Conan-Kudo May I ask you for which RPM/ Repo, Comps attribute you want to enable the regex search pattern?
Well, the idea is to enable this for searching everything dnf has... So being able to search package/group names, summaries, descriptions, dependencies, etc.
Thank you it means huge scope.
To make it clearer, anywhere we can use a glob based query, we should be able to use a regexp based query.
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).
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 indnf-URPM
.It is also needed for dnfdragora through dnf5daemon.