]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
Configure multiple preinstalled images paths
authorAlessandro Astone <ales.astone@gmail.com>
Sun, 18 Sep 2022 22:10:20 +0000 (00:10 +0200)
committerAlessandro Astone <ales.astone@gmail.com>
Thu, 22 Sep 2022 12:07:49 +0000 (14:07 +0200)
Precedence:
  /etc/waydroid-extra/images
  /usr/share/waydroid-extra/images

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

index 2ce6cb4bad1ce404c1869f8b7729af519892f644..c3e133dddb3f2acc4231980cbe77cb2dd4fdef65 100644 (file)
@@ -29,13 +29,16 @@ def setup_config(args):
     args.arch = helpers.arch.host()
     cfg["waydroid"]["arch"] = args.arch
 
-    preinstalled_images = tools.config.defaults["preinstalled_images_path"]
+    preinstalled_images_paths = tools.config.defaults["preinstalled_images_paths"]
     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")
+        for preinstalled_images in preinstalled_images_paths:
+            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
+                    break
+                else:
+                    logging.warning("Found directory {} but missing system or vendor image, ignoring...".format(preinstalled_images))
+
     if not args.images_path:
         args.images_path = tools.config.defaults["images_path"]
     cfg["waydroid"]["images_path"] = args.images_path
@@ -54,7 +57,7 @@ def setup_config(args):
         "/waydroid_" + args.arch + "/" + args.system_type + ".json"
     system_request = helpers.http.retrieve(args.system_ota)
     if system_request[0] != 200:
-        if args.images_path != preinstalled_images:
+        if args.images_path not in preinstalled_images_paths:
             raise ValueError(
                 "Failed to get system OTA channel: {}, error: {}".format(args.system_ota, system_request[0]))
         else:
@@ -72,7 +75,7 @@ def setup_config(args):
             break
 
     if not args.vendor_type:
-        if args.images_path != preinstalled_images:
+        if args.images_path not in preinstalled_images_paths:
             raise ValueError(
                 "Failed to get vendor OTA channel: {}".format(vendor_ota))
         else:
@@ -103,7 +106,7 @@ def init(args):
             logging.info("Stopping container")
             helpers.lxc.stop(args)
         helpers.images.umount_rootfs(args)
-        if args.images_path != tools.config.defaults["preinstalled_images_path"]:
+        if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
         if not os.path.isdir(tools.config.defaults["rootfs"]):
             os.mkdir(tools.config.defaults["rootfs"])
index 2acf464fa918c6a754c688234be50cec71873574..b788f5051d645f188d3bc769cfd49901b0c0de49 100644 (file)
@@ -25,11 +25,10 @@ def upgrade(args):
     helpers.images.umount_rootfs(args)
     helpers.drivers.loadBinderNodes(args)
     if not args.offline:
-        preinstalled_images_path = tools.config.defaults["preinstalled_images_path"]
-        if args.images_path != preinstalled_images_path:
+        if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
         else:
-            logging.info("Upgrade refused because a pre-installed image is detected at {}.".format(preinstalled_images_path))
+            logging.info("Upgrade refused because a pre-installed image is detected at {}.".format(args.images_path))
     helpers.lxc.setup_host_perms(args)
     helpers.lxc.set_lxc_config(args)
     helpers.lxc.make_base_props(args)
index 99db257b154b5575641776fe5968ca6f64764247..f91d76dd063a5b6c8cace1b00fc93b35ceb9574f 100644 (file)
@@ -43,7 +43,10 @@ defaults = {
     "vendor_type": "MAINLINE",
     "system_datetime": "0",
     "vendor_datetime": "0",
-    "preinstalled_images_path": "/usr/share/waydroid-extra/images"
+    "preinstalled_images_paths": [
+        "/etc/waydroid-extra/images",
+        "/usr/share/waydroid-extra/images",
+    ]
 }
 defaults["images_path"] = defaults["work"] + "/images"
 defaults["rootfs"] = defaults["work"] + "/rootfs"
index ee84c61ca90fc9c55c12f6b7006bfe86b6fc5423..8348c0cb24a7a97ea0d65b11b513a7a4252e5a49 100644 (file)
@@ -253,7 +253,7 @@ def make_base_props(args):
         opengles = "196608"
     props.append("ro.opengles.version=" + opengles)
 
-    if args.images_path != tools.config.defaults["preinstalled_images_path"]:
+    if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
         props.append("waydroid.system_ota=" + args.system_ota)
         props.append("waydroid.vendor_ota=" + args.vendor_ota)
     else: