* [PATCH v3 2/3] image: refactor SDK
  2021-12-17  9:10 [PATCH v3 0/3] sdk: make SDK an image Adriaan Schmidt
  2021-12-17  9:10 ` [PATCH v3 1/3] image: remove IMAGE_SUFFIX Adriaan Schmidt
@ 2021-12-17  9:10 ` Adriaan Schmidt
  2021-12-17  9:10 ` [PATCH v3 3/3] image: include all types and add tasks on demand Adriaan Schmidt
  2 siblings, 0 replies; 5+ messages in thread
From: Adriaan Schmidt @ 2021-12-17  9:10 UTC (permalink / raw)
  To: isar-users; +Cc: Adriaan Schmidt
- turn the image-sdk-extension into an image recipe variant (requires
  renaming of the class to `sdk` to use BBCLASSEXTEND).
- put the logic from sdkchroot into that variant
- turn the remainder of sdkcroot into the package sdk-files that
  that is then installed into SDKs
API change: SDK_FORMATS now has the same semantics (and knows the same
    formats) as IMAGE_FSTYPES. Because there is no image type to generate
    tar.xz images, for now the default SDK_FORMAT is `targz-img`.
NOTE: this patch does not work stand-alone. It requires changes to the
    way image types are handled.
Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 meta/classes/image-sdk-extension.bbclass      |  87 -----------
 meta/classes/image.bbclass                    |   2 +-
 meta/classes/sdk.bbclass                      | 137 ++++++++++++++++++
 .../{sdkchroot => sdk-files}/files/README.sdk |   0
 .../files/configscript.sh                     |   0
 .../files/gcc-sysroot-wrapper.sh              |   0
 .../files/relocate-sdk.sh                     |   0
 meta/recipes-devtools/sdk-files/sdk-files.bb  |  26 ++++
 meta/recipes-devtools/sdkchroot/sdkchroot.bb  |  78 ----------
 9 files changed, 164 insertions(+), 166 deletions(-)
 delete mode 100644 meta/classes/image-sdk-extension.bbclass
 create mode 100644 meta/classes/sdk.bbclass
 rename meta/recipes-devtools/{sdkchroot => sdk-files}/files/README.sdk (100%)
 rename meta/recipes-devtools/{sdkchroot => sdk-files}/files/configscript.sh (100%)
 rename meta/recipes-devtools/{sdkchroot => sdk-files}/files/gcc-sysroot-wrapper.sh (100%)
 rename meta/recipes-devtools/{sdkchroot => sdk-files}/files/relocate-sdk.sh (100%)
 create mode 100644 meta/recipes-devtools/sdk-files/sdk-files.bb
 delete mode 100644 meta/recipes-devtools/sdkchroot/sdkchroot.bb
diff --git a/meta/classes/image-sdk-extension.bbclass b/meta/classes/image-sdk-extension.bbclass
deleted file mode 100644
index 426b925..0000000
--- a/meta/classes/image-sdk-extension.bbclass
+++ /dev/null
@@ -1,87 +0,0 @@
-# This software is a part of ISAR.
-# Copyright (C) Siemens AG, 2019
-#
-# SPDX-License-Identifier: MIT
-#
-# This class extends the image.bbclass to supply the creation of a sdk
-
-SDK_INCLUDE_ISAR_APT ?= "0"
-SDK_FORMATS ?= "tar-xz"
-
-sdk_tar_xz() {
-    # Copy mount_chroot.sh for convenience
-    sudo cp ${SCRIPTSDIR}/mount_chroot.sh ${SDKCHROOT_DIR}
-
-    # Create SDK archive
-    cd -P ${SDKCHROOT_DIR}/..
-    sudo tar --transform="s|^rootfs|sdk-${DISTRO}-${DISTRO_ARCH}|" \
-        -c rootfs | xz -T0 > ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}.tar.xz
-    bbdebug 1 "SDK rootfs available in ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}.tar.xz"
-}
-
-do_populate_sdk[stamp-extra-info] = "${DISTRO}-${MACHINE}"
-do_populate_sdk[depends] = "sdkchroot:do_build"
-do_populate_sdk[vardeps] += "SDK_INCLUDE_ISAR_APT SDK_FORMATS"
-do_populate_sdk() {
-    local sdk_container_formats=""
-
-    if [ "${SDK_INCLUDE_ISAR_APT}" = "1" ]; then
-        # Copy isar-apt with deployed Isar packages
-        sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO} ${SDKCHROOT_DIR}/isar-apt
-    else
-        # Remove isar-apt repo entry
-        sudo rm -f ${SDKCHROOT_DIR}/etc/apt/sources.list.d/isar-apt.list
-    fi
-
-    sudo umount -R ${SDKCHROOT_DIR}/dev || true
-    sudo umount ${SDKCHROOT_DIR}/proc || true
-    sudo umount -R ${SDKCHROOT_DIR}/sys || true
-
-    # Remove setup scripts
-    sudo rm -f ${SDKCHROOT_DIR}/chroot-setup.sh ${SDKCHROOT_DIR}/configscript.sh
-
-    # Make all links relative
-    for link in $(find ${SDKCHROOT_DIR}/ -type l); do
-        target=$(readlink $link)
-
-        if [ "${target#/}" != "${target}" ]; then
-            basedir=$(dirname $link)
-            new_target=$(realpath --no-symlinks -m --relative-to=$basedir ${SDKCHROOT_DIR}/${target})
-
-            # remove first to allow rewriting directory links
-            sudo rm $link
-            sudo ln -s $new_target $link
-        fi
-    done
-
-    # Set up sysroot wrapper
-    for tool_pattern in "gcc-[0-9]*" "g++-[0-9]*" "cpp-[0-9]*" "ld.bfd" "ld.gold"; do
-        for tool in $(find ${SDKCHROOT_DIR}/usr/bin -type f -name "*-linux-gnu*-${tool_pattern}"); do
-            sudo mv "${tool}" "${tool}.bin"
-            sudo ln -sf gcc-sysroot-wrapper.sh ${tool}
-        done
-    done
-
-    # separate SDK formats: TAR and container formats
-    for sdk_format in ${SDK_FORMATS} ; do
-        case ${sdk_format} in
-            "tar-xz")
-                sdk_tar_xz
-                ;;
-            "docker-archive" | "oci" | "oci-archive" | "docker-daemon" | "containers-storage")
-                sdk_container_formats="${sdk_container_formats} ${sdk_format}"
-                ;;
-            *)
-                die "unsupported SDK format specified: ${sdk_format}"
-                ;;
-        esac
-    done
-
-    # generate the SDK in all the desired container formats
-    if [ -n "${sdk_container_formats}" ] ; then
-        bbnote "Generating SDK container in ${sdk_container_formats} format"
-        containerize_rootfs "${SDKCHROOT_DIR}" "sdk-${DISTRO}-${DISTRO_ARCH}" "${sdk_container_formats}"
-    fi
-}
-
-addtask populate_sdk after do_rootfs
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index b4d20f8..d2512d3 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -76,7 +76,7 @@ ROOTFS_DPKGSTATUS_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}"
 ROOTFS_POSTPROCESS_COMMAND_prepend = "${@bb.utils.contains('BASE_REPO_FEATURES', 'cache-deb-src', 'cache_deb_src', '', d)} "
 
 inherit rootfs
-inherit image-sdk-extension
+inherit sdk
 inherit image-tools-extension
 inherit image-postproc-extension
 inherit image-locales-extension
diff --git a/meta/classes/sdk.bbclass b/meta/classes/sdk.bbclass
new file mode 100644
index 0000000..adf9a1f
--- /dev/null
+++ b/meta/classes/sdk.bbclass
@@ -0,0 +1,137 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+#
+# This class extends the image.bbclass to supply the creation of a sdk
+
+# hook up the -sdk image variant
+BBCLASSEXTEND = "sdk"
+BPN = "${PN}"
+
+python sdk_virtclass_handler() {
+    pn = e.data.getVar('PN')
+    if pn.endswith('-sdk'):
+        e.data.setVar('BPN', pn[:-len('-sdk')])
+        e.data.appendVar('OVERRIDES', ':class-sdk')
+        # sdkchroot deploy only for sdk image
+        bb.build.addtask('deploy_sdkchroot', 'do_build', 'do_rootfs', d)
+    else:
+        # add do_populate_sdk only to the non-sdk variant
+        # it only exists to preserve the interface...
+        bb.build.addtask('populate_sdk', '', '', e.data)
+        e.data.appendVarFlag('do_populate_sdk', 'depends', '${BPN}-sdk:do_build')
+        e.data.appendVarFlag('do_clean', 'depends', '${BPN}-sdk:do_clean')
+}
+addhandler sdk_virtclass_handler
+sdk_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
+
+# SDK is image-specific:
+SDKCHROOT_DIR = "${DEPLOY_DIR_SDKCHROOT}/${BPN}-${MACHINE}"
+
+# SDK settings
+SDK_INCLUDE_ISAR_APT ?= "0"
+SDK_FORMATS ?= "targz-img"
+SDK_INSTALL ?= ""
+SDK_PREINSTALL += " \
+    debhelper \
+    autotools-dev \
+    dpkg \
+    locales \
+    docbook-to-man \
+    apt \
+    automake \
+    devscripts \
+    equivs"
+
+TOOLCHAIN = "crossbuild-essential-${DISTRO_ARCH}"
+TOOLCHAIN_${HOST_ARCH} = "build-essential"
+TOOLCHAIN_i386 = "build-essential"
+TOOLCHAIN_append_compat-arch = " crossbuild-essential-${COMPAT_DISTRO_ARCH}"
+
+# rootfs/image overrides for the SDK
+ROOTFS_ARCH_class-sdk = "${HOST_ARCH}"
+ROOTFS_DISTRO_class-sdk = "${HOST_DISTRO}"
+ROOTFS_PACKAGES_class-sdk = "sdk-files ${TOOLCHAIN} ${SDK_PREINSTALL} ${SDK_INSTALL}"
+ROOTFS_FEATURES_append_class-sdk = " clean-package-cache generate-manifest export-dpkg-status"
+ROOTFS_MANIFEST_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
+ROOTFS_DPKGSTATUS_DEPLOY_DIR_class-sdk = "${DEPLOY_DIR_SDKCHROOT}"
+
+IMAGE_FSTYPES_class-sdk = "${SDK_FORMATS}"
+
+# bitbake dependencies
+SDKDEPENDS += "sdk-files ${SDK_INSTALL}"
+SDKDEPENDS_append_riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_CROSS_COMPILE', True) == '1' and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
+DEPENDS_class-sdk = "${SDKDEPENDS}"
+
+SDKROOTFSDEPENDS = ""
+SDKROOTFSDEPENDS_class-sdk = "${BPN}:do_rootfs"
+do_rootfs_install[depends] += "${SDKROOTFSDEPENDS}"
+
+SDKROOTFSVARDEPS = ""
+SDKROOTFSVARDEPS_class-sdk = "SDK_INCLUDE_ISAR_APT"
+do_rootfs_install[vardeps] += "${SDKROOTFSVARDEPS}"
+
+# additional SDK steps
+ROOTFS_CONFIGURE_COMMAND_append_class-sdk = " ${@'rootfs_configure_isar_apt_dir' if d.getVar('SDK_INCLUDE_ISAR_APT') == '1' else ''}"
+rootfs_configure_isar_apt_dir() {
+    # Copy isar-apt instead of mounting:
+    sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO} ${ROOTFSDIR}/isar-apt
+}
+
+ROOTFS_POSTPROCESS_COMMAND_prepend_class-sdk = "sdkchroot_configscript "
+sdkchroot_configscript () {
+    sudo chroot ${ROOTFSDIR} /configscript.sh ${DISTRO_ARCH}
+}
+
+ROOTFS_POSTPROCESS_COMMAND_append_class-sdk = " sdkchroot_finalize"
+sdkchroot_finalize() {
+    if [ "${SDK_INCLUDE_ISAR_APT}" = "0" ]; then
+        # Remove isar-apt repo entry
+        sudo rm -f ${ROOTFSDIR}/etc/apt/sources.list.d/isar-apt.list
+    fi
+
+    sudo umount -R ${ROOTFSDIR}/dev || true
+    sudo umount ${ROOTFSDIR}/proc || true
+    sudo umount -R ${ROOTFSDIR}/sys || true
+
+    # Remove setup scripts
+    sudo rm -f ${ROOTFSDIR}/chroot-setup.sh ${ROOTFSDIR}/configscript.sh
+
+    # Make all links relative
+    for link in $(find ${ROOTFSDIR}/ -type l); do
+        target=$(readlink $link)
+
+        if [ "${target#/}" != "${target}" ]; then
+            basedir=$(dirname $link)
+            new_target=$(realpath --no-symlinks -m --relative-to=$basedir ${ROOTFSDIR}/${target})
+
+            # remove first to allow rewriting directory links
+            sudo rm $link
+            sudo ln -s $new_target $link
+        fi
+    done
+
+    # Set up sysroot wrapper
+    for tool_pattern in "gcc-[0-9]*" "g++-[0-9]*" "cpp-[0-9]*" "ld.bfd" "ld.gold"; do
+        for tool in $(find ${ROOTFSDIR}/usr/bin -type f -name "*-linux-gnu*-${tool_pattern}"); do
+            sudo mv "${tool}" "${tool}.bin"
+            sudo ln -sf gcc-sysroot-wrapper.sh ${tool}
+        done
+    done
+}
+
+do_deploy_sdkchroot[dirs] = "${DEPLOY_DIR_SDKCHROOT}"
+do_deploy_sdkchroot() {
+    ln -Tfsr "${ROOTFSDIR}" "${SDKCHROOT_DIR}"
+}
+
+CLEANFUNCS_class-sdk = "clean_deploy"
+clean_deploy() {
+    rm -f "${SDKCHROOT_DIR}"
+}
+
+do_populate_sdk[noexec] = "1"
+do_populate_sdk() {
+    :
+}
diff --git a/meta/recipes-devtools/sdkchroot/files/README.sdk b/meta/recipes-devtools/sdk-files/files/README.sdk
similarity index 100%
rename from meta/recipes-devtools/sdkchroot/files/README.sdk
rename to meta/recipes-devtools/sdk-files/files/README.sdk
diff --git a/meta/recipes-devtools/sdkchroot/files/configscript.sh b/meta/recipes-devtools/sdk-files/files/configscript.sh
similarity index 100%
rename from meta/recipes-devtools/sdkchroot/files/configscript.sh
rename to meta/recipes-devtools/sdk-files/files/configscript.sh
diff --git a/meta/recipes-devtools/sdkchroot/files/gcc-sysroot-wrapper.sh b/meta/recipes-devtools/sdk-files/files/gcc-sysroot-wrapper.sh
similarity index 100%
rename from meta/recipes-devtools/sdkchroot/files/gcc-sysroot-wrapper.sh
rename to meta/recipes-devtools/sdk-files/files/gcc-sysroot-wrapper.sh
diff --git a/meta/recipes-devtools/sdkchroot/files/relocate-sdk.sh b/meta/recipes-devtools/sdk-files/files/relocate-sdk.sh
similarity index 100%
rename from meta/recipes-devtools/sdkchroot/files/relocate-sdk.sh
rename to meta/recipes-devtools/sdk-files/files/relocate-sdk.sh
diff --git a/meta/recipes-devtools/sdk-files/sdk-files.bb b/meta/recipes-devtools/sdk-files/sdk-files.bb
new file mode 100644
index 0000000..36cdb31
--- /dev/null
+++ b/meta/recipes-devtools/sdk-files/sdk-files.bb
@@ -0,0 +1,26 @@
+# SDK Root filesystem
+#
+# This software is a part of ISAR.
+# Copyright (C) 2015-2018 ilbers GmbH
+
+DESCRIPTION = "Isar SDK Root filesystem"
+
+LICENSE = "gpl-2.0"
+LIC_FILES_CHKSUM = "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
+
+inherit dpkg-raw
+
+SRC_URI = " \
+    file://configscript.sh \
+    file://relocate-sdk.sh \
+    file://gcc-sysroot-wrapper.sh \
+    file://README.sdk"
+PV = "0.1"
+
+do_install() {
+    install -m 644 ${WORKDIR}/README.sdk ${D}
+    install -m 755 ${WORKDIR}/relocate-sdk.sh ${D}
+    install -m 755 -d ${D}/usr/bin
+    install -m 755 ${WORKDIR}/gcc-sysroot-wrapper.sh ${D}/usr/bin
+    install -m 755 ${WORKDIR}/configscript.sh ${D}
+}
diff --git a/meta/recipes-devtools/sdkchroot/sdkchroot.bb b/meta/recipes-devtools/sdkchroot/sdkchroot.bb
deleted file mode 100644
index e367eae..0000000
--- a/meta/recipes-devtools/sdkchroot/sdkchroot.bb
+++ /dev/null
@@ -1,78 +0,0 @@
-# SDK Root filesystem
-#
-# This software is a part of ISAR.
-# Copyright (C) 2015-2018 ilbers GmbH
-
-DESCRIPTION = "Isar SDK Root filesystem"
-
-LICENSE = "gpl-2.0"
-LIC_FILES_CHKSUM = "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
-
-SRC_URI = " \
-    file://configscript.sh \
-    file://relocate-sdk.sh \
-    file://gcc-sysroot-wrapper.sh \
-    file://README.sdk"
-PV = "0.1"
-
-SDK_INSTALL ?= ""
-
-DEPENDS += "${SDK_INSTALL}"
-
-DEPENDS_append_riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_CROSS_COMPILE', True) == '1' and d.getVar('PN') != 'crossbuild-essential-riscv64' else ''}"
-
-TOOLCHAIN = "crossbuild-essential-${DISTRO_ARCH}"
-TOOLCHAIN_${HOST_ARCH} = "build-essential"
-TOOLCHAIN_i386 = "build-essential"
-TOOLCHAIN_append_compat-arch = " crossbuild-essential-${COMPAT_DISTRO_ARCH}"
-
-inherit rootfs
-ROOTFS_ARCH = "${HOST_ARCH}"
-ROOTFS_DISTRO = "${HOST_DISTRO}"
-ROOTFSDIR = "${S}"
-ROOTFS_PACKAGES = "${SDK_PREINSTALL} ${SDK_INSTALL} ${TOOLCHAIN}"
-ROOTFS_FEATURES += "clean-package-cache generate-manifest export-dpkg-status"
-ROOTFS_MANIFEST_DEPLOY_DIR = "${DEPLOY_DIR_SDKCHROOT}"
-ROOTFS_DPKGSTATUS_DEPLOY_DIR = "${DEPLOY_DIR_SDKCHROOT}"
-
-SDK_PREINSTALL += " \
-    debhelper \
-    autotools-dev \
-    dpkg \
-    locales \
-    docbook-to-man \
-    apt \
-    automake \
-    devscripts \
-    equivs"
-
-SDK_INCLUDE_ISAR_APT ?= "0"
-
-S = "${WORKDIR}/rootfs"
-
-ROOTFS_CONFIGURE_COMMAND += "${@'rootfs_configure_isar_apt_dir' if d.getVar('SDK_INCLUDE_ISAR_APT') == '1' else ''}"
-rootfs_configure_isar_apt_dir() {
-    # Copy isar-apt instead of mounting:
-    sudo cp -Trpfx ${REPO_ISAR_DIR}/${DISTRO} ${ROOTFSDIR}/isar-apt
-}
-
-ROOTFS_POSTPROCESS_COMMAND =+ "sdkchroot_install_files"
-sdkchroot_install_files() {
-    # Configure root filesystem
-    sudo install -m 644 ${WORKDIR}/README.sdk ${S}
-    sudo install -m 755 ${WORKDIR}/relocate-sdk.sh ${S}
-    sudo install -m 755 ${WORKDIR}/gcc-sysroot-wrapper.sh ${S}/usr/bin
-    sudo install -m 755 ${WORKDIR}/configscript.sh ${S}
-    sudo chroot ${S} /configscript.sh  ${DISTRO_ARCH}
-}
-
-do_sdkchroot_deploy[dirs] = "${DEPLOY_DIR_SDKCHROOT}"
-do_sdkchroot_deploy() {
-    ln -Tfsr "${ROOTFSDIR}" "${SDKCHROOT_DIR}"
-}
-addtask sdkchroot_deploy before do_build after do_rootfs
-
-CLEANFUNCS = "clean_deploy"
-clean_deploy() {
-    rm -f "${SDKCHROOT_DIR}"
-}
-- 
2.30.2
^ permalink raw reply	[flat|nested] 5+ messages in thread* [PATCH v3 3/3] image: include all types and add tasks on demand
  2021-12-17  9:10 [PATCH v3 0/3] sdk: make SDK an image Adriaan Schmidt
  2021-12-17  9:10 ` [PATCH v3 1/3] image: remove IMAGE_SUFFIX Adriaan Schmidt
  2021-12-17  9:10 ` [PATCH v3 2/3] image: refactor SDK Adriaan Schmidt
@ 2021-12-17  9:10 ` Adriaan Schmidt
  2 siblings, 0 replies; 5+ messages in thread
From: Adriaan Schmidt @ 2021-12-17  9:10 UTC (permalink / raw)
  To: isar-users; +Cc: Adriaan Schmidt
To make the new SDK generation scheme work, we need to change the way
image tasks are added. Because IMAGE_FSTYPES can change during recipe
parsing when building the -sdk variant, image type classes must not
automatically add their do_*_image tasks.
Instead, we now always include all image types, and only enable
the tasks dynamically.
NOTE: This should NOT be merged. It is just to demo the new
    SDK extension.
Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 meta/classes/container-img.bbclass |  2 --
 meta/classes/cpiogz-img.bbclass    |  1 -
 meta/classes/ext4-img.bbclass      |  1 -
 meta/classes/fit-img.bbclass       |  2 +-
 meta/classes/image.bbclass         | 22 +++++++++++++++++++++-
 meta/classes/targz-img.bbclass     |  1 -
 meta/classes/ubi-img.bbclass       |  4 ++--
 meta/classes/ubifs-img.bbclass     |  3 +--
 meta/classes/wic-img.bbclass       |  1 -
 9 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/meta/classes/container-img.bbclass b/meta/classes/container-img.bbclass
index 8fef52a..70cecf4 100644
--- a/meta/classes/container-img.bbclass
+++ b/meta/classes/container-img.bbclass
@@ -15,5 +15,3 @@ do_container_image(){
     bbdebug 1 "Generate container image in these formats: ${CONTAINER_FORMATS}"
     containerize_rootfs "${IMAGE_ROOTFS}" "${rootfs_id}" "${CONTAINER_FORMATS}"
 }
-
-addtask container_image before do_image after do_image_tools
diff --git a/meta/classes/cpiogz-img.bbclass b/meta/classes/cpiogz-img.bbclass
index 2a49456..cacde0a 100644
--- a/meta/classes/cpiogz-img.bbclass
+++ b/meta/classes/cpiogz-img.bbclass
@@ -18,5 +18,4 @@ do_cpiogz_image() {
     sudo chown $(id -u):$(id -g) ${CPIOGZ_IMAGE_FILE}
 }
 
-addtask cpiogz_image before do_image after do_image_tools
 do_cpiogz_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass
index 5085afc..4b4f26e 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -19,6 +19,5 @@ do_ext4_image() {
                 -F -d '${PP_ROOTFS}' '${PP_DEPLOY}/${EXT4_IMAGE_FILE}'
 }
 
-addtask ext4_image before do_image after do_image_tools
 do_ext4_image[prefuncs] = 'set_image_size'
 do_ext4_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/fit-img.bbclass b/meta/classes/fit-img.bbclass
index 1ad0c5b..2c91153 100644
--- a/meta/classes/fit-img.bbclass
+++ b/meta/classes/fit-img.bbclass
@@ -25,5 +25,5 @@ do_fit_image() {
                 -f '${PP_WORK}/${FIT_IMAGE_SOURCE}' '${PP_DEPLOY}/${FIT_IMAGE_FILE}'
     sudo chown $(id -u):$(id -g) '${DEPLOY_DIR_IMAGE}/${FIT_IMAGE_FILE}'
 }
-addtask fit_image before do_image after do_image_tools do_transform_template
+addtask fit_image after do_transform_template
 do_fit_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index d2512d3..c21de30 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -225,4 +225,24 @@ EOSUDO
 addtask rootfs_finalize before do_rootfs after do_rootfs_postprocess
 
 # Last so that the image type can overwrite tasks if needed
-inherit ${IMAGE_FSTYPES}
+inherit container-img cpiogz-img ext4-img fit-img targz-img ubi-img ubifs-img wic-img
+
+python() {
+    fstypes = d.getVar('IMAGE_FSTYPES').split()
+    if 'container-img' in fstypes:
+        bb.build.addtask('container_image', 'do_image', 'do_image_tools', d)
+    if 'cpiogz-img' in fstypes:
+        bb.build.addtask('cpiogz_image', 'do_image', 'do_image_tools', d)
+    if 'ext4-img' in fstypes:
+        bb.build.addtask('ext4_image', 'do_image', 'do_image_tools', d)
+    if 'fit-img' in fstypes:
+        bb.build.addtask('fit_image', 'do_image', 'do_image_tools', d)
+    if 'targz-img' in fstypes:
+        bb.build.addtask('targz_image', 'do_image', 'do_image_tools', d)
+    if 'ubi-img' in fstypes:
+        bb.build.addtask('ubi_image', 'do_image', 'do_image_tools', d)
+    if 'unifs-img' in fstypes:
+        bb.build.addtask('ubifs_image', 'do_image', 'do_image_tools', d)
+    if 'wic-img' in fstypes:
+        bb.build.addtask('wic_image', 'do_image', 'do_image_tools', d)
+}
diff --git a/meta/classes/targz-img.bbclass b/meta/classes/targz-img.bbclass
index bf94af0..d96304f 100644
--- a/meta/classes/targz-img.bbclass
+++ b/meta/classes/targz-img.bbclass
@@ -11,5 +11,4 @@ do_targz_image() {
     sudo chown $(id -u):$(id -g) ${TARGZ_IMAGE_FILE}
 }
 
-addtask targz_image before do_image after do_image_tools
 do_targz_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/ubi-img.bbclass b/meta/classes/ubi-img.bbclass
index efaf058..db2bf18 100644
--- a/meta/classes/ubi-img.bbclass
+++ b/meta/classes/ubi-img.bbclass
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: MIT
 
 python() {
-    if not d.getVar("UBINIZE_ARGS"):
+    if "ubi-img" in d.getVar("IMAGE_FSTYPES").split() and not d.getVar("UBINIZE_ARGS"):
         raise bb.parse.SkipRecipe("UBINIZE_ARGS must be set")
 }
 
@@ -28,5 +28,5 @@ do_ubi_image() {
                 -o '${PP_DEPLOY}/${UBI_IMAGE_FILE}' '${PP_WORK}/${UBINIZE_CFG}'
     sudo chown $(id -u):$(id -g) '${DEPLOY_DIR_IMAGE}/${UBI_IMAGE_FILE}'
 }
-addtask ubi_image before do_image after do_image_tools do_transform_template
+addtask ubi_image after do_transform_template
 do_ubi_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/ubifs-img.bbclass b/meta/classes/ubifs-img.bbclass
index 229eb3e..8488e7c 100644
--- a/meta/classes/ubifs-img.bbclass
+++ b/meta/classes/ubifs-img.bbclass
@@ -4,7 +4,7 @@
 # SPDX-License-Identifier: MIT
 
 python() {
-    if not d.getVar("MKUBIFS_ARGS"):
+    if "ubifs-img" in d.getVar("IMAGE_FSTYPES").split() and not d.getVar("MKUBIFS_ARGS"):
         raise bb.parse.SkipRecipe("mkubifs_args must be set")
 }
 
@@ -28,5 +28,4 @@ do_ubifs_image() {
     sudo chown $(id -u):$(id -g) '${DEPLOY_DIR_IMAGE}/${UBIFS_IMAGE_FILE}'
 }
 
-addtask ubifs_image before do_image after do_image_tools
 do_ubifs_image[dirs] = "${DEPLOY_DIR_IMAGE}"
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 80ca5f7..c12d880 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -150,7 +150,6 @@ python do_wic_image() {
         bb.build.exec_func(cmd, d)
     progress_reporter.finish()
 }
-addtask wic_image before do_image after do_image_tools
 
 wic_do_mounts() {
     buildchroot_do_mounts
-- 
2.30.2
^ permalink raw reply	[flat|nested] 5+ messages in thread