Skip to contentSkip to conversation

image_types: catch exception if no CONVERSION_CMD is defined

PATCH In review Talel BELHAJ SALEM 2 participants 3 messages Apr 17 – Apr 21

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image_types: catch exception if no CONVERSION_CMD is defined

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.

---
 meta/classes-recipe/image_types.bbclass | 4 ++++
 1 file changed, 4 insertions(+)
meta/classes-recipe/image_types.bbclass +4 -0
index e6ef0ce11e..326602d960 100644
@@ -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)
 
Signature · 1 line
2.43.0
#1 lore raw

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

Quoted 91 lines · BELHADJ SALEM Talel via lists.openembedded.org

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.

---
 meta/classes-recipe/image_types.bbclass | 4 ++++
 1 file changed, 4 insertions(+)
meta/classes-recipe/image_types.bbclass +4 -1
index e6ef0ce11e..326602d960 100644
@@ -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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

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

Quoted 111 lines · Khem Raj

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

Quoted 92 lines · BELHADJ SALEM Talel via lists.openembedded.org

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.

---
 meta/classes-recipe/image_types.bbclass | 4 ++++
 1 file changed, 4 insertions(+)
meta/classes-recipe/image_types.bbclass +4 -1
index e6ef0ce11e..326602d960 100644
@@ -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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-