1 |
commit: 43ce14510666e67265dc16f0b0d72bd706074b41 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jun 1 19:40:31 2021 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jun 1 19:40:31 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43ce1451 |
7 |
|
8 |
qwhich: better support for binpkgs |
9 |
|
10 |
- don't use ROOT with PKGDIR |
11 |
- print coloured paths/matches for binpkgs |
12 |
- support dirs (-d) for binpkgs |
13 |
|
14 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
15 |
|
16 |
qwhich.c | 27 +++++++++++++++++++++------ |
17 |
1 file changed, 21 insertions(+), 6 deletions(-) |
18 |
|
19 |
diff --git a/qwhich.c b/qwhich.c |
20 |
index 24a9ff0..76b03a8 100644 |
21 |
--- a/qwhich.c |
22 |
+++ b/qwhich.c |
23 |
@@ -82,6 +82,7 @@ int qwhich_main(int argc, char **argv) |
24 |
tree_ctx *t; |
25 |
char *repo; |
26 |
int repolen; |
27 |
+ const char *ext; |
28 |
|
29 |
memset(&m, 0, sizeof(m)); |
30 |
|
31 |
@@ -144,7 +145,7 @@ int qwhich_main(int argc, char **argv) |
32 |
xarraypush_ptr(trees, t); |
33 |
} |
34 |
if (m.do_binpkg) { |
35 |
- t = tree_open_binpkg(portroot, pkgdir); |
36 |
+ t = tree_open_binpkg("/", pkgdir); |
37 |
if (t != NULL) |
38 |
xarraypush_ptr(trees, t); |
39 |
} |
40 |
@@ -159,7 +160,7 @@ int qwhich_main(int argc, char **argv) |
41 |
|
42 |
/* at least keep the IO constrained to a tree at a time */ |
43 |
array_for_each(trees, j, t) { |
44 |
- if (m.print_repo) { |
45 |
+ if (m.print_repo && t->repo != NULL) { |
46 |
repo = t->repo; |
47 |
repolen = strlen(repo); |
48 |
} else { |
49 |
@@ -168,12 +169,24 @@ int qwhich_main(int argc, char **argv) |
50 |
repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1); |
51 |
else if (t->cachetype == CACHE_METADATA_PMS) |
52 |
repolen = strlen(t->path) - (sizeof("/metadata/cache") - 1); |
53 |
- else if (t->cachetype == CACHE_EBUILD) |
54 |
+ else if (t->cachetype == CACHE_EBUILD || |
55 |
+ t->cachetype == CACHE_BINPKGS || |
56 |
+ t->cachetype == CACHE_PACKAGES) |
57 |
repolen = strlen(t->path); |
58 |
else |
59 |
repolen = 0; |
60 |
} |
61 |
|
62 |
+ switch (t->cachetype) { |
63 |
+ case CACHE_BINPKGS: |
64 |
+ case CACHE_PACKAGES: |
65 |
+ ext = "tbz2"; |
66 |
+ break; |
67 |
+ default: |
68 |
+ ext = "ebuild"; |
69 |
+ break; |
70 |
+ } |
71 |
+ |
72 |
array_for_each(atoms, i, atom) { |
73 |
tmc = tree_match_atom(t, atom, |
74 |
(m.match_latest ? TREE_MATCH_LATEST : 0 ) | |
75 |
@@ -186,7 +199,9 @@ int qwhich_main(int argc, char **argv) |
76 |
} else { |
77 |
if (t->cachetype == CACHE_METADATA_MD5 || |
78 |
t->cachetype == CACHE_METADATA_PMS || |
79 |
- t->cachetype == CACHE_EBUILD) |
80 |
+ t->cachetype == CACHE_EBUILD || |
81 |
+ t->cachetype == CACHE_BINPKGS || |
82 |
+ t->cachetype == CACHE_PACKAGES) |
83 |
{ |
84 |
if (m.print_path) |
85 |
printf("%s%.*s%s%s%s/%s%s%s\n", |
86 |
@@ -196,13 +211,13 @@ int qwhich_main(int argc, char **argv) |
87 |
DKBLUE, tmcw->atom->PN, |
88 |
NORM); |
89 |
else |
90 |
- printf("%s%.*s%s%s%s/%s%s/%s%s%s.ebuild%s\n", |
91 |
+ printf("%s%.*s%s%s%s/%s%s/%s%s%s.%s%s\n", |
92 |
DKGREEN, repolen, repo, |
93 |
m.print_repo ? "::" : "/", |
94 |
BOLD, tmcw->atom->CATEGORY, |
95 |
DKBLUE, tmcw->atom->PN, |
96 |
BLUE, tmcw->atom->PF, |
97 |
- DKGREEN, NORM); |
98 |
+ DKGREEN, ext, NORM); |
99 |
} else if (t->cachetype == CACHE_VDB && !m.print_path) { |
100 |
printf("%s%s/%s%s%s.ebuild%s\n", |
101 |
DKBLUE, tmcw->path, |