Fix offline bundle verification
This commit is contained in:
@@ -1 +1 @@
|
|||||||
b149cd26
|
b149cd26
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
ROOT = Path(__file__).resolve().parent
|
ROOT = Path(__file__).resolve().parent
|
||||||
MANIFEST = ROOT / "offline" / "manifest.json"
|
MANIFEST = ROOT / "offline" / "manifest.json"
|
||||||
|
BASE_IMAGE = "redroid/redroid:13.0.0-latest"
|
||||||
|
|
||||||
|
|
||||||
def digest(path, algorithm):
|
def digest(path, algorithm):
|
||||||
@@ -18,12 +21,42 @@ def digest(path, algorithm):
|
|||||||
return hasher.hexdigest()
|
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():
|
def main():
|
||||||
manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
|
manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
|
||||||
failures = []
|
failures = []
|
||||||
|
base_image_present, base_runtime = local_base_image_present()
|
||||||
for entry in manifest["artifacts"]:
|
for entry in manifest["artifacts"]:
|
||||||
path = ROOT / entry["relative_path"]
|
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 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"]))
|
failures.append("{} missing".format(entry["relative_path"]))
|
||||||
continue
|
continue
|
||||||
if path.stat().st_size != entry["size"]:
|
if path.stat().st_size != entry["size"]:
|
||||||
|
|||||||
Reference in New Issue
Block a user