Introduce `INSTALLER_TARGET_IMAGES` to allow bundling multiple target images
(defaulting to `INSTALLER_TARGET_IMAGE` if unset), dynamically generate
`ROOTFS_ADDITIONAL_FILES` for each target image including `.wic` and
`.wic.bmap` files, and update multiconfig task dependencies to include all
configured installer images.
The `deploy-image` script of the `isar-installer` already supports multiple
target images and allows the user to select the required image to install.
Example: To bundle multiple target images, set the following in `local.conf`:
```
INSTALLER_TARGET_IMAGES = "isar-image-base isar-image-debug isar-image-ci"
```
Signed-off-by: Badrikesh Prusty <
badrikes...@siemens.com>
---
RECIPE-API-CHANGELOG.md | 13 ++++
.../installer-add-rootfs.bbclass | 69 +++++++++++++------
2 files changed, 61 insertions(+), 21 deletions(-)
diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index 6d7c56b9..07034b83 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -919,3 +919,16 @@ The following includes were considered internal and are no longer available:
The other original includes still exist and inherit the corresponding new
class. However, they issue a warning to perform the recommended conversion
because these transitional includes will eventually be dropped.
+
+### Support bundling multiple images in the installer
+
+Introduce `INSTALLER_TARGET_IMAGES` to allow bundling multiple installer
+images (defaulting to `INSTALLER_TARGET_IMAGE` if unset), dynamically
+generate `ROOTFS_ADDITIONAL_FILES` for each target image including `.wic`
+and `.wic.bmap` files, and update MC task dependencies to include all
+configured installer images.
+
+Example: To bundle multiple target images, set the following in local.conf:
+```
+INSTALLER_TARGET_IMAGES = "isar-image-base isar-image-debug isar-image-ci"
+```
diff --git a/meta-isar/classes-recipe/installer-add-rootfs.bbclass b/meta-isar/classes-recipe/installer-add-rootfs.bbclass
index 6708932c..2fa551bd 100644
--- a/meta-isar/classes-recipe/installer-add-rootfs.bbclass
+++ b/meta-isar/classes-recipe/installer-add-rootfs.bbclass
@@ -9,6 +9,7 @@ inherit rootfs-add-files
INSTALLER_MC ??= "isar-installer"
INSTALLER_TARGET_IMAGE ??= "isar-image-base"
+INSTALLER_TARGET_IMAGES ??= "${INSTALLER_TARGET_IMAGE}"
INSTALLER_TARGET_MC ??= "installer-target"
INSTALLER_TARGET_DISTRO ??= "${DISTRO}"
INSTALLER_TARGET_MACHINE ??= "${MACHINE}"
@@ -19,39 +20,65 @@ IMAGE_DATA_POSTFIX ??= "wic.zst"
IMAGE_DATA_POSTFIX:buster ??= "wic.xz"
IMAGE_DATA_POSTFIX:bullseye ??= "wic.xz"
-ROOTFS_ADDITIONAL_FILES ??= "installer-target installer-target-bmap"
-
-def get_installer_source(d, suffix):
- installer_target_image = d.getVar('INSTALLER_TARGET_IMAGE') or ""
- if not installer_target_image:
- return ""
+def get_installer_sources(d, suffix):
+ installer_target_images = sorted(set((d.getVar('INSTALLER_TARGET_IMAGES') or "").split()))
+ if not installer_target_images:
+ return [""]
target_deploy_dir = d.getVar('INSTALLER_TARGET_DEPLOY_DIR_IMAGE')
- image_data = d.getVar('IMAGE_DATA_FILE')
- return f"{target_deploy_dir}/{image_data}.{suffix}"
+ target_distro = d.getVar('INSTALLER_TARGET_DISTRO')
+ target_machine = d.getVar('INSTALLER_TARGET_MACHINE')
+ sources = []
+ for image in installer_target_images:
+ image_data = f"{image}-{target_distro}-{target_machine}"
+ sources.append(f"{target_deploy_dir}/{image_data}.{suffix}")
+ return sources
-def get_installer_destination(d, suffix):
- installer_target_image = d.getVar('INSTALLER_TARGET_IMAGE') or ""
- if not installer_target_image:
- return "/install/keep"
- image_data = d.getVar('IMAGE_DATA_FILE')
- return f"/install/{image_data}.{suffix}"
+def get_installer_destinations(d, suffix):
+ installer_target_images = sorted(set((d.getVar('INSTALLER_TARGET_IMAGES') or "").split()))
+ if not installer_target_images:
+ return ["/install/keep"]
+ target_distro = d.getVar('INSTALLER_TARGET_DISTRO')
+ target_machine = d.getVar('INSTALLER_TARGET_MACHINE')
+ dests = []
+ for image in installer_target_images:
+ image_data = f"{image}-{target_distro}-{target_machine}"
+ dests.append(f"/install/{image_data}.{suffix}")
+ return dests
def get_mc_depends(d, task):
- installer_target_image = d.getVar('INSTALLER_TARGET_IMAGE') or ""
- if not installer_target_image:
+ installer_target_images = sorted(set((d.getVar('INSTALLER_TARGET_IMAGES') or "").split()))
+ if not installer_target_images:
return ""
installer_mc = d.getVar('INSTALLER_MC') or ""
installer_target_mc = d.getVar('INSTALLER_TARGET_MC') or ""
- return f"mc:{installer_mc}:{installer_target_mc}:{installer_target_image}:{task}"
+ deps = []
+ for image in installer_target_images:
+ deps.append(f"mc:{installer_mc}:{installer_target_mc}:{image}:{task}")
+ return " ".join(deps)
def get_image_type(suffix):
image_type = suffix.split(".")[0]
return f"{image_type}"
-ROOTFS_ADDITIONAL_FILE_installer-target[source] = "${@ get_installer_source(d, d.getVar('IMAGE_DATA_POSTFIX'))}"
-ROOTFS_ADDITIONAL_FILE_installer-target[destination] = "${@ get_installer_destination(d, d.getVar('IMAGE_DATA_POSTFIX'))}"
-ROOTFS_ADDITIONAL_FILE_installer-target-bmap[source] = "${@ get_installer_source(d, "wic.bmap")}"
-ROOTFS_ADDITIONAL_FILE_installer-target-bmap[destination] = "${@ get_installer_destination(d, "wic.bmap")}"
+python() {
+ entries = []
+
+ def add_entries(postfix, suffix):
+ sources = get_installer_sources(d, suffix)
+ dests = get_installer_destinations(d, suffix)
+
+ for idx, (src, dst) in enumerate(zip(sources, dests)):
+ name = f"installer-target-{idx}{postfix}"
+ var = f"ROOTFS_ADDITIONAL_FILE_{name}"
+ entries.append(name)
+ d.setVarFlag(var, "source", src)
+ d.setVarFlag(var, "destination", dst)
+
+ add_entries("", d.getVar("IMAGE_DATA_POSTFIX"))
+ add_entries("-bmap", "wic.bmap")
+
+ d.setVar("ROOTFS_ADDITIONAL_FILES", " ".join(entries))
+}
INSTALLER_TARGET_TASK ??="do_image_${@ get_image_type(d.getVar('IMAGE_DATA_POSTFIX'))}"
do_rootfs_install[mcdepends] += "${@ get_mc_depends(d, d.getVar('INSTALLER_TARGET_TASK'))}"
--
2.47.3