diff mbox series

fitimage: introduce FIT_CONF_STRIP_EXT

Message ID 20260107092600.73848-1-dev@g0hl1n.net
State Under Review
Headers show
Series fitimage: introduce FIT_CONF_STRIP_EXT | expand

Commit Message

Richard Leitner Jan. 7, 2026, 9:26 a.m. UTC
Introduce a configuration variable named FIT_CONF_STRIP_EXT which
removes the file-type extension from the configuration node name.

This feature enables us to give configuration nodes arbritary names
(based on the dtb file names). This is in my case needed to ensure
consistent configuration names which where previously (walnascar)
generated using a fitimage_emit_section_config:append() function.

Signed-off-by: Richard Leitner <dev@g0hl1n.net>
---
 meta/classes-recipe/kernel-fit-image.bbclass | 1 +
 meta/conf/image-fitimage.conf                | 3 +++
 meta/lib/oe/fitimage.py                      | 4 ++++
 meta/lib/oeqa/selftest/cases/fitimage.py     | 3 +++
 4 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-fit-image.bbclass b/meta/classes-recipe/kernel-fit-image.bbclass
index fd0d21ceee..6f78016e14 100644
--- a/meta/classes-recipe/kernel-fit-image.bbclass
+++ b/meta/classes-recipe/kernel-fit-image.bbclass
@@ -54,6 +54,7 @@  python do_compile() {
     root_node = oe.fitimage.ItsNodeRootKernel(
         d.getVar("FIT_DESC"), d.getVar("FIT_ADDRESS_CELLS"),
         d.getVar('HOST_PREFIX'), d.getVar('UBOOT_ARCH'),  d.getVar("FIT_CONF_PREFIX"),
+        oe.types.boolean(d.getVar('FIT_CONF_STRIP_EXT')),
         oe.types.boolean(d.getVar('FIT_KERNEL_SIGN_ENABLE')), d.getVar("FIT_KERNEL_SIGN_KEYDIR"),
         d.getVar("UBOOT_MKIMAGE"), d.getVar("UBOOT_MKIMAGE_DTCOPTS"),
         d.getVar("UBOOT_MKIMAGE_SIGN"), d.getVar("UBOOT_MKIMAGE_SIGN_ARGS"),
diff --git a/meta/conf/image-fitimage.conf b/meta/conf/image-fitimage.conf
index 090ee148f4..6bf0dd1299 100644
--- a/meta/conf/image-fitimage.conf
+++ b/meta/conf/image-fitimage.conf
@@ -35,6 +35,9 @@  FIT_SIGN_INDIVIDUAL ?= "0"
 FIT_CONF_PREFIX ?= "conf-"
 FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
 
+FIT_CONF_STRIP_EXT ?= "0"
+FIT_CONF_STRIP_EXT[doc] = "Set true to strip a possible file-type extension from a FIT configuration node name"
+
 FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio"
 
 # Allow user to support special use cases where the kernel binary is
diff --git a/meta/lib/oe/fitimage.py b/meta/lib/oe/fitimage.py
index f303799155..bbd5e1843f 100644
--- a/meta/lib/oe/fitimage.py
+++ b/meta/lib/oe/fitimage.py
@@ -154,6 +154,7 @@  class ItsNodeRootKernel(ItsNode):
     firt DTB. If there is no dtb present than the default configuation the kernel.
     """
     def __init__(self, description, address_cells, host_prefix, arch, conf_prefix,
+                 conf_strip_ext=False,
                  sign_enable=False, sign_keydir=None,
                  mkimage=None, mkimage_dtcopts=None,
                  mkimage_sign=None, mkimage_sign_args=None,
@@ -171,6 +172,7 @@  class ItsNodeRootKernel(ItsNode):
         self._host_prefix = host_prefix
         self._arch = arch
         self._conf_prefix = conf_prefix
+        self._conf_strip_ext = conf_strip_ext
 
         # Signature related properties
         self._sign_enable = sign_enable
@@ -468,6 +470,8 @@  class ItsNodeRootKernel(ItsNode):
                 dtb_name = dtb.name
                 if dtb.name.startswith("fdt-"):
                     dtb_name = dtb.name[len("fdt-"):]
+                if self._conf_strip_ext:
+                    dtb_name = dtb_name.rsplit(".", 1)[0]
                 self._fitimage_emit_one_section_config(self._conf_prefix + dtb_name, dtb)
             for dtb in self._dtb_alias:
                 self._fitimage_emit_one_section_config(self._conf_prefix + dtb.alias_name, dtb)
diff --git a/meta/lib/oeqa/selftest/cases/fitimage.py b/meta/lib/oeqa/selftest/cases/fitimage.py
index 8df5e92a34..84741f10ae 100644
--- a/meta/lib/oeqa/selftest/cases/fitimage.py
+++ b/meta/lib/oeqa/selftest/cases/fitimage.py
@@ -412,6 +412,7 @@  class KernelFitImageBase(FitImageTestCase):
             'DEPLOY_DIR_IMAGE',
             'FIT_CONF_DEFAULT_DTB',
             'FIT_CONF_PREFIX',
+            'FIT_CONF_STRIP_EXT',
             'FIT_DESC',
             'FIT_HASH_ALG',
             'FIT_KERNEL_COMP_ALG',
@@ -1070,6 +1071,7 @@  class FitImagePyTests(KernelFitImageBase):
             'FIT_ADDRESS_CELLS': "1",
             'FIT_CONF_DEFAULT_DTB': "",
             'FIT_CONF_PREFIX': "conf-",
+            'FIT_CONF_STRIP_EXT': "0",
             'FIT_DESC': "Kernel fitImage for a dummy distro",
             'FIT_GENERATE_KEYS': "0",
             'FIT_HASH_ALG': "sha256",
@@ -1115,6 +1117,7 @@  class FitImagePyTests(KernelFitImageBase):
         root_node = oe.fitimage.ItsNodeRootKernel(
             bb_vars["FIT_DESC"], bb_vars["FIT_ADDRESS_CELLS"],
             bb_vars['HOST_PREFIX'], bb_vars['UBOOT_ARCH'],  bb_vars["FIT_CONF_PREFIX"],
+            oe.types.boolean(bb_vars['FIT_CONF_STRIP_EXT']),
             oe.types.boolean(bb_vars['UBOOT_SIGN_ENABLE']), bb_vars["UBOOT_SIGN_KEYDIR"],
             bb_vars["UBOOT_MKIMAGE"], bb_vars["UBOOT_MKIMAGE_DTCOPTS"],
             bb_vars["UBOOT_MKIMAGE_SIGN"], bb_vars["UBOOT_MKIMAGE_SIGN_ARGS"],