feat(routers): integrate Banana Pi Client API and onboard LibreSpeed measurements
Discover Ethernet routers under the board, map physical SIM slots, expose vendor controls and real telemetry, and provide packaged VPS speed tests with a live monochrome gauge. Enforce compact typography across Core and Node UI.
This commit is contained in:
@@ -12,7 +12,7 @@ import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BINARY_VERSION = "0.8.53"
|
||||
VERSION = "0.8.53-113"
|
||||
VERSION = "0.8.53-124"
|
||||
sys.path.insert(0, str(ROOT.parents[1] / "scripts/packaging"))
|
||||
from debian import package
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
"""Bounded prepared-Ubuntu package smoke check; never installs or opens hardware."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import uuid
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def qualify(package, expected):
|
||||
assert os.geteuid() != 0
|
||||
release = platform.freedesktop_os_release()
|
||||
assert (release["ID"], release["VERSION_ID"], platform.machine()) == (
|
||||
"ubuntu",
|
||||
"24.04",
|
||||
"x86_64",
|
||||
)
|
||||
raw = package.read_bytes()
|
||||
assert hashlib.sha256(raw).hexdigest() == expected
|
||||
report = dict(
|
||||
schema="missioncore.router-client-api.prepared-host-package-check/v1",
|
||||
session_id=uuid.uuid4().hex,
|
||||
started_at=datetime.now(UTC).isoformat(),
|
||||
monotonic_started=time.monotonic(),
|
||||
clean_image_qualified=False,
|
||||
hardware_access=False,
|
||||
checks=[],
|
||||
)
|
||||
|
||||
def run(name, args, allowed=(0,), **kwargs):
|
||||
result = subprocess.run(args, capture_output=True, timeout=60, **kwargs)
|
||||
assert result.returncode in allowed, name + ": " + result.stderr.decode()[:300]
|
||||
report["checks"].append(dict(id=name, exit_code=result.returncode))
|
||||
return result.stdout
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="router-api-package-", dir=package.parent) as scratch:
|
||||
root = Path(scratch)
|
||||
run("control", ["dpkg-deb", "-e", str(package), str(root / "control")])
|
||||
run("payload", ["dpkg-deb", "-x", str(package), str(root / "payload")])
|
||||
for name in ["postinst", "prerm"]:
|
||||
run("shell-" + name, ["/bin/sh", "-n", str(root / "control" / name)])
|
||||
control = (root / "control/control").read_text()
|
||||
assert "python3-dbus" in control and "bluez (>= 5.72)" in control
|
||||
assert "Version: 0.8.53-124" in control
|
||||
profile_path = root / "payload/usr/share/mission-core-node/router-observation-profile.json"
|
||||
profile = json.loads(profile_path.read_text())
|
||||
assert profile["network_changes"] is False
|
||||
assert any(
|
||||
a["id"] == "dexaflow-client-api/v1" and a["identity"] == "device_ca"
|
||||
for a in profile["adapters"]
|
||||
)
|
||||
report["checks"].append(dict(id="embedded-router-profile", exit_code=0))
|
||||
runtime = root / "payload/usr/lib/mission-core-jk-bms"
|
||||
for path in runtime.rglob("*.py"):
|
||||
compile(path.read_text(), str(path), "exec")
|
||||
run(
|
||||
"python-imports",
|
||||
[
|
||||
"/usr/bin/python3",
|
||||
"-B",
|
||||
"-c",
|
||||
"import runtime.protocol, runtime.service, runtime.bluez, runtime.server; "
|
||||
"from gi.repository import GLib",
|
||||
],
|
||||
cwd=runtime,
|
||||
)
|
||||
help_text = run(
|
||||
"node-executable-help",
|
||||
[str(root / "payload/usr/lib/mission-core-node/node-agent"), "--help"],
|
||||
allowed=(0, 1, 2),
|
||||
)
|
||||
assert len(help_text) < 65536
|
||||
run("apt-simulation", ["apt-get", "--simulate", "--no-remove", "install", str(package)])
|
||||
report.update(
|
||||
state="complete",
|
||||
finished_at=datetime.now(UTC).isoformat(),
|
||||
duration_seconds=time.monotonic() - report["monotonic_started"],
|
||||
package_sha256=expected,
|
||||
)
|
||||
print(json.dumps(report))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("package", type=Path)
|
||||
parser.add_argument("sha256")
|
||||
args = parser.parse_args()
|
||||
qualify(args.package.resolve(), args.sha256)
|
||||
@@ -0,0 +1,101 @@
|
||||
"""Client API router adapter over qualified Node113; preserve OS and other plugins."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[3]
|
||||
NODE = REPO / "apps/node-agent"
|
||||
VERSION = "0.8.53-124"
|
||||
BASE_SHA = "3d7d72a086e46d1058c4115e35c5c532fac37f039602257534348ca885ec9612"
|
||||
sys.path.insert(0, str(REPO / "scripts/packaging"))
|
||||
from debian import package # noqa: E402
|
||||
|
||||
|
||||
def build(binary, output):
|
||||
if output.exists():
|
||||
raise FileExistsError("Published releases are immutable")
|
||||
raw = (NODE / "build/bms-control-113/mission-core-node_0.8.53-113_amd64.deb").read_bytes()
|
||||
if hashlib.sha256(raw).hexdigest() != BASE_SHA:
|
||||
raise ValueError("Qualified baseline changed")
|
||||
stream = io.BytesIO(raw)
|
||||
assert stream.read(8) == b"!<arch>\n"
|
||||
archives = {}
|
||||
while header := stream.read(60):
|
||||
size = int(header[48:58])
|
||||
name = header[:16].decode().strip().rstrip("/")
|
||||
archives[name] = stream.read(size)
|
||||
if size % 2:
|
||||
stream.read(1)
|
||||
|
||||
def members(name):
|
||||
with tarfile.open(fileobj=io.BytesIO(archives[name]), mode="r:gz") as archive:
|
||||
return [(m.name, archive.extractfile(m).read(), m.mode) for m in archive if m.isfile()]
|
||||
|
||||
controls, files = members("control.tar.gz"), members("data.tar.gz")
|
||||
old = {n: d for n, d, _ in files}
|
||||
compiled = binary.read_bytes()
|
||||
assert compiled[:6] == b"\x7fELF\x02\x01" and compiled[18:20] == b"\x3e\x00"
|
||||
source_files = {
|
||||
str(p.relative_to(REPO)): hashlib.sha256(p.read_bytes()).hexdigest()
|
||||
for directory in (
|
||||
NODE / "internal", NODE / "cmd", NODE / "packaging", NODE / "web/dist",
|
||||
REPO / "packages/router-ui/src",
|
||||
)
|
||||
for p in sorted(directory.rglob("*"))
|
||||
if p.is_file() and "__pycache__" not in p.parts
|
||||
}
|
||||
provenance = dict(
|
||||
schema="missioncore.node.packaging-revision/v1",
|
||||
version=VERSION,
|
||||
qualified_base_sha256=BASE_SHA,
|
||||
qualified_base_provenance=json.loads(
|
||||
old["usr/share/doc/mission-core-node/provenance.json"]
|
||||
),
|
||||
scope=("Board-owned routers: physical SIM inventory, instance settings, counter rates, "
|
||||
"typed radio/VPN observation, bounded report/history reads and guarded explicit operations; preserve host networking"),
|
||||
binary_sha256=hashlib.sha256(compiled).hexdigest(),
|
||||
source_files=source_files,
|
||||
)
|
||||
changes = {
|
||||
"usr/lib/mission-core-node/node-agent": compiled,
|
||||
"usr/share/doc/mission-core-node/provenance.json": (
|
||||
json.dumps(provenance, indent=2) + "\n"
|
||||
).encode(),
|
||||
}
|
||||
profile = "usr/share/mission-core-node/router-observation-profile.json"
|
||||
assert profile in old
|
||||
changes[profile] = (NODE / "internal/routers/profile.json").read_bytes()
|
||||
replaced = []
|
||||
for name, data, mode in controls:
|
||||
if name == "control":
|
||||
assert b"Version: 0.8.53-113\n" in data
|
||||
data = data.replace(b"Version: 0.8.53-113\n", f"Version: {VERSION}\n".encode())
|
||||
replaced.append((name, data, mode))
|
||||
payload = [(n, changes.get(n, d), m) for n, d, m in files]
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_bytes(package(replaced, payload))
|
||||
report = dict(
|
||||
version=VERSION,
|
||||
base_sha256=BASE_SHA,
|
||||
sha256=hashlib.sha256(output.read_bytes()).hexdigest(),
|
||||
bytes=output.stat().st_size,
|
||||
changed_controls=["control"],
|
||||
changed_payloads=list(changes),
|
||||
added_payloads=[],
|
||||
retained_payload_count=len(files) - len(changes),
|
||||
)
|
||||
output.with_suffix(".json").write_text(json.dumps(report, indent=2) + "\n")
|
||||
print(json.dumps(report))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--binary", type=Path, required=True)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
build(args.binary, args.output)
|
||||
Reference in New Issue
Block a user