diff options
Diffstat (limited to 'remote/sbb-remote')
| -rwxr-xr-x | remote/sbb-remote | 14 |
1 files changed, 9 insertions, 5 deletions
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} |
