<div dir="ltr">Hmm. In local.conf.sample.extended, I find:<div><div><br></div><div># Additional image generation features</div><div>#</div><div># The following is a list of classes to import to use in the generation of images</div><div># currently an example class is image_types_uboot</div><div># IMAGE_CLASSES = " image_types_uboot"</div><div><br></div></div><div>Indeed, image_types_uboot isn't part of IMAGE_CLASSES by default. I'd expect a machine config to add wic to IMAGE_CLASSES if it needs wic output.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <span dir="ltr"><<a href="mailto:ed.bartosh@linux.intel.com" target="_blank">ed.bartosh@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Jan 30, 2017 at 09:27:54AM -0800, Rick Altherr wrote:<br>
> Why didn't you make this image_types_wic.bbclass and use IMAGE_CLASSES to<br>
> load it?<br>
<br>
</span>Because of the following:<br>
- IMAGE_CLASSES[doc] = "A list of classes that all images should<br>
inherit." I'm not sure all images should include wic class. I'll probably<br>
make this inheritance conditional.<br>
- so far IMAGE_CLASSES is used for qemuboot, image_types,<br>
image_types_uboot and testimage,<br>
so the usage is more or less follows the description. wic is out of<br>
that usage scenario, I believe.<br>
- 'inherit image_wic' is more explicit than IMAGE_CLASSES +=<br>
"image_types"\n inherit ${IMAGE_CLASSES}<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
><br>
> On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <<a href="mailto:ed.bartosh@linux.intel.com">ed.bartosh@linux.intel.com</a>><br>
> wrote:<br>
><br>
> > There is a lot of wic code in image.bbclass and image_types.bbclass<br>
> > Having all code separated in one file should make it more readable<br>
> > and easier to maintain.<br>
> ><br>
> > Signed-off-by: Ed Bartosh <<a href="mailto:ed.bartosh@linux.intel.com">ed.bartosh@linux.intel.com</a>><br>
> > ---<br>
> > meta/classes/image-wic.bbclass | 120 ++++++++++++++++++++++++++++++<br>
> > +++++++++<br>
> > meta/classes/image.bbclass | 25 +-------<br>
> > meta/classes/image_types.<wbr>bbclass | 95 ------------------------------<wbr>-<br>
> > 3 files changed, 122 insertions(+), 118 deletions(-)<br>
> > create mode 100644 meta/classes/image-wic.bbclass<br>
> ><br>
> > diff --git a/meta/classes/image-wic.<wbr>bbclass b/meta/classes/image-wic.<br>
> > bbclass<br>
> > new file mode 100644<br>
> > index 0000000..2acfd65<br>
> > --- /dev/null<br>
> > +++ b/meta/classes/image-wic.<wbr>bbclass<br>
> > @@ -0,0 +1,120 @@<br>
> > +# The WICVARS variable is used to define list of bitbake variables used<br>
> > in wic code<br>
> > +# variables from this list is written to <image>.env file<br>
> > +WICVARS ?= "\<br>
> > + BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD HDDDIR<br>
> > IMAGE_BASENAME IMAGE_BOOT_FILES \<br>
> > + IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD ISODIR<br>
> > MACHINE_ARCH RECIPE_SYSROOT_NATIVE \<br>
> > + ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR<br>
> > TARGET_SYS"<br>
> > +<br>
> > +WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.<wbr>wks"<br>
> > +WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"<br>
> > +WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/<wbr>wic' % p for p in<br>
> > '${BBPATH}'.split(':'))}:${@':<wbr>'.join('%s/scripts/lib/wic/<wbr>canned-wks' % l<br>
> > for l in '${BBPATH}:${COREBASE}'.split(<wbr>':'))}"<br>
> > +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.<wbr>split(),<br>
> > '${WKS_SEARCH_PATH}') or ''}"<br>
> > +<br>
> > +def wks_search(files, search_path):<br>
> > + for f in files:<br>
> > + if os.path.isabs(f):<br>
> > + if os.path.exists(f):<br>
> > + return f<br>
> > + else:<br>
> > + searched = bb.utils.which(search_path, f)<br>
> > + if searched:<br>
> > + return searched<br>
> > +<br>
> > +WIC_CREATE_EXTRA_ARGS ?= ""<br>
> > +<br>
> > +IMAGE_CMD_wic () {<br>
> > + out="${IMGDEPLOYDIR}/${IMAGE_<wbr>NAME}"<br>
> > + wks="${WKS_FULL_PATH}"<br>
> > + if [ -z "$wks" ]; then<br>
> > + bbfatal "No kickstart files from WKS_FILES were found:<br>
> > ${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."<br>
> > + fi<br>
> > +<br>
> > + BUILDDIR="${TOPDIR}" wic create "$wks" --vars<br>
> > "${STAGING_DIR}/${MACHINE}/<wbr>imgdata/" -e "${IMAGE_BASENAME}" -o "$out/"<br>
> > ${WIC_CREATE_EXTRA_ARGS}<br>
> > + mv "$out/$(basename "${wks%.wks}")"*.direct<br>
> > "$out${IMAGE_NAME_SUFFIX}.wic"<br>
> > + rm -rf "$out/"<br>
> > +}<br>
> > +IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES"<br>
> > +<br>
> > +# Rebuild when the wks file or vars in WICVARS change<br>
> > +USING_WIC = "${@bb.utils.contains_any('<wbr>IMAGE_FSTYPES', 'wic ' + '<br>
> > '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), '1', '', d)}"<br>
> > +WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' %<br>
> > os.path.exists('${WKS_FULL_<wbr>PATH}') if '${USING_WIC}' else ''}"<br>
> > +do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"<br>
> > +do_image_wic[depends] += "wic-tools:do_build"<br>
> > +<br>
> > +python () {<br>
> > + if d.getVar('USING_WIC') and 'do_bootimg' in d:<br>
> > + bb.build.addtask('do_image_<wbr>wic', '', 'do_bootimg', d)<br>
> > +}<br>
> > +<br>
> > +python do_write_wks_template () {<br>
> > + """Write out expanded template contents to WKS_FULL_PATH."""<br>
> > + import re<br>
> > +<br>
> > + template_body = d.getVar('_WKS_TEMPLATE')<br>
> > +<br>
> > + # Remove any remnant variable references left behind by the expansion<br>
> > + # due to undefined variables<br>
> > + expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")<br>
> > + while True:<br>
> > + new_body = re.sub(expand_var_regexp, '', template_body)<br>
> > + if new_body == template_body:<br>
> > + break<br>
> > + else:<br>
> > + template_body = new_body<br>
> > +<br>
> > + wks_file = d.getVar('WKS_FULL_PATH')<br>
> > + with open(wks_file, 'w') as f:<br>
> > + f.write(template_body)<br>
> > +}<br>
> > +<br>
> > +python () {<br>
> > + if d.getVar('USING_WIC'):<br>
> > + wks_file_u = d.getVar('WKS_FULL_PATH', False)<br>
> > + wks_file = d.expand(wks_file_u)<br>
> > + base, ext = os.path.splitext(wks_file)<br>
> > + if ext == '.in' and os.path.exists(wks_file):<br>
> > + wks_out_file = os.path.join(d.getVar('<wbr>WORKDIR'),<br>
> > os.path.basename(base))<br>
> > + d.setVar('WKS_FULL_PATH', wks_out_file)<br>
> > + d.setVar('WKS_TEMPLATE_PATH', wks_file_u)<br>
> > + d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True')<br>
> > +<br>
> > + # We need to re-parse each time the file changes, and bitbake<br>
> > + # needs to be told about that explicitly.<br>
> > + bb.parse.mark_dependency(d, wks_file)<br>
> > +<br>
> > + try:<br>
> > + with open(wks_file, 'r') as f:<br>
> > + body = f.read()<br>
> > + except (IOError, OSError) as exc:<br>
> > + pass<br>
> > + else:<br>
> > + # Previously, I used expandWithRefs to get the dependency<br>
> > list<br>
> > + # and add it to WICVARS, but there's no point re-parsing<br>
> > the<br>
> > + # file in process_wks_template as well, so just put it in<br>
> > + # a variable and let the metadata deal with the deps.<br>
> > + d.setVar('_WKS_TEMPLATE', body)<br>
> > + bb.build.addtask('do_write_<wbr>wks_template',<br>
> > 'do_image_wic', None, d)<br>
> > +}<br>
> > +<br>
> > +#<br>
> > +# Write environment variables used by wic<br>
> > +# to tmp/sysroots/<machine>/<wbr>imgdata/<image>.env<br>
> > +#<br>
> > +python do_rootfs_wicenv () {<br>
> > + wicvars = d.getVar('WICVARS')<br>
> > + if not wicvars:<br>
> > + return<br>
> > +<br>
> > + stdir = d.getVar('STAGING_DIR')<br>
> > + outdir = os.path.join(stdir, d.getVar('MACHINE'), 'imgdata')<br>
> > + bb.utils.mkdirhier(outdir)<br>
> > + basename = d.getVar('IMAGE_BASENAME')<br>
> > + with open(os.path.join(outdir, basename) + '.env', 'w') as envf:<br>
> > + for var in wicvars.split():<br>
> > + value = d.getVar(var)<br>
> > + if value:<br>
> > + envf.write('%s="%s"\n' % (var, value.strip()))<br>
> > +}<br>
> > +addtask do_rootfs_wicenv after do_image before do_image_wic<br>
> > +do_rootfs_wicenv[vardeps] += "${WICVARS}"<br>
> > +do_rootfs_wicenv[prefuncs] = 'set_image_size'<br>
> > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass<br>
> > index 13fd996..1a549e9 100644<br>
> > --- a/meta/classes/image.bbclass<br>
> > +++ b/meta/classes/image.bbclass<br>
> > @@ -192,6 +192,8 @@ python () {<br>
> > IMAGE_CLASSES += "image_types"<br>
> > inherit ${IMAGE_CLASSES}<br>
> ><br>
> > +inherit image-wic<br>
> > +<br>
> > IMAGE_POSTPROCESS_COMMAND ?= ""<br>
> ><br>
> > # some default locales<br>
> > @@ -332,29 +334,6 @@ fakeroot python do_image_qa () {<br>
> > }<br>
> > addtask do_image_qa after do_image_complete before do_build<br>
> ><br>
> > -#<br>
> > -# Write environment variables used by wic<br>
> > -# to tmp/sysroots/<machine>/<wbr>imgdata/<image>.env<br>
> > -#<br>
> > -python do_rootfs_wicenv () {<br>
> > - wicvars = d.getVar('WICVARS')<br>
> > - if not wicvars:<br>
> > - return<br>
> > -<br>
> > - stdir = d.getVar('STAGING_DIR')<br>
> > - outdir = os.path.join(stdir, d.getVar('MACHINE'), 'imgdata')<br>
> > - bb.utils.mkdirhier(outdir)<br>
> > - basename = d.getVar('IMAGE_BASENAME')<br>
> > - with open(os.path.join(outdir, basename) + '.env', 'w') as envf:<br>
> > - for var in wicvars.split():<br>
> > - value = d.getVar(var)<br>
> > - if value:<br>
> > - envf.write('%s="%s"\n' % (var, value.strip()))<br>
> > -}<br>
> > -addtask do_rootfs_wicenv after do_image before do_image_wic<br>
> > -do_rootfs_wicenv[vardeps] += "${WICVARS}"<br>
> > -do_rootfs_wicenv[prefuncs] = 'set_image_size'<br>
> > -<br>
> > def setup_debugfs_variables(d):<br>
> > d.appendVar('IMAGE_ROOTFS', '-dbg')<br>
> > d.appendVar('IMAGE_LINK_NAME', '-dbg')<br>
> > diff --git a/meta/classes/image_types.<wbr>bbclass b/meta/classes/image_types.<br>
> > bbclass<br>
> > index ad95dc6..e2ecf93 100644<br>
> > --- a/meta/classes/image_types.<wbr>bbclass<br>
> > +++ b/meta/classes/image_types.<wbr>bbclass<br>
> > @@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {<br>
> ><br>
> > IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o<br>
> > ${IMGDEPLOYDIR}/${IMAGE_NAME}$<wbr>{IMAGE_NAME_SUFFIX}.ubifs ${MKUBIFS_ARGS}"<br>
> ><br>
> > -WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.<wbr>wks"<br>
> > -WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"<br>
> > -WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/<wbr>wic' % p for p in<br>
> > '${BBPATH}'.split(':'))}:${@':<wbr>'.join('%s/scripts/lib/wic/<wbr>canned-wks' % l<br>
> > for l in '${BBPATH}:${COREBASE}'.split(<wbr>':'))}"<br>
> > -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.<wbr>split(),<br>
> > '${WKS_SEARCH_PATH}') or ''}"<br>
> > -<br>
> > -def wks_search(files, search_path):<br>
> > - for f in files:<br>
> > - if os.path.isabs(f):<br>
> > - if os.path.exists(f):<br>
> > - return f<br>
> > - else:<br>
> > - searched = bb.utils.which(search_path, f)<br>
> > - if searched:<br>
> > - return searched<br>
> > -<br>
> > -WIC_CREATE_EXTRA_ARGS ?= ""<br>
> > -<br>
> > -IMAGE_CMD_wic () {<br>
> > - out="${IMGDEPLOYDIR}/${IMAGE_<wbr>NAME}"<br>
> > - wks="${WKS_FULL_PATH}"<br>
> > - if [ -z "$wks" ]; then<br>
> > - bbfatal "No kickstart files from WKS_FILES were found:<br>
> > ${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."<br>
> > - fi<br>
> > -<br>
> > - BUILDDIR="${TOPDIR}" wic create "$wks" --vars<br>
> > "${STAGING_DIR}/${MACHINE}/<wbr>imgdata/" -e "${IMAGE_BASENAME}" -o "$out/"<br>
> > ${WIC_CREATE_EXTRA_ARGS}<br>
> > - mv "$out/$(basename "${wks%.wks}")"*.direct<br>
> > "$out${IMAGE_NAME_SUFFIX}.wic"<br>
> > - rm -rf "$out/"<br>
> > -}<br>
> > -IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES"<br>
> > -<br>
> > -# Rebuild when the wks file or vars in WICVARS change<br>
> > -USING_WIC = "${@bb.utils.contains_any('<wbr>IMAGE_FSTYPES', 'wic ' + '<br>
> > '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), '1', '', d)}"<br>
> > -WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' %<br>
> > os.path.exists('${WKS_FULL_<wbr>PATH}') if '${USING_WIC}' else ''}"<br>
> > -do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"<br>
> > -do_image_wic[depends] += "wic-tools:do_build"<br>
> > -<br>
> > -python () {<br>
> > - if d.getVar('USING_WIC') and 'do_bootimg' in d:<br>
> > - bb.build.addtask('do_image_<wbr>wic', '', 'do_bootimg', d)<br>
> > -}<br>
> > -<br>
> > -python do_write_wks_template () {<br>
> > - """Write out expanded template contents to WKS_FULL_PATH."""<br>
> > - import re<br>
> > -<br>
> > - template_body = d.getVar('_WKS_TEMPLATE')<br>
> > -<br>
> > - # Remove any remnant variable references left behind by the expansion<br>
> > - # due to undefined variables<br>
> > - expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")<br>
> > - while True:<br>
> > - new_body = re.sub(expand_var_regexp, '', template_body)<br>
> > - if new_body == template_body:<br>
> > - break<br>
> > - else:<br>
> > - template_body = new_body<br>
> > -<br>
> > - wks_file = d.getVar('WKS_FULL_PATH')<br>
> > - with open(wks_file, 'w') as f:<br>
> > - f.write(template_body)<br>
> > -}<br>
> > -<br>
> > -python () {<br>
> > - if d.getVar('USING_WIC'):<br>
> > - wks_file_u = d.getVar('WKS_FULL_PATH', False)<br>
> > - wks_file = d.expand(wks_file_u)<br>
> > - base, ext = os.path.splitext(wks_file)<br>
> > - if ext == '.in' and os.path.exists(wks_file):<br>
> > - wks_out_file = os.path.join(d.getVar('<wbr>WORKDIR'),<br>
> > os.path.basename(base))<br>
> > - d.setVar('WKS_FULL_PATH', wks_out_file)<br>
> > - d.setVar('WKS_TEMPLATE_PATH', wks_file_u)<br>
> > - d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True')<br>
> > -<br>
> > - # We need to re-parse each time the file changes, and bitbake<br>
> > - # needs to be told about that explicitly.<br>
> > - bb.parse.mark_dependency(d, wks_file)<br>
> > -<br>
> > - try:<br>
> > - with open(wks_file, 'r') as f:<br>
> > - body = f.read()<br>
> > - except (IOError, OSError) as exc:<br>
> > - pass<br>
> > - else:<br>
> > - # Previously, I used expandWithRefs to get the dependency<br>
> > list<br>
> > - # and add it to WICVARS, but there's no point re-parsing<br>
> > the<br>
> > - # file in process_wks_template as well, so just put it in<br>
> > - # a variable and let the metadata deal with the deps.<br>
> > - d.setVar('_WKS_TEMPLATE', body)<br>
> > - bb.build.addtask('do_write_<wbr>wks_template',<br>
> > 'do_image_wic', None, d)<br>
> > -}<br>
> > -<br>
> > EXTRA_IMAGECMD = ""<br>
> ><br>
> > inherit siteinfo<br>
> > @@ -380,7 +289,3 @@ IMAGE_EXTENSION_live = "hddimg iso"<br>
> > # The IMAGE_TYPES_MASKED variable will be used to mask out from the<br>
> > IMAGE_FSTYPES,<br>
> > # images that will not be built at do_rootfs time: vmdk, vdi, qcow2,<br>
> > hdddirect, hddimg, iso, etc.<br>
> > IMAGE_TYPES_MASKED ?= ""<br>
> > -<br>
> > -# The WICVARS variable is used to define list of bitbake variables used<br>
> > in wic code<br>
> > -# variables from this list is written to <image>.env file<br>
> > -WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD HDDDIR<br>
> > IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME IMAGE_ROOTFS<br>
> > INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH RECIPE_SYSROOT_NATIVE<br>
> > ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS"<br>
> > --<br>
> > 2.1.4<br>
> ><br>
> > --<br>
> > ______________________________<wbr>_________________<br>
> > Openembedded-core mailing list<br>
> > <a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
> > <a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
> ><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
--<br>
Regards,<br>
Ed<br>
</font></span></blockquote></div><br></div>