commit:     f4eb959a8a9f7b52d52c7842f53dccff8bea2699
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May  5 08:57:41 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May  5 08:57:41 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f4eb959a

qkeyword: add --matchmaint/-m flag, bug #685052

Add option to match against maintainer email address listed in
package metadata.xml.

Closes: https://bugs.gentoo.org/685052
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md                   |  7 +++++++
 man/include/qkeyword.desc | 11 +++++++++++
 man/qkeyword.1            | 14 ++++++++++++++
 qkeyword.c                | 21 ++++++++++++++++++++-
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index 0d05670..e433123 100644
--- a/TODO.md
+++ b/TODO.md
@@ -90,3 +90,10 @@
 # quse
 - make -v only print requested USE-flag when flags given
 - read VDB on -v to print details about current USE-flag status, bug #656550
+
+# qkeyword
+- avoid multiple atom\_explode in path traversal
+  * during qkeyword\_vercmp
+  * during qkeyword\_results\_cb
+  * in libq/cache\_read\_metadata
+- drop -c argument? it can be fully expressed using -p cat/

diff --git a/man/include/qkeyword.desc b/man/include/qkeyword.desc
index 3bbfb43..b7a863c 100644
--- a/man/include/qkeyword.desc
+++ b/man/include/qkeyword.desc
@@ -1,3 +1,14 @@
 \fIqkeyword\fR allows various searches based on KEYWORDS aimed at Gentoo
 developers.  Various modes allow to query which packages would be
 available, or are candidate for keywording.
+.P
+By default, the entire tree is traversed.  Since this process can be
+slow, or result in too many results, the match arguments can be used to
+reduce the set of packages evaluated.  \fB-p\fR and \fB-c\fR match
+package name and category respectively.  They can both be used at the
+same time, but \fB-p\fR accepts regular atom format, including version
+and/or range.  Hence, \fB-p\fR can be used to set both category as well
+as package in one go.  The \fB-m\fR maintainer match, while reducing the
+resulting set, is likely to slow down the query processing since the
+metadata.xml file has to be read for each package examined.  It is best
+used in combination with \fB-p\fR or \fB-c\fR.

diff --git a/man/qkeyword.1 b/man/qkeyword.1
index d32e771..d91bc77 100644
--- a/man/qkeyword.1
+++ b/man/qkeyword.1
@@ -9,6 +9,17 @@ qkeyword \- list packages based on keywords
 \fIqkeyword\fR allows various searches based on KEYWORDS aimed at Gentoo
 developers.  Various modes allow to query which packages would be
 available, or are candidate for keywording.
+.P
+By default, the entire tree is traversed.  Since this process can be
+slow, or result in too many results, the match arguments can be used to
+reduce the set of packages evaluated.  \fB-p\fR and \fB-c\fR match
+package name and category respectively.  They can both be used at the
+same time, but \fB-p\fR accepts regular atom format, including version
+and/or range.  Hence, \fB-p\fR can be used to set both category as well
+as package in one go.  The \fB-m\fR maintainer match, while reducing the
+resulting set, is likely to slow down the query processing since the
+metadata.xml file has to be read for each package examined.  It is best
+used in combination with \fB-p\fR or \fB-c\fR.
 .SH OPTIONS
 .TP
 \fB\-p\fR \fI<arg>\fR, \fB\-\-matchpkg\fR \fI<arg>\fR
@@ -17,6 +28,9 @@ match pkgname.
 \fB\-c\fR \fI<arg>\fR, \fB\-\-matchcat\fR \fI<arg>\fR
 match catname.
 .TP
+\fB\-m\fR \fI<arg>\fR, \fB\-\-matchmaint\fR \fI<arg>\fR
+match maintainer email from metadata.xml (slow).
+.TP
 \fB\-i\fR, \fB\-\-imlate\fR
 list packages that can be marked stable on a given arch.
 .TP

diff --git a/qkeyword.c b/qkeyword.c
index ffcd6ae..e8fb5d6 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -28,10 +28,11 @@
 /* Required portage-utils stuff                                     */
 /********************************************************************/
 
-#define QKEYWORD_FLAGS "p:c:idtans" COMMON_FLAGS
+#define QKEYWORD_FLAGS "p:c:m:idtans" COMMON_FLAGS
 static struct option const qkeyword_long_opts[] = {
        {"matchpkg", a_argument, NULL, 'p'},
        {"matchcat", a_argument, NULL, 'c'},
+       {"matchmaint", a_argument, NULL, 'm'},
        {"imlate",  no_argument, NULL, 'i'},
        {"dropped", no_argument, NULL, 'd'},
        {"testing", no_argument, NULL, 't'},
@@ -43,6 +44,7 @@ static struct option const qkeyword_long_opts[] = {
 static const char * const qkeyword_opts_help[] = {
        "match pkgname",
        "match catname",
+       "match maintainer email from metadata.xml (slow)",
        "list packages that can be marked stable on a given arch",
        "list packages that have dropped keywords on a version bump on a given 
arch",
        "list packages that have ~arch versions, but no stable versions on a 
given arch",
@@ -56,6 +58,7 @@ static const char * const qkeyword_opts_help[] = {
 typedef struct {
        depend_atom *qatom;
        depend_atom *lastatom;
+       char *qmaint;
        int *keywordsbuf;
        size_t keywordsbuflen;
        const char *arch;
@@ -610,6 +613,8 @@ qkeyword_results_cb(cache_pkg_ctx *pkg_ctx, void *priv)
        char buf[_Q_PATH_MAX];
        depend_atom *patom = NULL;
        cache_pkg_meta *meta;
+       cache_metadata_xml *metadata;
+       struct elist *emailw;
        int ret;
 
        snprintf(buf, sizeof(buf), "%s/%s",
@@ -632,6 +637,17 @@ qkeyword_results_cb(cache_pkg_ctx *pkg_ctx, void *priv)
                return EXIT_SUCCESS;
        }
 
+       if (data->qmaint != NULL) {
+               metadata = cache_read_metadata(pkg_ctx);
+               for (emailw = metadata->email; emailw != NULL; emailw = 
emailw->next) {
+                       if (strcmp(emailw->addr, data->qmaint) != 0)
+                               break;
+               }
+               cache_close_metadata(metadata);
+               if (emailw != NULL)
+                       return EXIT_SUCCESS;
+       }
+
        keywords = data->keywordsbuf;
        meta = cache_pkg_read(pkg_ctx);
        if (meta == NULL) {
@@ -747,11 +763,13 @@ int qkeyword_main(int argc, char **argv)
        qkeyword_data data;
        char *pkg = NULL;
        char *cat = NULL;
+       char *maint = NULL;
 
        while ((i = GETOPT_LONG(QKEYWORD, qkeyword, "")) != -1) {
                switch (i) {
                        case 'p': pkg = optarg; break;
                        case 'c': cat = optarg; break;
+                       case 'm': maint = optarg; break;
                        case 'i':
                        case 'd':
                        case 't':
@@ -801,6 +819,7 @@ int qkeyword_main(int argc, char **argv)
        data.lastatom = NULL;
        data.keywordsbuf = NULL;
        data.keywordsbuflen = 0;
+       data.qmaint = maint;
 
        switch (action) {
                case 'i': i = qkeyword_traverse(qkeyword_imlate, &data);        
break;

Reply via email to