From patchwork Thu Dec 3 15:58:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 107218 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.17063.1796313527011006180 for ; Thu, 03 Dec 2026 07:58:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=ME1OGbQ3; spf=pass (domain: gmail.com, ip: 209.85.221.46, mailfrom: alex.kanavin@gmail.com) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-491971ac844so2183f8f.2 for ; Thu, 03 Dec 2026 07:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796313525; x=1796918325; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=PNxF/1BbQ4e40vwaf3MkjGjj83DI0PgVwqdAbkaJrnY=; b=ME1OGbQ35qSyXICV082Tf21dvR5lvW4JQQoy/Y9gPAzzwYabDUKc2MbqgN9TxtxiRl a+Fmz2c7yb7Y3S9NGq8wVmScR8UG33gUEGcWqRL0fSrCcfGaBJbRP1lf6ZAUC1682MHp bLp/8s3RXRolo+ObvZmn73dpxs55sK346y2E9ZcMRtGfgzclZwFyo6ROFGLWLWfVmsOt Y6OzW2meVF9vt+wPPqW5PqjmFxYUAWnB+ndW/xf/s2N9nS1Piru51fo71R2iaiyaqOLz bhSKg2y0q7Z1zGejBLmK4t3xOSKfo76kwv2DJb3/XaSKjfBCsctd1CUnsSSYX1FY2T7t 0mTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796313525; x=1796918325; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PNxF/1BbQ4e40vwaf3MkjGjj83DI0PgVwqdAbkaJrnY=; b=LEIBr2Yz/L0jo6Rp2e0b5eQJjztn79gEbNQgM2EZsZ6GxtYHMSxLpr8DucKKTc2+ZW rk7PZgjBH2Eor//VTuunCL1NSEum7KWqCJGjrGaXJIdWKcepns2Qq+JX5MdYBQIu+Xxb ts1feNar2UAOwHX95x9CRTRR17SbEUjiVfVUtWZbRE2h/xFHeEYBWGMF9wuiP2zXiLK+ yuOfDYbF7xWCbNIHxgE/q43LYT2hOTToH3E4Quxp6ju+XAQ7qEbJf/tFNL4lAHqwsKwd ziJp9Mkm15wRYZEd/2ryhYW450wyzokbhFG7tSaooooc10qxtEVNvCV0CW7e0ksFpqkk zN8w== X-Gm-Message-State: APuU4Z/T0UVgC1m+B8g6ULjilYgHMXIw5kZxq6w0u8WzTV/h1XgDpqW2 4tMwM3uCKPPgg5cxVdorY5jeJwSJ2TNPi+piDnVRtNORwTkhelXXPtfijMapbA== X-Gm-Gg: AZFdTZcyiIvLg7ZQjwuYUMhTy+Zdu+8zCQypIN0OR4OEoMqNhK3BINSxLbb6D7onUSU Nyr6jh6H4xLnvy2FTiv4Wq9ANjePo2N0LBLE7vl/65/wVcJDjYMXel+0Qgjqjvyop/bCcHLAduz 4uJX0kMOGm39MtbSDgwQgZodzbpIe7E6dDGpWB7OZ+Bqw5iyirQkUOott4pWR+wCQrLmF/HjSam vnFYhw7NgNY/FS1OKX3CMfflcyxTjDVaNLJwW9MILeFBFnwTFzZDbWIcS2+tNTjFTvQp8PsrGyV ZJ53U8kBhOMX0YObaIFKtmUzVFsndejz4O9AZzj7sm1/medwmIqGbllf10UAcMd2mC7uiQ2G81l BT+yo9bT2AI4o4QuEjAylcrwiBAi2qYnkNF6BG8+2/AvRSwHNqo/ekPdSW8oE0/rpJ0TkghRKI9 QUwxFxAKbdeIWrGXk5WM+nqAUnvHk/El02WjcT0l1icGkXSJwRoTPisKRp9/FG6VJbS1YEzCXtg ottw5/ElOZ1qwJJqH8ufLeXZj6OblFxWeybDbUIgAnFsExCQnNjjX+t5LFbI3sVhTmq63JCwi9a ADxcdf5CWQts5CpRPeQPVDAy+1ERU+sWRuz6jyyfNswOJChFXN6nfdqKRpq2vzhAjDq0mCObECY uigsUdCMgWoo= X-Received: by 2002:a05:6000:2507:b0:4b7:66fb:b092 with SMTP id ffacd0b85a97d-4b766fbb479mr66860195f8f.48.1796313525037; Thu, 03 Dec 2026 07:58:45 -0800 (PST) Return-Path: Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6ae2dd55sm82333075f8f.30.2026.12.03.07.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 07:58:44 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: yocto-patches@lists.yoctoproject.org Cc: daniel.turull@ericsson.com, Alexander Kanavin Subject: [auh][PATCH 1/2] modules/state: rework state to include both original and updated version Date: Thu, 3 Dec 2026 16:58:29 +0100 Message-ID: <20261203155830.3136352-1-alex@linutronix.de> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 03 Dec 2026 15:58:56 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5661 The state information in incremental mode did not keep the original versions that recipse were updated from, only the new versions. This is problematic when upstreams release new versions in quick succession: if a layer updates a recipe to an intermediate version after AUH produced an update from the original version to latest version, AUH will not re-roll the update from an intermediate to latest because it doesn't track the original versions, and the update will only be retried after a retry period (typically 30 days) expires. Additionally, it would be useful to know when the original version, or the latest version was first seen by AUH; if either period grows too much, that means the AUH upgrade attempts are being ignored, the recipe isn't being updated, and the situation needs to be looked at. The patch reworks the state format from being a dict of recipes containing a dict of (latest) versions to a flat dict of recipes that contains the original version, the new version, when either was first seen, and when an AUH did the update. The rest of the code is adapted to that; it's difficult to test all the corner cases, but I confirmed that at least the update and the skipping after work as they should. Note that AUH will not try to migrate the v1 state to v2 state. It will simply detect that the state is not usable, and re-run the full update cycle to repopulate state. Signed-off-by: Alexander Kanavin --- modules/state.py | 81 +++++++++++++++++++++++------------------------ upgrade-helper.py | 9 +++--- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/modules/state.py b/modules/state.py index d70972b..1a99760 100644 --- a/modules/state.py +++ b/modules/state.py @@ -32,7 +32,7 @@ RESULT_SUCCESS = "success" RESULT_FAILURE = "failure" STATE_FILENAME = "auh-state.json" -STATE_VERSION = 1 +STATE_VERSION = 2 SECONDS_PER_DAY = 86400 DEFAULT_RETRY_SAME_VERSION_DAYS = 30 @@ -41,7 +41,7 @@ DEFAULT_SUCCESS_MAX_AGE_DAYS = 30 class State: - """Tracks upgrade attempts as {recipe: {version: {timestamp, result}}}.""" + """Tracks upgrade attempts as {recipe: {old_version, new_version, timestamp, result}}.""" def __init__(self, state_dir, retry_same_version_days=DEFAULT_RETRY_SAME_VERSION_DAYS, @@ -53,10 +53,8 @@ class State: self.success_max_age = success_max_age_days * SECONDS_PER_DAY self.retry_any_version = retry_any_version_days * SECONDS_PER_DAY self.any_version_recipes = set(retry_any_version_recipes or []) - self.data = self._load() - self._prune() - def _load(self): + def _load_state_file(self): if os.path.exists(self.path): try: with open(self.path) as f: @@ -71,43 +69,60 @@ class State: return raw.get("recipes", {}) return {} + def load_state(self, pkggroups): + """ Loads existing state, and trims it to contain only the packages in need of update (passed in via pkggroups argument). """ + self.data = {} + existing_state = self._load_state_file() + for g in pkggroups: + for p in g['pkgs']: + pn = p['PN'] + if pn in existing_state: + self.data[pn] = existing_state[pn] + def save(self): with open(self.path, "w") as f: json.dump({"version": STATE_VERSION, "recipes": self.data}, f, indent=2) - def record(self, pn, version, result): - entry = {"timestamp": time.time(), "result": result} - if pn not in self.data: - self.data[pn] = {} - self.data[pn][version] = entry - - def should_skip(self, pn, version): - """Return True if this recipe/version should not be attempted.""" - return self.check(pn, version)['skip'] - - def skip_reason(self, pn, version): - """Return a human-readable string explaining why pn/version is being skipped.""" - return self.check(pn, version)['reason'] - - def check(self, pn, version): + def record(self, pn, old_version, new_version, result): + current_time = time.time() + oldversion_firstseen = current_time + newversion_firstseen = current_time + + if pn in self.data: + if self.data[pn]['oldversion'] == old_version: + oldversion_firstseen = self.data[pn]['oldversion_firstseen'] + if self.data[pn]['newversion'] == new_version: + newversion_firstseen = self.data[pn]['newversion_firstseen'] + + self.data[pn] = {"timestamp": current_time, + "result": result, + "oldversion": old_version, + "oldversion_firstseen": oldversion_firstseen, + "newversion": new_version, + "newversion_firstseen": newversion_firstseen, + } + + def check(self, pn, old_version, new_version): """Return {'skip': bool, 'reason': str} for a recipe/version pair. For any_version_recipes, any recent attempt (any version) causes a skip. For normal recipes, only a matching version entry causes a skip. """ + + entry = self.data.get(pn, {}) + + if not entry: + return {'skip': False, 'reason': ''} + if pn in self.any_version_recipes: - entry = self._newest_entry(pn) max_age = self.retry_any_version else: - entry = self.data.get(pn, {}).get(version) - if entry is None: - return {'skip': False, 'reason': ''} max_age = self.success_max_age \ if entry.get("result") == RESULT_SUCCESS \ else self.retry_same_version - if not entry: + if pn not in self.any_version_recipes and (entry['oldversion'] != old_version or entry['newversion'] != new_version): return {'skip': False, 'reason': ''} ts = entry.get("timestamp", 0) @@ -122,19 +137,3 @@ class State: return {'skip': True, 'reason': "%slast attempt %s result=%s; will retry in %d day(s)" % (prefix, when, result, retry_in)} - - def _newest_entry(self, pn): - """Return the most recent entry for a recipe across all versions.""" - versions = self.data.get(pn, {}) - return max(versions.values(), key=lambda e: e.get("timestamp", 0), - default={}) - - def _prune(self): - """Remove entries that check() would no longer skip.""" - for pn in list(self.data): - versions = self.data[pn] - for ver in list(versions): - if not self.check(pn, ver)['skip']: - del versions[ver] - if not versions: - del self.data[pn] diff --git a/upgrade-helper.py b/upgrade-helper.py index 56b1f02..4e9249e 100755 --- a/upgrade-helper.py +++ b/upgrade-helper.py @@ -496,12 +496,13 @@ class Updater(object): pkggroups_ctx.append({"name":",".join([pkg_ctx['PN'] for pkg_ctx in pkgs_ctx]),"pkgs":pkgs_ctx,"error":None, 'base_dir':self.uh_recipes_all_dir}) I(" ############################################################") if self.state: + self.state.load_state(pkggroups_ctx) kept = [] for g in pkggroups_ctx: - pn, npv = g['pkgs'][0]['PN'], g['pkgs'][0]['NPV'] - r = self.state.check(pn, npv) + pn, opv, npv = g['pkgs'][0]['PN'], g['pkgs'][0]['PV'], g['pkgs'][0]['NPV'] + r = self.state.check(pn, opv, npv) if r['skip']: - I(" %s %s: skipping (%s)" % (pn, npv, r['reason'])) + I(" %s %s -> %s: skipping (%s)" % (pn, opv, npv, r['reason'])) self.statistics.skip(g, r['reason']) else: kept.append(g) @@ -579,7 +580,7 @@ class Updater(object): # upgrades them atomically; individual outcomes are not tracked. for pkg_ctx in g['pkgs']: I(" %s %s: recording result=%s" % (pkg_ctx['PN'], pkg_ctx['NPV'], result)) - self.state.record(pkg_ctx['PN'], pkg_ctx['NPV'], result) + self.state.record(pkg_ctx['PN'], pkg_ctx['PV'], pkg_ctx['NPV'], result) if self.state: self.state.save() From patchwork Thu Dec 3 15:58:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kanavin X-Patchwork-Id: 107219 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.17313.1796313527416805644 for ; Thu, 03 Dec 2026 07:58:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20260707 header.b=0B9Y5xyQ; spf=pass (domain: gmail.com, ip: 209.85.221.47, mailfrom: alex.kanavin@gmail.com) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4a357b1c649so301f8f.3 for ; Thu, 03 Dec 2026 07:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796313526; x=1796918326; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=qVqvDrFkV71ddnvUOBLiitFXp2dgaCTe5A9HayVIO6k=; b=0B9Y5xyQwog7WyVnH4xWwMhUKMnMH5DhGg6Km803XObf9XCF8t78Li+ZsXPOWg+QvW bhZgYrzE+1CaGV97gyqFGXhfLG9EsXB6vcEDWr4i7W9foIGUJhLiiz35ajtUI2l+MaFZ yf8O243xNuVQuXfvQyjEWmepbxJNI40s+q3USSOh2cFScOboPYoo9gm8G0B/deHZZpml gN5ok5u8Z00DtYTiDL7CHnwtp0ki33KzLWWoT2VqiOG1dPdA+IfyFiMNBGcxLr4J7O2q yljbXhdetka8d0/BkOEnGpH8ExtxbNnHARy7mST7ZJe8tcXbLRltzPI8pZ+adLLayUWl JBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796313526; x=1796918326; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=qVqvDrFkV71ddnvUOBLiitFXp2dgaCTe5A9HayVIO6k=; b=BAfmQ+RhFkMkrUas++zUJCZqa069TZfa6Lm2IHq7k96OfKqem5Zpb4lMk79QOf8LLg J5RoDD3kSWbes1hKKfaUczVYgzMQGbAOHtynKk6ViJrpfEXXumq3q6S8SM/ZbcKo9noq RGeynfVURkZMSbKESx3J0LYSvg3N6a5uemAFeQkeDcs/cy5ToYTr4OwnFrndqf+IpfHH NQFw6wJM3kFbdpzDehReXN+J66arCfbmFQq2fvimWj8MdAk15HeTvfRmgmx004utC4EU qQQ5qXocBg022NZpMlIqeyqIUOFQEeH4T4O8I7L3gR9YTojxXnplx8dZ9UsyNYj7FGZg hZ1g== X-Gm-Message-State: APuU4Z/h1z7j5p3IKsV+ju3aKZkAINGNZtsZoZIjcUHpI76/zFjPlAqJ a698C7DYqX6WWyrooXyaro0ItYNH48Sr6R9oXct21COy4CvRZLE1IaoWUVXWVg== X-Gm-Gg: AZFdTZf0SIr+FbN17+sBq7Hmr5lUOJtg5GKPH8oXNhAhlnsY6kxMkZ3hYgjuNEAkPUw ErFqUB/V04mU8zFotYEIUkvr182lWJCmjA/mvhUWl3hnCfEdLsCyev6SnYRRTDy5UeUaEhBPrAl mrlLlk1vPLn0yXxyybZLpBfycKgPKMu2kmU9MntqsTS9WZHJO+jl4CP3BdRb1bDnIS+CPcjb3zO kwDWEWTXgrQT+kI3BKGdrDlbnKFWPs58gNHlcCrJGA+zNJ26WMHXxnuT3xLYiU2zNCNT857ZgXE Q733EQftNFBgfmZw/MqWAgDk+UxiG/+GOTGIWl3qQE71Cg8Pc1UCvvbzZvKvS14bzJwT5ykOwCe Y1mRme0S7gDsykPdy+Jud9YeBRBVVzCGLY7dGD5feovZmiuz+BISFQndgMBeGnhXy6IQ9AjBGB1 0rzk9iRTzGCyLiezNSR9f1ZWViWY8xmNwCN0p0O71IvqfJSWr/FowEiqEmeZuVvBEAZ2G5xLxfW dGh8NlUIRyrEHDLqGoH2KeUHxnHfURHWXz8Xm6cYdk6PBw266/ik8q1q9y5Gl9Yyq6FOcmKMcEr Y3BbiyYV95+1wOkFfnLzQfi+gzWvzyHdLe0r3yaJ1UTW7jAOUtY+5e23EpkvrQJNzCtaKGE9s0G 4RLGDYNCXjjE= X-Received: by 2002:a05:6000:2512:b0:4b7:75cf:37fc with SMTP id ffacd0b85a97d-4b775cf386amr58214131f8f.52.1796313525812; Thu, 03 Dec 2026 07:58:45 -0800 (PST) Return-Path: Received: from Zen2.lab.linutronix.de. (drugstore.linutronix.de. [80.153.143.164]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6ae2dd55sm82333075f8f.30.2026.12.03.07.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 07:58:45 -0800 (PST) From: Alexander Kanavin X-Google-Original-From: Alexander Kanavin To: yocto-patches@lists.yoctoproject.org Cc: daniel.turull@ericsson.com, Alexander Kanavin Subject: [auh][PATCH 2/2] modules/statistics.py: rework and include first-seen statistics in status reports Date: Thu, 3 Dec 2026 16:58:30 +0100 Message-ID: <20261203155830.3136352-2-alex@linutronix.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203155830.3136352-1-alex@linutronix.de> References: <20261203155830.3136352-1-alex@linutronix.de> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Thu, 03 Dec 2026 15:58:57 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5662 This module's code quality wasn't great (non-pythonic code, excessive amout of unneeded class data, producing a not particularly useful per-maintainer report), so I took the opportunity to clean it all up. The status reports now includes information about how long ago the current and new versions were first seen. This helps identify recipes which are falling behind upstream development: if either the current or new version was first seen many days ago, then updating that recipe should be prioritized: INFO: Recipe upgrade statistics: * Succeeded: 1 gpgme, 2.2.0 (first seen 117 day(s) ago) -> 2.3.1 (first seen 117 day(s) ago), Unassigned Signed-off-by: Alexander Kanavin --- modules/state.py | 14 ++++++ modules/statistics.py | 107 +++++++++++++++++++----------------------- upgrade-helper.py | 2 +- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/modules/state.py b/modules/state.py index 1a99760..6d67118 100644 --- a/modules/state.py +++ b/modules/state.py @@ -137,3 +137,17 @@ class State: return {'skip': True, 'reason': "%slast attempt %s result=%s; will retry in %d day(s)" % (prefix, when, result, retry_in)} + + def get_oldver_firstseen_days(self, pkg, ver): + if self.data[pkg]['oldversion'] == ver: + firstseen = time.time() - self.data[pkg]['oldversion_firstseen'] + else: + firstseen = 0 + return int(firstseen / SECONDS_PER_DAY) + + def get_newver_firstseen_days(self, pkg, ver): + if self.data[pkg]['newversion'] == ver: + firstseen = time.time() - self.data[pkg]['newversion_firstseen'] + else: + firstseen = 0 + return int(firstseen / SECONDS_PER_DAY) diff --git a/modules/statistics.py b/modules/statistics.py index 5126a39..0cc7ab8 100644 --- a/modules/statistics.py +++ b/modules/statistics.py @@ -25,16 +25,10 @@ class Statistics(object): def __init__(self): - self.succeeded = dict() - self.failed = dict() - self.succeeded["total"] = 0 - self.failed["total"] = 0 self.upgrade_stats = dict() - self.maintainers = set() - self.total_attempted = 0 self.skipped = [] - def _update(self, pn, new_ver, maintainer, error): + def _update(self, p, error): if error is None: status = "Succeeded" else: @@ -43,85 +37,82 @@ class Statistics(object): if not status in self.upgrade_stats: self.upgrade_stats[status] = [] - self.upgrade_stats[status].append((pn, new_ver, maintainer)) - - # add maintainer to the set of unique maintainers - self.maintainers.add(maintainer) - - if not maintainer in self.succeeded: - self.succeeded[maintainer] = 0 - if not maintainer in self.failed: - self.failed[maintainer] = 0 - - if status == "Succeeded": - self.succeeded["total"] += 1 - self.succeeded[maintainer] += 1 - else: - self.failed["total"] += 1 - self.failed[maintainer] += 1 - - self.total_attempted += 1 + self.upgrade_stats[status].append(p) def update(self, group): for p in group['pkgs']: - self._update(p['PN'],p['NPV'],p['MAINTAINER'],group['error']) + self._update(p,group['error']) def skip(self, group, reason): for p in group['pkgs']: - self.skipped.append((p['PN'],p['NPV'],p['MAINTAINER'],reason)) + self.skipped.append((p,reason)) - def _pkg_stats(self): + def _pkg_stats(self, state): stat_msg = "Recipe upgrade statistics:\n\n" for status in self.upgrade_stats: list_len = len(self.upgrade_stats[status]) if list_len > 0: - stat_msg += " * " + status + ": " + str(list_len) + "\n" + stat_msg += " * {}: {}\n".format(status, str(list_len)) - for pkg, new_ver, maintainer in self.upgrade_stats[status]: - stat_msg += " " + pkg + ", " + new_ver - if maintainer: - stat_msg += ", " + maintainer - stat_msg += "\n" + for p in self.upgrade_stats[status]: + pkg = p['PN'] + old_ver = p['PV'] + old_ver_firstseen = state.get_oldver_firstseen_days(pkg, old_ver) + new_ver = p['NPV'] + new_ver_firstseen = state.get_newver_firstseen_days(pkg, new_ver) + maintainer = p['MAINTAINER'] + stat_msg += " {}, {} (first seen {} day(s) ago) -> {} (first seen {} day(s) ago), {}\n".format(pkg, old_ver, old_ver_firstseen, new_ver, new_ver_firstseen,maintainer) if self.skipped: stat_msg += " * Skipped: {}\n".format(len(self.skipped)) - for (pkg, new_ver, maintainer, reason) in self.skipped: - stat_msg += " {}, {}, {}, {}\n".format(pkg, new_ver, reason, maintainer) - if self.total_attempted == 0: - percent_succeded = 0 + skipped_with_firstseen = [{'p':p, 'reason':reason, + 'oldver_firstseen':state.get_oldver_firstseen_days(p['PN'], p['PV']), + 'newver_firstseen':state.get_newver_firstseen_days(p['PN'], p['NPV'])} + for (p, reason) in self.skipped] + skipped_with_firstseen.sort(key=lambda item: item['oldver_firstseen'] if item['oldver_firstseen'] > item['newver_firstseen'] else item['newver_firstseen'], reverse=True) + + for s in skipped_with_firstseen: + p = s['p'] + old_ver_firstseen = s['oldver_firstseen'] + new_ver_firstseen = s['newver_firstseen'] + pkg = p['PN'] + old_ver = p['PV'] + new_ver = p['NPV'] + maintainer = p['MAINTAINER'] + stat_msg += " {}, {} (first seen {} day(s) ago) -> {} (first seen {} day(s) ago), {}, {}\n".format(pkg, old_ver, old_ver_firstseen, new_ver, new_ver_firstseen, s['reason'], maintainer) + + attempted = 0 + succeeded = 0 + failed = 0 + for k,v in self.upgrade_stats.items(): + attempted = attempted + len(v) + if k == 'Succeeded': + succeeded = len(v) + else: + failed = failed + len(v) + + if attempted == 0: + percent_succeeded = 0 percent_failed = 0 else: - percent_succeded = self.succeeded["total"] * 100.0 / self.total_attempted - percent_failed = self.failed["total"] * 100.0 / self.total_attempted + percent_succeeded = succeeded * 100.0 / attempted + percent_failed = failed * 100.0 / attempted stat_msg += "\n TOTAL: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n\n" % \ - (self.total_attempted, self.succeeded["total"], - percent_succeded, - self.failed["total"], + (attempted, succeeded, + percent_succeeded, + failed, percent_failed) return stat_msg - def _maintainer_stats(self): - stat_msg = "Recipe upgrade statistics per Maintainer:\n\n" - for m in self.maintainers: - attempted = self.succeeded[m] + self.failed[m] - stat_msg += " %s: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n" % \ - (m.split("@")[0] if m else "Maintainerless", attempted, self.succeeded[m], - self.succeeded[m] * 100.0 / attempted, - self.failed[m], - self.failed[m] * 100.0 / attempted) - - return stat_msg - - def get_summary(self, publish_work_url, workdir): + def get_summary(self, publish_work_url, workdir, state): msg = '' if publish_work_url: msg += "AUH finished upgrade batch the result patches/logs can be found at:\n" \ "%s/%s, next are the statistics:\n\n" % (publish_work_url, workdir) - msg += self._pkg_stats() - msg += self._maintainer_stats() + msg += self._pkg_stats(state) return msg diff --git a/upgrade-helper.py b/upgrade-helper.py index 4e9249e..d85941e 100755 --- a/upgrade-helper.py +++ b/upgrade-helper.py @@ -623,7 +623,7 @@ class Updater(object): attach_tarball = False statistics_summary = self.statistics.get_summary( - publish_work_url, os.path.basename(self.uh_work_dir)) + publish_work_url, os.path.basename(self.uh_work_dir), self.state) statistics_file = os.path.join(self.uh_work_dir, "statistics_summary")