From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 921DC138334 for ; Fri, 27 Dec 2019 20:42:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AEB30E0B83; Fri, 27 Dec 2019 20:42:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 827F6E0B83 for ; Fri, 27 Dec 2019 20:42:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F1EAB34DC2D for ; Fri, 27 Dec 2019 20:42:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E2BB034 for ; Fri, 27 Dec 2019 20:42:34 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1577479124.1e5b2c8d3fb58335990e411af98498f249b54980.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: tests/qlop/, / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c tests/qlop/list01.good tests/qlop/list10.good tests/qlop/sync.log X-VCS-Directories: / tests/qlop/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 1e5b2c8d3fb58335990e411af98498f249b54980 X-VCS-Branch: master Date: Fri, 27 Dec 2019 20:42:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b418f47a-9207-4cb8-85ec-62c733b862da X-Archives-Hash: 52be857f923b18ad70eb352f45d50705 commit: 1e5b2c8d3fb58335990e411af98498f249b54980 Author: Fabian Groffen gentoo org> AuthorDate: Fri Dec 27 20:38:44 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Dec 27 20:38:44 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1e5b2c8d 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 gentoo.org> qlop.c | 50 +++++++++++++++++++++++++++++++++++++++++++------- tests/qlop/list01.good | 2 +- tests/qlop/list10.good | 4 ++-- tests/qlop/sync.log | 12 ++++++------ 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/qlop.c b/qlop.c index 7cc8f44..634431a 100644 --- a/qlop.c +++ b/qlop.c @@ -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 2689952..c923b2f 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 348992a..52b4fd3 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 8979b23..24e1074 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