1 |
commit: 1038786d92a885dece9cc82588e88d8367a0fda2 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Dec 27 19:14:44 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Dec 27 19:14:44 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1038786d |
7 |
|
8 |
qkeyword: apply profile masks to -S/-T results |
9 |
|
10 |
Technically, this should be enough to implement the Puppet provider for |
11 |
Gentoo. |
12 |
|
13 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
14 |
|
15 |
man/include/qkeyword-01-latest-testing.include | 23 ++++++++ |
16 |
man/include/qkeyword.desc | 10 +++- |
17 |
man/qkeyword.1 | 34 ++++++++++-- |
18 |
qkeyword.c | 73 +++++++++++++++++++++----- |
19 |
4 files changed, 121 insertions(+), 19 deletions(-) |
20 |
|
21 |
diff --git a/man/include/qkeyword-01-latest-testing.include b/man/include/qkeyword-01-latest-testing.include |
22 |
new file mode 100644 |
23 |
index 0000000..1c2fde5 |
24 |
--- /dev/null |
25 |
+++ b/man/include/qkeyword-01-latest-testing.include |
26 |
@@ -0,0 +1,23 @@ |
27 |
+.SH "RETRIEVING LATEST TESTING VERSION AVAILABLE" |
28 |
+.PP |
29 |
+To retrieve the latest available version in the ebuild tree marked as |
30 |
+testing for the given ARCH, can be done with a combination of flags, |
31 |
+mostly to restrict the search. For instance, to find the latest version |
32 |
+of \fIsys-devel/gcc\fR available, one could use: |
33 |
+.nf |
34 |
+$ qkeyword -p sys-devel/gcc -T |
35 |
+sys-devel/gcc-8.3.0 |
36 |
+.fi |
37 |
+It may be that there is a newer version available, but masked for the |
38 |
+configured profile (via package.mask). Using \fB-v\fR will inform about |
39 |
+this scenario happening: |
40 |
+.nf |
41 |
+$ qkeyword -p dev-vcs/cvs -Tv |
42 |
+masked by =dev-vcs/cvs-1.12.12*: dev-vcs/cvs-1.12.12-r12 |
43 |
+.fi |
44 |
+Unrelated, but to locate the mask given, use verbose mode on \fIq\fR's |
45 |
+mask listing: |
46 |
+.nf |
47 |
+$ q -mv dev-vcs/cvs |
48 |
+=dev-vcs/cvs-1.12.12* [/repo/gentoo/profiles/prefix/sunos/solaris/package.mask] |
49 |
+.fi |
50 |
|
51 |
diff --git a/man/include/qkeyword.desc b/man/include/qkeyword.desc |
52 |
index b7a863c..adc55ea 100644 |
53 |
--- a/man/include/qkeyword.desc |
54 |
+++ b/man/include/qkeyword.desc |
55 |
@@ -1,5 +1,5 @@ |
56 |
-\fIqkeyword\fR allows various searches based on KEYWORDS aimed at Gentoo |
57 |
-developers. Various modes allow to query which packages would be |
58 |
+\fIqkeyword\fR allows various searches based on KEYWORDS. Some uses are |
59 |
+aimed at Gentoo developers, to allow querying which packages would be |
60 |
available, or are candidate for keywording. |
61 |
.P |
62 |
By default, the entire tree is traversed. Since this process can be |
63 |
@@ -12,3 +12,9 @@ as package in one go. The \fB-m\fR maintainer match, while reducing the |
64 |
resulting set, is likely to slow down the query processing since the |
65 |
metadata.xml file has to be read for each package examined. It is best |
66 |
used in combination with \fB-p\fR or \fB-c\fR. |
67 |
+.P |
68 |
+\fIqkeyword\fR uses the keyword found in the configured profile (ARCH) |
69 |
+for its queries. This keyword can be overridden by giving the desired |
70 |
+keyword as argument. Note that this does not change the profile in use, |
71 |
+which most notably can result in incorrect masks being applied for the |
72 |
+\fB-T\fR and \fB-S\fR options. |
73 |
|
74 |
diff --git a/man/qkeyword.1 b/man/qkeyword.1 |
75 |
index 34beb18..5a26218 100644 |
76 |
--- a/man/qkeyword.1 |
77 |
+++ b/man/qkeyword.1 |
78 |
@@ -6,8 +6,8 @@ qkeyword \- list packages based on keywords |
79 |
.B qkeyword |
80 |
\fI[opts] <action> <args>\fR |
81 |
.SH DESCRIPTION |
82 |
-\fIqkeyword\fR allows various searches based on KEYWORDS aimed at Gentoo |
83 |
-developers. Various modes allow to query which packages would be |
84 |
+\fIqkeyword\fR allows various searches based on KEYWORDS. Some uses are |
85 |
+aimed at Gentoo developers, to allow querying which packages would be |
86 |
available, or are candidate for keywording. |
87 |
.P |
88 |
By default, the entire tree is traversed. Since this process can be |
89 |
@@ -20,6 +20,12 @@ as package in one go. The \fB-m\fR maintainer match, while reducing the |
90 |
resulting set, is likely to slow down the query processing since the |
91 |
metadata.xml file has to be read for each package examined. It is best |
92 |
used in combination with \fB-p\fR or \fB-c\fR. |
93 |
+.P |
94 |
+\fIqkeyword\fR uses the keyword found in the configured profile (ARCH) |
95 |
+for its queries. This keyword can be overridden by giving the desired |
96 |
+keyword as argument. Note that this does not change the profile in use, |
97 |
+which most notably can result in incorrect masks being applied for the |
98 |
+\fB-T\fR and \fB-S\fR options. |
99 |
.SH OPTIONS |
100 |
.TP |
101 |
\fB\-p\fR \fI<arg>\fR, \fB\-\-matchpkg\fR \fI<arg>\fR |
102 |
@@ -75,7 +81,29 @@ Print this help and exit. |
103 |
.TP |
104 |
\fB\-V\fR, \fB\-\-version\fR |
105 |
Print version and exit. |
106 |
- |
107 |
+.SH "RETRIEVING LATEST TESTING VERSION AVAILABLE" |
108 |
+.PP |
109 |
+To retrieve the latest available version in the ebuild tree marked as |
110 |
+testing for the given ARCH, can be done with a combination of flags, |
111 |
+mostly to restrict the search. For instance, to find the latest version |
112 |
+of \fIsys-devel/gcc\fR available, one could use: |
113 |
+.nf |
114 |
+$ qkeyword -p sys-devel/gcc -T |
115 |
+sys-devel/gcc-8.3.0 |
116 |
+.fi |
117 |
+It may be that there is a newer version available, but masked for the |
118 |
+configured profile (via package.mask). Using \fB-v\fR will inform about |
119 |
+this scenario happening: |
120 |
+.nf |
121 |
+$ qkeyword -p dev-vcs/cvs -Tv |
122 |
+masked by =dev-vcs/cvs-1.12.12*: dev-vcs/cvs-1.12.12-r12 |
123 |
+.fi |
124 |
+Unrelated, but to locate the mask given, use verbose mode on \fIq\fR's |
125 |
+mask listing: |
126 |
+.nf |
127 |
+$ q -mv dev-vcs/cvs |
128 |
+=dev-vcs/cvs-1.12.12* [/repo/gentoo/profiles/prefix/sunos/solaris/package.mask] |
129 |
+.fi |
130 |
.SH "REPORTING BUGS" |
131 |
Please report bugs via http://bugs.gentoo.org/ |
132 |
.br |
133 |
|
134 |
diff --git a/qkeyword.c b/qkeyword.c |
135 |
index 4a55b6a..4e84ebd 100644 |
136 |
--- a/qkeyword.c |
137 |
+++ b/qkeyword.c |
138 |
@@ -76,8 +76,9 @@ static set *archs = NULL; |
139 |
static char **archlist = NULL; |
140 |
static size_t archlist_count; |
141 |
static size_t arch_longest_len; |
142 |
-const char status[3] = {'-', '~', '+'}; |
143 |
-int qkeyword_test_arch = 0; |
144 |
+static const char status[3] = {'-', '~', '+'}; |
145 |
+static int qkeyword_test_arch = 0; |
146 |
+static set *pmasks = NULL; |
147 |
|
148 |
enum { none = 0, testing, stable, minus }; |
149 |
|
150 |
@@ -226,13 +227,33 @@ qkeyword_imlate(tree_pkg_ctx *pkg_ctx, void *priv) |
151 |
} |
152 |
|
153 |
static int |
154 |
-qkeyword_lstable(tree_pkg_ctx *pkg_ctx, void *priv) |
155 |
+qkeyword_kw(tree_pkg_ctx *pkg_ctx, void *priv, int what) |
156 |
{ |
157 |
qkeyword_data *data = (qkeyword_data *)priv; |
158 |
+ depend_atom *atom; |
159 |
+ array_t *masks; |
160 |
|
161 |
- if (data->keywordsbuf[qkeyword_test_arch] == stable) |
162 |
+ if (data->keywordsbuf[qkeyword_test_arch] == what) |
163 |
{ |
164 |
- printf("%s", atom_format(data->fmt, tree_get_atom(pkg_ctx, true))); |
165 |
+ size_t n; |
166 |
+ depend_atom *mask; |
167 |
+ |
168 |
+ atom = tree_get_atom(pkg_ctx, false); |
169 |
+ masks = get_set(atom_format("%[CAT]%[PN]", atom), pmasks); |
170 |
+ if (masks != NULL) { |
171 |
+ array_for_each(masks, n, mask) { |
172 |
+ if (atom_compare(atom, mask) == EQUAL) { |
173 |
+ if (verbose) { |
174 |
+ printf("masked by %s: ", atom_to_string(mask)); |
175 |
+ printf("%s\n", atom_format(data->fmt, |
176 |
+ tree_get_atom(pkg_ctx, true))); |
177 |
+ } |
178 |
+ return EXIT_FAILURE; |
179 |
+ } |
180 |
+ } |
181 |
+ } |
182 |
+ |
183 |
+ printf("%s\n", atom_format(data->fmt, tree_get_atom(pkg_ctx, true))); |
184 |
return EXIT_SUCCESS; |
185 |
} |
186 |
|
187 |
@@ -240,17 +261,15 @@ qkeyword_lstable(tree_pkg_ctx *pkg_ctx, void *priv) |
188 |
} |
189 |
|
190 |
static int |
191 |
-qkeyword_ltesting(tree_pkg_ctx *pkg_ctx, void *priv) |
192 |
+qkeyword_lstable(tree_pkg_ctx *pkg_ctx, void *priv) |
193 |
{ |
194 |
- qkeyword_data *data = (qkeyword_data *)priv; |
195 |
- |
196 |
- if (data->keywordsbuf[qkeyword_test_arch] == testing) |
197 |
- { |
198 |
- printf("%s\n", atom_format(data->fmt, tree_get_atom(pkg_ctx, true))); |
199 |
- return EXIT_SUCCESS; |
200 |
- } |
201 |
+ return qkeyword_kw(pkg_ctx, priv, stable); |
202 |
+} |
203 |
|
204 |
- return EXIT_FAILURE; |
205 |
+static int |
206 |
+qkeyword_ltesting(tree_pkg_ctx *pkg_ctx, void *priv) |
207 |
+{ |
208 |
+ return qkeyword_kw(pkg_ctx, priv, testing); |
209 |
} |
210 |
|
211 |
static int |
212 |
@@ -868,6 +887,32 @@ int qkeyword_main(int argc, char **argv) |
213 |
data.keywordsbuflen = 0; |
214 |
data.qmaint = maint; |
215 |
|
216 |
+ /* prepare masks for easy(er) matching by key-ing on CAT/PN */ |
217 |
+ { |
218 |
+ DECLARE_ARRAY(masks); |
219 |
+ array_t *bucket; |
220 |
+ array_t *ebuck; |
221 |
+ size_t n; |
222 |
+ char *mask; |
223 |
+ depend_atom *atom; |
224 |
+ |
225 |
+ pmasks = create_set(); |
226 |
+ |
227 |
+ array_set(package_masks, masks); |
228 |
+ array_for_each(masks, n, mask) { |
229 |
+ if ((atom = atom_explode(mask)) == NULL) |
230 |
+ continue; |
231 |
+ bucket = xzalloc(sizeof(array_t)); |
232 |
+ xarraypush_ptr(bucket, atom); |
233 |
+ ebuck = add_set_value(atom_format("%[CAT]%[PN]", atom), |
234 |
+ bucket, pmasks); |
235 |
+ if (ebuck != NULL) { |
236 |
+ xarraypush_ptr(ebuck, atom); |
237 |
+ xarrayfree_int(bucket); |
238 |
+ } |
239 |
+ } |
240 |
+ } |
241 |
+ |
242 |
switch (action) { |
243 |
case 'i': i = qkeyword_traverse(qkeyword_imlate, &data); break; |
244 |
case 'd': i = qkeyword_traverse(qkeyword_dropped, &data); |