]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Add support for preinstalled images
authorErfan Abdi <erfangplus@gmail.com>
Tue, 31 Aug 2021 08:35:19 +0000 (13:05 +0430)
committerErfan Abdi <erfangplus@gmail.com>
Tue, 31 Aug 2021 08:35:19 +0000 (13:05 +0430)
* on “/usr/share/waydroid-extra/images”

tools/actions/initializer.py
tools/actions/upgrader.py
tools/config/__init__.py
tools/helpers/arguments.py

index c5783a459a125c9cb3f68c0d7c3dd7ccda846573..2173b459dd19a5223d8355e1f6d569b48b72f7b4 100644 (file)
@@ -21,6 +21,16 @@ def setup_config(args):
     cfg = tools.config.load(args)
     args.arch = helpers.arch.host()
     cfg["waydroid"]["arch"] = args.arch
+
+    preinstalled_images = tools.config.defaults["preinstalled_images_path"]
+    if not args.images_path:
+        if os.path.isdir(preinstalled_images):
+            if os.path.isfile(preinstalled_images + "/system.img") and os.path.isfile(preinstalled_images + "/vendor.img"):
+                args.images_path = preinstalled_images
+            else:
+                logging.error("Missing system or vendor on preinstalled images dir, fallback to default")
+    if not args.images_path:
+        args.images_path = tools.config.defaults["images_path"]
     cfg["waydroid"]["images_path"] = args.images_path
 
     channels_cfg = tools.config.load_channels()
@@ -37,8 +47,11 @@ def setup_config(args):
         "/waydroid_" + args.arch + "/" + args.system_type + ".json"
     system_request = requests.get(args.system_ota)
     if system_request.status_code != 200:
-        raise ValueError(
-            "Failed to get system OTA channel: {}".format(args.system_ota))
+        if args.images_path != preinstalled_images:
+            raise ValueError(
+                "Failed to get system OTA channel: {}".format(args.system_ota))
+        else:
+            args.system_ota = "None"
 
     device_codename = helpers.props.host_get(args, "ro.product.device")
     args.vendor_type = None
@@ -52,8 +65,12 @@ def setup_config(args):
             break
 
     if not args.vendor_type:
-        raise ValueError(
-            "Failed to get vendor OTA channel: {}".format(vendor_ota))
+        if args.images_path != preinstalled_images:
+            raise ValueError(
+                "Failed to get vendor OTA channel: {}".format(vendor_ota))
+        else:
+            args.vendor_ota = "None"
+            args.vendor_type = get_vendor_type(args)
 
     cfg["waydroid"]["vendor_type"] = args.vendor_type
     cfg["waydroid"]["system_ota"] = args.system_ota
@@ -74,7 +91,8 @@ def init(args):
             logging.info("Stopping container")
             helpers.lxc.stop(args)
         helpers.images.umount_rootfs(args)
-        helpers.images.get(args)
+        if args.images_path != tools.config.defaults["preinstalled_images_path"]:
+            helpers.images.get(args)
         if not os.path.isdir(tools.config.defaults["rootfs"]):
             os.mkdir(tools.config.defaults["rootfs"])
         helpers.lxc.setup_host_perms(args)
index cb1aaa5bdd66fc9c7f3c7d0fd24e0ea86dc86585..71a64e7e90ae41f0cedb40cf7276ddc35f31286e 100644 (file)
@@ -25,7 +25,8 @@ def upgrade(args):
     helpers.images.umount_rootfs(args)
     helpers.drivers.loadBinderNodes(args)
     if not args.offline:
-        helpers.images.get(args)
+        if args.images_path != tools.config.defaults["preinstalled_images_path"]:
+            helpers.images.get(args)
     helpers.lxc.setup_host_perms(args)
     helpers.lxc.set_lxc_config(args)
     helpers.lxc.make_base_props(args)
index f26e37691c14bd49d43a6e4e92c905d23b9bc898..9af1657eba81b6e0af3a39feec753a322fc18daf 100644 (file)
@@ -41,7 +41,8 @@ defaults = {
     "work": "/home/.waydroid",
     "vendor_type": "MAINLINE",
     "system_datetime": "0",
-    "vendor_datetime": "0"
+    "vendor_datetime": "0",
+    "preinstalled_images_path": "/usr/share/waydroid-extra/images"
 }
 defaults["images_path"] = defaults["work"] + "/images"
 defaults["rootfs"] = defaults["work"] + "/rootfs"
index 4c95287837f34e4877770ea24c67a79a0514b64f..1879c76f1a8c3e002ad01023c43adee46b0e1be4 100644 (file)
@@ -21,7 +21,6 @@ def arguments_init(subparser):
     ret = subparser.add_parser("init", help="set up waydroid specific"
                                " configs and install images")
     ret.add_argument("-i", "--images_path",
-                        default=tools.config.defaults["images_path"],
                         help="custom path to waeiod images (default in"
                              " /home/.waydroid/images)")
     ret.add_argument("-f", "--force", action="store_true",