diff mbox series

image_types: catch exception if no CONVERSION_CMD is defined

Message ID 20260417235422.838481-1-bhstalel@gmail.com
State Changes Requested, archived
Commit 76316c765d3183f7ecbf8e83c514c392d5a86eed
Headers show
Series image_types: catch exception if no CONVERSION_CMD is defined | expand

Commit Message

Talel BELHADJ SALEM April 17, 2026, 11:54 p.m. UTC
When new conversion type is defined, BitBake assumes
that CONVERSION_CMD: is defined for the type, so it gets
the variable which returns NoneType if it is not defined.

That generates the following exception which may not be clear
for some:

--
ERROR: /../techleef-image.bb: Error executing a python function in <code>:

The stack trace of python calls that resulted in this exception/failure was:
File: '<code>', lineno: 16, function: <module>
     0012:__anon_117__.._recipe_populate_sdk_base_bbclass(d)
     0013:__anon_427__.._recipe_populate_sdk_base_bbclass(d)
     0014:__anon_131__.._recipe_image_bbclass(d)
     0015:__anon_187__.._recipe_image_bbclass(d)
 *** 0016:__anon_535__.._recipe_image_bbclass(d)
     0017:__anon_44__.._recipe_rootfs_ipk_bbclass(d)
     0018:__anon_191__.._recipe_siteinfo_bbclass(d)
     0019:__anon_17__.._recipe_license_image_bbclass(d)
     0020:__anon_206__.._recipe_image_types_wic_bbclass(d)
File: '/../image.bbclass', lineno: 501, function: __anon_535__.._recipe_image_bbclass
     0497:                    if original_type not in alltypes:
     0498:                        rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
     0499:
     0500:        for bt in basetypes[t]:
 *** 0501:            gen_conversion_cmds(bt)
     0502:
     0503:        localdata.setVar('type', realt)
     0504:        if t not in alltypes:
     0505:            rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
File: '/../image.bbclass', lineno: 490, function: gen_conversion_cmds
     0486:                        type = type[8:]
     0487:                    # Create input image first.
     0488:                    gen_conversion_cmds(type)
     0489:                    localdata.setVar('type', type)
 *** 0490:                    cmd = "\t" + localdata.getVar("CONVERSION_CMD:" + ctype)
     0491:                    if cmd not in cmds:
     0492:                        cmds.append(cmd)
     0493:                    vardeps.add('CONVERSION_CMD:' + ctype)
     0494:                    subimage = type + "." + ctype
Exception: TypeError: can only concatenate str (not "NoneType") to str

ERROR: Parsing halted due to errors, see error messages above
--

Fail with human readable error if no CONVERSION_CMD is defined for
any defined subtype.

Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com>
---
 meta/classes-recipe/image_types.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Khem Raj April 21, 2026, 4:49 a.m. UTC | #1
Add meta-tegra to layermix and pick a tegra machine e.g.
MACHINE="p3737-0000-p3701-0005"
and then it ends up with

ERROR:
/mnt/b/yoe/master/kas-build/../layers/meta-openembedded/meta-filesystems/recipes-filesystems/images/
meta-filesystems-image-all.bb: No CONVERSION_CMD defined for subtype "tar"
- possibly invalid conversion type name or missing support class
ERROR:
/mnt/b/yoe/master/kas-build/../layers/meta-openembedded/meta-filesystems/recipes-filesystems/images/
meta-filesystems-image-ptest.bb: No CONVERSION_CMD defined for subtype
"tar" - possibly invalid conversion type name or missing support class
ERROR: Parsing halted due to errors, see error messages above

I wonder if CONVERSION_CMD is missing for tar in the original class

On Fri, Apr 17, 2026 at 4:54 PM BELHADJ SALEM Talel via
lists.openembedded.org <bhstalel=gmail.com@lists.openembedded.org> wrote:

> When new conversion type is defined, BitBake assumes
> that CONVERSION_CMD: is defined for the type, so it gets
> the variable which returns NoneType if it is not defined.
>
> That generates the following exception which may not be clear
> for some:
>
> --
> ERROR: /../techleef-image.bb: Error executing a python function in <code>:
>
> The stack trace of python calls that resulted in this exception/failure
> was:
> File: '<code>', lineno: 16, function: <module>
>      0012:__anon_117__.._recipe_populate_sdk_base_bbclass(d)
>      0013:__anon_427__.._recipe_populate_sdk_base_bbclass(d)
>      0014:__anon_131__.._recipe_image_bbclass(d)
>      0015:__anon_187__.._recipe_image_bbclass(d)
>  *** 0016:__anon_535__.._recipe_image_bbclass(d)
>      0017:__anon_44__.._recipe_rootfs_ipk_bbclass(d)
>      0018:__anon_191__.._recipe_siteinfo_bbclass(d)
>      0019:__anon_17__.._recipe_license_image_bbclass(d)
>      0020:__anon_206__.._recipe_image_types_wic_bbclass(d)
> File: '/../image.bbclass', lineno: 501, function:
> __anon_535__.._recipe_image_bbclass
>      0497:                    if original_type not in alltypes:
>      0498:
> rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
>      0499:
>      0500:        for bt in basetypes[t]:
>  *** 0501:            gen_conversion_cmds(bt)
>      0502:
>      0503:        localdata.setVar('type', realt)
>      0504:        if t not in alltypes:
>      0505:
> rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
> File: '/../image.bbclass', lineno: 490, function: gen_conversion_cmds
>      0486:                        type = type[8:]
>      0487:                    # Create input image first.
>      0488:                    gen_conversion_cmds(type)
>      0489:                    localdata.setVar('type', type)
>  *** 0490:                    cmd = "\t" +
> localdata.getVar("CONVERSION_CMD:" + ctype)
>      0491:                    if cmd not in cmds:
>      0492:                        cmds.append(cmd)
>      0493:                    vardeps.add('CONVERSION_CMD:' + ctype)
>      0494:                    subimage = type + "." + ctype
> Exception: TypeError: can only concatenate str (not "NoneType") to str
>
> ERROR: Parsing halted due to errors, see error messages above
> --
>
> Fail with human readable error if no CONVERSION_CMD is defined for
> any defined subtype.
>
> Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com>
> ---
>  meta/classes-recipe/image_types.bbclass | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/meta/classes-recipe/image_types.bbclass
> b/meta/classes-recipe/image_types.bbclass
> index e6ef0ce11e..326602d960 100644
> --- a/meta/classes-recipe/image_types.bbclass
> +++ b/meta/classes-recipe/image_types.bbclass
> @@ -44,6 +44,10 @@ def imagetypes_getdepends(d):
>                  deprecated.add(var)
>
>          for ctype in resttypes:
> +            ctype_cmd = d.getVar('CONVERSION_CMD:' + ctype)
> +            if not ctype_cmd:
> +                bb.fatal('No CONVERSION_CMD defined for subtype "%s"'
> +                         ' - possibly invalid conversion type name or
> missing support class' % ctype)
>              adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype), deps)
>              adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype), deps)
>
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#235513):
> https://lists.openembedded.org/g/openembedded-core/message/235513
> Mute This Topic: https://lists.openembedded.org/mt/118885182/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Talel BELHADJ SALEM April 21, 2026, 6:19 a.m. UTC | #2
I have quickly checked meta-tegra and they have full image type:
tegraflash.tar and they treat it as full type with IMAGE_CMD:tegraflash.tar

The problem is that BitBake splits every entry in IMAGE_FSTYPES with "."
and takes the first as base type and the rest as conversion types

and "tar" is not a CONVERSION_CMD, actually, in the original types class,
it is an IMAGE_CMD:tar, so BitBake won't find the conversion type for tar

I also checked the IMAGE_CMD:tegraflash.tar and they ended up calling tar
directly, so they did not intend to use tar as conversion type at all.

Now I wonder how it worked before ?

The quick fix for tegra is to replace "." with "_" or "-" to avoid
splitting "tar" into a subtype

I will analyze this more later after work.

Kind Regards
Talel

On Tue, Apr 21, 2026 at 5:49 AM Khem Raj <raj.khem@gmail.com> wrote:

> Add meta-tegra to layermix and pick a tegra machine e.g.
> MACHINE="p3737-0000-p3701-0005"
> and then it ends up with
>
> ERROR:
> /mnt/b/yoe/master/kas-build/../layers/meta-openembedded/meta-filesystems/recipes-filesystems/images/
> meta-filesystems-image-all.bb: No CONVERSION_CMD defined for subtype
> "tar" - possibly invalid conversion type name or missing support class
> ERROR:
> /mnt/b/yoe/master/kas-build/../layers/meta-openembedded/meta-filesystems/recipes-filesystems/images/
> meta-filesystems-image-ptest.bb: No CONVERSION_CMD defined for subtype
> "tar" - possibly invalid conversion type name or missing support class
> ERROR: Parsing halted due to errors, see error messages above
>
> I wonder if CONVERSION_CMD is missing for tar in the original class
>
> On Fri, Apr 17, 2026 at 4:54 PM BELHADJ SALEM Talel via
> lists.openembedded.org <bhstalel=gmail.com@lists.openembedded.org> wrote:
>
>> When new conversion type is defined, BitBake assumes
>> that CONVERSION_CMD: is defined for the type, so it gets
>> the variable which returns NoneType if it is not defined.
>>
>> That generates the following exception which may not be clear
>> for some:
>>
>> --
>> ERROR: /../techleef-image.bb: Error executing a python function in
>> <code>:
>>
>> The stack trace of python calls that resulted in this exception/failure
>> was:
>> File: '<code>', lineno: 16, function: <module>
>>      0012:__anon_117__.._recipe_populate_sdk_base_bbclass(d)
>>      0013:__anon_427__.._recipe_populate_sdk_base_bbclass(d)
>>      0014:__anon_131__.._recipe_image_bbclass(d)
>>      0015:__anon_187__.._recipe_image_bbclass(d)
>>  *** 0016:__anon_535__.._recipe_image_bbclass(d)
>>      0017:__anon_44__.._recipe_rootfs_ipk_bbclass(d)
>>      0018:__anon_191__.._recipe_siteinfo_bbclass(d)
>>      0019:__anon_17__.._recipe_license_image_bbclass(d)
>>      0020:__anon_206__.._recipe_image_types_wic_bbclass(d)
>> File: '/../image.bbclass', lineno: 501, function:
>> __anon_535__.._recipe_image_bbclass
>>      0497:                    if original_type not in alltypes:
>>      0498:
>> rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
>>      0499:
>>      0500:        for bt in basetypes[t]:
>>  *** 0501:            gen_conversion_cmds(bt)
>>      0502:
>>      0503:        localdata.setVar('type', realt)
>>      0504:        if t not in alltypes:
>>      0505:
>> rm_tmp_images.add(localdata.expand("${IMAGE_NAME}.${type}"))
>> File: '/../image.bbclass', lineno: 490, function: gen_conversion_cmds
>>      0486:                        type = type[8:]
>>      0487:                    # Create input image first.
>>      0488:                    gen_conversion_cmds(type)
>>      0489:                    localdata.setVar('type', type)
>>  *** 0490:                    cmd = "\t" +
>> localdata.getVar("CONVERSION_CMD:" + ctype)
>>      0491:                    if cmd not in cmds:
>>      0492:                        cmds.append(cmd)
>>      0493:                    vardeps.add('CONVERSION_CMD:' + ctype)
>>      0494:                    subimage = type + "." + ctype
>> Exception: TypeError: can only concatenate str (not "NoneType") to str
>>
>> ERROR: Parsing halted due to errors, see error messages above
>> --
>>
>> Fail with human readable error if no CONVERSION_CMD is defined for
>> any defined subtype.
>>
>> Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com>
>> ---
>>  meta/classes-recipe/image_types.bbclass | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/meta/classes-recipe/image_types.bbclass
>> b/meta/classes-recipe/image_types.bbclass
>> index e6ef0ce11e..326602d960 100644
>> --- a/meta/classes-recipe/image_types.bbclass
>> +++ b/meta/classes-recipe/image_types.bbclass
>> @@ -44,6 +44,10 @@ def imagetypes_getdepends(d):
>>                  deprecated.add(var)
>>
>>          for ctype in resttypes:
>> +            ctype_cmd = d.getVar('CONVERSION_CMD:' + ctype)
>> +            if not ctype_cmd:
>> +                bb.fatal('No CONVERSION_CMD defined for subtype "%s"'
>> +                         ' - possibly invalid conversion type name or
>> missing support class' % ctype)
>>              adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype), deps)
>>              adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype), deps)
>>
>> --
>> 2.43.0
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#235513):
>> https://lists.openembedded.org/g/openembedded-core/message/235513
>> Mute This Topic: https://lists.openembedded.org/mt/118885182/1997914
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>> raj.khem@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>
diff mbox series

Patch

diff --git a/meta/classes-recipe/image_types.bbclass b/meta/classes-recipe/image_types.bbclass
index e6ef0ce11e..326602d960 100644
--- a/meta/classes-recipe/image_types.bbclass
+++ b/meta/classes-recipe/image_types.bbclass
@@ -44,6 +44,10 @@  def imagetypes_getdepends(d):
                 deprecated.add(var)
 
         for ctype in resttypes:
+            ctype_cmd = d.getVar('CONVERSION_CMD:' + ctype)
+            if not ctype_cmd:
+                bb.fatal('No CONVERSION_CMD defined for subtype "%s"'
+                         ' - possibly invalid conversion type name or missing support class' % ctype)
             adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype), deps)
             adddep(d.getVar("COMPRESS_DEPENDS_%s" % ctype), deps)