summaryrefslogtreecommitdiffstats
path: root/meta/classes/image.bbclass
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:58:10 +0000
commitba57ba1942546045907a7e1831515ad2da420ab2 (patch)
tree468db28a9962f957b9f4f57783adca523f02df93 /meta/classes/image.bbclass
parent5ac3dc76a5afc2ed35b1abfc8e330e0c580eadf0 (diff)
downloadpoky-ba57ba1942546045907a7e1831515ad2da420ab2.tar.gz
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. (From OE-Core rev: 588f14370372a66329b54606071175519ce88f1e) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/image.bbclass')
-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 () {
303 basetype = type[:-len("." + ctype)] 303 basetype = type[:-len("." + ctype)]
304 break 304 break
305 305
306 if basetype != type:
307 # New base type itself might be generated by a conversion command.
308 basetype = _image_base_type(basetype)
309
306 return basetype 310 return basetype
307 311
308 basetypes = {} 312 basetypes = {}
@@ -379,18 +383,35 @@ python () {
379 bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t) 383 bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
380 cmds.append(localdata.expand("\tcd ${DEPLOY_DIR_IMAGE}")) 384 cmds.append(localdata.expand("\tcd ${DEPLOY_DIR_IMAGE}"))
381 385
382 for bt in basetypes[t]: 386 rm_tmp_images = set()
387 def gen_conversion_cmds(bt):
383 for ctype in ctypes: 388 for ctype in ctypes:
384 if bt.endswith("." + ctype): 389 if bt.endswith("." + ctype):
390 type = bt[0:-len(ctype) - 1]
391 # Create input image first.
392 gen_conversion_cmds(type)
393 localdata.setVar('type', type)
385 cmds.append("\t" + localdata.getVar("COMPRESS_CMD_" + ctype, True)) 394 cmds.append("\t" + localdata.getVar("COMPRESS_CMD_" + ctype, True))
386 vardeps.add('COMPRESS_CMD_' + ctype) 395 vardeps.add('COMPRESS_CMD_' + ctype)
387 subimages.append(realt + "." + ctype) 396 subimages.append(type + "." + ctype)
397 if type not in alltypes:
398 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
399
400 for bt in basetypes[t]:
401 gen_conversion_cmds(bt)
388 402
403 localdata.setVar('type', realt)
389 if realt not in alltypes: 404 if realt not in alltypes:
390 cmds.append(localdata.expand("\trm ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) 405 rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"))
391 else: 406 else:
392 subimages.append(realt) 407 subimages.append(realt)
393 408
409 # Clean up after applying all conversion commands. Some of them might
410 # use the same input, therefore we cannot delete sooner without applying
411 # some complex dependency analysis.
412 for image in rm_tmp_images:
413 cmds.append("\trm " + image)
414
394 after = 'do_image' 415 after = 'do_image'
395 for dep in typedeps[t]: 416 for dep in typedeps[t]:
396 after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_") 417 after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_")