This commit is contained in:
eric
2026-04-04 00:21:41 -05:00
parent 415fdd3238
commit 0712fcdb84
6 changed files with 158 additions and 69 deletions

View File

@@ -22,19 +22,37 @@ def ensure_base_image(container_runtime, android_version):
stderr=subprocess.DEVNULL,
check=False,
)
if inspect.returncode == 0:
local_present = inspect.returncode == 0
helper.print_color(
"Trying to pull base image {} first ...".format(base_image),
helper.bcolors.GREEN,
)
pull = subprocess.run([container_runtime, "pull", base_image], check=False)
if pull.returncode == 0:
return "pulled"
if local_present:
helper.print_color(
"Online pull failed, falling back to local image cache ...",
helper.bcolors.YELLOW,
)
return "present"
tar_name = "redroid-redroid-{}-latest.tar".format(android_version)
tar_path = os.path.join(helper.get_image_dir(), tar_name)
if not os.path.isfile(tar_path):
raise FileNotFoundError(
"Base image {} is missing and offline archive {} was not found".format(
"Online pull for {} failed, local image cache is missing, and offline archive {} was not found".format(
base_image,
tar_path,
)
)
helper.print_color(
"Online pull failed, loading local image archive {} ...".format(tar_path),
helper.bcolors.YELLOW,
)
subprocess.run([container_runtime, "load", "-i", tar_path], check=True)
return tar_path