Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: man/, /, man/include/
Date: Mon, 30 Jan 2023 14:15:01
Message-Id: 1675088051.49da23ddba819dcf41bc3e5c1a2fb1c8801895d3.grobian@gentoo
1 commit: 49da23ddba819dcf41bc3e5c1a2fb1c8801895d3
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 30 14:14:11 2023 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 30 14:14:11 2023 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=49da23dd
7
8 qdepends: add support for IDEPEND, #892533
9
10 Bug: https://bugs.gentoo.org/892533
11 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
12
13 man/include/qdepends.desc | 3 ++-
14 man/qdepends.1 | 8 ++++++--
15 qdepends.c | 38 +++++++++++++++++++++++++-------------
16 3 files changed, 33 insertions(+), 16 deletions(-)
17
18 diff --git a/man/include/qdepends.desc b/man/include/qdepends.desc
19 index 19000d0..70b27be 100644
20 --- a/man/include/qdepends.desc
21 +++ b/man/include/qdepends.desc
22 @@ -4,7 +4,8 @@ applet has two different modes, forward and reverse dependency querying.
23 Default operation is forward mode, answering the queries "what does
24 package X depend on", while reverse mode answers "what packages depend
25 on X". Both modes can be further specified into build (DEPEND), run
26 -(RDEPEND), post (PDEPEND) and EAPI7's BDEPEND dependencies.
27 +(RDEPEND), post (PDEPEND), EAPI7's build (BDEPEND) and EAPI8's
28 +install-time (IDEPEND) dependencies.
29 .P
30 By default, \fIqdepends\fR returns the unique set of atoms that match
31 all dependency variables. To split this out per variable, use \fB-v\fR
32
33 diff --git a/man/qdepends.1 b/man/qdepends.1
34 index 5e5b00a..95e2b37 100644
35 --- a/man/qdepends.1
36 +++ b/man/qdepends.1
37 @@ -1,5 +1,5 @@
38 .\" generated by mkman.py, please do NOT edit!
39 -.TH qdepends "1" "May 2022" "Gentoo Foundation" "qdepends"
40 +.TH qdepends "1" "Jan 2023" "Gentoo Foundation" "qdepends"
41 .SH NAME
42 qdepends \- show dependency info
43 .SH SYNOPSIS
44 @@ -12,7 +12,8 @@ applet has two different modes, forward and reverse dependency querying.
45 Default operation is forward mode, answering the queries "what does
46 package X depend on", while reverse mode answers "what packages depend
47 on X". Both modes can be further specified into build (DEPEND), run
48 -(RDEPEND), post (PDEPEND) and EAPI7's BDEPEND dependencies.
49 +(RDEPEND), post (PDEPEND), EAPI7's build (BDEPEND) and EAPI8's
50 +install-time (IDEPEND) dependencies.
51 .P
52 By default, \fIqdepends\fR returns the unique set of atoms that match
53 all dependency variables. To split this out per variable, use \fB-v\fR
54 @@ -52,6 +53,9 @@ Show PDEPEND info.
55 \fB\-b\fR, \fB\-\-bdepend\fR
56 Show BDEPEND info.
57 .TP
58 +\fB\-I\fR, \fB\-\-idepend\fR
59 +Show IDEPEND info.
60 +.TP
61 \fB\-Q\fR, \fB\-\-query\fR
62 Query reverse deps. This basically reverses the search to any
63 package that references \fI<arg>\fR in DEPEND, RDEPEND, PDEPEND or BDEPEND.
64
65 diff --git a/qdepends.c b/qdepends.c
66 index f222011..1ecfab5 100644
67 --- a/qdepends.c
68 +++ b/qdepends.c
69 @@ -1,5 +1,5 @@
70 /*
71 - * Copyright 2005-2022 Gentoo Authors
72 + * Copyright 2005-2023 Gentoo Authors
73 * Distributed under the terms of the GNU General Public License v2
74 *
75 * Copyright 2005-2010 Ned Ludd - <solar@g.o>
76 @@ -22,12 +22,13 @@
77 #include "xasprintf.h"
78 #include "xregex.h"
79
80 -#define QDEPENDS_FLAGS "drpbQitUF:SR" COMMON_FLAGS
81 +#define QDEPENDS_FLAGS "drpbIQitUF:SR" COMMON_FLAGS
82 static struct option const qdepends_long_opts[] = {
83 {"depend", no_argument, NULL, 'd'},
84 {"rdepend", no_argument, NULL, 'r'},
85 {"pdepend", no_argument, NULL, 'p'},
86 {"bdepend", no_argument, NULL, 'b'},
87 + {"idepend", no_argument, NULL, 'I'},
88 {"query", no_argument, NULL, 'Q'},
89 {"installed", no_argument, NULL, 'i'},
90 {"tree", no_argument, NULL, 't'},
91 @@ -42,6 +43,7 @@ static const char * const qdepends_opts_help[] = {
92 "Show RDEPEND info",
93 "Show PDEPEND info",
94 "Show BDEPEND info",
95 + "Show IDEPEND info",
96 "Query reverse deps",
97 "Search installed packages using VDB",
98 "Search available ebuilds in the tree",
99 @@ -71,17 +73,22 @@ struct qdepends_opt_state {
100 #define QMODE_RDEPEND (1<<1)
101 #define QMODE_PDEPEND (1<<2)
102 #define QMODE_BDEPEND (1<<3)
103 +#define QMODE_IDEPEND (1<<4)
104 #define QMODE_INSTALLED (1<<5)
105 #define QMODE_TREE (1<<6)
106 #define QMODE_REVERSE (1<<7)
107 #define QMODE_FILTERUSE (1<<8)
108
109 +#define QMODE_DEP_FIRST QMODE_DEPEND
110 +#define QMODE_DEP_LAST QMODE_IDEPEND
111 +
112 const char *depend_files[] = { /* keep *DEPEND aligned with above defines */
113 /* 0 */ "DEPEND",
114 /* 1 */ "RDEPEND",
115 /* 2 */ "PDEPEND",
116 /* 3 */ "BDEPEND",
117 - /* 4 */ NULL
118 + /* 4 */ "IDEPEND",
119 + /* 5 */ NULL
120 };
121
122 static bool
123 @@ -161,15 +168,19 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
124 xarrayfree_int(state->deps);
125 clear_set(state->udeps);
126
127 +#define get_depstr(X) \
128 + i == QMODE_DEPEND ? tree_pkg_meta_get(pkg_ctx, DEPEND) : \
129 + i == QMODE_RDEPEND ? tree_pkg_meta_get(pkg_ctx, RDEPEND) : \
130 + i == QMODE_PDEPEND ? tree_pkg_meta_get(pkg_ctx, PDEPEND) : \
131 + i == QMODE_BDEPEND ? tree_pkg_meta_get(pkg_ctx, BDEPEND) : \
132 + tree_pkg_meta_get(pkg_ctx, IDEPEND) ;
133 +
134 dfile = depend_files;
135 - for (i = QMODE_DEPEND; i <= QMODE_BDEPEND; i <<= 1, dfile++) {
136 + for (i = QMODE_DEP_FIRST; i <= QMODE_DEP_LAST; i <<= 1, dfile++) {
137 if (!(state->qmode & i))
138 continue;
139
140 - depstr = i == 1<<0 ? tree_pkg_meta_get(pkg_ctx, DEPEND) :
141 - i == 1<<1 ? tree_pkg_meta_get(pkg_ctx, RDEPEND) :
142 - i == 1<<2 ? tree_pkg_meta_get(pkg_ctx, PDEPEND) :
143 - tree_pkg_meta_get(pkg_ctx, BDEPEND);
144 + depstr = get_depstr(i);
145 if (depstr == NULL)
146 continue;
147 dep_tree = dep_grow_tree(depstr);
148 @@ -193,10 +204,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
149 tree_pkg_ctx *vpkg =
150 tree_open_pkg(vcat, pkg_ctx->name);
151 if (vpkg != NULL) {
152 - depstr = i == 1<<0 ? tree_pkg_meta_get(vpkg, DEPEND) :
153 - i == 1<<1 ? tree_pkg_meta_get(vpkg, RDEPEND) :
154 - i == 1<<2 ? tree_pkg_meta_get(vpkg, PDEPEND) :
155 - tree_pkg_meta_get(vpkg, BDEPEND);
156 + depstr = get_depstr(i);
157 if (depstr != NULL) {
158 dep_node *dep_vdb = dep_grow_tree(depstr);
159 if (dep_vdb != NULL) {
160 @@ -293,6 +301,8 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
161 if (verbose && ret == 1)
162 printf("\n");
163
164 +#undef get_depstr
165 +
166 if (!verbose) {
167 if ((state->qmode & QMODE_REVERSE) == 0 || ret == 1) {
168 for (n = list_set(state->udeps, &d); n > 0; n--)
169 @@ -335,6 +345,7 @@ int qdepends_main(int argc, char **argv)
170 case 'r': state.qmode |= QMODE_RDEPEND; break;
171 case 'p': state.qmode |= QMODE_PDEPEND; break;
172 case 'b': state.qmode |= QMODE_BDEPEND; break;
173 + case 'I': state.qmode |= QMODE_IDEPEND; break;
174 case 'Q': state.qmode |= QMODE_REVERSE; break;
175 case 'i': state.qmode |= QMODE_INSTALLED; break;
176 case 't': state.qmode |= QMODE_TREE; break;
177 @@ -350,7 +361,8 @@ int qdepends_main(int argc, char **argv)
178 state.qmode |= QMODE_DEPEND |
179 QMODE_RDEPEND |
180 QMODE_PDEPEND |
181 - QMODE_BDEPEND;
182 + QMODE_BDEPEND |
183 + QMODE_IDEPEND ;
184 }
185
186 /* default to installed packages */