[v4,4/7] imager: Split imager deps between image types

Message ID 20230511105020.1881496-5-amikan@ilbers.de
State Superseded, archived
Headers show
Series Imager schroot migration | expand

Commit Message

Anton Mikanovich May 11, 2023, 10:50 a.m. UTC
To reduce dependencies install time and disk space consumption we need
to install only those imager dependencies which used in every image
type prepare logic. So split variables between tasks.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/image-tools-extension.bbclass | 10 ++++++----
 meta/classes/image.bbclass                 |  8 ++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass
index 04ed1f84..58799fcf 100644
--- a/meta/classes/image-tools-extension.bbclass
+++ b/meta/classes/image-tools-extension.bbclass
@@ -15,6 +15,8 @@  SCHROOT_MOUNTS = "${WORKDIR}:${PP_WORK} ${IMAGE_ROOTFS}:${PP_ROOTFS} ${DEPLOY_DI
 SCHROOT_MOUNTS += "${REPO_ISAR_DIR}/${DISTRO}:/isar-apt"
 
 imager_run() {
+    local_install="${@(d.getVar("INSTALL_%s" % d.getVar("BB_CURRENTTASK")) or '').strip()}"
+
     schroot_create_configs
     insert_mounts
 
@@ -34,8 +36,8 @@  imager_run() {
     trap 'exit 1' INT HUP QUIT TERM ALRM USR1
     trap 'imager_cleanup' EXIT
 
-    if [ -n "${@d.getVar("IMAGER_INSTALL").strip()}" ]; then
-        echo "Installing deps: ${IMAGER_INSTALL}"
+    if [ -n "${local_install}" ]; then
+        echo "Installing imager deps: ${local_install}"
 
         distro="${BASE_DISTRO}-${BASE_DISTRO_CODENAME}"
         if [ ${ISAR_CROSS_COMPILE} -eq 1 ]; then
@@ -64,13 +66,13 @@  EOF"
                 -o APT::Get::List-Cleanup='0'
             apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
                 --allow-unauthenticated --allow-downgrades --download-only install \
-                ${IMAGER_INSTALL}"
+                ${local_install}"
 
         deb_dl_dir_export ${schroot_dir} ${distro}
         schroot -r -c ${session_id} -d / -u root -- sh -c " \
             apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \
                 --allow-unauthenticated --allow-downgrades install \
-                ${IMAGER_INSTALL}"
+                ${local_install}"
     fi
 
     schroot -r -c ${session_id} "$@"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 42e4b0c9..b9d3d411 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -208,6 +208,8 @@  python() {
     imager_build_deps = set()
     conversion_install = set()
     for bt in basetypes:
+        local_imager_install = set()
+        local_conversion_install = set()
         vardeps = set()
         cmds = []
         bt_clean = bt.replace('-', '_').replace('.', '_')
@@ -231,6 +233,7 @@  python() {
         # imager install
         for dep in (d.getVar('IMAGER_INSTALL:' + bt_clean) or '').split():
             imager_install.add(dep)
+            local_imager_install.add(dep)
         for dep in (d.getVar('IMAGER_BUILD_DEPS:' + bt_clean) or '').split():
             imager_build_deps.add(dep)
 
@@ -273,6 +276,7 @@  python() {
                     vardeps.add('CONVERSION_CMD:' + c)
                     for dep in (localdata.getVar('CONVERSION_DEPS:' + c) or '').split():
                         conversion_install.add(dep)
+                        local_conversion_install.add(dep)
                     # remove temporary image files
                     if t not in image_types:
                         rm_images.add(localdata.expand('${IMAGE_FILE_HOST}'))
@@ -305,6 +309,10 @@  python() {
             d.appendVarFlag(task, 'depends', task_deps)
         bb.build.addtask(task, 'do_image', after, d)
 
+        # set per type imager dependencies
+        d.setVar('INSTALL_image_%s' % bt_clean, d.getVar('IMAGER_INSTALL'))
+        d.appendVar('INSTALL_image_%s' % bt_clean, ' ' + ' '.join(sorted(local_imager_install | local_conversion_install)))
+
     d.appendVar('IMAGER_INSTALL', ' ' + ' '.join(sorted(imager_install | conversion_install)))
     d.appendVar('IMAGER_BUILD_DEPS', ' ' + ' '.join(sorted(imager_build_deps)))
 }