Fix offline bundle verification

This commit is contained in:
eric
2026-04-09 02:33:32 +00:00
parent 8a1eebcb02
commit 604e7d60f0
2 changed files with 34 additions and 1 deletions

View File

@@ -1 +1 @@
b149cd26
b149cd26

View File

@@ -2,12 +2,15 @@
import hashlib
import json
import shutil
import subprocess
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parent
MANIFEST = ROOT / "offline" / "manifest.json"
BASE_IMAGE = "redroid/redroid:13.0.0-latest"
def digest(path, algorithm):
@@ -18,12 +21,42 @@ def digest(path, algorithm):
return hasher.hexdigest()
def runtime_available(runtime):
return shutil.which(runtime) is not None
def local_base_image_present():
for runtime in ("docker", "podman"):
if not runtime_available(runtime):
continue
result = subprocess.run(
[runtime, "image", "inspect", BASE_IMAGE],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=False,
)
if result.returncode == 0:
return True, runtime
return False, ""
def main():
manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
failures = []
base_image_present, base_runtime = local_base_image_present()
for entry in manifest["artifacts"]:
path = ROOT / entry["relative_path"]
if path.name == "redroid-redroid-13.0.0-latest.tar" and base_image_present:
print("SKIP {} ({} already present locally)".format(entry["relative_path"], BASE_IMAGE))
continue
if not path.is_file():
if path.name == "redroid-redroid-13.0.0-latest.tar":
failures.append(
"{} missing (and {} not found in local {} storage)".format(
entry["relative_path"], BASE_IMAGE, base_runtime or "docker/podman"
)
)
continue
failures.append("{} missing".format(entry["relative_path"]))
continue
if path.stat().st_size != entry["size"]: