From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it0-f52.google.com (mail-it0-f52.google.com [209.85.214.52]) by mail.openembedded.org (Postfix) with ESMTP id 9209177404 for ; Mon, 30 Jan 2017 19:07:23 +0000 (UTC) Received: by mail-it0-f52.google.com with SMTP id r185so108705902ita.0 for ; Mon, 30 Jan 2017 11:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/Qulhmh2edwwx2lnZ3uIuIf59DfMwX8sQM0JFRkdGkQ=; b=KM82v8uEUpjPWAyrHvjRrjIrEY1g/vkjAAGgzZHPqH+tAi9+N4OJHjrPGXj+SygXt0 C7U0z5vOKinZ+BDvrVqzjDitsZC2cpFt5ltcV0+jwcRqYB4NC/cIKTPG6+nr4ABK0k+t n2z2ECVXYENK2t5L5NWxYpvkKev4xmtFClP9a8BCF9AwV+x7iP3yu01xMLFWL0RHAhK/ 1c1dgHKEb5idrScaVJv/S8vFSsksqInDMETC3pf+O2EPC7SQUGnqgVJIRVXfgBisAw29 JK4PAjDzBOwzcyc4qDUIMj1Ad9hxEMbt90yED6nQhZZ2kBpX/ekLykGlm0Qq5lgHZXg1 d3Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/Qulhmh2edwwx2lnZ3uIuIf59DfMwX8sQM0JFRkdGkQ=; b=BfpP8Vn+Znb4TBoR38yt6qHCjfSdGNgc9p15vTGFeZ9ljVrLCjh25eUUHQ/2XR0yVQ 8Xz6ubjzqru2XbzrKKXtNd6EQPIB4SNbcapypqVVy4DsxshntFHDCWOKWMP0QX9Q5roR QqttTV+Wat4GsyqZ5R2RGoF7sXEvxUG6jCRl3KlUPtidKuSsvbgaTIOiyPVTVpyXy0zf eGyzqeN2zqxl12lVzfd+vy75CtgpI2MhTPhjY8wZ9oMbUmkIVs24BP1dPirVljqzMQN/ 0uGMagDS/mqMgYR7eahXQWsHGYSufYofqP+D7w6+FILSdrRrbMPxEqOrfS4KnKyp9qRH SrIg== X-Gm-Message-State: AIkVDXJGMddzyVdZ9C87NhjfSKNzo5jHZbLbeUOSonMdIE+LuLwwEUT6DCELfA0AnBhu9zui9DlyGGvhoD1Vxu7k X-Received: by 10.36.64.70 with SMTP id n67mr16299448ita.21.1485803243381; Mon, 30 Jan 2017 11:07:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.133.226 with HTTP; Mon, 30 Jan 2017 11:07:22 -0800 (PST) In-Reply-To: <20170130184254.GA10554@linux.intel.com> References: <257efe25e625e8aaa0f1d435716f0c5f61071700.1485547221.git.ed.bartosh@linux.intel.com> <20170130171832.GA7232@linux.intel.com> <20170130174514.GA19307@linux.intel.com> <20170130181533.GA14744@linux.intel.com> <20170130184254.GA10554@linux.intel.com> From: Rick Altherr Date: Mon, 30 Jan 2017 11:07:22 -0800 Message-ID: To: Ed Bartosh Cc: OE-core Subject: Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2017 19:07:23 -0000 Content-Type: multipart/alternative; boundary=001a1135a57a87a1ca05475486c9 --001a1135a57a87a1ca05475486c9 Content-Type: text/plain; charset=UTF-8 LGTM On Mon, Jan 30, 2017 at 10:42 AM, Ed Bartosh wrote: > On Mon, Jan 30, 2017 at 10:41:27AM -0800, Rick Altherr wrote: > > Agreed. What if it was image_types_wic.bbclass and you did something > > similar to build_uboot() in image.bbclass? > > > > I can do this for now: > IMAGE_TYPE_wic = "image_type_wic" > inherit ${IMAGE_TYPE_wic} > > which is the same as 'inherit image_type_wic', just takes 2 lines, but > looks more consistent. > > does this look ok? > > > On Mon, Jan 30, 2017 at 10:15 AM, Ed Bartosh > > > wrote: > > > > > On Mon, Jan 30, 2017 at 10:25:59AM -0800, Rick Altherr wrote: > > > > I'm not clear on which path is the preferred one. There are lots of > bits > > > > and pieces in image_types.bbclass that implement various image types. > > > > uboot got added as a separate class at some point. The comments in > > > > local.conf.sample.extended imply IMAGE_CLASSES should be used to load > > > > additional image_types_* classes to add support for additional image > > > > types. Having the wic image type implemented in a separate > > > > image-wic.bbclass that is directly inherited by image.bbclass adds a > 3rd > > > > approach. Which one do we want contributors to use in the future? > > > > > > > > > > I didn't want to create even more confusion. What I wanted is stated > in the > > > commit message - to put existing wic code into a file for better > > > maintenance. If this is more confusing than having wic code in > different > > > places of image.class and image_types.class then we can just drop this > > > patch. However, I personally find it more maintainable this way. > > > > > > Suggesting people to change machine configs just because wic code is > > > moved to separate file doesn't look good to me either. > > > > > > > On Mon, Jan 30, 2017 at 9:45 AM, Ed Bartosh < > ed.bartosh@linux.intel.com> > > > > wrote: > > > > > > > > > On Mon, Jan 30, 2017 at 09:47:42AM -0800, Rick Altherr wrote: > > > > > > Hmm. In local.conf.sample.extended, I find: > > > > > > > > > > > > # Additional image generation features > > > > > > # > > > > > > # The following is a list of classes to import to use in the > > > generation > > > > > of > > > > > > images > > > > > > # currently an example class is image_types_uboot > > > > > > # IMAGE_CLASSES = " image_types_uboot" > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > So far all machine configs add wic to IMAGE_TYPES and it works just > > > > > fine. Why to change? > > > > > > > > > > > On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh < > > > ed.bartosh@linux.intel.com> > > > > > > wrote: > > > > > > > > > > > > > On Mon, Jan 30, 2017 at 09:27:54AM -0800, Rick Altherr wrote: > > > > > > > > Why didn't you make this image_types_wic.bbclass and use > > > > > IMAGE_CLASSES to > > > > > > > > load it? > > > > > > > > > > > > > > Because of the following: > > > > > > > - IMAGE_CLASSES[doc] = "A list of classes that all images > should > > > > > > > inherit." I'm not sure all images should include wic class. > I'll > > > > > probably > > > > > > > make this inheritance conditional. > > > > > > > - so far IMAGE_CLASSES is used for qemuboot, image_types, > > > > > > > image_types_uboot and testimage, > > > > > > > so the usage is more or less follows the description. wic is > out > > > of > > > > > > > that usage scenario, I believe. > > > > > > > - 'inherit image_wic' is more explicit than IMAGE_CLASSES += > > > > > > > "image_types"\n inherit ${IMAGE_CLASSES} > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh < > > > > > ed.bartosh@linux.intel.com > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > There is a lot of wic code in image.bbclass and > > > image_types.bbclass > > > > > > > > > Having all code separated in one file should make it more > > > readable > > > > > > > > > and easier to maintain. > > > > > > > > > > > > > > > > > > Signed-off-by: Ed Bartosh > > > > > > > > > --- > > > > > > > > > meta/classes/image-wic.bbclass | 120 > > > > > ++++++++++++++++++++++++++++++ > > > > > > > > > +++++++++ > > > > > > > > > meta/classes/image.bbclass | 25 +------- > > > > > > > > > meta/classes/image_types.bbclass | 95 > > > > > ------------------------------ > > > > > > > - > > > > > > > > > 3 files changed, 122 insertions(+), 118 deletions(-) > > > > > > > > > create mode 100644 meta/classes/image-wic.bbclass > > > > > > > > > > > > > > > > > > diff --git a/meta/classes/image-wic.bbclass > > > > > b/meta/classes/image-wic. > > > > > > > > > bbclass > > > > > > > > > new file mode 100644 > > > > > > > > > index 0000000..2acfd65 > > > > > > > > > --- /dev/null > > > > > > > > > +++ b/meta/classes/image-wic.bbclass > > > > > > > > > @@ -0,0 +1,120 @@ > > > > > > > > > +# The WICVARS variable is used to define list of bitbake > > > variables > > > > > > > used > > > > > > > > > in wic code > > > > > > > > > +# variables from this list is written to .env file > > > > > > > > > +WICVARS ?= "\ > > > > > > > > > + BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE > FAKEROOTCMD > > > > > HDDDIR > > > > > > > > > IMAGE_BASENAME IMAGE_BOOT_FILES \ > > > > > > > > > + IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES > > > INITRD > > > > > > > ISODIR > > > > > > > > > MACHINE_ARCH RECIPE_SYSROOT_NATIVE \ > > > > > > > > > + ROOTFS_SIZE STAGING_DATADIR STAGING_DIR > > > STAGING_LIBDIR > > > > > > > > > TARGET_SYS" > > > > > > > > > + > > > > > > > > > +WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks" > > > > > > > > > +WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks" > > > > > > > > > +WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p > for > > > p in > > > > > > > > > '${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/ > > > > > canned-wks' > > > > > > > % l > > > > > > > > > for l in '${BBPATH}:${COREBASE}'.split(':'))}" > > > > > > > > > +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), > > > > > > > > > '${WKS_SEARCH_PATH}') or ''}" > > > > > > > > > + > > > > > > > > > +def wks_search(files, search_path): > > > > > > > > > + for f in files: > > > > > > > > > + if os.path.isabs(f): > > > > > > > > > + if os.path.exists(f): > > > > > > > > > + return f > > > > > > > > > + else: > > > > > > > > > + searched = bb.utils.which(search_path, f) > > > > > > > > > + if searched: > > > > > > > > > + return searched > > > > > > > > > + > > > > > > > > > +WIC_CREATE_EXTRA_ARGS ?= "" > > > > > > > > > + > > > > > > > > > +IMAGE_CMD_wic () { > > > > > > > > > + out="${IMGDEPLOYDIR}/${IMAGE_NAME}" > > > > > > > > > + wks="${WKS_FULL_PATH}" > > > > > > > > > + if [ -z "$wks" ]; then > > > > > > > > > + bbfatal "No kickstart files from WKS_FILES > were > > > > > found: > > > > > > > > > ${WKS_FILES}. Please set WKS_FILE or WKS_FILES > appropriately." > > > > > > > > > + fi > > > > > > > > > + > > > > > > > > > + BUILDDIR="${TOPDIR}" wic create "$wks" --vars > > > > > > > > > "${STAGING_DIR}/${MACHINE}/imgdata/" -e > "${IMAGE_BASENAME}" -o > > > > > "$out/" > > > > > > > > > ${WIC_CREATE_EXTRA_ARGS} > > > > > > > > > + mv "$out/$(basename "${wks%.wks}")"*.direct > > > > > > > > > "$out${IMAGE_NAME_SUFFIX}.wic" > > > > > > > > > + rm -rf "$out/" > > > > > > > > > +} > > > > > > > > > +IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES" > > > > > > > > > + > > > > > > > > > +# Rebuild when the wks file or vars in WICVARS change > > > > > > > > > +USING_WIC = "${@bb.utils.contains_any('IMAGE_FSTYPES', > 'wic > > > ' + ' > > > > > > > > > '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), > > > '1', > > > > > '', > > > > > > > d)}" > > > > > > > > > +WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % > > > > > > > > > os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else > ''}" > > > > > > > > > +do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}" > > > > > > > > > +do_image_wic[depends] += "wic-tools:do_build" > > > > > > > > > + > > > > > > > > > +python () { > > > > > > > > > + if d.getVar('USING_WIC') and 'do_bootimg' in d: > > > > > > > > > + bb.build.addtask('do_image_wic', '', > 'do_bootimg', d) > > > > > > > > > +} > > > > > > > > > + > > > > > > > > > +python do_write_wks_template () { > > > > > > > > > + """Write out expanded template contents to > > > WKS_FULL_PATH.""" > > > > > > > > > + import re > > > > > > > > > + > > > > > > > > > + template_body = d.getVar('_WKS_TEMPLATE') > > > > > > > > > + > > > > > > > > > + # Remove any remnant variable references left behind > by > > > the > > > > > > > expansion > > > > > > > > > + # due to undefined variables > > > > > > > > > + expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}") > > > > > > > > > + while True: > > > > > > > > > + new_body = re.sub(expand_var_regexp, '', > > > template_body) > > > > > > > > > + if new_body == template_body: > > > > > > > > > + break > > > > > > > > > + else: > > > > > > > > > + template_body = new_body > > > > > > > > > + > > > > > > > > > + wks_file = d.getVar('WKS_FULL_PATH') > > > > > > > > > + with open(wks_file, 'w') as f: > > > > > > > > > + f.write(template_body) > > > > > > > > > +} > > > > > > > > > + > > > > > > > > > +python () { > > > > > > > > > + if d.getVar('USING_WIC'): > > > > > > > > > + wks_file_u = d.getVar('WKS_FULL_PATH', False) > > > > > > > > > + wks_file = d.expand(wks_file_u) > > > > > > > > > + base, ext = os.path.splitext(wks_file) > > > > > > > > > + if ext == '.in' and os.path.exists(wks_file): > > > > > > > > > + wks_out_file = os.path.join(d.getVar(' > WORKDIR'), > > > > > > > > > os.path.basename(base)) > > > > > > > > > + d.setVar('WKS_FULL_PATH', wks_out_file) > > > > > > > > > + d.setVar('WKS_TEMPLATE_PATH', wks_file_u) > > > > > > > > > + d.setVar('WKS_FILE_CHECKSUM', > > > > > '${WKS_TEMPLATE_PATH}:True') > > > > > > > > > + > > > > > > > > > + # We need to re-parse each time the file > changes, > > > and > > > > > > > bitbake > > > > > > > > > + # needs to be told about that explicitly. > > > > > > > > > + bb.parse.mark_dependency(d, wks_file) > > > > > > > > > + > > > > > > > > > + try: > > > > > > > > > + with open(wks_file, 'r') as f: > > > > > > > > > + body = f.read() > > > > > > > > > + except (IOError, OSError) as exc: > > > > > > > > > + pass > > > > > > > > > + else: > > > > > > > > > + # Previously, I used expandWithRefs to > get the > > > > > > > dependency > > > > > > > > > list > > > > > > > > > + # and add it to WICVARS, but there's no > point > > > > > > > re-parsing > > > > > > > > > the > > > > > > > > > + # file in process_wks_template as well, so > > > just > > > > > put > > > > > > > it in > > > > > > > > > + # a variable and let the metadata deal > with > > > the > > > > > deps. > > > > > > > > > + d.setVar('_WKS_TEMPLATE', body) > > > > > > > > > + bb.build.addtask('do_write_wks_template', > > > > > > > > > 'do_image_wic', None, d) > > > > > > > > > +} > > > > > > > > > + > > > > > > > > > +# > > > > > > > > > +# Write environment variables used by wic > > > > > > > > > +# to tmp/sysroots//imgdata/.env > > > > > > > > > +# > > > > > > > > > +python do_rootfs_wicenv () { > > > > > > > > > + wicvars = d.getVar('WICVARS') > > > > > > > > > + if not wicvars: > > > > > > > > > + return > > > > > > > > > + > > > > > > > > > + stdir = d.getVar('STAGING_DIR') > > > > > > > > > + outdir = os.path.join(stdir, d.getVar('MACHINE'), > > > 'imgdata') > > > > > > > > > + bb.utils.mkdirhier(outdir) > > > > > > > > > + basename = d.getVar('IMAGE_BASENAME') > > > > > > > > > + with open(os.path.join(outdir, basename) + '.env', > 'w') as > > > > > envf: > > > > > > > > > + for var in wicvars.split(): > > > > > > > > > + value = d.getVar(var) > > > > > > > > > + if value: > > > > > > > > > + envf.write('%s="%s"\n' % (var, > value.strip())) > > > > > > > > > +} > > > > > > > > > +addtask do_rootfs_wicenv after do_image before > do_image_wic > > > > > > > > > +do_rootfs_wicenv[vardeps] += "${WICVARS}" > > > > > > > > > +do_rootfs_wicenv[prefuncs] = 'set_image_size' > > > > > > > > > diff --git a/meta/classes/image.bbclass > > > > > b/meta/classes/image.bbclass > > > > > > > > > index 13fd996..1a549e9 100644 > > > > > > > > > --- a/meta/classes/image.bbclass > > > > > > > > > +++ b/meta/classes/image.bbclass > > > > > > > > > @@ -192,6 +192,8 @@ python () { > > > > > > > > > IMAGE_CLASSES += "image_types" > > > > > > > > > inherit ${IMAGE_CLASSES} > > > > > > > > > > > > > > > > > > +inherit image-wic > > > > > > > > > + > > > > > > > > > IMAGE_POSTPROCESS_COMMAND ?= "" > > > > > > > > > > > > > > > > > > # some default locales > > > > > > > > > @@ -332,29 +334,6 @@ fakeroot python do_image_qa () { > > > > > > > > > } > > > > > > > > > addtask do_image_qa after do_image_complete before > do_build > > > > > > > > > > > > > > > > > > -# > > > > > > > > > -# Write environment variables used by wic > > > > > > > > > -# to tmp/sysroots//imgdata/.env > > > > > > > > > -# > > > > > > > > > -python do_rootfs_wicenv () { > > > > > > > > > - wicvars = d.getVar('WICVARS') > > > > > > > > > - if not wicvars: > > > > > > > > > - return > > > > > > > > > - > > > > > > > > > - stdir = d.getVar('STAGING_DIR') > > > > > > > > > - outdir = os.path.join(stdir, d.getVar('MACHINE'), > > > 'imgdata') > > > > > > > > > - bb.utils.mkdirhier(outdir) > > > > > > > > > - basename = d.getVar('IMAGE_BASENAME') > > > > > > > > > - with open(os.path.join(outdir, basename) + '.env', > 'w') as > > > > > envf: > > > > > > > > > - for var in wicvars.split(): > > > > > > > > > - value = d.getVar(var) > > > > > > > > > - if value: > > > > > > > > > - envf.write('%s="%s"\n' % (var, > value.strip())) > > > > > > > > > -} > > > > > > > > > -addtask do_rootfs_wicenv after do_image before > do_image_wic > > > > > > > > > -do_rootfs_wicenv[vardeps] += "${WICVARS}" > > > > > > > > > -do_rootfs_wicenv[prefuncs] = 'set_image_size' > > > > > > > > > - > > > > > > > > > def setup_debugfs_variables(d): > > > > > > > > > d.appendVar('IMAGE_ROOTFS', '-dbg') > > > > > > > > > d.appendVar('IMAGE_LINK_NAME', '-dbg') > > > > > > > > > diff --git a/meta/classes/image_types.bbclass > > > > > > > b/meta/classes/image_types. > > > > > > > > > bbclass > > > > > > > > > index ad95dc6..e2ecf93 100644 > > > > > > > > > --- a/meta/classes/image_types.bbclass > > > > > > > > > +++ b/meta/classes/image_types.bbclass > > > > > > > > > @@ -192,97 +192,6 @@ IMAGE_CMD_ubi () { > > > > > > > > > > > > > > > > > > IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o > > > > > > > > > ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs > > > > > > > ${MKUBIFS_ARGS}" > > > > > > > > > > > > > > > > > > -WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks" > > > > > > > > > -WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks" > > > > > > > > > -WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p > for > > > p in > > > > > > > > > '${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/ > > > > > canned-wks' > > > > > > > % l > > > > > > > > > for l in '${BBPATH}:${COREBASE}'.split(':'))}" > > > > > > > > > -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), > > > > > > > > > '${WKS_SEARCH_PATH}') or ''}" > > > > > > > > > - > > > > > > > > > -def wks_search(files, search_path): > > > > > > > > > - for f in files: > > > > > > > > > - if os.path.isabs(f): > > > > > > > > > - if os.path.exists(f): > > > > > > > > > - return f > > > > > > > > > - else: > > > > > > > > > - searched = bb.utils.which(search_path, f) > > > > > > > > > - if searched: > > > > > > > > > - return searched > > > > > > > > > - > > > > > > > > > -WIC_CREATE_EXTRA_ARGS ?= "" > > > > > > > > > - > > > > > > > > > -IMAGE_CMD_wic () { > > > > > > > > > - out="${IMGDEPLOYDIR}/${IMAGE_NAME}" > > > > > > > > > - wks="${WKS_FULL_PATH}" > > > > > > > > > - if [ -z "$wks" ]; then > > > > > > > > > - bbfatal "No kickstart files from WKS_FILES > were > > > > > found: > > > > > > > > > ${WKS_FILES}. Please set WKS_FILE or WKS_FILES > appropriately." > > > > > > > > > - fi > > > > > > > > > - > > > > > > > > > - BUILDDIR="${TOPDIR}" wic create "$wks" --vars > > > > > > > > > "${STAGING_DIR}/${MACHINE}/imgdata/" -e > "${IMAGE_BASENAME}" -o > > > > > "$out/" > > > > > > > > > ${WIC_CREATE_EXTRA_ARGS} > > > > > > > > > - mv "$out/$(basename "${wks%.wks}")"*.direct > > > > > > > > > "$out${IMAGE_NAME_SUFFIX}.wic" > > > > > > > > > - rm -rf "$out/" > > > > > > > > > -} > > > > > > > > > -IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH WKS_FILES" > > > > > > > > > - > > > > > > > > > -# Rebuild when the wks file or vars in WICVARS change > > > > > > > > > -USING_WIC = "${@bb.utils.contains_any('IMAGE_FSTYPES', > 'wic > > > ' + ' > > > > > > > > > '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), > > > '1', > > > > > '', > > > > > > > d)}" > > > > > > > > > -WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % > > > > > > > > > os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else > ''}" > > > > > > > > > -do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}" > > > > > > > > > -do_image_wic[depends] += "wic-tools:do_build" > > > > > > > > > - > > > > > > > > > -python () { > > > > > > > > > - if d.getVar('USING_WIC') and 'do_bootimg' in d: > > > > > > > > > - bb.build.addtask('do_image_wic', '', > 'do_bootimg', d) > > > > > > > > > -} > > > > > > > > > - > > > > > > > > > -python do_write_wks_template () { > > > > > > > > > - """Write out expanded template contents to > > > WKS_FULL_PATH.""" > > > > > > > > > - import re > > > > > > > > > - > > > > > > > > > - template_body = d.getVar('_WKS_TEMPLATE') > > > > > > > > > - > > > > > > > > > - # Remove any remnant variable references left behind > by > > > the > > > > > > > expansion > > > > > > > > > - # due to undefined variables > > > > > > > > > - expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}") > > > > > > > > > - while True: > > > > > > > > > - new_body = re.sub(expand_var_regexp, '', > > > template_body) > > > > > > > > > - if new_body == template_body: > > > > > > > > > - break > > > > > > > > > - else: > > > > > > > > > - template_body = new_body > > > > > > > > > - > > > > > > > > > - wks_file = d.getVar('WKS_FULL_PATH') > > > > > > > > > - with open(wks_file, 'w') as f: > > > > > > > > > - f.write(template_body) > > > > > > > > > -} > > > > > > > > > - > > > > > > > > > -python () { > > > > > > > > > - if d.getVar('USING_WIC'): > > > > > > > > > - wks_file_u = d.getVar('WKS_FULL_PATH', False) > > > > > > > > > - wks_file = d.expand(wks_file_u) > > > > > > > > > - base, ext = os.path.splitext(wks_file) > > > > > > > > > - if ext == '.in' and os.path.exists(wks_file): > > > > > > > > > - wks_out_file = os.path.join(d.getVar(' > WORKDIR'), > > > > > > > > > os.path.basename(base)) > > > > > > > > > - d.setVar('WKS_FULL_PATH', wks_out_file) > > > > > > > > > - d.setVar('WKS_TEMPLATE_PATH', wks_file_u) > > > > > > > > > - d.setVar('WKS_FILE_CHECKSUM', > > > > > '${WKS_TEMPLATE_PATH}:True') > > > > > > > > > - > > > > > > > > > - # We need to re-parse each time the file > changes, > > > and > > > > > > > bitbake > > > > > > > > > - # needs to be told about that explicitly. > > > > > > > > > - bb.parse.mark_dependency(d, wks_file) > > > > > > > > > - > > > > > > > > > - try: > > > > > > > > > - with open(wks_file, 'r') as f: > > > > > > > > > - body = f.read() > > > > > > > > > - except (IOError, OSError) as exc: > > > > > > > > > - pass > > > > > > > > > - else: > > > > > > > > > - # Previously, I used expandWithRefs to > get the > > > > > > > dependency > > > > > > > > > list > > > > > > > > > - # and add it to WICVARS, but there's no > point > > > > > > > re-parsing > > > > > > > > > the > > > > > > > > > - # file in process_wks_template as well, so > > > just > > > > > put > > > > > > > it in > > > > > > > > > - # a variable and let the metadata deal > with > > > the > > > > > deps. > > > > > > > > > - d.setVar('_WKS_TEMPLATE', body) > > > > > > > > > - bb.build.addtask('do_write_wks_template', > > > > > > > > > 'do_image_wic', None, d) > > > > > > > > > -} > > > > > > > > > - > > > > > > > > > EXTRA_IMAGECMD = "" > > > > > > > > > > > > > > > > > > inherit siteinfo > > > > > > > > > @@ -380,7 +289,3 @@ IMAGE_EXTENSION_live = "hddimg iso" > > > > > > > > > # The IMAGE_TYPES_MASKED variable will be used to mask out > > > from > > > > > the > > > > > > > > > IMAGE_FSTYPES, > > > > > > > > > # images that will not be built at do_rootfs time: vmdk, > vdi, > > > > > qcow2, > > > > > > > > > hdddirect, hddimg, iso, etc. > > > > > > > > > IMAGE_TYPES_MASKED ?= "" > > > > > > > > > - > > > > > > > > > -# The WICVARS variable is used to define list of bitbake > > > variables > > > > > > > used > > > > > > > > > in wic code > > > > > > > > > -# variables from this list is written to .env file > > > > > > > > > -WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE > FAKEROOTCMD > > > > > HDDDIR > > > > > > > > > IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME > IMAGE_ROOTFS > > > > > > > > > INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH > > > RECIPE_SYSROOT_NATIVE > > > > > > > > > ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR > > > TARGET_SYS" > > > > > > > > > -- > > > > > > > > > 2.1.4 > > > > > > > > > > > > > > > > > > -- > > > > > > > > > _______________________________________________ > > > > > > > > > Openembedded-core mailing list > > > > > > > > > Openembedded-core@lists.openembedded.org > > > > > > > > > http://lists.openembedded.org/ > mailman/listinfo/openembedded- > > > core > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > -- > > > > > > > Regards, > > > > > > > Ed > > > > > > > > > > > > > > > > > -- > > > > > -- > > > > > Regards, > > > > > Ed > > > > > > > > > > > -- > > > -- > > > Regards, > > > Ed > > > > > -- > -- > Regards, > Ed > --001a1135a57a87a1ca05475486c9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
LGTM

On Mon, Jan 30, 2017 at 10:42 AM, Ed Bartosh &l= t;ed.bartos= h@linux.intel.com> wrote:
<= span class=3D"">On Mon, Jan 30, 2017 at 10:41:27AM -0800, Rick Altherr wrot= e:
> Agreed.=C2=A0 What if it was image_types_wic.bbclass and you did somet= hing
> similar to build_uboot() in image.bbclass?
>

I can do this for now:
IMAGE_TYPE_wic =3D "image_type_wic"
inherit ${IMAGE_TYPE_wic}

which is the same as 'inherit image_type_wic', just takes 2 lines, = but
looks more consistent.

does this look ok?

> On Mon, Jan 30, 2017 at 10:15 AM, Ed Bartosh <ed.bartosh@linux.intel.com>
> wrote:
>
> > On Mon, Jan 30, 2017 at 10:25:59AM -0800, Rick Altherr wrote:
> > > I'm not clear on which path is the preferred one.=C2=A0 = There are lots of bits
> > > and pieces in image_types.bbclass that implement various ima= ge types.
> > >=C2=A0 uboot got added as a separate class at some point.=C2= =A0 The comments in
> > > local.conf.sample.extended imply IMAGE_CLASSES should be use= d to load
> > > additional image_types_* classes to add support for addition= al image
> > > types.=C2=A0 Having the wic image type implemented in a sepa= rate
> > > image-wic.bbclass that is directly inherited by image.bbclas= s adds a 3rd
> > > approach.=C2=A0 Which one do we want contributors to use in = the future?
> > >
> >
> > I didn't want to create even more confusion. What I wanted is= stated in the
> > commit message - to put existing wic code into a file for better<= br> > > maintenance. If this is more confusing than having wic code in di= fferent
> > places of image.class and image_types.class then we can just drop= this
> > patch. However, I personally find it more maintainable this way.<= br> > >
> > Suggesting people to change machine configs just because wic code= is
> > moved to separate file doesn't look good to me either.
> >
> > > On Mon, Jan 30, 2017 at 9:45 AM, Ed Bartosh <ed.bartosh@linux.intel.com>
> > > wrote:
> > >
> > > > On Mon, Jan 30, 2017 at 09:47:42AM -0800, Rick Altherr = wrote:
> > > > > Hmm.=C2=A0 In local.conf.sample.extended, I find:<= br> > > > > >
> > > > > # Additional image generation features
> > > > > #
> > > > > # The following is a list of classes to import to = use in the
> > generation
> > > > of
> > > > > images
> > > > > # currently an example class is image_types_uboot<= br> > > > > > # IMAGE_CLASSES =3D " image_types_uboot"=
> > > > >
> > > > > Indeed, image_types_uboot isn't part of IMAGE_= CLASSES by default.
> > I'd
> > > > > expect a machine config to add wic to IMAGE_CLASSE= S if it needs wic
> > > > output.
> > > > >
> > > >
> > > > So far all machine configs add wic to IMAGE_TYPES and i= t works just
> > > > fine. Why to change?
> > > >
> > > > > On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh < > > ed.bartosh@linux.in= tel.com>
> > > > > wrote:
> > > > >
> > > > > > On Mon, Jan 30, 2017 at 09:27:54AM -0800, Ric= k Altherr wrote:
> > > > > > > Why didn't you make this image_types= _wic.bbclass and use
> > > > IMAGE_CLASSES to
> > > > > > > load it?
> > > > > >
> > > > > > Because of the following:
> > > > > > - IMAGE_CLASSES[doc] =3D "A list of clas= ses that all images should
> > > > > >=C2=A0 =C2=A0inherit." I'm not sure a= ll images should include wic class. I'll
> > > > probably
> > > > > >=C2=A0 =C2=A0make this inheritance conditional= .
> > > > > > - so far IMAGE_CLASSES is used for qemuboot, = image_types,
> > > > > >=C2=A0 =C2=A0image_types_uboot and testimage,<= br> > > > > > >=C2=A0 =C2=A0so the usage is more or less foll= ows the description. wic is out
> > of
> > > > > >=C2=A0 =C2=A0that usage scenario, I believe. > > > > > > - 'inherit image_wic' is more explici= t than IMAGE_CLASSES +=3D
> > > > > >=C2=A0 =C2=A0"image_types"\n inherit= ${IMAGE_CLASSES}
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > On Fri, Jan 27, 2017 at 12:19 PM, Ed Bar= tosh <
> > > > ed.bartos= h@linux.intel.com
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > There is a lot of wic code in image= .bbclass and
> > image_types.bbclass
> > > > > > > > Having all code separated in one fi= le should make it more
> > readable
> > > > > > > > and easier to maintain.
> > > > > > > >
> > > > > > > > Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>=
> > > > > > > > ---
> > > > > > > >=C2=A0 meta/classes/image-wic.bbclas= s=C2=A0 =C2=A0| 120
> > > > ++++++++++++++++++++++++++++++
> > > > > > > > +++++++++
> > > > > > > >=C2=A0 meta/classes/image.bbclass=C2= =A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 25 +-------
> > > > > > > >=C2=A0 meta/classes/image_types.bbclass |=C2=A0 95
> > > > ------------------------------
> > > > > > -
> > > > > > > >=C2=A0 3 files changed, 122 insertio= ns(+), 118 deletions(-)
> > > > > > > >=C2=A0 create mode 100644 meta/class= es/image-wic.bbclass
> > > > > > > >
> > > > > > > > diff --git a/meta/classes/image-wic= .bbclass
> > > > b/meta/classes/image-wic.
> > > > > > > > bbclass
> > > > > > > > new file mode 100644
> > > > > > > > index 0000000..2acfd65
> > > > > > > > --- /dev/null
> > > > > > > > +++ b/meta/classes/image-wic.b= bclass
> > > > > > > > @@ -0,0 +1,120 @@
> > > > > > > > +# The WICVARS variable is used to = define list of bitbake
> > variables
> > > > > > used
> > > > > > > > in wic code
> > > > > > > > +# variables from this list is writ= ten to <image>.env file
> > > > > > > > +WICVARS ?=3D "\
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD
> > > > HDDDIR
> > > > > > > > IMAGE_BASENAME IMAGE_BOOT_FILES \ > > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES
> > INITRD
> > > > > > ISODIR
> > > > > > > > MACHINE_ARCH RECIPE_SYSROOT_NATIVE = \
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0ROOTFS_SIZE STAGING_DATADIR STAGING_DIR
> > STAGING_LIBDIR
> > > > > > > > TARGET_SYS"
> > > > > > > > +
> > > > > > > > +WKS_FILE ??=3D "${IMAGE_BASEN= AME}.${MACHINE}.wks"
> > > > > > > > +WKS_FILES ?=3D "${WKS_FILE} $= {IMAGE_BASENAME}.wks"
> > > > > > > > +WKS_SEARCH_PATH ?=3D "${THISD= IR}:${@':'.join('%s/wic' % p for
> > p in
> > > > > > > > '${BBPATH}'.split(':= 9;))}:${@':'.join('%s/scripts/lib/wic/
> > > > canned-wks'
> > > > > > % l
> > > > > > > > for l in '${BBPATH}:${COREBASE}= '.split(':'))}"
> > > > > > > > +WKS_FULL_PATH =3D "${@wks_sea= rch('${WKS_FILES}'.split(),
> > > > > > > > '${WKS_SEARCH_PATH}') or &#= 39;'}"
> > > > > > > > +
> > > > > > > > +def wks_search(files, search_path)= :
> > > > > > > > +=C2=A0 =C2=A0 for f in files:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if os.= path.isabs(f):
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if os.path.exists(f):
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 return f
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:<= br> > > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 searched =3D bb.utils.which(search_path, f)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if searched:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 return searched
> > > > > > > > +
> > > > > > > > +WIC_CREATE_EXTRA_ARGS ?=3D "&= quot;
> > > > > > > > +
> > > > > > > > +IMAGE_CMD_wic () {
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0out=3D&= quot;${IMGDEPLOYDIR}/${IMAGE_NAME}"
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0wks=3D&= quot;${WKS_FULL_PATH}"
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0if [ -z= "$wks" ]; then
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0bbfatal "No kickstart files from WKS_FILES were > > > > found:
> > > > > > > > ${WKS_FILES}. Please set WKS_FILE o= r WKS_FILES appropriately."
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0fi
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0BUILDDI= R=3D"${TOPDIR}" wic create "$wks" --vars
> > > > > > > > "${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o
> > > > "$out/"
> > > > > > > > ${WIC_CREATE_EXTRA_ARGS}
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0mv &quo= t;$out/$(basename "${wks%.wks}")"*.direct
> > > > > > > > "$out${IMAGE_NAME_SUFFIX}.wic&= quot;
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf = "$out/"
> > > > > > > > +}
> > > > > > > > +IMAGE_CMD_wic[vardepsexclude] =3D = "WKS_FULL_PATH WKS_FILES"
> > > > > > > > +
> > > > > > > > +# Rebuild when the wks file or var= s in WICVARS change
> > > > > > > > +USING_WIC =3D "${@bb.utils.co= ntains_any('IMAGE_FSTYPES', 'wic
> > ' + '
> > > > > > > > '.join('wic.%s' % c for= c in '${CONVERSIONTYPES}'.split()),
> > '1',
> > > > '',
> > > > > > d)}"
> > > > > > > > +WKS_FILE_CHECKSUM =3D "${@= 9;${WKS_FULL_PATH}:%s' %
> > > > > > > > os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"
> > > > > > > > +do_image_wic[file-checksums] +=3D = "${WKS_FILE_CHECKSUM}"
> > > > > > > > +do_image_wic[depends] +=3D "w= ic-tools:do_build"
> > > > > > > > +
> > > > > > > > +python () {
> > > > > > > > +=C2=A0 =C2=A0 if d.getVar('USI= NG_WIC') and 'do_bootimg' in d:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 bb.bui= ld.addtask('do_image_wic', '', 'do_bootimg', d= )
> > > > > > > > +}
> > > > > > > > +
> > > > > > > > +python do_write_wks_template () {<= br> > > > > > > > > +=C2=A0 =C2=A0 """Wr= ite out expanded template contents to
> > WKS_FULL_PATH."""
> > > > > > > > +=C2=A0 =C2=A0 import re
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 template_body =3D d.= getVar('_WKS_TEMPLATE')
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 # Remove any remnant= variable references left behind by
> > the
> > > > > > expansion
> > > > > > > > +=C2=A0 =C2=A0 # due to undefined v= ariables
> > > > > > > > +=C2=A0 =C2=A0 expand_var_regexp = =3D re.compile(r"\${[^{}@\n\t :]+}")
> > > > > > > > +=C2=A0 =C2=A0 while True:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 new_bo= dy =3D re.sub(expand_var_regexp, '',
> > template_body)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if new= _body =3D=3D template_body:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 break
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:<= br> > > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 template_body =3D new_body
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 wks_file =3D d.getVa= r('WKS_FULL_PATH')
> > > > > > > > +=C2=A0 =C2=A0 with open(wks_file, = 'w') as f:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 f.writ= e(template_body)
> > > > > > > > +}
> > > > > > > > +
> > > > > > > > +python () {
> > > > > > > > +=C2=A0 =C2=A0 if d.getVar('USI= NG_WIC'):
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 wks_fi= le_u =3D d.getVar('WKS_FULL_PATH', False)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 wks_fi= le =3D d.expand(wks_file_u)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 base, = ext =3D os.path.splitext(wks_file)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ext= =3D=3D '.in' and os.path.exists(wks_file):
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 wks_out_file =3D os.path.join(d.getVar('WORKDIR'),
> > > > > > > > os.path.basename(base))
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_FULL_PATH', wks_out_file)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_TEMPLATE_PATH', wks_file_u)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_FILE_CHECKSUM',
> > > > '${WKS_TEMPLATE_PATH}:True')
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 # We need to re-parse each time the file changes,
> > and
> > > > > > bitbake
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 # needs to be told about that explicitly.
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 bb.parse.mark_dependency(d, wks_file)
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 try:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 with open(wks_file, 'r') as f:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 body =3D f.read()
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 except (IOError, OSError) as exc:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 pass
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 else:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # Previously, I used expandWithRefs to get the
> > > > > > dependency
> > > > > > > > list
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # and add it to WICVARS, but there's no point
> > > > > > re-parsing
> > > > > > > > the
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # file in process_wks_template as well, so
> > just
> > > > put
> > > > > > it in
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # a variable and let the metadata deal with
> > the
> > > > deps.
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 d.setVar('_WKS_TEMPLATE', body)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 bb.build.addtask('do_write_wks_template'= ,
> > > > > > > > 'do_image_wic', None, d) > > > > > > > > +}
> > > > > > > > +
> > > > > > > > +#
> > > > > > > > +# Write environment variables used= by wic
> > > > > > > > +# to tmp/sysroots/<machine>/= imgdata/<image>.env
> > > > > > > > +#
> > > > > > > > +python do_rootfs_wicenv () {
> > > > > > > > +=C2=A0 =C2=A0 wicvars =3D d.getVar= ('WICVARS')
> > > > > > > > +=C2=A0 =C2=A0 if not wicvars:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return=
> > > > > > > > +
> > > > > > > > +=C2=A0 =C2=A0 stdir =3D d.getVar(&= #39;STAGING_DIR')
> > > > > > > > +=C2=A0 =C2=A0 outdir =3D os.path.j= oin(stdir, d.getVar('MACHINE'),
> > 'imgdata')
> > > > > > > > +=C2=A0 =C2=A0 bb.utils.mkdirhier(o= utdir)
> > > > > > > > +=C2=A0 =C2=A0 basename =3D d.getVa= r('IMAGE_BASENAME')
> > > > > > > > +=C2=A0 =C2=A0 with open(os.path.jo= in(outdir, basename) + '.env', 'w') as
> > > > envf:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 for va= r in wicvars.split():
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 value =3D d.getVar(var)
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if value:
> > > > > > > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 envf.write('%s=3D"%s"\n' % (var, va= lue.strip()))
> > > > > > > > +}
> > > > > > > > +addtask do_rootfs_wicenv after do_= image before do_image_wic
> > > > > > > > +do_rootfs_wicenv[vardeps] +=3D &qu= ot;${WICVARS}"
> > > > > > > > +do_rootfs_wicenv[prefuncs] =3D = 9;set_image_size'
> > > > > > > > diff --git a/meta/classes/image.bbc= lass
> > > > b/meta/classes/image.bbclass
> > > > > > > > index 13fd996..1a549e9 100644
> > > > > > > > --- a/meta/classes/image.bbclass > > > > > > > > +++ b/meta/classes/image.bbclass > > > > > > > > @@ -192,6 +192,8 @@ python () {
> > > > > > > >=C2=A0 IMAGE_CLASSES +=3D "imag= e_types"
> > > > > > > >=C2=A0 inherit ${IMAGE_CLASSES}
> > > > > > > >
> > > > > > > > +inherit image-wic
> > > > > > > > +
> > > > > > > >=C2=A0 IMAGE_POSTPROCESS_COMMAND ?= =3D ""
> > > > > > > >
> > > > > > > >=C2=A0 # some default locales
> > > > > > > > @@ -332,29 +334,6 @@ fakeroot pytho= n do_image_qa () {
> > > > > > > >=C2=A0 }
> > > > > > > >=C2=A0 addtask do_image_qa after do_= image_complete before do_build
> > > > > > > >
> > > > > > > > -#
> > > > > > > > -# Write environment variables used= by wic
> > > > > > > > -# to tmp/sysroots/<machine>/= imgdata/<image>.env
> > > > > > > > -#
> > > > > > > > -python do_rootfs_wicenv () {
> > > > > > > > -=C2=A0 =C2=A0 wicvars =3D d.getVar= ('WICVARS')
> > > > > > > > -=C2=A0 =C2=A0 if not wicvars:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 return=
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 stdir =3D d.getVar(&= #39;STAGING_DIR')
> > > > > > > > -=C2=A0 =C2=A0 outdir =3D os.path.j= oin(stdir, d.getVar('MACHINE'),
> > 'imgdata')
> > > > > > > > -=C2=A0 =C2=A0 bb.utils.mkdirhier(o= utdir)
> > > > > > > > -=C2=A0 =C2=A0 basename =3D d.getVa= r('IMAGE_BASENAME')
> > > > > > > > -=C2=A0 =C2=A0 with open(os.path.jo= in(outdir, basename) + '.env', 'w') as
> > > > envf:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 for va= r in wicvars.split():
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 value =3D d.getVar(var)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if value:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 envf.write('%s=3D"%s"\n' % (var, va= lue.strip()))
> > > > > > > > -}
> > > > > > > > -addtask do_rootfs_wicenv after do_= image before do_image_wic
> > > > > > > > -do_rootfs_wicenv[vardeps] +=3D &qu= ot;${WICVARS}"
> > > > > > > > -do_rootfs_wicenv[prefuncs] =3D = 9;set_image_size'
> > > > > > > > -
> > > > > > > >=C2=A0 def setup_debugfs_variables(d= ):
> > > > > > > >=C2=A0 =C2=A0 =C2=A0 d.appendVar(= 9;IMAGE_ROOTFS', '-dbg')
> > > > > > > >=C2=A0 =C2=A0 =C2=A0 d.appendVar(= 9;IMAGE_LINK_NAME', '-dbg')
> > > > > > > > diff --git a/meta/classes/image_typ= es.bbclass
> > > > > > b/meta/classes/image_types.
> > > > > > > > bbclass
> > > > > > > > index ad95dc6..e2ecf93 100644
> > > > > > > > --- a/meta/classes/image_types.bbclass
> > > > > > > > +++ b/meta/classes/image_types.bbclass
> > > > > > > > @@ -192,97 +192,6 @@ IMAGE_CMD_ubi = () {
> > > > > > > >
> > > > > > > >=C2=A0 IMAGE_CMD_ubifs =3D "mkf= s.ubifs -r ${IMAGE_ROOTFS} -o
> > > > > > > > ${IMGDEPLOYDIR}/${IMAGE_NAME}$= {IMAGE_NAME_SUFFIX}.ubifs
> > > > > > ${MKUBIFS_ARGS}"
> > > > > > > >
> > > > > > > > -WKS_FILE ??=3D "${IMAGE_BASEN= AME}.${MACHINE}.wks"
> > > > > > > > -WKS_FILES ?=3D "${WKS_FILE} $= {IMAGE_BASENAME}.wks"
> > > > > > > > -WKS_SEARCH_PATH ?=3D "${THISD= IR}:${@':'.join('%s/wic' % p for
> > p in
> > > > > > > > '${BBPATH}'.split(':= 9;))}:${@':'.join('%s/scripts/lib/wic/
> > > > canned-wks'
> > > > > > % l
> > > > > > > > for l in '${BBPATH}:${COREBASE}= '.split(':'))}"
> > > > > > > > -WKS_FULL_PATH =3D "${@wks_sea= rch('${WKS_FILES}'.split(),
> > > > > > > > '${WKS_SEARCH_PATH}') or &#= 39;'}"
> > > > > > > > -
> > > > > > > > -def wks_search(files, search_path)= :
> > > > > > > > -=C2=A0 =C2=A0 for f in files:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if os.= path.isabs(f):
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if os.path.exists(f):
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 return f
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:<= br> > > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 searched =3D bb.utils.which(search_path, f)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 if searched:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 return searched
> > > > > > > > -
> > > > > > > > -WIC_CREATE_EXTRA_ARGS ?=3D "&= quot;
> > > > > > > > -
> > > > > > > > -IMAGE_CMD_wic () {
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0out=3D&= quot;${IMGDEPLOYDIR}/${IMAGE_NAME}"
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0wks=3D&= quot;${WKS_FULL_PATH}"
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0if [ -z= "$wks" ]; then
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0bbfatal "No kickstart files from WKS_FILES were > > > > found:
> > > > > > > > ${WKS_FILES}. Please set WKS_FILE o= r WKS_FILES appropriately."
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0fi
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0BUILDDI= R=3D"${TOPDIR}" wic create "$wks" --vars
> > > > > > > > "${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o
> > > > "$out/"
> > > > > > > > ${WIC_CREATE_EXTRA_ARGS}
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0mv &quo= t;$out/$(basename "${wks%.wks}")"*.direct
> > > > > > > > "$out${IMAGE_NAME_SUFFIX}.wic&= quot;
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf = "$out/"
> > > > > > > > -}
> > > > > > > > -IMAGE_CMD_wic[vardepsexclude] =3D = "WKS_FULL_PATH WKS_FILES"
> > > > > > > > -
> > > > > > > > -# Rebuild when the wks file or var= s in WICVARS change
> > > > > > > > -USING_WIC =3D "${@bb.utils.co= ntains_any('IMAGE_FSTYPES', 'wic
> > ' + '
> > > > > > > > '.join('wic.%s' % c for= c in '${CONVERSIONTYPES}'.split()),
> > '1',
> > > > '',
> > > > > > d)}"
> > > > > > > > -WKS_FILE_CHECKSUM =3D "${@= 9;${WKS_FULL_PATH}:%s' %
> > > > > > > > os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"
> > > > > > > > -do_image_wic[file-checksums] +=3D = "${WKS_FILE_CHECKSUM}"
> > > > > > > > -do_image_wic[depends] +=3D "w= ic-tools:do_build"
> > > > > > > > -
> > > > > > > > -python () {
> > > > > > > > -=C2=A0 =C2=A0 if d.getVar('USI= NG_WIC') and 'do_bootimg' in d:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 bb.bui= ld.addtask('do_image_wic', '', 'do_bootimg', d= )
> > > > > > > > -}
> > > > > > > > -
> > > > > > > > -python do_write_wks_template () {<= br> > > > > > > > > -=C2=A0 =C2=A0 """Wr= ite out expanded template contents to
> > WKS_FULL_PATH."""
> > > > > > > > -=C2=A0 =C2=A0 import re
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 template_body =3D d.= getVar('_WKS_TEMPLATE')
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 # Remove any remnant= variable references left behind by
> > the
> > > > > > expansion
> > > > > > > > -=C2=A0 =C2=A0 # due to undefined v= ariables
> > > > > > > > -=C2=A0 =C2=A0 expand_var_regexp = =3D re.compile(r"\${[^{}@\n\t :]+}")
> > > > > > > > -=C2=A0 =C2=A0 while True:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 new_bo= dy =3D re.sub(expand_var_regexp, '',
> > template_body)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if new= _body =3D=3D template_body:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 break
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:<= br> > > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 template_body =3D new_body
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 wks_file =3D d.getVa= r('WKS_FULL_PATH')
> > > > > > > > -=C2=A0 =C2=A0 with open(wks_file, = 'w') as f:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 f.writ= e(template_body)
> > > > > > > > -}
> > > > > > > > -
> > > > > > > > -python () {
> > > > > > > > -=C2=A0 =C2=A0 if d.getVar('USI= NG_WIC'):
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 wks_fi= le_u =3D d.getVar('WKS_FULL_PATH', False)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 wks_fi= le =3D d.expand(wks_file_u)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 base, = ext =3D os.path.splitext(wks_file)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ext= =3D=3D '.in' and os.path.exists(wks_file):
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 wks_out_file =3D os.path.join(d.getVar('WORKDIR'),
> > > > > > > > os.path.basename(base))
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_FULL_PATH', wks_out_file)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_TEMPLATE_PATH', wks_file_u)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 d.setVar('WKS_FILE_CHECKSUM',
> > > > '${WKS_TEMPLATE_PATH}:True')
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 # We need to re-parse each time the file changes,
> > and
> > > > > > bitbake
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 # needs to be told about that explicitly.
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 bb.parse.mark_dependency(d, wks_file)
> > > > > > > > -
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 try:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 with open(wks_file, 'r') as f:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 body =3D f.read()
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 except (IOError, OSError) as exc:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 pass
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 else:
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # Previously, I used expandWithRefs to get the
> > > > > > dependency
> > > > > > > > list
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # and add it to WICVARS, but there's no point
> > > > > > re-parsing
> > > > > > > > the
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # file in process_wks_template as well, so
> > just
> > > > put
> > > > > > it in
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 # a variable and let the metadata deal with
> > the
> > > > deps.
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 d.setVar('_WKS_TEMPLATE', body)
> > > > > > > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 bb.build.addtask('do_write_wks_template'= ,
> > > > > > > > 'do_image_wic', None, d) > > > > > > > > -}
> > > > > > > > -
> > > > > > > >=C2=A0 EXTRA_IMAGECMD =3D "&quo= t;
> > > > > > > >
> > > > > > > >=C2=A0 inherit siteinfo
> > > > > > > > @@ -380,7 +289,3 @@ IMAGE_EXTENSION= _live =3D "hddimg iso"
> > > > > > > >=C2=A0 # The IMAGE_TYPES_MASKED vari= able will be used to mask out
> > from
> > > > the
> > > > > > > > IMAGE_FSTYPES,
> > > > > > > >=C2=A0 # images that will not be bui= lt at do_rootfs time: vmdk, vdi,
> > > > qcow2,
> > > > > > > > hdddirect, hddimg, iso, etc.
> > > > > > > >=C2=A0 IMAGE_TYPES_MASKED ?=3D "= ;"
> > > > > > > > -
> > > > > > > > -# The WICVARS variable is used to = define list of bitbake
> > variables
> > > > > > used
> > > > > > > > in wic code
> > > > > > > > -# variables from this list is writ= ten to <image>.env file
> > > > > > > > -WICVARS ?=3D "BBLAYERS IMGDEP= LOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD
> > > > HDDDIR
> > > > > > > > IMAGE_BASENAME IMAGE_BOOT_FILES IMA= GE_LINK_NAME IMAGE_ROOTFS
> > > > > > > > INITRAMFS_FSTYPES INITRD ISODIR MAC= HINE_ARCH
> > RECIPE_SYSROOT_NATIVE
> > > > > > > > ROOTFS_SIZE STAGING_DATADIR STAGING= _DIR STAGING_LIBDIR
> > TARGET_SYS"
> > > > > > > > --
> > > > > > > > 2.1.4
> > > > > > > >
> > > > > > > > --
> > > > > > > > ______________________________= _________________
> > > > > > > > Openembedded-core mailing list
> > > > > > > > Openembedded-core@lists.openembedded.org<= br> > > > > > > > > = http://lists.openembedded.org/mailman/listinfo/openembedded-
> > core
> > > > > > > >
> > > > > >
> > > > > > --
> > > > > > --
> > > > > > Regards,
> > > > > > Ed
> > > > > >
> > > >
> > > > --
> > > > --
> > > > Regards,
> > > > Ed
> > > >
> >
> > --
> > --
> > Regards,
> > Ed
> >

--
--
Regards,
Ed

--001a1135a57a87a1ca05475486c9--