1 |
commit: f926e13ef6202ec76ba057141933e835ee571787 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat May 2 09:46:57 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat May 2 09:58:33 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f926e13e |
7 |
|
8 |
qlop: add -v mode to -E that displays emerge invocation |
9 |
|
10 |
Really complete the --emerge option with --verbose to get: |
11 |
|
12 |
% qlop -Ev |
13 |
emerge -uaD @world |
14 |
U sys-kernel/linux-firmware-20200421 [20200316] |
15 |
N www-servers/nginx-1.18.0 |
16 |
D www-servers/nginx-1.17.10 |
17 |
|
18 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
19 |
|
20 |
man/include/qlop.optdesc.yaml | 13 +++++++ |
21 |
qlop.c | 84 ++++++++++++++++++++++++++++++++++++++++--- |
22 |
2 files changed, 92 insertions(+), 5 deletions(-) |
23 |
|
24 |
diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml |
25 |
index 463a19d..c6e0833 100644 |
26 |
--- a/man/include/qlop.optdesc.yaml |
27 |
+++ b/man/include/qlop.optdesc.yaml |
28 |
@@ -55,3 +55,16 @@ running: | |
29 |
observed, or no previous occurrences for the operation exist, |
30 |
\fIunknown\fR is printed. When combined with \fB-t\fR the |
31 |
elapsed time is also displayed. |
32 |
+emerge: | |
33 |
+ Immitate \fBemerge\fR(1) output, as if \fBemerge -pv\fR had been |
34 |
+ run. This produces a list of packages that were installed (N), |
35 |
+ upgraded (U), downgraded (UD), re-installed (R) or unmerged (D). |
36 |
+ The list always includes the version numbers, and for up/downgrades |
37 |
+ the previous version is listed between square brackets after the |
38 |
+ package. When \fB-v\fR is used, the \fBemerge\fR invocations are |
39 |
+ printed as well, to really show what happened. When concurrent |
40 |
+ merges are present in the displayed timeframe, the output will be |
41 |
+ hard to read. This is a limitation of the \fIemerge.log\fR format. |
42 |
+ It is possible to combine this flag with the \fB-d\fR flag, in which |
43 |
+ case the default behaviour of displaying the last merge (\fB-l\fR) |
44 |
+ is disabled. |
45 |
|
46 |
diff --git a/qlop.c b/qlop.c |
47 |
index 69133bb..d5ace83 100644 |
48 |
--- a/qlop.c |
49 |
+++ b/qlop.c |
50 |
@@ -539,7 +539,82 @@ static int do_emerge_log( |
51 |
continue; |
52 |
|
53 |
/* are we interested in this line? */ |
54 |
- if (flags->do_sync && ( |
55 |
+ if (flags->show_emerge && verbose && ( |
56 |
+ strncmp(p, " *** emerge ", 13) == 0)) |
57 |
+ { |
58 |
+ char shortopts[8]; /* must hold as many opts converted below */ |
59 |
+ int numopts = 0; |
60 |
+ |
61 |
+ printf("emerge"); |
62 |
+ for (p += 13; (q = strtok(p, " \n")) != NULL; p = NULL) { |
63 |
+ if (strncmp(q, "--", 2) == 0) { |
64 |
+ /* portage seems to normalise options given into |
65 |
+ * their long forms always; I don't want to keep a |
66 |
+ * mapping table to short forms here, but it's |
67 |
+ * tempting, so I just do a few of the often used |
68 |
+ * ones */ |
69 |
+ q += 2; |
70 |
+ if (strcmp(q, "ask") == 0) { |
71 |
+ shortopts[numopts++] = 'a'; |
72 |
+ } else if (strcmp(q, "verbose") == 0) { |
73 |
+ shortopts[numopts++] = 'v'; |
74 |
+ } else if (strcmp(q, "oneshot") == 0) { |
75 |
+ shortopts[numopts++] = '1'; |
76 |
+ } else if (strcmp(q, "deep") == 0) { |
77 |
+ shortopts[numopts++] = 'D'; |
78 |
+ } else if (strcmp(q, "update") == 0) { |
79 |
+ shortopts[numopts++] = 'u'; |
80 |
+ } else if (strcmp(q, "depclean") == 0) { |
81 |
+ shortopts[numopts++] = 'c'; |
82 |
+ } else if (strcmp(q, "unmerge") == 0) { |
83 |
+ shortopts[numopts++] = 'C'; |
84 |
+ } else { |
85 |
+ q = NULL; |
86 |
+ } |
87 |
+ |
88 |
+ /* process next token */ |
89 |
+ if (q != NULL) |
90 |
+ continue; |
91 |
+ } |
92 |
+ |
93 |
+ /* if we're here, we've assembled opts whatever we could */ |
94 |
+ if (numopts > 0) { |
95 |
+ printf(" %s-%.*s%s", |
96 |
+ GREEN, numopts, shortopts, NORM); |
97 |
+ numopts = 0; |
98 |
+ } |
99 |
+ |
100 |
+ if (*q == '\0') { |
101 |
+ /* skip empty token, likely the trailing \n */ |
102 |
+ continue; |
103 |
+ } |
104 |
+ |
105 |
+ if (strncmp(q, "--", 2) == 0) { |
106 |
+ printf(" %s--%s%s", GREEN, q, NORM); |
107 |
+ } else if (strcmp(q, "@world") == 0 || |
108 |
+ strcmp(q, "@system") == 0) |
109 |
+ { |
110 |
+ printf(" %s%s%s", YELLOW, q, NORM); |
111 |
+ } else if (strcmp(q, "world") == 0 || |
112 |
+ strcmp(q, "system") == 0) |
113 |
+ { |
114 |
+ printf(" %s@%s%s", YELLOW, q, NORM); |
115 |
+ } else { |
116 |
+ /* this should be an atom */ |
117 |
+ atom = atom_explode(q); |
118 |
+ if (atom == NULL) { |
119 |
+ /* or not ... just print it */ |
120 |
+ printf(" %s", q); |
121 |
+ } else { |
122 |
+ printf(" %s", atom_format( |
123 |
+ "%[pfx]%[CAT]%[PF]%[sfx]" |
124 |
+ "%[SLOT]%[SUBSLOT]%[REPO]", atom)); |
125 |
+ atom_implode(atom); |
126 |
+ } |
127 |
+ } |
128 |
+ } |
129 |
+ printf("\n"); |
130 |
+ } else if (flags->do_sync && ( |
131 |
strncmp(p, " === Sync completed ", 20) == 0 || |
132 |
strcmp(p, " === sync\n") == 0)) |
133 |
{ |
134 |
@@ -702,7 +777,7 @@ static int do_emerge_log( |
135 |
printf(" %sU%sD%s ", BLUE, DKBLUE, NORM); |
136 |
break; |
137 |
} |
138 |
- printf("%s", atom_format(flags->fmt, pkgw->atom)); |
139 |
+ printf("%s", atom_format("%[CAT]%[PF]", pkgw->atom)); |
140 |
if (state == NEWER || state == OLDER) |
141 |
printf(" %s[%s%s%s]%s", DKBLUE, NORM, |
142 |
atom_format("%[PVR]", upgrade_atom), |
143 |
@@ -836,7 +911,7 @@ static int do_emerge_log( |
144 |
* is the only distinquishable choice, appearing |
145 |
* in the place of N(ew). */ |
146 |
printf("%sD%s %s", RED, NORM, |
147 |
- atom_format(flags->fmt, pkgw->atom)); |
148 |
+ atom_format("%[CAT]%[PF]", pkgw->atom)); |
149 |
if (flags->do_time) |
150 |
printf(": %s\n", fmt_elapsedtime(flags, elapsed)); |
151 |
else |
152 |
@@ -1266,8 +1341,7 @@ int qlop_main(int argc, char **argv) |
153 |
m.do_unmerge = 1; |
154 |
m.do_autoclean = 1; |
155 |
m.show_lastmerge = 1; |
156 |
- m.show_emerge = 1; |
157 |
- verbose = 1; break; |
158 |
+ m.show_emerge = 1; break; |
159 |
case 'r': m.do_running = 1; |
160 |
runningmode++; break; |
161 |
case 'a': m.do_average = 1; break; |