From: Patrick Ohly <[email protected]> If a certain image type can be created both by applying conversion commands to a base type as well as via a specialized command (like a fictious IMAGE_CMD_ext4.xz, or some dedicated task, as indicated by IMAGE_TYPES_MASKED = ext4.xz), then pick the more specialized method and skip generating the conversion commands.
That way developers can choose between using the builtin conversion support or re-implementing certain types, for example more efficiently without intermediate files. Fixes: [YOCTO #9076] Signed-off-by: Patrick Ohly <[email protected]> Signed-off-by: Ed Bartosh <[email protected]> --- meta/classes/image.bbclass | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 5c68b01..06c0918 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -149,10 +149,20 @@ inherit ${IMAGE_TYPE_live} IMAGE_TYPE_vm = '${@ "image-vm" if image_type_active("hdddirect", d) else ""}' inherit ${IMAGE_TYPE_vm} -def image_split_type(type, allctypes): +def image_split_type(type, allctypes, d): '''Returns (basetype, set of compression types in use).''' basetype = type compressiontypes = set() + + # Abort stripping the type further if "basetype" has a matching + # IMAGE_CMD or is a masked image type. For example, if there + # was a fictional IMAGE_CMD_ext4.xz which creates a compressed + # file directly, then we should use that instead of using + # IMAGE_CMD_ext4 + CONVERSION_CMD_xz. + if d.getVar('IMAGE_CMD_' + basetype, True) or \ + basetype in d.getVar('IMAGE_TYPES_MASKED', True).split(): + return (basetype, compressiontypes) + for ctype in allctypes: if type.endswith("." + ctype): basetype = type[:-len("." + ctype)] @@ -161,7 +171,7 @@ def image_split_type(type, allctypes): if basetype != type: # New base type itself might be generated by a conversion command. - basetype, newctypes = image_split_type(basetype, allctypes) + basetype, newctypes = image_split_type(basetype, allctypes, d) compressiontypes.update(newctypes) return (basetype, compressiontypes) @@ -178,7 +188,7 @@ def image_getdepends(d): deps = [] ctypes = set(d.getVar('CONVERSIONTYPES', True).split()) for type in (d.getVar('IMAGE_FSTYPES', True) or "").split(): - basetype, compressiontypes = image_split_type(type, ctypes) + basetype, compressiontypes = image_split_type(type, ctypes, d) for ctype in compressiontypes: adddep(d.getVar("CONVERSION_DEPENDS_%s" % ctype, True) if d.getVar("CONVERSION_CMD_%s" % ctype, True) else d.getVar("COMPRESSION_DEPENDS_%s" % ctype, True), @@ -369,7 +379,7 @@ python () { alltypes.append("debugfs_" + t) def _add_type(t): - baset = image_split_type(t, ctypes)[0] + baset = image_split_type(t, ctypes, d)[0] input_t = t if baset not in basetypes: basetypes[baset]= [] @@ -388,7 +398,7 @@ python () { if dep not in alltypes: alltypes.append(dep) _add_type(dep) - basedep = image_split_type(dep, ctypes)[0] + basedep = image_split_type(dep, ctypes, d)[0] typedeps[baset].add(basedep) if baset != input_t: @@ -439,14 +449,17 @@ python () { d.delVarFlag('IMAGE_CMD_' + realt, 'func') rm_tmp_images = set() - def gen_conversion_cmds(bt): + def gen_conversion_cmds(basetype, type): + if basetype == type: + # Done, no further conversions needed. + return for ctype in ctypes: - if bt.endswith("." + ctype): - type = bt[0:-len(ctype) - 1] + if type.endswith("." + ctype): + type = type[0:-len(ctype) - 1] if type.startswith("debugfs_"): type = type[8:] # Create input image first. - gen_conversion_cmds(type) + gen_conversion_cmds(basetype, type) localdata.setVar('type', type) cmd = "\t" + (localdata.getVar("CONVERSION_CMD_" + ctype, True) or localdata.getVar("COMPRESS_CMD_" + ctype, True)) if cmd not in cmds: @@ -459,8 +472,10 @@ python () { if type not in alltypes: rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) - for bt in basetypes[t]: - gen_conversion_cmds(bt) + for type in basetypes[t]: + # Probably t == bt, but better check explicitly, perhaps that'll change. + bt = image_split_type(type, ctypes, d)[0] + gen_conversion_cmds(bt, type) localdata.setVar('type', realt) if t not in alltypes: -- 2.1.4 -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
