Files
static-musl-builds/scripts/sync_busybox_version.py
T
Hermes Agent 92f2c636be
busybox static musl build / build-and-release (push) Failing after 31s
doggo static musl build / build-and-release (push) Successful in 19s
gdu static musl build / build-and-release (push) Successful in 37s
iperf3 static musl build / build-and-release (push) Successful in 20s
speedtest-go static musl build / build-and-release (push) Successful in 32s
feat: add more static musl tools
2026-05-08 00:04:34 +00:00

55 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
import re
import sys
import urllib.request
from pathlib import Path
DOWNLOADS_URL = "https://busybox.net/downloads/"
VERSION_RE = re.compile(r"busybox-([0-9]+(?:\.[0-9]+)+)\.tar\.bz2")
def version_key(version: str):
return tuple(int(part) for part in version.split("."))
def fetch_latest_version() -> str:
req = urllib.request.Request(
DOWNLOADS_URL,
headers={"User-Agent": "static-musl-builds-updater"},
)
with urllib.request.urlopen(req, timeout=30) as resp:
html = resp.read().decode("utf-8", "replace")
versions = sorted(set(VERSION_RE.findall(html)), key=version_key)
if not versions:
raise RuntimeError("No BusyBox versions found on downloads page")
return versions[-1]
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--version-file", required=True, type=Path)
parser.add_argument("--update-file", action="store_true")
args = parser.parse_args()
latest = fetch_latest_version()
current = args.version_file.read_text(encoding="utf-8").strip() if args.version_file.exists() else ""
print(f"current={current or '<missing>'}")
print(f"latest={latest}")
if current == latest:
print("status=up-to-date")
return 0
print("status=update-available")
if args.update_file:
args.version_file.parent.mkdir(parents=True, exist_ok=True)
args.version_file.write_text(latest + "\n", encoding="utf-8")
print(f"updated_file={args.version_file}")
return 0
if __name__ == "__main__":
sys.exit(main())