[OE-core] [PATCH v3 4/4] image.bbclass: prefer specialized image creation methods over chaining
Ed Bartosh
ed.bartosh at linux.intel.com
Tue Jun 7 14:17:56 UTC 2016
From: Patrick Ohly <patrick.ohly at intel.com>
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 <patrick.ohly at intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh at intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
meta/classes/image.bbclass | 17 ++++++++++-------
meta/classes/image_types.bbclass | 16 +++++++++++++---
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 47d1c9f..ebbdf06 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -326,7 +326,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]= []
@@ -345,7 +345,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:
@@ -396,14 +396,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:
@@ -418,7 +421,7 @@ python () {
for type in basetypes[t]:
# Probably t == bt, but better check explicitly, perhaps that'll change.
- bt = image_split_type(type, ctypes)[0]
+ bt = image_split_type(type, ctypes, d)[0]
gen_conversion_cmds(bt, type)
localdata.setVar('type', realt)
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index 225142b..8e79731 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -9,10 +9,20 @@ IMAGE_NAME_SUFFIX ??= ".rootfs"
# set this value to 2048 (2MiB alignment).
IMAGE_ROOTFS_ALIGNMENT ?= "1"
-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)]
@@ -21,7 +31,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)
@@ -38,7 +48,7 @@ def image_getdepends(d):
deps = []
ctypes = set(d.getVar('COMPRESSIONTYPES', 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("COMPRESS_DEPENDS_%s" % ctype, True), deps)
for typedepends in (d.getVar("IMAGE_TYPEDEP_%s" % basetype, True) or "").split():
--
2.1.4
More information about the Openembedded-core
mailing list