summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2016-03-07 15:51:14 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-09 16:36:31 +0000
commit588f14370372a66329b54606071175519ce88f1e (patch)
tree5301fde1dacad6e1c099fbd0c6d1ae59e762a203
parent0d02159c8d66bb136f7da2c10fda7d1a57f40cec (diff)
downloadopenembedded-core-contrib-588f14370372a66329b54606071175519ce88f1e.tar.gz
openembedded-core-contrib-588f14370372a66329b54606071175519ce88f1e.tar.bz2
openembedded-core-contrib-588f14370372a66329b54606071175519ce88f1e.zip
image.bbclass: support chaining compression (aka conversion) commands
It makes sense to use the compression mechanism also for conversion, for example of a whole-disk image into .vdi (VirtualBox). That part already works, like this: COMPRESSIONTYPES_append = " vdi" COMPRESS_CMD_vdi = "qemu-img convert -O vdi ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type} ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.vdi" IMAGE_DEPENDS_vdi = "qemu-native" But then it also makes sense to allow compressing the resulting image, which only works after enhancing the image.bbclass. For example, suppose a custom image command produces "dsk" images. Then it becomes possible to set IMAGE_FSTYPES = " dsk.xz dsk.vdi.xz" and do_image_dsk will automatically produce the intermediate images, convert to dsk.xz resp. dsk.vdi -> dsk.vdi.xz and delete all intermediate images. Symlinks are also set correctly. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/image.bbclass27
1 files changed, 24 insertions, 3 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 8b6c30bce8..c61d8140c5 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -303,6 +303,10 @@ python () {
basetype = type[:-len("." + ctype)]
break
+ if basetype != type:
+ # New base type itself might be generated by a conversion command.
+ basetype = _image_base_type(basetype)
+
return basetype
basetypes = {}
@@ -379,18 +383,35 @@ python () {
bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
cmds.append(localdata.expand("\tcd ${DEPLOY_DIR_IMAGE}"))
- for bt in basetypes[t]:
+ rm_tmp_images = set()
+ def gen_conversion_cmds(bt):
for ctype in ctypes:
if bt.endswith("." + ctype):
+ type = bt[0:-len(ctype) - 1]
+ # Create input image first.
+ gen_conversion_cmds(type)
+ localdata.setVar('type', type)
cmds.append("\t" + localdata.getVar("COMPRESS_CMD_" + ctype, True))
vardeps.add('COMPRESS_CMD_' + ctype)
- subimages.append(realt + "." + ctype)
+ subimages.append(type + "." + ctype)
+ 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)
+ localdata.setVar('type', realt)
if realt not in alltypes:
- cmds.append(localdata.expand("\trm ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
+ rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
else:
subimages.append(realt)
+ # Clean up after applying all conversion commands. Some of them might
+ # use the same input, therefore we cannot delete sooner without applying
+ # some complex dependency analysis.
+ for image in rm_tmp_images:
+ cmds.append("\trm " + image)
+
after = 'do_image'
for dep in typedeps[t]:
after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")