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/
Date: Tue, 10 Sep 2019 18:25:16
Message-Id: 1568139711.3dc607a8a6cfd3bafbc2f10d9a7c3aae90c3a757.grobian@gentoo
1 commit: 3dc607a8a6cfd3bafbc2f10d9a7c3aae90c3a757
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 10 18:21:51 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 10 18:21:51 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3dc607a8
7
8 qlop: add mode to print last run in a similar way like emerge(1) does
9
10 For example, the output could be like this, showing upgrade information:
11
12 % ./qlop -E -t
13 U app-shells/bash-5.0_p11 [5.0_p9-r0]: 2′38″
14 U app-admin/eselect-1.4.15 [1.4.14-r0]: 19s
15 U sys-libs/talloc-2.3.0 [2.2.0-r0]: 1′56″
16 U app-portage/prefix-toolkit-5 [4-r0]: 10s
17 U dev-python/cryptography-2.7 [2.6.1-r0]: 1′59″
18 U net-dns/bind-tools-9.14.5 [9.14.4-r0]: 4′17″
19 R dev-python/sphinxcontrib-applehelp-1.0.1: 28s
20 R dev-python/sphinxcontrib-devhelp-1.0.1: 27s
21 R dev-python/sphinxcontrib-jsmath-1.0.1: 25s
22 R dev-python/sphinxcontrib-htmlhelp-1.0.2: 28s
23 R dev-python/sphinxcontrib-serializinghtml-1.1.3: 28s
24 R dev-python/sphinxcontrib-qthelp-1.0.2: 28s
25 U dev-python/sphinx-2.0.1 [1.7.5-r1]: 1′13″
26 U net-mail/notmuch-0.29.1-r1 [0.28.4-r0]: 1′00″
27
28 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
29
30 man/qlop.1 | 5 ++++-
31 qlop.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
32 2 files changed, 52 insertions(+), 2 deletions(-)
33
34 diff --git a/man/qlop.1 b/man/qlop.1
35 index baa5bf5..de1e525 100644
36 --- a/man/qlop.1
37 +++ b/man/qlop.1
38 @@ -1,5 +1,5 @@
39 .\" generated by mkman.py, please do NOT edit!
40 -.TH qlop "1" "Jul 2019" "Gentoo Foundation" "qlop"
41 +.TH qlop "1" "Sep 2019" "Gentoo Foundation" "qlop"
42 .SH NAME
43 qlop \- emerge log analyzer
44 .SH SYNOPSIS
45 @@ -65,6 +65,9 @@ Show autoclean unmerge history.
46 \fB\-s\fR, \fB\-\-sync\fR
47 Show sync history.
48 .TP
49 +\fB\-E\fR, \fB\-\-emerge\fR
50 +Show last merge like how emerge(1) -v would show it.
51 +.TP
52 \fB\-e\fR, \fB\-\-endtime\fR
53 Report time at which the operation finished (iso started).
54 .TP
55
56 diff --git a/qlop.c b/qlop.c
57 index 243c8b6..3cc3367 100644
58 --- a/qlop.c
59 +++ b/qlop.c
60 @@ -24,7 +24,7 @@
61
62 #define QLOP_DEFAULT_LOGFILE "emerge.log"
63
64 -#define QLOP_FLAGS "ctaHMmuUslerd:f:w:F:" COMMON_FLAGS
65 +#define QLOP_FLAGS "ctaHMmuUsElerd:f:w:F:" COMMON_FLAGS
66 static struct option const qlop_long_opts[] = {
67 {"summary", no_argument, NULL, 'c'},
68 {"time", no_argument, NULL, 't'},
69 @@ -35,6 +35,7 @@ static struct option const qlop_long_opts[] = {
70 {"unmerge", no_argument, NULL, 'u'},
71 {"autoclean", no_argument, NULL, 'U'},
72 {"sync", no_argument, NULL, 's'},
73 + {"emerge", no_argument, NULL, 'E'},
74 {"endtime", no_argument, NULL, 'e'},
75 {"running", no_argument, NULL, 'r'},
76 {"date", a_argument, NULL, 'd'},
77 @@ -54,6 +55,7 @@ static const char * const qlop_opts_help[] = {
78 "Show unmerge history",
79 "Show autoclean unmerge history",
80 "Show sync history",
81 + "Show last merge like how emerge(1) -v would show it",
82 "Report time at which the operation finished (iso started)",
83 "Show current emerging packages",
84 "Limit selection to this time (1st -d is start, 2nd -d is end)",
85 @@ -85,6 +87,7 @@ struct qlop_mode {
86 char do_machine:1;
87 char do_endtime:1;
88 char show_lastmerge:1;
89 + char show_emerge:1;
90 const char *fmt;
91 };
92
93 @@ -334,6 +337,7 @@ static int do_emerge_log(
94 time_t elapsed;
95 depend_atom *atom;
96 depend_atom *atomw;
97 + depend_atom *upgrade_atom = NULL;
98 DECLARE_ARRAY(merge_matches);
99 DECLARE_ARRAY(merge_averages);
100 DECLARE_ARRAY(unmerge_matches);
101 @@ -638,6 +642,34 @@ static int do_emerge_log(
102 flags->do_time ? ": " : "",
103 flags->do_time ?
104 fmt_elapsedtime(flags, elapsed) : "");
105 + } else if (flags->show_emerge) {
106 + int state = NOT_EQUAL;
107 + if (upgrade_atom != NULL)
108 + state = atom_compare(pkgw->atom, upgrade_atom);
109 + switch (state) {
110 + /* "NRUD " */
111 + case EQUAL:
112 + printf(" %sR%s ", YELLOW, NORM);
113 + break;
114 + case NOT_EQUAL:
115 + printf("%sN%s ", GREEN, NORM);
116 + break;
117 + case NEWER:
118 + printf(" %sU%s ", BLUE, NORM);
119 + break;
120 + case OLDER:
121 + printf(" %sU%sD%s ", BLUE, DKBLUE, NORM);
122 + break;
123 + }
124 + printf("%s", atom_format(flags->fmt, pkgw->atom));
125 + if (state == NEWER || state == OLDER)
126 + printf(" %s[%s%s%s]%s", DKBLUE, NORM,
127 + atom_format("%[PVR]", upgrade_atom),
128 + DKBLUE, NORM);
129 + if (flags->do_time)
130 + printf(": %s\n", fmt_elapsedtime(flags, elapsed));
131 + else
132 + printf("\n");
133 } else if (flags->do_time) {
134 printf("%s >>> %s: %s\n",
135 fmt_date(flags, pkgw->tbegin, tstart),
136 @@ -675,6 +707,14 @@ static int do_emerge_log(
137 if (atom == NULL)
138 continue;
139
140 + if (p[-20] == ' ' && flags->show_emerge)
141 + {
142 + if (upgrade_atom != NULL)
143 + atom_implode(upgrade_atom);
144 + upgrade_atom = atom;
145 + continue;
146 + }
147 +
148 /* see if we need this atom */
149 atomw = NULL;
150 array_for_each(atoms, i, atomw) {
151 @@ -942,6 +982,7 @@ int qlop_main(int argc, char **argv)
152 m.do_machine = 0;
153 m.do_endtime = 0;
154 m.show_lastmerge = 0;
155 + m.show_emerge = 0;
156 m.fmt = NULL;
157
158 while ((ret = GETOPT_LONG(QLOP, qlop, "")) != -1) {
159 @@ -953,6 +994,12 @@ int qlop_main(int argc, char **argv)
160 case 'u': m.do_unmerge = 1; break;
161 case 'U': m.do_autoclean = 1; break;
162 case 's': m.do_sync = 1; break;
163 + case 'E': m.do_merge = 1;
164 + m.do_unmerge = 1;
165 + m.do_autoclean = 1;
166 + m.show_lastmerge = 1;
167 + m.show_emerge = 1;
168 + verbose = 1; break;
169 case 'r': m.do_running = 1; break;
170 case 'a': m.do_average = 1; break;
171 case 'c': m.do_summary = 1; break;