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/include/, /
Date: Sun, 17 Nov 2019 15:12:43
Message-Id: 1574002950.f9eef8946dee223de1115e572633a7ddefa3197c.grobian@gentoo
1 commit: f9eef8946dee223de1115e572633a7ddefa3197c
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 17 15:02:30 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 17 15:02:30 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f9eef894
7
8 qlist: add -k option to operate on binpkgs
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 man/include/qlist.desc | 3 ++-
13 man/include/qlist.optdesc.yaml | 2 ++
14 qlist.c | 22 +++++++++++++++-------
15 3 files changed, 19 insertions(+), 8 deletions(-)
16
17 diff --git a/man/include/qlist.desc b/man/include/qlist.desc
18 index e02d971..e26d63d 100644
19 --- a/man/include/qlist.desc
20 +++ b/man/include/qlist.desc
21 @@ -3,4 +3,5 @@ package. Alternatively, lists whether a package is installed,
22 optionally with version, USE-flag, SLOT or REPO information. The
23 \fIpkgname\fR to query for does not have to be an exact match, it may be
24 part of it, e.g.\ an entire category, or any package with some string in
25 -its name.
26 +its name. When no packages are given to match, \fIqlist\fR lists all
27 +installed packages.
28
29 diff --git a/man/include/qlist.optdesc.yaml b/man/include/qlist.optdesc.yaml
30 index 5fff904..30d8446 100644
31 --- a/man/include/qlist.optdesc.yaml
32 +++ b/man/include/qlist.optdesc.yaml
33 @@ -1,6 +1,8 @@
34 installed: |
35 Instead of listing the contents of a package, just print the package
36 name if the package is currently installed.
37 +binpkgs: |
38 + Operate on binary packages instead of installed packges.
39 umap: |
40 List USE-flags enabled when the package was installed. This flag
41 implies \fB\-I\fR.
42
43 diff --git a/qlist.c b/qlist.c
44 index a97111d..30c0c6f 100644
45 --- a/qlist.c
46 +++ b/qlist.c
47 @@ -21,16 +21,16 @@
48 #include "tree.h"
49 #include "xregex.h"
50
51 -#define QLIST_FLAGS "ISRUcDeadosF:" COMMON_FLAGS
52 +#define QLIST_FLAGS "IkSRUcDedosF:" COMMON_FLAGS
53 static struct option const qlist_long_opts[] = {
54 {"installed", no_argument, NULL, 'I'},
55 + {"binpkgs", no_argument, NULL, 'k'},
56 {"slots", no_argument, NULL, 'S'},
57 {"repo", no_argument, NULL, 'R'},
58 {"umap", no_argument, NULL, 'U'},
59 {"columns", no_argument, NULL, 'c'},
60 {"showdebug", no_argument, NULL, 128},
61 {"exact", no_argument, NULL, 'e'},
62 - {"all", no_argument, NULL, 'a'},
63 {"dir", no_argument, NULL, 'd'},
64 {"obj", no_argument, NULL, 'o'},
65 {"sym", no_argument, NULL, 's'},
66 @@ -40,13 +40,13 @@ static struct option const qlist_long_opts[] = {
67 };
68 static const char * const qlist_opts_help[] = {
69 "Just show installed package names",
70 + "Use binpkgs instead of installed packages",
71 "Display installed packages with slots (use twice for subslots)",
72 "Display installed packages with repository",
73 "Display installed packages with flags used",
74 "Display column view",
75 "Show /usr/lib/debug and /usr/src/debug files",
76 "Exact match (only CAT/PN or PN without PV)",
77 - "Show every installed package",
78 "Only show directories",
79 "Only show objects",
80 "Only show symlinks",
81 @@ -410,6 +410,7 @@ int qlist_main(int argc, char **argv)
82 int show_slots = 0;
83 bool show_repo = false;
84 bool do_columns = false;
85 + bool do_binpkgs = false;
86 char qfmt[128];
87 struct qlist_opt_state state = {
88 .argc = argc,
89 @@ -430,8 +431,8 @@ int qlist_main(int argc, char **argv)
90 while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
91 switch (i) {
92 COMMON_GETOPTS_CASES(qlist)
93 - case 'a': state.all = true; /* fall through */
94 case 'I': state.just_pkgname = true; break;
95 + case 'k': do_binpkgs = true; break;
96 case 'S': state.just_pkgname = true; show_slots++; break;
97 case 'R': state.just_pkgname = show_repo = true; break;
98 case 'U': state.just_pkgname = state.show_umap = true; break;
99 @@ -448,8 +449,12 @@ int qlist_main(int argc, char **argv)
100 /* default to showing syms and objs */
101 if (!state.show_dir && !state.show_obj && !state.show_sym)
102 state.show_obj = state.show_sym = true;
103 - if (argc == optind && !state.all)
104 - qlist_usage(EXIT_FAILURE);
105 + if (argc == optind) {
106 + if (state.just_pkgname)
107 + state.all = true;
108 + else
109 + qlist_usage(EXIT_FAILURE);
110 + }
111
112 if (state.fmt == NULL) {
113 const char *l = "%[";
114 @@ -483,7 +488,10 @@ int qlist_main(int argc, char **argv)
115 state.buf = xmalloc(state.buflen);
116 state.atoms = xcalloc(argc - optind, sizeof(*state.atoms));
117 ret = 1;
118 - vdb = tree_open_vdb(portroot, portvdb);
119 + if (do_binpkgs)
120 + vdb = tree_open_binpkg(portroot, pkgdir);
121 + else
122 + vdb = tree_open_vdb(portroot, portvdb);
123 if (vdb != NULL) {
124 ret = tree_foreach_pkg_sorted(vdb, qlist_cb, &state);
125 tree_close(vdb);