diff options
| author | 2019-12-27 21:38:44 +0100 | |
|---|---|---|
| committer | 2019-12-27 21:38:44 +0100 | |
| commit | 1e5b2c8d3fb58335990e411af98498f249b54980 (patch) | |
| tree | 6c62184a223b7216719a8faa6cb96cca349ef4a2 | |
| parent | qkeyword: apply profile masks to -S/-T results (diff) | |
| download | portage-utils-1e5b2c8d3fb58335990e411af98498f249b54980.tar.gz portage-utils-1e5b2c8d3fb58335990e411af98498f249b54980.tar.bz2 portage-utils-1e5b2c8d3fb58335990e411af98498f249b54980.zip | |
qlop: some changes to -r (running) mode
- warn when qlop needs to defer to log heuristics (#701968)
- print running packages most recent first
- suppress identical running packages (#701392)
- ignore batches in emerge.log that appear to be backwards in time
Bug: https://bugs.gentoo.org/701968
Bug: https://bugs.gentoo.org/701392
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
| -rw-r--r-- | qlop.c | 50 | ||||
| -rw-r--r-- | tests/qlop/list01.good | 2 | ||||
| -rw-r--r-- | tests/qlop/list10.good | 4 | ||||
| -rw-r--r-- | tests/qlop/sync.log | 12 |
4 files changed, 52 insertions, 16 deletions
@@ -371,6 +371,7 @@ static int do_emerge_log( char *p; char *q; time_t tstart = LONG_MAX; + time_t tlast = tbegin; time_t tstart_emerge = 0; time_t last_merge = 0; time_t sync_start = 0; @@ -531,6 +532,9 @@ static int do_emerge_log( } tstart = atol(buf); + if (tstart < tlast) + continue; + tlast = tstart; if (tstart < tbegin || tstart > tend) continue; @@ -845,6 +849,7 @@ static int do_emerge_log( fclose(fp); if (flags->do_running) { time_t cutofftime; + set *pkgs_seen = create_set(); tstart = time(NULL); @@ -856,7 +861,8 @@ static int do_emerge_log( /* can't report endtime for non-finished operations */ flags->do_endtime = 0; - sync_time /= sync_cnt; + if (sync_time > 0) + sync_time /= sync_cnt; if (sync_start >= cutofftime) { elapsed = tstart - sync_start; if (elapsed >= sync_time) @@ -876,9 +882,10 @@ static int do_emerge_log( fmt_elapsedtime(flags, sync_time - elapsed)); } } - array_for_each(merge_matches, i, pkgw) { + array_for_each_rev(merge_matches, i, pkgw) { time_t maxtime = 0; bool isMax = false; + bool notseen; if (pkgw->tbegin < cutofftime) continue; @@ -886,6 +893,11 @@ static int do_emerge_log( snprintf(afmt, sizeof(afmt), "%s/%s", pkgw->atom->CATEGORY, pkgw->atom->PN); + /* eliminate dups, bug #701392 */ + add_set_unique(afmt, pkgs_seen, ¬seen); + if (!notseen) + continue; + elapsed = tstart - pkgw->tbegin; pkg = get_set(afmt, merge_averages); if (pkg != NULL) { @@ -923,9 +935,11 @@ static int do_emerge_log( maxtime > 0 && verbose ? isMax ? " (longest run)" : " (average run)" : ""); } + clear_set(pkgs_seen); array_for_each(unmerge_matches, i, pkgw) { time_t maxtime = 0; bool isMax = false; + bool notseen; if (pkgw->tbegin < cutofftime) continue; @@ -933,6 +947,11 @@ static int do_emerge_log( snprintf(afmt, sizeof(afmt), "%s/%s", pkgw->atom->CATEGORY, pkgw->atom->PN); + /* eliminate dups, bug #701392 */ + add_set_unique(afmt, pkgs_seen, ¬seen); + if (!notseen) + continue; + elapsed = tstart - pkgw->tbegin; pkg = get_set(afmt, unmerge_averages); if (pkg != NULL) { @@ -959,6 +978,7 @@ static int do_emerge_log( maxtime > 0 && verbose ? isMax ? " (longest run)" : " (average run)" : ""); } + free_set(pkgs_seen); } else if (flags->do_average) { size_t total_merges = 0; size_t total_unmerges = 0; @@ -1135,9 +1155,22 @@ static array_t *probe_proc(array_t *atoms) scandir_free(procs, procslen); } else { /* flag /proc doesn't exist */ + warn("/proc doesn't exist, running merges are based on heuristics"); return NULL; } + if (array_cnt(ret_atoms) == 0) { + /* if we didn't find anything, this is either because nothing is + * running, or because we didn't have appropriate permissions -- + * try to figure out which of the two is it (there is no good + * way) */ + if (geteuid() != 0) { + warn("insufficient privileges for full /proc access, " + "running merges are based on heuristics"); + return NULL; + } + } + if (array_cnt(atoms) > 0) { size_t j; depend_atom *atomr; @@ -1351,12 +1384,15 @@ int qlop_main(int argc, char **argv) } if (m.do_running) { - array_t *new_atoms = probe_proc(atoms); + array_t *new_atoms = NULL; + + if (runningmode > 1) { + warn("running without /proc scanning, heuristics only"); + } else { + new_atoms = probe_proc(atoms); + } - if (runningmode > 1 || new_atoms == NULL) { - warn("/proc not available, deducing running " - "merges from emerge.log"); - } else if (array_cnt(new_atoms) == 0) { + if (new_atoms != NULL && array_cnt(new_atoms) == 0) { /* proc supported, found nothing running */ start_time = LONG_MAX; } diff --git a/tests/qlop/list01.good b/tests/qlop/list01.good index 26899526..c923b2f1 100644 --- a/tests/qlop/list01.good +++ b/tests/qlop/list01.good @@ -1,2 +1,2 @@ -2005-01-27T05:35:03 *** rsync://192.168.0.5/gentoo-portage +2005-05-22T23:21:43 *** rsync://192.168.0.5/gentoo-portage 2015-05-16T08:20:02 *** gentoo diff --git a/tests/qlop/list10.good b/tests/qlop/list10.good index 348992aa..52b4fd35 100644 --- a/tests/qlop/list10.good +++ b/tests/qlop/list10.good @@ -1,3 +1,3 @@ -1568982460 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown -1568996270 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown 1568996308 >>> net-analyzer/wireshark... (99 of 129) ETA: unknown +1568996270 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown +1568982460 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown diff --git a/tests/qlop/sync.log b/tests/qlop/sync.log index 8979b23f..24e10745 100644 --- a/tests/qlop/sync.log +++ b/tests/qlop/sync.log @@ -44,12 +44,12 @@ 1106806630: *** exiting successfully. 1106806630: *** terminating. -1106804103: Started emerge on: Jan 27, 2005 05:35:03 -1106804103: *** emerge sync -1106804103: === sync -1106804103: >>> starting rsync with rsync://192.168.0.5/gentoo-portage -1106804537: === Sync completed with rsync://192.168.0.5/gentoo-portage -1106804538: *** terminating. +1116804103: Started emerge on: Jan 27, 2005 05:35:03 +1116804103: *** emerge sync +1116804103: === sync +1116804103: >>> starting rsync with rsync://192.168.0.5/gentoo-portage +1116804537: === Sync completed with rsync://192.168.0.5/gentoo-portage +1116804538: *** terminating. 1431764402: Started emerge on: May 16, 2015 04:20:01 1431764402: *** emerge --quiet --keep-going --verbose --nospinner --oneshot --quiet-build=n --sync 1431764402: === sync |
