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: /
Date: Sat, 27 Jun 2020 09:38:13
Message-Id: 1593250645.f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184.grobian@gentoo
1 commit: f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 27 09:37:25 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 27 09:37:25 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f6dd53fa
7
8 qpkg: fix VDB access method, warn when atoms didn't match anything
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11
12 TODO.md | 1 +
13 qpkg.c | 53 +++++++++++++++++++++++++++++++++++------------------
14 2 files changed, 36 insertions(+), 18 deletions(-)
15
16 diff --git a/TODO.md b/TODO.md
17 index 86a9e84..8188fe1 100644
18 --- a/TODO.md
19 +++ b/TODO.md
20 @@ -64,6 +64,7 @@
21 and qpkg is doing parts of qtbz2's compose
22 - share install\_mask code from qmerge to handle negatives from
23 pkg\_install\_mask too
24 +- make world agument really read world file, add @all?
25
26 # qgrep
27 - make it use standard xarray instead of its own buf\_list
28
29 diff --git a/qpkg.c b/qpkg.c
30 index 5e55406..41ac0f5 100644
31 --- a/qpkg.c
32 +++ b/qpkg.c
33 @@ -395,7 +395,10 @@ int qpkg_main(int argc, char **argv)
34 * to tar when we create the binary package. */
35 xchdir(portroot);
36
37 - /* first process any arguments which point to /var/db/pkg */
38 + /* first process any arguments which point to /var/db/pkg, an
39 + * undocumented method to allow easily tab-completing into vdb as
40 + * arguments, the trailing / needs to be present for this (as tab
41 + * completion would do) */
42 pkgs_made = 0;
43 s = strlen(portvdb);
44 for (i = optind; i < argc; ++i) {
45 @@ -404,22 +407,31 @@ int qpkg_main(int argc, char **argv)
46 argv[i] = NULL;
47 continue;
48 }
49 - if (argv[i][asize-1] == '/')
50 - argv[i][asize-1] = '\0';
51 - if (!strncmp(portvdb, argv[i], s))
52 - memmove(argv[i], argv[i]+s+1, asize-s);
53 - else if (argv[i][0] == '/' && !strncmp(portvdb, argv[i]+1, s))
54 - memmove(argv[i], argv[i]+s+2, asize-s-1);
55 - else
56 - continue;
57 -
58 - atom = atom_explode(argv[i]);
59 - if (atom) {
60 - if (!qpkg_make(atom)) ++pkgs_made;
61 - atom_implode(atom);
62 - } else
63 - warn("could not explode '%s'", argv[i]);
64 - argv[i] = NULL;
65 + if (asize > s && argv[i][0] == '/' && argv[i][asize - 1] == '/') {
66 + char *path = argv[i];
67 +
68 + /* chop off trailing / */
69 + argv[i][asize - 1] = '\0';
70 +
71 + /* eliminate duplicate leading /, we know it starts with / */
72 + while (path[1] == '/')
73 + path++;
74 +
75 + if (strncmp(portvdb, path, s) == 0) {
76 + path += s + 1 /* also eat / after portvdb */;
77 +
78 + atom = atom_explode(path);
79 + if (atom) {
80 + if (!qpkg_make(atom))
81 + pkgs_made++;
82 + atom_implode(atom);
83 + } else
84 + warn("could not explode '%s'", path);
85 + argv[i] = NULL;
86 + } else {
87 + argv[i][asize - 1] = '/'; /* restore, it may be a cat match */
88 + }
89 + }
90 }
91
92 /* now try to run through vdb and locate matches for user inputs */
93 @@ -431,14 +443,19 @@ int qpkg_main(int argc, char **argv)
94 if (argv[i] == NULL)
95 continue;
96 if (strcmp(argv[i], "world") == 0) {
97 - /* we're basically done, this means all */
98 + /* this is a crude hack, we include all packages for this,
99 + * which isn't exactly @world, but all its deps too */
100 tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, NULL);
101 + break; /* no point in continuing since we did everything */
102 }
103 atom = atom_explode(argv[i]);
104 if (atom == NULL)
105 continue;
106
107 + s = pkgs_made;
108 tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, atom);
109 + if (s == pkgs_made)
110 + warn("no match for '%s'", argv[i]);
111 atom_implode(atom);
112 }
113 tree_close(ctx);