cli: lib: scripts: Implement scaled DLC build/dev flows

Builds will be able to handle scaled DLC installations.
Developers will be able to deploy scaled DLC ebuilds.

BUG=b:236008158
TEST=./run_tests lib/dlc_lib_unittest.py cli/deploy_unittest.py
TEST=cros deploy'ment of scaled DLC

Cq-Depend: chromium:3991672
Change-Id: Ib6d538734f11f43ef0de3732fdeb6650ef1038ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3990920
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Yuanpeng Ni‎ <yuanpengni@chromium.org>
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Ram Chandrasekar <rchandrasekar@google.com>
diff --git a/cli/deploy.py b/cli/deploy.py
index 12f72c4..c33a824 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -1222,9 +1222,6 @@
             logging.error("Failed to uninstall DLC.")
             raise
 
-        # TODO(andrewlassalle): Copy the DLC image to the preload location instead
-        # of to dlc_a and dlc_b, and let dlcserive install the images to their final
-        # location.
         logging.notice("Deploy the DLC image for %s", dlc_id)
         dlc_img_path_src = os.path.join(
             sysroot,
@@ -1233,6 +1230,15 @@
             dlc_package,
             dlc_lib.DLC_IMAGE,
         )
+        if not os.path.exists(dlc_img_path_src):
+            dlc_img_path_src = os.path.join(
+                sysroot,
+                dlc_lib.DLC_BUILD_DIR_SCALED,
+                dlc_id,
+                dlc_package,
+                dlc_lib.DLC_IMAGE,
+            )
+
         dlc_img_path = os.path.join(_DLC_INSTALL_ROOT, dlc_id, dlc_package)
         dlc_img_path_a = os.path.join(dlc_img_path, "dlc_a")
         dlc_img_path_b = os.path.join(dlc_img_path, "dlc_b")
@@ -1266,6 +1272,14 @@
             dlc_package,
             dlc_lib.DLC_TMP_META_DIR,
         )
+        if not os.path.exists(src_meta_dir):
+            src_meta_dir = os.path.join(
+                sysroot,
+                dlc_lib.DLC_BUILD_DIR_SCALED,
+                dlc_id,
+                dlc_package,
+                dlc_lib.DLC_TMP_META_DIR,
+            )
         device.CopyToDevice(
             src_meta_dir + "/",
             dest_meta_dir,