From fc02ae2b562a3c608b41302d84d69b29415b927c Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 19 Oct 2026 21:36:15 +0200 Subject: build-log: show the last attempt's log, not always build.log slackrepo writes one log per command (build, rebuild, update, remove). A failed update left build.log from an older successful build, so the viewer showed a success next to a failed result. The helper (0.4.1) now returns the newest command log and its name, which the viewer shows in the title and header. Co-Authored-By: Claude Opus 5.5 --- remote/sbb-remote | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'remote') diff --git a/remote/sbb-remote b/remote/sbb-remote index a3b83a6..25427c0 100755 --- a/remote/sbb-remote +++ b/remote/sbb-remote @@ -38,7 +38,7 @@ import tempfile import time import tomllib -VERSION = "0.4.0" +VERSION = "0.4.1" DEFAULTS = { "state_dir": "/var/lib/sb-builder", "repo_dir": "/var/lib/sbopkg/SBo-danix", @@ -59,7 +59,8 @@ PKGNAME = re.compile(r"^[A-Za-z0-9._+-]+$") ACTIONS = ("build", "rebuild", "update", "remove") PRESET = "/usr/libexec/gpg-preset-passphrase" ITEM = re.compile(r"^[A-Za-z0-9._+-]+/[A-Za-z0-9._+-]+$") # category/pkg -LOG_TAIL = 512 * 1024 # bytes of build.log returned; the failure is at the end +LOG_TAIL = 512 * 1024 # bytes of the log returned; the failure is at the end +COMMAND_LOGS = ("build.log", "rebuild.log", "update.log", "remove.log") # one per slackrepo command ACTIVE = ("starting", "running") START_GRACE = 10 # seconds a job may sit in "starting" before it counts as lost @@ -510,12 +511,15 @@ def cmd_build_log(cfg, item=None): if not ITEM.match(item or "") or ".." in item: raise Error(f"bad package path: {item}") d = os.path.join(cfg["slackrepo_logdir"], item) - build = os.path.join(d, "build.log") - if not os.path.isfile(build): + # the last attempt's log is the newest command log, not necessarily build.log + logs = [os.path.join(d, n) for n in COMMAND_LOGS if os.path.isfile(os.path.join(d, n))] + if not logs: raise Error(f"no build log for {item}") + build = max(logs, key=os.path.getmtime) text, truncated = _tail(build, LOG_TAIL) resource = os.path.join(d, "resource.log") - return {"build": text, "truncated": truncated, "mtime": int(os.path.getmtime(build)), + return {"name": os.path.basename(build), "build": text, "truncated": truncated, + "mtime": int(os.path.getmtime(build)), "resource": _tail(resource, LOG_TAIL)[0] if os.path.isfile(resource) else None} -- cgit v1.2.3