''s
This commit is contained in:
28
redroid.py
28
redroid.py
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from stuff.houdini import Houdini
|
||||
@@ -13,6 +14,31 @@ import tools.helper as helper
|
||||
SUPPORTED_ANDROID_VERSIONS = ["13.0.0"]
|
||||
|
||||
|
||||
def ensure_base_image(container_runtime, android_version):
|
||||
base_image = "redroid/redroid:{}-latest".format(android_version)
|
||||
inspect = subprocess.run(
|
||||
[container_runtime, "image", "inspect", base_image],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
check=False,
|
||||
)
|
||||
if inspect.returncode == 0:
|
||||
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(
|
||||
base_image,
|
||||
tar_path,
|
||||
)
|
||||
)
|
||||
|
||||
subprocess.run([container_runtime, "load", "-i", tar_path], check=True)
|
||||
return tar_path
|
||||
|
||||
|
||||
def build_layers(args):
|
||||
dockerfile = "FROM redroid/redroid:{}-latest\n".format(args.android)
|
||||
tags = [args.android]
|
||||
@@ -103,6 +129,7 @@ def main():
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
base_image_source = ensure_base_image(args.container, args.android)
|
||||
dockerfile, tags = build_layers(args)
|
||||
|
||||
print("\nDockerfile\n{}".format(dockerfile))
|
||||
@@ -115,6 +142,7 @@ def main():
|
||||
"Successfully built {}".format(image_name),
|
||||
helper.bcolors.GREEN,
|
||||
)
|
||||
print("Base image source: {}".format(base_image_source))
|
||||
|
||||
if args.houdini:
|
||||
print_recommended_flow(image_name)
|
||||
|
||||
Reference in New Issue
Block a user