From 64b61b2ec26035de23ad822431e63f1c3933f1a2 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 13 Apr 2020 21:49:27 -0700 Subject: [PATCH] dsynth - Add skip count for ignored and other failure conditions * Improve implementation for the skip count in the logs and HTML interfaces. Requested-by: tuxillo --- usr.bin/dsynth/build.c | 107 ++++++++++++++++++++++++-------------- usr.bin/dsynth/dsynth.h | 8 +-- usr.bin/dsynth/html.c | 10 +++- usr.bin/dsynth/runstats.c | 4 +- 4 files changed, 82 insertions(+), 47 deletions(-) diff --git a/usr.bin/dsynth/build.c b/usr.bin/dsynth/build.c index 8064f48f30..008ddd53d8 100644 --- a/usr.bin/dsynth/build.c +++ b/usr.bin/dsynth/build.c @@ -606,7 +606,8 @@ skip_to_flavor: } else { dlog(DLOG_SUCC, "[XXX] %s meta-node complete\n", pkg->portdir); - RunStatsUpdateCompletion(NULL, DLOG_SUCC, pkg, ""); + RunStatsUpdateCompletion(NULL, DLOG_SUCC, pkg, + "", ""); } } } else if (pkg->flags & PKGF_PACKAGED) { @@ -814,6 +815,17 @@ startbuild(pkg_t **build_listp, pkg_t ***build_tailp) */ if (ipkg->flags & PKGF_NOBUILD) { char *reason; + char skipbuf[16]; + int scount; + + scount = buildskipcount_dueto(ipkg, 1); + buildskipcount_dueto(ipkg, 0); + if (scount) { + snprintf(skipbuf, sizeof(skipbuf), " %d", + scount); + } else { + skipbuf[0] = 0; + } ipkg->flags |= PKGF_FAILURE; ipkg->flags &= ~PKGF_BUILDLIST; @@ -821,18 +833,20 @@ startbuild(pkg_t **build_listp, pkg_t ***build_tailp) reason = buildskipreason(NULL, ipkg); if (ipkg->flags & PKGF_NOBUILD_I) { ++BuildIgnoreCount; - dlog(DLOG_IGN, "[XXX] %s ignored due to %s\n", - ipkg->portdir, reason); - RunStatsUpdateCompletion(NULL, DLOG_IGN, - ipkg, reason); + dlog(DLOG_IGN, + "[XXX] %s%s ignored due to %s\n", + ipkg->portdir, skipbuf, reason); + RunStatsUpdateCompletion(NULL, DLOG_IGN, ipkg, + reason, skipbuf); doHook(ipkg, "hook_pkg_ignored", HookPkgIgnored, 0); } else { ++BuildSkipCount; - dlog(DLOG_SKIP, "[XXX] %s skipped due to %s\n", - ipkg->portdir, reason); - RunStatsUpdateCompletion(NULL, DLOG_SKIP, - ipkg, reason); + dlog(DLOG_SKIP, + "[XXX] %s%s skipped due to %s\n", + ipkg->portdir, skipbuf, reason); + RunStatsUpdateCompletion(NULL, DLOG_SKIP, ipkg, + reason, skipbuf); doHook(ipkg, "hook_pkg_skipped", HookPkgSkipped, 0); } @@ -842,6 +856,17 @@ startbuild(pkg_t **build_listp, pkg_t ***build_tailp) } if (pkgi->flags & PKGF_NOBUILD) { char *reason; + char skipbuf[16]; + int scount; + + scount = buildskipcount_dueto(pkgi, 1); + buildskipcount_dueto(pkgi, 0); + if (scount) { + snprintf(skipbuf, sizeof(skipbuf), " %d", + scount); + } else { + skipbuf[0] = 0; + } pkgi->flags |= PKGF_FAILURE; pkgi->flags &= ~PKGF_BUILDLIST; @@ -849,18 +874,19 @@ startbuild(pkg_t **build_listp, pkg_t ***build_tailp) reason = buildskipreason(NULL, pkgi); if (pkgi->flags & PKGF_NOBUILD_I) { ++BuildIgnoreCount; - dlog(DLOG_IGN, "[XXX] %s ignored due to %s\n", - pkgi->portdir, reason); - RunStatsUpdateCompletion(NULL, DLOG_IGN, - pkgi, reason); + dlog(DLOG_IGN, "[XXX] %s%s ignored due to %s\n", + pkgi->portdir, skipbuf, reason); + RunStatsUpdateCompletion(NULL, DLOG_IGN, pkgi, + reason, skipbuf); doHook(pkgi, "hook_pkg_ignored", HookPkgIgnored, 0); } else { ++BuildSkipCount; - dlog(DLOG_SKIP, "[XXX] %s skipped due to %s\n", - pkgi->portdir, reason); - RunStatsUpdateCompletion(NULL, DLOG_SKIP, - pkgi, reason); + dlog(DLOG_SKIP, + "[XXX] %s%s skipped due to %s\n", + pkgi->portdir, skipbuf, reason); + RunStatsUpdateCompletion(NULL, DLOG_SKIP, pkgi, + reason, skipbuf); doHook(pkgi, "hook_pkg_skipped", HookPkgSkipped, 0); } @@ -1035,8 +1061,20 @@ workercomplete(worker_t *work) */ pkg = work->pkg; if (pkg->flags & (PKGF_ERROR|PKGF_NOBUILD)) { + char skipbuf[16]; + int scount; + pkg->flags |= PKGF_FAILURE; + scount = buildskipcount_dueto(pkg, 1); + buildskipcount_dueto(pkg, 0); + if (scount) { + snprintf(skipbuf, sizeof(skipbuf), " %d", + scount); + } else { + skipbuf[0] = 0; + } + /* * This NOBUILD condition XXX can occur if the package is * not allowed to be built. @@ -1047,42 +1085,33 @@ workercomplete(worker_t *work) reason = buildskipreason(NULL, pkg); if (pkg->flags & PKGF_NOBUILD_I) { ++BuildIgnoreCount; - dlog(DLOG_SKIP, "[%03d] IGNORD %s - %s\n", - work->index, pkg->portdir, reason); - RunStatsUpdateCompletion(work, DLOG_SKIP, - pkg, reason); + dlog(DLOG_SKIP, "[%03d] IGNORD %s%s - %s\n", + work->index, pkg->portdir, + skipbuf, reason); + RunStatsUpdateCompletion(work, DLOG_SKIP, pkg, + reason, skipbuf); doHook(pkg, "hook_pkg_ignored", HookPkgIgnored, 0); } else { ++BuildSkipCount; - dlog(DLOG_SKIP, "[%03d] SKIPPD %s - %s\n", - work->index, pkg->portdir, reason); - RunStatsUpdateCompletion(work, DLOG_SKIP, - pkg, reason); + dlog(DLOG_SKIP, "[%03d] SKIPPD %s%s - %s\n", + work->index, pkg->portdir, + skipbuf, reason); + RunStatsUpdateCompletion(work, DLOG_SKIP, pkg, + reason, skipbuf); doHook(pkg, "hook_pkg_skipped", HookPkgSkipped, 0); } free(reason); } else { - char skipbuf[16]; - int scount; - - scount = buildskipcount_dueto(pkg, 1); - buildskipcount_dueto(pkg, 0); - if (scount) { - snprintf(skipbuf, sizeof(skipbuf), " %d", - scount); - } else { - skipbuf[0] = 0; - } - ++BuildFailCount; dlog(DLOG_FAIL | DLOG_RED, "[%03d] FAILURE %s%s ##%16.16s %02d:%02d:%02d\n", work->index, pkg->portdir, skipbuf, getphasestr(work->phase), h, m, s); - RunStatsUpdateCompletion(work, DLOG_FAIL, pkg, skipbuf); + RunStatsUpdateCompletion(work, DLOG_FAIL, pkg, + skipbuf, ""); doHook(pkg, "hook_pkg_failure", HookPkgFailure, 0); } } else { @@ -1091,7 +1120,7 @@ workercomplete(worker_t *work) dlog(DLOG_SUCC | DLOG_GRN, "[%03d] SUCCESS %s ##%02d:%02d:%02d\n", work->index, pkg->portdir, h, m, s); - RunStatsUpdateCompletion(work, DLOG_SUCC, pkg, ""); + RunStatsUpdateCompletion(work, DLOG_SUCC, pkg, "", ""); doHook(pkg, "hook_pkg_success", HookPkgSuccess, 0); } ++BuildCount; diff --git a/usr.bin/dsynth/dsynth.h b/usr.bin/dsynth/dsynth.h index 8e467a90b3..8cab870479 100644 --- a/usr.bin/dsynth/dsynth.h +++ b/usr.bin/dsynth/dsynth.h @@ -475,8 +475,8 @@ typedef struct runstats { void (*update)(worker_t *work, const char *portdir); void (*updateTop)(topinfo_t *info); void (*updateLogs)(void); - void (*updateCompletion)(worker_t *work, int dlogid, - pkg_t *pkg, const char *reason); + void (*updateCompletion)(worker_t *work, int dlogid, pkg_t *pkg, + const char *reason, const char *skipbuf); void (*sync)(void); } runstats_t; @@ -618,8 +618,8 @@ void RunStatsUpdate(worker_t *work, const char *portdir); void RunStatsUpdateTop(int active); void RunStatsUpdateLogs(void); void RunStatsSync(void); -void RunStatsUpdateCompletion(worker_t *work, int logid, - pkg_t *pkg, const char *reason); +void RunStatsUpdateCompletion(worker_t *work, int logid, pkg_t *pkg, + const char *reason, const char *skipbuf); int copyfile(char *src, char *dst); int ipcreadmsg(int fd, wmsg_t *msg); diff --git a/usr.bin/dsynth/html.c b/usr.bin/dsynth/html.c index ea8fafbf57..d84d354649 100644 --- a/usr.bin/dsynth/html.c +++ b/usr.bin/dsynth/html.c @@ -384,7 +384,8 @@ HtmlUpdateLogs(void) } static void -HtmlUpdateCompletion(worker_t *work, int dlogid, pkg_t *pkg, const char *reason) +HtmlUpdateCompletion(worker_t *work, int dlogid, pkg_t *pkg, + const char *reason, const char *skipbuf) { FILE *fp; char *path; @@ -396,6 +397,11 @@ HtmlUpdateCompletion(worker_t *work, int dlogid, pkg_t *pkg, const char *reason) const char *result; char *mreason; + if (skipbuf[0] == 0) + skipbuf = "0"; + else if (skipbuf[0] == ' ') + ++skipbuf; + mreason = NULL; if (work) { t = time(NULL) - work->start_time; @@ -426,7 +432,7 @@ HtmlUpdateCompletion(worker_t *work, int dlogid, pkg_t *pkg, const char *reason) break; case DLOG_IGN: result = "ignored"; - asprintf(&mreason, "%s:|:0", reason); + asprintf(&mreason, "%s:|:%s", reason, skipbuf); reason = mreason; break; case DLOG_SKIP: diff --git a/usr.bin/dsynth/runstats.c b/usr.bin/dsynth/runstats.c index 8b0d676982..a1bd12ef90 100644 --- a/usr.bin/dsynth/runstats.c +++ b/usr.bin/dsynth/runstats.c @@ -192,12 +192,12 @@ RunStatsSync(void) void RunStatsUpdateCompletion(worker_t *work, int logid, pkg_t *pkg, - const char *reason) + const char *reason, const char *skipbuf) { runstats_t *rs; for (rs = RSBase; rs; rs = rs->next) { if (rs->updateCompletion) - rs->updateCompletion(work, logid, pkg, reason); + rs->updateCompletion(work, logid, pkg, reason, skipbuf); } } -- 2.41.0