[oe-commits] [openembedded-core] 43/78: image.bbclass: support chaining compression (aka conversion) commands
git at git.openembedded.org
git at git.openembedded.org
Wed Mar 9 00:10:20 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit eb24bce1c06365c9a797c8046c5abe3329941cc8
Author: Patrick Ohly <patrick.ohly at intel.com>
AuthorDate: Mon Mar 7 15:51:14 2016 +0100
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 at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/classes/image.bbclass | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 8b6c30b..c61d814 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(".", "_")
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list