Skip to contentSkip to conversation

Fix for #10835 - WIC should not rely on hddimg creation for finding all needed artifacts

PATCH In review Ed Bartosh 4 participants 26 messages Jan 27, 2017 – Feb 1, 2017

lore
Share & tools
lore

Ed Bartosh

author
#0 lore raw

v3 cover Fix for #10835 - WIC should not rely on hddimg creation for finding all needed artifacts

Hi,

This patchset usage of hddimg from wic codebase due to planned deprecation of hddimg.

While working on this wic-related code in meta/classes/ has been moved to image-wic.bbclass to make it more maintainable.

Changes in v2: rebased on top of ross/mut
Changes in v3: removed patches that add tasks, fixed test cases,
rebased on top of patches that make use of artifacts from DEPLOY_DIR_IMAGE, rebased on to pf ross/mut

The following changes since commit 2624674adefd86d15bc0bec2bb2a3876f785b947:

selftest: check results in test_image_vars_dir* (2017-01-27 17:27:30 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib ed/wic/wip
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=ed/wic/wip

Ed Bartosh (10):
image-wic: move wic code to image-wic.bbclass
wic: use INITRD_LIVE in isoimage-isohybrid
wic: isoimage-isohybrid: stop using HDDDIR
image-wic: remove HDDDIR from WICVARS
isoimage-isohybrid: use TRANSLATED_TARGET_ARCH instead of MACHINE_ARCH
selftest: stop using hddimg in the wic test suite
selftest: wic: fix test_iso_image test case grub-efi.bbclass: use 'grub-efi-' prefix
wic-tools: add dependency to systemd-boot
isoimage-isohybrid: renamed variable hdd_dir

Tom Zanussi (1):
wic: Look for image artifacts in a common location

 meta/classes/grub-efi.bbclass                      |  10 +-
 meta/classes/image-wic.bbclass                     | 120 +++++++++++++++++++++
 meta/classes/image.bbclass                         |  25 +----
 meta/classes/image_types.bbclass                   |  95 ----------------
 meta/lib/oeqa/selftest/wic.py                      |   6 +-
 meta/recipes-core/meta/wic-tools.bb                |   4 +-
 scripts/lib/wic/plugins/source/bootimg-efi.py      |  39 +++++--
 .../lib/wic/plugins/source/isoimage-isohybrid.py   |  36 ++++---
 8 files changed, 182 insertions(+), 153 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v3 1/11 image-wic: move wic code to image-wic.bbclass

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.

---
 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
meta/classes/image-wic.bbclass new file +120 -0
new file mode 100644
index 0000000..2acfd65
@@ -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 <image>.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/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass +2 -23
index 13fd996..1a549e9 100644
@@ -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/<machine>/imgdata/<image>.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')
meta/classes/image_types.bbclass +0 -95

104 lines not on this page · raw message

Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Please name the class image_wic.bbclass instead.

As dashes are not allowed in function names, you cannot use the image_wic_do_write_wks_template pattern of function names if you use a class name with a dash in it.

Signature · 1 line
Ola x Nilsson
Quoted 336 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ed Bartosh
Sent: den 27 januari 2017 21:20
To: [email protected]
Subject: [OE-core] [PATCH v3 01/11] image-wic: move wic code to image- wic.bbclass

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.

---
 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

meta/classes/image- renamed from meta/classes/image-wic.bbclass +0 -0

wic.bbclass new file mode 100644 index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +4 -0
@@ -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 <image>.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"

meta/classes/image-wic.bbclass new file +4 -0
+
+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 ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+	fi
+
+	BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o "$out/" ${WIC_CREATE_EXTRA_ARGS}

meta/classes/image-wic.bbclass new file +1 -0
+	mv "$out/$(basename "${wks%.wks}")"*.direct

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+	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 ''}"

meta/classes/image-wic.bbclass new file +35 -0
+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))

meta/classes/image-wic.bbclass new file +43 -0
+            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/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass index renamed from meta/classes/image.bbclass +0 -0

13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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

meta/classes/image.bbclass +0 -2
-#
-# Write environment variables used by wic -# to

tmp/sysroots/<machine>/imgdata/<image>.env

meta/classes/image.bbclass +0 -17
-#
-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}"

meta/classes/image.bbclass +0 -2
-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

meta/classes/image_types.bbclass +0 -0
@@ -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}"

meta/classes/image_types.bbclass +0 -3
-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 ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-	fi
-
-	BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o "$out/" ${WIC_CREATE_EXTRA_ARGS}

meta/classes/image_types.bbclass +0 -1
-	mv "$out/$(basename "${wks%.wks}")"*.direct

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -5
-	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 ''}"

meta/classes/image_types.bbclass +0 -36
-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))

meta/classes/image_types.bbclass +0 -20
-            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)

meta/classes/image_types.bbclass +0 -2
-}
-
 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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables used in wic

code -# variables from this list is written to <image>.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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#3 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Quoted 6 lines · Ola x Nilsson

Please name the class image_wic.bbclass instead.

As dashes are not allowed in function names, you cannot use the image_wic_do_write_wks_template pattern of function names if you use a class name with a dash in it.

Thanks for pointing out to it. Will fix it in the next versison of this patchset.

Quoted 339 lines
Signature · 1 line
Ola x Nilsson
Quoted 336 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Ed Bartosh
Sent: den 27 januari 2017 21:20
To: [email protected]
Subject: [OE-core] [PATCH v3 01/11] image-wic: move wic code to image- wic.bbclass

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.

---
 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

meta/classes/image- renamed from meta/classes/image-wic.bbclass +0 -0

wic.bbclass new file mode 100644 index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +4 -0
@@ -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 <image>.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"

meta/classes/image-wic.bbclass new file +4 -0
+
+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 ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+	fi
+
+	BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o "$out/" ${WIC_CREATE_EXTRA_ARGS}

meta/classes/image-wic.bbclass new file +1 -0
+	mv "$out/$(basename "${wks%.wks}")"*.direct

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+	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 ''}"

meta/classes/image-wic.bbclass new file +35 -0
+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))

meta/classes/image-wic.bbclass new file +43 -0
+            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/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass index renamed from meta/classes/image.bbclass +0 -0

13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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

meta/classes/image.bbclass +0 -2
-#
-# Write environment variables used by wic -# to

tmp/sysroots/<machine>/imgdata/<image>.env

meta/classes/image.bbclass +0 -17
-#
-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}"

meta/classes/image.bbclass +0 -2
-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

meta/classes/image_types.bbclass +0 -0
@@ -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}"

meta/classes/image_types.bbclass +0 -3
-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 ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-	fi
-
-	BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o "$out/" ${WIC_CREATE_EXTRA_ARGS}

meta/classes/image_types.bbclass +0 -1
-	mv "$out/$(basename "${wks%.wks}")"*.direct

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -5
-	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 ''}"

meta/classes/image_types.bbclass +0 -36
-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))

meta/classes/image_types.bbclass +0 -20
-            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)

meta/classes/image_types.bbclass +0 -2
-}
-
 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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables used in wic

code -# variables from this list is written to <image>.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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 3 lines
--
Regards,
Ed
#4 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

In reply to Ed Bartosh

Why didn't you make this image_types_wic.bbclass and use IMAGE_CLASSES to load it?

Quoted 340 lines · Ed Bartosh

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.

---
 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
meta/classes/image-wic. renamed from meta/classes/image-wic.bbclass +0 -0

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables used

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.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"

meta/classes/image-wic.bbclass new file +4 -0
+
+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 ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+       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"

meta/classes/image-wic.bbclass new file +6 -0
+       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 ''}"

meta/classes/image-wic.bbclass new file +36 -0
+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))

meta/classes/image-wic.bbclass new file +15 -0
+            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

meta/classes/image-wic.bbclass new file +4 -0
+                # 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)

meta/classes/image-wic.bbclass new file +24 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass +2 -23
index 13fd996..1a549e9 100644
@@ -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/<machine>/imgdata/<image>.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')
meta/classes/image_types. renamed from meta/classes/image_types.bbclass +0 -0

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -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}"

meta/classes/image_types.bbclass +0 -3
-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 ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-       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"

meta/classes/image_types.bbclass +0 -6
-       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 ''}"

meta/classes/image_types.bbclass +0 -36
-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))

meta/classes/image_types.bbclass +0 -15
-            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

meta/classes/image_types.bbclass +0 -4
-                # 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)

meta/classes/image_types.bbclass +0 -2
-}
-
 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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables used

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#5 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Quoted 2 lines · Rick Altherr

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}

Quoted 344 lines
Quoted 340 lines · Ed Bartosh

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.

---
 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
meta/classes/image-wic. renamed from meta/classes/image-wic.bbclass +0 -0

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables used

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.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"

meta/classes/image-wic.bbclass new file +4 -0
+
+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 ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+       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"

meta/classes/image-wic.bbclass new file +6 -0
+       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 ''}"

meta/classes/image-wic.bbclass new file +36 -0
+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))

meta/classes/image-wic.bbclass new file +15 -0
+            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

meta/classes/image-wic.bbclass new file +4 -0
+                # 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)

meta/classes/image-wic.bbclass new file +24 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass +2 -23
index 13fd996..1a549e9 100644
@@ -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/<machine>/imgdata/<image>.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')
meta/classes/image_types. renamed from meta/classes/image_types.bbclass +0 -0

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -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}"

meta/classes/image_types.bbclass +0 -3
-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 ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-       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"

meta/classes/image_types.bbclass +0 -6
-       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 ''}"

meta/classes/image_types.bbclass +0 -36
-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))

meta/classes/image_types.bbclass +0 -15
-            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

meta/classes/image_types.bbclass +0 -4
-                # 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)

meta/classes/image_types.bbclass +0 -2
-}
-
 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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables used

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 3 lines
--
Regards,
Ed
#6 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

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.

Quoted 387 lines · Ed Bartosh
Quoted 2 lines · Rick Altherr

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}

Quoted 15 lines

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <[email protected]

Quoted 10 lines · 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.

---
 meta/classes/image-wic.bbclass   | 120 ++++++++++++++++++++++++++++++
+++++++++
 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95 ------------------------------

-

Quoted 11 lines

meta/classes/image-wic.bbclass line 1

Quoted 11 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
meta/classes/image-wic. renamed from meta/classes/image-wic.bbclass +0 -0

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables

used

Quoted 6 lines
Quoted 6 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD HDDDIR

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD

ISODIR

Quoted 8 lines
Quoted 8 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR
TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+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

Quoted 28 lines
Quoted 28 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+       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

Quoted 8 lines
Quoted 8 lines

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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)}"

Quoted 9 lines
Quoted 9 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +7 -0
+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)
+}
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 19 lines
Quoted 19 lines
meta/classes/image-wic.bbclass new file +19 -0
+    # 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)
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+        if ext == '.in' and os.path.exists(wks_file):
+            wks_out_file = os.path.join(d.getVar('WORKDIR'),

os.path.basename(base))

meta/classes/image-wic.bbclass new file +5 -0
+            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

Quoted 10 lines

meta/classes/image-wic.bbclass

Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so just put

it in

Quoted 64 lines
Quoted 64 lines
meta/classes/image-wic.bbclass new file +3 -0
+                # 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)

meta/classes/image-wic.bbclass new file +24 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass +2 -19
index 13fd996..1a549e9 100644
@@ -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/<machine>/imgdata/<image>.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()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 8 lines
Quoted 8 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -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}"

Quoted 5 lines
Quoted 5 lines
meta/classes/image_types.bbclass +0 -3
-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

Quoted 28 lines
Quoted 28 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-       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

Quoted 8 lines
Quoted 8 lines

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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)}"

Quoted 9 lines
Quoted 9 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -7
-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)
-}
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 19 lines
Quoted 19 lines
meta/classes/image_types.bbclass +0 -19
-    # 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)
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -2
-        if ext == '.in' and os.path.exists(wks_file):
-            wks_out_file = os.path.join(d.getVar('WORKDIR'),

os.path.basename(base))

meta/classes/image_types.bbclass +0 -5
-            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

Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so just put

it in

Quoted 8 lines
Quoted 8 lines
meta/classes/image_types.bbclass +0 -3
-                # 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)

meta/classes/image_types.bbclass +0 -2
-}
-
 EXTRA_IMAGECMD = ""
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

inherit siteinfo

meta/classes/image_types.bbclass +0 -0
@@ -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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables

used

Quoted 9 lines
Quoted 9 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.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

Quoted 6 lines
Quoted 6 lines

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

--
--
Regards,
Ed

author
#7 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Quoted 6 lines · Rick Altherr

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

Quoted 6 lines
# 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?

Quoted 390 lines
Quoted 387 lines · Ed Bartosh
Quoted 2 lines · Rick Altherr

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}

Quoted 15 lines

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <[email protected]

Quoted 10 lines · 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.

---
 meta/classes/image-wic.bbclass   | 120 ++++++++++++++++++++++++++++++
+++++++++
 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95 ------------------------------

-

Quoted 11 lines

meta/classes/image-wic.bbclass line 1

Quoted 11 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
meta/classes/image-wic. renamed from meta/classes/image-wic.bbclass +0 -0

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables

used

Quoted 6 lines
Quoted 6 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD HDDDIR

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD

ISODIR

Quoted 8 lines
Quoted 8 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR
TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+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

Quoted 28 lines
Quoted 28 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +18 -0
+
+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."

meta/classes/image-wic.bbclass new file +3 -0
+       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

Quoted 8 lines
Quoted 8 lines

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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)}"

Quoted 9 lines
Quoted 9 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +7 -0
+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)
+}
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 19 lines
Quoted 19 lines
meta/classes/image-wic.bbclass new file +19 -0
+    # 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)
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+        if ext == '.in' and os.path.exists(wks_file):
+            wks_out_file = os.path.join(d.getVar('WORKDIR'),

os.path.basename(base))

meta/classes/image-wic.bbclass new file +5 -0
+            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

Quoted 10 lines

meta/classes/image-wic.bbclass

Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so just put

it in

Quoted 64 lines
Quoted 64 lines
meta/classes/image-wic.bbclass new file +3 -0
+                # 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)

meta/classes/image-wic.bbclass new file +24 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.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'
meta/classes/image.bbclass +2 -19
index 13fd996..1a549e9 100644
@@ -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/<machine>/imgdata/<image>.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()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 8 lines
Quoted 8 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -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}"

Quoted 5 lines
Quoted 5 lines
meta/classes/image_types.bbclass +0 -3
-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

Quoted 28 lines
Quoted 28 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -18
-
-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."

meta/classes/image_types.bbclass +0 -3
-       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

Quoted 8 lines
Quoted 8 lines

"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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)}"

Quoted 9 lines
Quoted 9 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -7
-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)
-}
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 19 lines
Quoted 19 lines
meta/classes/image_types.bbclass +0 -19
-    # 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)
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -2
-        if ext == '.in' and os.path.exists(wks_file):
-            wks_out_file = os.path.join(d.getVar('WORKDIR'),

os.path.basename(base))

meta/classes/image_types.bbclass +0 -5
-            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

Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so just put

it in

Quoted 8 lines
Quoted 8 lines
meta/classes/image_types.bbclass +0 -3
-                # 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)

meta/classes/image_types.bbclass +0 -2
-}
-
 EXTRA_IMAGECMD = ""
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

inherit siteinfo

meta/classes/image_types.bbclass +0 -0
@@ -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 ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables

used

Quoted 9 lines
Quoted 9 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.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

Quoted 6 lines
Quoted 6 lines

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

--
--
Regards,
Ed

Signature · 3 lines
--
Regards,
Ed
#8 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

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?

Quoted 442 lines · Ed Bartosh
Quoted 5 lines · Rick Altherr

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

Quoted 6 lines

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.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 5 lines
Quoted 2 lines · Ed Bartosh
Quoted 1 line · Rick Altherr

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

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

Quoted 11 lines
Quoted 11 lines

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}

Quoted 2 lines

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines · 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.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables

used

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD

ISODIR

Quoted 8 lines
Quoted 8 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR
TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+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'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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',

'',

Quoted 36 lines
Quoted 36 lines

d)}"

Quoted 9 lines
Quoted 9 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +7 -0
+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)
+}
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 17 lines
Quoted 17 lines
meta/classes/image-wic.bbclass new file +17 -0
+    # 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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +4 -0
+        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))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file changes, and

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so just

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal with the

deps.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +8 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
+#
+python do_rootfs_wicenv () {
+    wicvars = d.getVar('WICVARS')
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+    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:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
meta/classes/image-wic.bbclass new file +8 -0
+        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'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/classes/image.bbclass +0 -6
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.env
-#
-python do_rootfs_wicenv () {
-    wicvars = d.getVar('WICVARS')
Quoted 8 lines
Quoted 8 lines

meta/classes/image.bbclass fakeroot python do_image_qa () {

Quoted 8 lines
meta/classes/image.bbclass +0 -8
-    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:

Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
meta/classes/image.bbclass +0 -5
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var, value.strip()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 5 lines
Quoted 5 lines
meta/classes/image_types.bbclass +0 -3
-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'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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',

'',

Quoted 36 lines
Quoted 36 lines

d)}"

Quoted 9 lines
Quoted 9 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -7
-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)
-}
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 17 lines
Quoted 17 lines
meta/classes/image_types.bbclass +0 -17
-    # 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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -4
-        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))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

meta/classes/image_types.bbclass

Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file changes, and

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so just

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal with the

deps.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 10 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 291

Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk, vdi,

qcow2,

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

author
#9 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Quoted 9 lines · Rick Altherr

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.

Quoted 445 lines
Quoted 442 lines · Ed Bartosh
Quoted 5 lines · Rick Altherr

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

Quoted 6 lines

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.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 5 lines
Quoted 2 lines · Ed Bartosh
Quoted 1 line · Rick Altherr

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

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

Quoted 11 lines
Quoted 11 lines

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}

Quoted 2 lines

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines · 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.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake variables

used

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD

ISODIR

Quoted 8 lines
Quoted 8 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR
TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+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'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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',

'',

Quoted 36 lines
Quoted 36 lines

d)}"

Quoted 9 lines
Quoted 9 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +7 -0
+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)
+}
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 17 lines
Quoted 17 lines
meta/classes/image-wic.bbclass new file +17 -0
+    # 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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +4 -0
+        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))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file changes, and

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so just

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal with the

deps.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +8 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
+#
+python do_rootfs_wicenv () {
+    wicvars = d.getVar('WICVARS')
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+    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:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
meta/classes/image-wic.bbclass new file +8 -0
+        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'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
meta/classes/image.bbclass +0 -6
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.env
-#
-python do_rootfs_wicenv () {
-    wicvars = d.getVar('WICVARS')
Quoted 8 lines
Quoted 8 lines

meta/classes/image.bbclass fakeroot python do_image_qa () {

Quoted 8 lines
meta/classes/image.bbclass +0 -8
-    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:

Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
meta/classes/image.bbclass +0 -5
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var, value.strip()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 5 lines
Quoted 5 lines
meta/classes/image_types.bbclass +0 -3
-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'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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',

'',

Quoted 36 lines
Quoted 36 lines

d)}"

Quoted 9 lines
Quoted 9 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -7
-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)
-}
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 17 lines
Quoted 17 lines
meta/classes/image_types.bbclass +0 -17
-    # 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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_CMD_ubi () {

Quoted 8 lines
meta/classes/image_types.bbclass +0 -4
-        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))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

meta/classes/image_types.bbclass

Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file changes, and

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so just

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal with the

deps.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 10 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 291

Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk, vdi,

qcow2,

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake variables

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines

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
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

Signature · 3 lines
--
Regards,
Ed
#10 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Agreed. What if it was image_types_wic.bbclass and you did something similar to build_uboot() in image.bbclass?

Quoted 505 lines · Ed Bartosh
Quoted 9 lines · Rick Altherr

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.

Quoted 9 lines
Quoted 6 lines · Ed Bartosh
Quoted 5 lines · Rick Altherr

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

Quoted 6 lines
Quoted 6 lines

of

Quoted 5 lines

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

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

expect a machine config to add wic to IMAGE_CLASSES if it needs wic

output.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 1 line

On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <

[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines · wrote:
Quoted 1 line · Rick Altherr

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

load it?

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

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

Quoted 4 lines
Quoted 4 lines

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

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

that usage scenario, I believe.
- 'inherit image_wic' is more explicit than IMAGE_CLASSES += "image_types"\n inherit ${IMAGE_CLASSES}

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · wrote:

There is a lot of wic code in image.bbclass and

image_types.bbclass

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Having all code separated in one file should make it more

readable

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and easier to maintain.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake

variables

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

used

Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES

INITRD

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ISODIR

Quoted 2 lines
Quoted 2 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR

STAGING_LIBDIR

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines

TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
+WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
+WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for

p in

Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image-wic.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 14 lines
Quoted 14 lines

'',

Quoted 13 lines
Quoted 13 lines

d)}"

Quoted 4 lines
Quoted 4 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +2 -0
+do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
+do_image_wic[depends] += "wic-tools:do_build"
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines
meta/classes/image-wic.bbclass new file +5 -0
+    import re
+
+    template_body = d.getVar('_WKS_TEMPLATE')
+
+    # Remove any remnant variable references left behind by

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+    # due to undefined variables
+    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
+    while True:
+        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta/classes/image-wic.bbclass new file +13 -0
+        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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +4 -0
+        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))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file changes,

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal with

the

Quoted 17 lines
Quoted 17 lines

deps.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +5 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+#
+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')

Quoted 30 lines
Quoted 30 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+    bb.utils.mkdirhier(outdir)
+    basename = d.getVar('IMAGE_BASENAME')
+    with open(os.path.join(outdir, basename) + '.env', 'w') as

envf:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
meta/classes/image-wic.bbclass new file +8 -0
+        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'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 345

Quoted 11 lines
meta/classes/image.bbclass +0 -11
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.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')

Quoted 24 lines
Quoted 24 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 348

Quoted 3 lines
meta/classes/image.bbclass +0 -3
-    bb.utils.mkdirhier(outdir)
-    basename = d.getVar('IMAGE_BASENAME')
-    with open(os.path.join(outdir, basename) + '.env', 'w') as

envf:

Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
meta/classes/image.bbclass +0 -5
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var, value.strip()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
-WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
-WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for

p in

Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 14 lines
Quoted 14 lines

'',

Quoted 13 lines
Quoted 13 lines

d)}"

Quoted 4 lines
Quoted 4 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -2
-do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
-do_image_wic[depends] += "wic-tools:do_build"
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image_types.bbclass

Quoted 5 lines
meta/classes/image_types.bbclass +0 -5
-    import re
-
-    template_body = d.getVar('_WKS_TEMPLATE')
-
-    # Remove any remnant variable references left behind by

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-    # due to undefined variables
-    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
-    while True:
-        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta/classes/image_types.bbclass +0 -13
-        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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -4
-        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))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass

Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file changes,

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal with

the

Quoted 11 lines
Quoted 11 lines

deps.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 10 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 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

Quoted 8 lines
Quoted 8 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 291

Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk, vdi,

qcow2,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake

variables

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH

RECIPE_SYSROOT_NATIVE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR

TARGET_SYS"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

--
2.1.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-

core

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

author
#11 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

Quoted 3 lines · Rick Altherr

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?

Quoted 508 lines
Quoted 505 lines · Ed Bartosh
Quoted 9 lines · Rick Altherr

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.

Quoted 9 lines
Quoted 6 lines · Ed Bartosh
Quoted 5 lines · Rick Altherr

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

Quoted 6 lines
Quoted 6 lines

of

Quoted 5 lines

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

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

expect a machine config to add wic to IMAGE_CLASSES if it needs wic

output.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 1 line

On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <

[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines · wrote:
Quoted 1 line · Rick Altherr

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

load it?

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

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

Quoted 4 lines
Quoted 4 lines

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

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

that usage scenario, I believe.
- 'inherit image_wic' is more explicit than IMAGE_CLASSES += "image_types"\n inherit ${IMAGE_CLASSES}

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · wrote:

There is a lot of wic code in image.bbclass and

image_types.bbclass

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Having all code separated in one file should make it more

readable

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and easier to maintain.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake

variables

Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

used

Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES

INITRD

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ISODIR

Quoted 2 lines
Quoted 2 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR

STAGING_LIBDIR

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines

TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
+WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
+WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for

p in

Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image-wic.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 14 lines
Quoted 14 lines

'',

Quoted 13 lines
Quoted 13 lines

d)}"

Quoted 4 lines
Quoted 4 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image-wic.bbclass new file +2 -0
+do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
+do_image_wic[depends] += "wic-tools:do_build"
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines
meta/classes/image-wic.bbclass new file +5 -0
+    import re
+
+    template_body = d.getVar('_WKS_TEMPLATE')
+
+    # Remove any remnant variable references left behind by

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+    # due to undefined variables
+    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
+    while True:
+        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta/classes/image-wic.bbclass new file +13 -0
+        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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +4 -0
+        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))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file changes,

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal with

the

Quoted 17 lines
Quoted 17 lines

deps.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +5 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+#
+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')

Quoted 30 lines
Quoted 30 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+    bb.utils.mkdirhier(outdir)
+    basename = d.getVar('IMAGE_BASENAME')
+    with open(os.path.join(outdir, basename) + '.env', 'w') as

envf:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

Review

Quoted 9 lines
meta/classes/image-wic.bbclass new file +8 -0
+        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'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +2 -0
@@ -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
 
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 345

Quoted 11 lines
meta/classes/image.bbclass +0 -11
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.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')

Quoted 24 lines
Quoted 24 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 348

Quoted 3 lines
meta/classes/image.bbclass +0 -3
-    bb.utils.mkdirhier(outdir)
-    basename = d.getVar('IMAGE_BASENAME')
-    with open(os.path.join(outdir, basename) + '.env', 'w') as

envf:

Quoted 20 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
meta/classes/image.bbclass +0 -5
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var, value.strip()))
-}
Quoted 8 lines

Review

Quoted 8 lines
meta/classes/image.bbclass +0 -4
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
-WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
-WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for

p in

Quoted 31 lines
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${WKS_FILES}. Please set WKS_FILE or WKS_FILES appropriately."

meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e "${IMAGE_BASENAME}" -o

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 14 lines
Quoted 14 lines

'',

Quoted 13 lines
Quoted 13 lines

d)}"

Quoted 4 lines
Quoted 4 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"

meta/classes/image_types.bbclass +0 -2
-do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
-do_image_wic[depends] += "wic-tools:do_build"
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image_types.bbclass

Quoted 5 lines
meta/classes/image_types.bbclass +0 -5
-    import re
-
-    template_body = d.getVar('_WKS_TEMPLATE')
-
-    # Remove any remnant variable references left behind by

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-    # due to undefined variables
-    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
-    while True:
-        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 22 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
meta/classes/image_types.bbclass +0 -13
-        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)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -4
-        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))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass

Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file changes,

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no point

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal with

the

Quoted 11 lines
Quoted 11 lines

deps.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 10 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 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

Quoted 8 lines
Quoted 8 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 291

Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk, vdi,

qcow2,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake

variables

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH

RECIPE_SYSROOT_NATIVE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR

TARGET_SYS"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

--
2.1.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-

core

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

Signature · 3 lines
--
Regards,
Ed
#12 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

LGTM

Quoted 576 lines · Ed Bartosh
Quoted 3 lines · Rick Altherr

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?

Quoted 6 lines

On Mon, Jan 30, 2017 at 10:15 AM, Ed Bartosh <[email protected]

Quoted 2 lines · wrote:
Quoted 1 line · Rick Altherr

I'm not clear on which path is the preferred one. There are lots of

bits

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 2 lines
Quoted 2 lines

commit message - to put existing wic code into a file for better maintenance. If this is more confusing than having wic code in

different

Quoted 7 lines
Quoted 7 lines

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.

Quoted 1 line

On Mon, Jan 30, 2017 at 9:45 AM, Ed Bartosh <

[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 5 lines · Rick Altherr

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

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

of

Quoted 5 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

expect a machine config to add wic to IMAGE_CLASSES if it needs

wic

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines

output.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 1 line

On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <

[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

wrote:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines · Rick Altherr
Quoted 1 line

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

load it?

Because of the following:
- IMAGE_CLASSES[doc] = "A list of classes that all images

should

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

inherit." I'm not sure all images should include wic class.

I'll

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

probably

Quoted 4 lines
Quoted 4 lines

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

Quoted 40 lines
Quoted 40 lines

of

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

that usage scenario, I believe.
- 'inherit image_wic' is more explicit than IMAGE_CLASSES += "image_types"\n inherit ${IMAGE_CLASSES}

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · wrote:

There is a lot of wic code in image.bbclass and

image_types.bbclass

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Having all code separated in one file should make it more

readable

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and easier to maintain.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake

variables

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

used

Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES

INITRD

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ISODIR

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR

STAGING_LIBDIR

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines

TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
+WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
+WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p

for

Quoted 17 lines
Quoted 17 lines

p in

Quoted 16 lines
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

"${IMAGE_BASENAME}" -o

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image-wic.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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

Quoted 7 lines
Quoted 7 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image-wic.bbclass

Quoted 6 lines
meta/classes/image-wic.bbclass new file +6 -0
+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)

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+}
+
+python do_write_wks_template () {
+    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines
meta/classes/image-wic.bbclass new file +5 -0
+    import re
+
+    template_body = d.getVar('_WKS_TEMPLATE')
+
+    # Remove any remnant variable references left behind

by

Quoted 16 lines
Quoted 16 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+    # due to undefined variables
+    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
+    while True:
+        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image-wic.bbclass new file +9 -0
+        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)
+}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no

point

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal

with

Quoted 19 lines
Quoted 19 lines

the

Quoted 17 lines
Quoted 17 lines

deps.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +5 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+#
+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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+    bb.utils.mkdirhier(outdir)
+    basename = d.getVar('IMAGE_BASENAME')
+    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+        for var in wicvars.split():
+            value = d.getVar(var)
+            if value:
+                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+}
+addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
meta/classes/image-wic.bbclass new file +2 -0
+do_rootfs_wicenv[vardeps] += "${WICVARS}"
+do_rootfs_wicenv[prefuncs] = 'set_image_size'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +0 -0
@@ -192,6 +192,8 @@ python () {
 IMAGE_CLASSES += "image_types"
 inherit ${IMAGE_CLASSES}
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 335

Quoted 8 lines
meta/classes/image.bbclass +2 -0
+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

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 344

Quoted 12 lines
meta/classes/image.bbclass +0 -11
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 347

Quoted 3 lines
meta/classes/image.bbclass +0 -3
-    bb.utils.mkdirhier(outdir)
-    basename = d.getVar('IMAGE_BASENAME')
-    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image.bbclass +0 -4
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 353

Quoted 2 lines
meta/classes/image.bbclass +0 -2
-}
-addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

Review

Quoted 7 lines
meta/classes/image.bbclass +0 -3
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
-WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
-WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p

for

Quoted 17 lines
Quoted 17 lines

p in

Quoted 16 lines
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

"${IMAGE_BASENAME}" -o

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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

Quoted 7 lines
Quoted 7 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image_types.bbclass

Quoted 6 lines
meta/classes/image_types.bbclass +0 -6
-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)

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-}
-
-python do_write_wks_template () {
-    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image_types.bbclass

Quoted 5 lines
meta/classes/image_types.bbclass +0 -5
-    import re
-
-    template_body = d.getVar('_WKS_TEMPLATE')
-
-    # Remove any remnant variable references left behind

by

Quoted 16 lines
Quoted 16 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-    # due to undefined variables
-    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
-    while True:
-        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image_types.bbclass +0 -9
-        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)
-}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no

point

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal

with

Quoted 9 lines
Quoted 9 lines

the

Quoted 8 lines
Quoted 8 lines

deps.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 EXTRA_IMAGECMD = ""
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 3 lines

inherit siteinfo

meta/classes/image_types.bbclass +0 -0
@@ -380,7 +289,3 @@ IMAGE_EXTENSION_live = "hddimg iso"
 # The IMAGE_TYPES_MASKED variable will be used to mask out

from

Quoted 3 lines
Quoted 3 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk,

vdi,

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

qcow2,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake

variables

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

HDDDIR

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME

IMAGE_ROOTFS

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH

RECIPE_SYSROOT_NATIVE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR

TARGET_SYS"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

--
2.1.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/

mailman/listinfo/openembedded-

Quoted 15 lines
Quoted 15 lines

core

Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
--
Regards,
Ed

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

author
#13 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

BTW, to be consistent with this approach we also need to rename image-live and image-vm, right? Actually, image-live name was the reason for me to name image-wic.

Quoted 581 lines · Rick Altherr

LGTM

Quoted 576 lines · Ed Bartosh
Quoted 3 lines · Rick Altherr

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?

Quoted 6 lines

On Mon, Jan 30, 2017 at 10:15 AM, Ed Bartosh <[email protected]

Quoted 2 lines · wrote:
Quoted 1 line · Rick Altherr

I'm not clear on which path is the preferred one. There are lots of

bits

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 2 lines
Quoted 2 lines

commit message - to put existing wic code into a file for better maintenance. If this is more confusing than having wic code in

different

Quoted 7 lines
Quoted 7 lines

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.

Quoted 1 line

On Mon, Jan 30, 2017 at 9:45 AM, Ed Bartosh <

[email protected]>

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 5 lines · Rick Altherr

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

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

of

Quoted 5 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line

expect a machine config to add wic to IMAGE_CLASSES if it needs

wic

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines

output.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works just fine. Why to change?

Quoted 1 line

On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <

[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

wrote:

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines · Rick Altherr
Quoted 1 line

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

load it?

Because of the following:
- IMAGE_CLASSES[doc] = "A list of classes that all images

should

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

inherit." I'm not sure all images should include wic class.

I'll

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

probably

Quoted 4 lines
Quoted 4 lines

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

Quoted 40 lines
Quoted 40 lines

of

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

that usage scenario, I believe.
- 'inherit image_wic' is more explicit than IMAGE_CLASSES += "image_types"\n inherit ${IMAGE_CLASSES}

Quoted 1 line
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · wrote:

There is a lot of wic code in image.bbclass and

image_types.bbclass

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Having all code separated in one file should make it more

readable

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and easier to maintain.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of bitbake

variables

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

used

Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

in wic code

meta/classes/image-wic.bbclass new file +3 -0
+# variables from this list is written to <image>.env file
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES

INITRD

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ISODIR

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR

STAGING_LIBDIR

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines

TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
+WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
+WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p

for

Quoted 17 lines
Quoted 17 lines

p in

Quoted 16 lines
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" +WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

"${IMAGE_BASENAME}" -o

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image-wic.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +6 -0
+       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

Quoted 7 lines
Quoted 7 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image-wic.bbclass

Quoted 6 lines
meta/classes/image-wic.bbclass new file +6 -0
+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)

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+}
+
+python do_write_wks_template () {
+    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines
meta/classes/image-wic.bbclass new file +5 -0
+    import re
+
+    template_body = d.getVar('_WKS_TEMPLATE')
+
+    # Remove any remnant variable references left behind

by

Quoted 16 lines
Quoted 16 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+    # due to undefined variables
+    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
+    while True:
+        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image-wic.bbclass new file +9 -0
+        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)
+}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's no

point

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal

with

Quoted 19 lines
Quoted 19 lines

the

Quoted 17 lines
Quoted 17 lines

deps.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +5 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+#
+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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+    bb.utils.mkdirhier(outdir)
+    basename = d.getVar('IMAGE_BASENAME')
+    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+        for var in wicvars.split():
+            value = d.getVar(var)
+            if value:
+                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+}
+addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
meta/classes/image-wic.bbclass new file +2 -0
+do_rootfs_wicenv[vardeps] += "${WICVARS}"
+do_rootfs_wicenv[prefuncs] = 'set_image_size'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +0 -0
@@ -192,6 +192,8 @@ python () {
 IMAGE_CLASSES += "image_types"
 inherit ${IMAGE_CLASSES}
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 335

Quoted 8 lines
meta/classes/image.bbclass +2 -0
+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

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 344

Quoted 12 lines
meta/classes/image.bbclass +0 -11
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 347

Quoted 3 lines
meta/classes/image.bbclass +0 -3
-    bb.utils.mkdirhier(outdir)
-    basename = d.getVar('IMAGE_BASENAME')
-    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image.bbclass +0 -4
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 353

Quoted 2 lines
meta/classes/image.bbclass +0 -2
-}
-addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines

Review

Quoted 7 lines
meta/classes/image.bbclass +0 -3
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 6 lines
Quoted 6 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.ubifs

${MKUBIFS_ARGS}"

Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
-WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
-WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p

for

Quoted 17 lines
Quoted 17 lines

p in

Quoted 16 lines
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/

canned-wks'

Quoted 14 lines
Quoted 14 lines

% l

Quoted 13 lines
Quoted 13 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}" -WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.split(), '${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

"${IMAGE_BASENAME}" -o

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

"$out/"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

meta/classes/image_types.bbclass

Quoted 9 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -6
-       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

Quoted 7 lines
Quoted 7 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()),

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image_types.bbclass

Quoted 6 lines
meta/classes/image_types.bbclass +0 -6
-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)

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-}
-
-python do_write_wks_template () {
-    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image_types.bbclass

Quoted 5 lines
meta/classes/image_types.bbclass +0 -5
-    import re
-
-    template_body = d.getVar('_WKS_TEMPLATE')
-
-    # Remove any remnant variable references left behind

by

Quoted 16 lines
Quoted 16 lines

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

expansion

Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-    # due to undefined variables
-    expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
-    while True:
-        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image_types.bbclass +0 -9
-        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)
-}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's no

point

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as well, so

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal

with

Quoted 9 lines
Quoted 9 lines

the

Quoted 8 lines
Quoted 8 lines

deps.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_wks_template',

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 EXTRA_IMAGECMD = ""
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 3 lines

inherit siteinfo

meta/classes/image_types.bbclass +0 -0
@@ -380,7 +289,3 @@ IMAGE_EXTENSION_live = "hddimg iso"
 # The IMAGE_TYPES_MASKED variable will be used to mask out

from

Quoted 3 lines
Quoted 3 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time: vmdk,

vdi,

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

qcow2,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of bitbake

variables

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

used

Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines

in wic code

meta/classes/image_types.bbclass +0 -2
-# variables from this list is written to <image>.env file
-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

HDDDIR

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME

IMAGE_ROOTFS

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH

RECIPE_SYSROOT_NATIVE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR

TARGET_SYS"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

--
2.1.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/

mailman/listinfo/openembedded-

Quoted 15 lines
Quoted 15 lines

core

Quoted 13 lines
Quoted 13 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
--
Regards,
Ed

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

Signature · 3 lines
--
Regards,
Ed
#14 lore raw

Re: [PATCH v3 01/11] image-wic: move wic code to image-wic.bbclass

I guess so. Or rename image_types_uboot to image-uboot. Personally, I'm going to assume image-live has to do with adding packages to generate a live image whereas image_types_live would be for turning an image into a bootable ISO.

Quoted 646 lines · Ed Bartosh

BTW, to be consistent with this approach we also need to rename image-live and image-vm, right? Actually, image-live name was the reason for me to name image-wic.

Quoted 21 lines · Rick Altherr

LGTM

On Mon, Jan 30, 2017 at 10:42 AM, Ed Bartosh <[email protected]

Quoted 15 lines · wrote:
Quoted 3 lines · Rick Altherr

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?

Quoted 1 line

On Mon, Jan 30, 2017 at 10:15 AM, Ed Bartosh <

[email protected]

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines · wrote:
Quoted 1 line · Rick Altherr

I'm not clear on which path is the preferred one. There are

lots of

Quoted 2 lines
Quoted 2 lines

bits

Quoted 1 line
Quoted 1 line
Quoted 1 line

and pieces in image_types.bbclass that implement various image

types.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

uboot got added as a separate class at some point. The

comments in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

local.conf.sample.extended imply IMAGE_CLASSES should be used to

load

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

additional image_types_* classes to add support for additional

image

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

types. Having the wic image type implemented in a separate image-wic.bbclass that is directly inherited by image.bbclass

adds a

Quoted 2 lines
Quoted 2 lines

3rd

Quoted 1 line
Quoted 1 line
Quoted 1 line

approach. Which one do we want contributors to use in the

future?

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

I didn't want to create even more confusion. What I wanted is

stated

Quoted 5 lines
Quoted 5 lines

in the

Quoted 2 lines
Quoted 2 lines

commit message - to put existing wic code into a file for better maintenance. If this is more confusing than having wic code in

different

Quoted 1 line
Quoted 1 line

places of image.class and image_types.class then we can just drop

this

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

patch. However, I personally find it more maintainable this way.

Suggesting people to change machine configs just because wic code

is

Quoted 12 lines
Quoted 12 lines
Quoted 3 lines
Quoted 3 lines

moved to separate file doesn't look good to me either.

Quoted 1 line

On Mon, Jan 30, 2017 at 9:45 AM, Ed Bartosh <

[email protected]>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · wrote:
Quoted 5 lines · Rick Altherr

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

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

generation

Quoted 6 lines
Quoted 6 lines

of

Quoted 5 lines

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.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I'd

Quoted 1 line
Quoted 1 line
Quoted 1 line

expect a machine config to add wic to IMAGE_CLASSES if it

needs

Quoted 5 lines
Quoted 5 lines

wic

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

output.

Quoted 1 line

So far all machine configs add wic to IMAGE_TYPES and it works

just

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

fine. Why to change?

Quoted 1 line

On Mon, Jan 30, 2017 at 9:18 AM, Ed Bartosh <

[email protected]>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line · wrote:

On Mon, Jan 30, 2017 at 09:27:54AM -0800, Rick Altherr

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Why didn't you make this image_types_wic.bbclass and use

IMAGE_CLASSES to

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

load it?

Because of the following:
- IMAGE_CLASSES[doc] = "A list of classes that all images

should

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

inherit." I'm not sure all images should include wic

class.

Quoted 6 lines
Quoted 6 lines

I'll

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

probably

Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
Quoted 4 lines

out

Quoted 3 lines
Quoted 3 lines

of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

that usage scenario, I believe.
- 'inherit image_wic' is more explicit than IMAGE_CLASSES

+=
> > > > > > > >   "image_types"\n inherit ${IMAGE_CLASSES}
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

On Fri, Jan 27, 2017 at 12:19 PM, Ed Bartosh <

[email protected]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line · wrote:

There is a lot of wic code in image.bbclass and

image_types.bbclass

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Having all code separated in one file should make it

more

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

readable

Quoted 16 lines
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and easier to maintain.

---
 meta/classes/image-wic.bbclass   | 120

++++++++++++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

+++++++++

 meta/classes/image.bbclass       |  25 +-------
 meta/classes/image_types.bbclass |  95

------------------------------

Quoted 5 lines
Quoted 5 lines

-

Quoted 4 lines

Review

Quoted 4 lines
 3 files changed, 122 insertions(+), 118 deletions(-)
 create mode 100644 meta/classes/image-wic.bbclass
(quoted diff) +0 -0

b/meta/classes/image-wic.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

meta/classes/image-wic.bbclass line 1

Quoted 7 lines

bbclass
new file mode 100644
index 0000000..2acfd65

meta/classes/image-wic.bbclass new file +1 -0
@@ -0,0 +1,120 @@
+# The WICVARS variable is used to define list of

bitbake

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

variables

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

used

Quoted 2 lines
Quoted 2 lines

in wic code
+# variables from this list is written to <image>.env

file

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+WICVARS ?= "\
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

HDDDIR

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

IMAGE_BASENAME IMAGE_BOOT_FILES \
+ IMAGE_LINK_NAME IMAGE_ROOTFS

INITRAMFS_FSTYPES

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

INITRD

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ISODIR

Quoted 2 lines
Quoted 2 lines

MACHINE_ARCH RECIPE_SYSROOT_NATIVE \
+ ROOTFS_SIZE STAGING_DATADIR STAGING_DIR

STAGING_LIBDIR

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines

TARGET_SYS"

meta/classes/image-wic.bbclass new file +4 -0
+
+WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
+WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
+WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic'

% p

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

p in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':

'.join('%s/scripts/lib/wic/

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

canned-wks'

Quoted 3 lines
Quoted 3 lines

% l

Quoted 2 lines
Quoted 2 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}"
+WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.

split(),

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

'${WKS_SEARCH_PATH}') or ''}"

meta/classes/image-wic.bbclass new file +10 -0
+
+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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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

Quoted 8 lines
Quoted 8 lines

were

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +3 -0
+       fi
+
+       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

Quoted 8 lines
Quoted 8 lines

"${IMAGE_BASENAME}" -o

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

"$out/"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image-wic.bbclass

Quoted 6 lines

${WIC_CREATE_EXTRA_ARGS}
+ mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image-wic.bbclass new file +3 -0
+       rm -rf "$out/"
+}
+IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH

WKS_FILES"

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+
+# Rebuild when the wks file or vars in WICVARS change
+USING_WIC = "${@bb.utils.contains_any('

IMAGE_FSTYPES',

Quoted 3 lines
Quoted 3 lines

'wic

Quoted 2 lines
Quoted 2 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in

'${CONVERSIONTYPES}'.split()),

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

+WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}'

else

Quoted 13 lines
Quoted 13 lines

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image-wic.bbclass

Quoted 6 lines
meta/classes/image-wic.bbclass new file +6 -0
+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)

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+}
+
+python do_write_wks_template () {
+    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image-wic.bbclass

Quoted 5 lines
meta/classes/image-wic.bbclass new file +5 -0
+    import re
+
+    template_body = d.getVar('_WKS_TEMPLATE')
+
+    # Remove any remnant variable references left

behind

Quoted 5 lines
Quoted 5 lines

by

Quoted 4 lines
Quoted 4 lines

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

expansion

Quoted 2 lines
Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+    # due to undefined variables
+    expand_var_regexp = re.compile(r"\${[^{}@\n\t

:]+}")

Quoted 41 lines
Quoted 41 lines
Quoted 12 lines
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+    while True:
+        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image-wic.bbclass new file +9 -0
+        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)
+}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+
+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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image-wic.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image-wic.bbclass new file +3 -0
+            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+
+            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image-wic.bbclass new file +10 -0
+            # 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
Quoted 4 lines
Quoted 4 lines

get the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
+ # and add it to WICVARS, but there's

no

Quoted 4 lines
Quoted 4 lines

point

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
+ # file in process_wks_template as

well, so

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

+ # a variable and let the metadata deal

with

Quoted 4 lines
Quoted 4 lines

the

Quoted 3 lines
Quoted 3 lines

deps.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+                d.setVar('_WKS_TEMPLATE', body)
+                bb.build.addtask('do_write_

wks_template',

Quoted 82 lines
Quoted 82 lines
Quoted 15 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

'do_image_wic', None, d)

meta/classes/image-wic.bbclass new file +5 -0
+}
+
+#
+# Write environment variables used by wic
+# to tmp/sysroots/<machine>/imgdata/<image>.env
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image-wic.bbclass

Quoted 8 lines
meta/classes/image-wic.bbclass new file +8 -0
+#
+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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image-wic.bbclass

Quoted 3 lines
meta/classes/image-wic.bbclass new file +3 -0
+    bb.utils.mkdirhier(outdir)
+    basename = d.getVar('IMAGE_BASENAME')
+    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image-wic.bbclass new file +4 -0
+        for var in wicvars.split():
+            value = d.getVar(var)
+            if value:
+                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image-wic.bbclass

Quoted 2 lines
meta/classes/image-wic.bbclass new file +2 -0
+}
+addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
meta/classes/image-wic.bbclass new file +2 -0
+do_rootfs_wicenv[vardeps] += "${WICVARS}"
+do_rootfs_wicenv[prefuncs] = 'set_image_size'
(quoted diff) +0 -0

b/meta/classes/image.bbclass

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

index 13fd996..1a549e9 100644

meta/classes/image.bbclass +0 -0
@@ -192,6 +192,8 @@ python () {
 IMAGE_CLASSES += "image_types"
 inherit ${IMAGE_CLASSES}
 
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 335

Quoted 8 lines
meta/classes/image.bbclass +2 -0
+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

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 344

Quoted 12 lines
meta/classes/image.bbclass +0 -11
-#
-# Write environment variables used by wic
-# to tmp/sysroots/<machine>/imgdata/<image>.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')

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 347

Quoted 3 lines
meta/classes/image.bbclass +0 -3
-    bb.utils.mkdirhier(outdir)
-    basename = d.getVar('IMAGE_BASENAME')
-    with open(os.path.join(outdir, basename) + '.env',

'w') as

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

envf:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image.bbclass +0 -4
-        for var in wicvars.split():
-            value = d.getVar(var)
-            if value:
-                envf.write('%s="%s"\n' % (var,

value.strip()))

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image.bbclass fakeroot python do_image_qa () { · line 353

Quoted 2 lines
meta/classes/image.bbclass +0 -2
-}
-addtask do_rootfs_wicenv after do_image before

do_image_wic

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

Review

Quoted 7 lines
meta/classes/image.bbclass +0 -3
-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')
(quoted diff) +0 -0

b/meta/classes/image_types.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

bbclass
index ad95dc6..e2ecf93 100644

meta/classes/image_types.bbclass +0 -0
@@ -192,97 +192,6 @@ IMAGE_CMD_ubi () {
 
 IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o

${IMGDEPLOYDIR}/${IMAGE_NAME}$

{IMAGE_NAME_SUFFIX}.ubifs

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

${MKUBIFS_ARGS}"

Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
-WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
-WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic'

% p

Quoted 3 lines
Quoted 3 lines

for

Quoted 2 lines
Quoted 2 lines

p in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'${BBPATH}'.split(':'))}:${@':

'.join('%s/scripts/lib/wic/

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

canned-wks'

Quoted 3 lines
Quoted 3 lines

% l

Quoted 2 lines
Quoted 2 lines

for l in '${BBPATH}:${COREBASE}'.split(':'))}"
-WKS_FULL_PATH = "${@wks_search('${WKS_FILES}'.

split(),

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

'${WKS_SEARCH_PATH}') or ''}"

meta/classes/image_types.bbclass +0 -10
-
-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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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

Quoted 8 lines
Quoted 8 lines

were

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

found:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

${WKS_FILES}. Please set WKS_FILE or WKS_FILES

appropriately."

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
meta/classes/image_types.bbclass +0 -3
-       fi
-
-       BUILDDIR="${TOPDIR}" wic create "$wks" --vars

"${STAGING_DIR}/${MACHINE}/imgdata/" -e

Quoted 8 lines
Quoted 8 lines

"${IMAGE_BASENAME}" -o

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

"$out/"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image_types.bbclass

Quoted 6 lines

${WIC_CREATE_EXTRA_ARGS}
- mv "$out/$(basename "${wks%.wks}")"*.direct
"$out${IMAGE_NAME_SUFFIX}.wic"

meta/classes/image_types.bbclass +0 -3
-       rm -rf "$out/"
-}
-IMAGE_CMD_wic[vardepsexclude] = "WKS_FULL_PATH

WKS_FILES"

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

meta/classes/image_types.bbclass

Quoted 3 lines
meta/classes/image_types.bbclass +0 -3
-
-# Rebuild when the wks file or vars in WICVARS change
-USING_WIC = "${@bb.utils.contains_any('

IMAGE_FSTYPES',

Quoted 3 lines
Quoted 3 lines

'wic

Quoted 2 lines
Quoted 2 lines

' + '

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

'.join('wic.%s' % c for c in

'${CONVERSIONTYPES}'.split()),

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

'1',

Quoted 4 lines
Quoted 4 lines

'',

Quoted 3 lines
Quoted 3 lines

d)}"

Quoted 2 lines
Quoted 2 lines

-WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}'

else

Quoted 13 lines
Quoted 13 lines

''}"

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

meta/classes/image_types.bbclass

Quoted 6 lines
meta/classes/image_types.bbclass +0 -6
-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)

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines
meta/classes/image_types.bbclass +0 -4
-}
-
-python do_write_wks_template () {
-    """Write out expanded template contents to

WKS_FULL_PATH."""

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

meta/classes/image_types.bbclass

Quoted 5 lines
meta/classes/image_types.bbclass +0 -5
-    import re
-
-    template_body = d.getVar('_WKS_TEMPLATE')
-
-    # Remove any remnant variable references left

behind

Quoted 5 lines
Quoted 5 lines

by

Quoted 4 lines
Quoted 4 lines

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

expansion

Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-    # due to undefined variables
-    expand_var_regexp = re.compile(r"\${[^{}@\n\t

:]+}")

Quoted 41 lines
Quoted 41 lines
Quoted 12 lines
Quoted 12 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

meta/classes/image_types.bbclass

Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-    while True:
-        new_body = re.sub(expand_var_regexp, '',

template_body)

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta/classes/image_types.bbclass +0 -9
-        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)
-}
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass

Quoted 8 lines
meta/classes/image_types.bbclass +0 -8
-
-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'),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

os.path.basename(base))

meta/classes/image_types.bbclass +0 -3
-            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')

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-
-            # We need to re-parse each time the file

changes,

Quoted 12 lines
Quoted 12 lines

and

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

bitbake

Quoted 10 lines
Quoted 10 lines
meta/classes/image_types.bbclass +0 -10
-            # 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
Quoted 4 lines
Quoted 4 lines

get the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

dependency

Quoted 2 lines
Quoted 2 lines

list
- # and add it to WICVARS, but there's

no

Quoted 4 lines
Quoted 4 lines

point

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

re-parsing

Quoted 2 lines
Quoted 2 lines

the
- # file in process_wks_template as

well, so

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

just

Quoted 3 lines
Quoted 3 lines

put

Quoted 2 lines
Quoted 2 lines

it in

Quoted 1 line
Quoted 1 line

- # a variable and let the metadata deal

with

Quoted 4 lines
Quoted 4 lines

the

Quoted 3 lines
Quoted 3 lines

deps.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -2
-                d.setVar('_WKS_TEMPLATE', body)
-                bb.build.addtask('do_write_

wks_template',

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

meta/classes/image_types.bbclass IMAGE_EXTENSION_live = "hddimg iso" · line 289

Quoted 8 lines

'do_image_wic', None, d)

meta/classes/image_types.bbclass +0 -2
-}
-
 EXTRA_IMAGECMD = ""
 
 inherit siteinfo
@@ -380,7 +289,3 @@ IMAGE_EXTENSION_live = "hddimg iso"
 # The IMAGE_TYPES_MASKED variable will be used to

mask out

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

from

Quoted 3 lines
Quoted 3 lines

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
meta/classes/image_types.bbclass +0 -0
 IMAGE_FSTYPES,
 # images that will not be built at do_rootfs time:

vmdk,

Quoted 6 lines
Quoted 6 lines

vdi,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

qcow2,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

meta/classes/image_types.bbclass

Quoted 4 lines

hdddirect, hddimg, iso, etc.
IMAGE_TYPES_MASKED ?= ""

meta/classes/image_types.bbclass +0 -2
-
-# The WICVARS variable is used to define list of

bitbake

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

variables

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

used

Quoted 2 lines
Quoted 2 lines

in wic code
-# variables from this list is written to <image>.env

file

Quoted 39 lines
Quoted 39 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

-WICVARS ?= "BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE

FAKEROOTCMD

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

HDDDIR

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

IMAGE_BASENAME IMAGE_BOOT_FILES IMAGE_LINK_NAME

IMAGE_ROOTFS

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

INITRAMFS_FSTYPES INITRD ISODIR MACHINE_ARCH

RECIPE_SYSROOT_NATIVE

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR

TARGET_SYS"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

--
2.1.4

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/

mailman/listinfo/openembedded-

Quoted 20 lines
Quoted 20 lines

core

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

Quoted 5 lines
Quoted 5 lines

--
--
Regards,
Ed

--
--
Regards,
Ed

author
#15 lore raw

PATCH v3 2/11 wic: use INITRD_LIVE in isoimage-isohybrid

In reply to Ed Bartosh

INITRD variable is not set if hddimg is disabled. isoimage-isohybrid can't get correct name for initrd if INITRD variable is not set.

Added INITRD_LIVE to WICVARS and used it in isoimage-isohybrid code to get initrd artifact name. Used INITRD if INITRD_LIVE is not set.

---
 meta/classes/image-wic.bbclass                       | 4 ++--
 meta/lib/oeqa/selftest/wic.py                        | 2 +-
 scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
meta/classes/image-wic.bbclass +2 -2
index 2acfd65..ab2e541 100644
@@ -2,8 +2,8 @@
 # variables from this list is written to <image>.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"
+           IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE 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"
meta/lib/oeqa/selftest/wic.py +1 -1
index 53631fa..8eb77ae 100644
@@ -373,7 +373,7 @@ class Wic(oeSelfTest):
         wicvars = set(get_bb_var('WICVARS', image).split())
         # filter out optional variables
         wicvars = wicvars.difference(('HDDDIR', 'IMAGE_BOOT_FILES',
-                                      'INITRD', 'ISODIR'))
+                                      'INITRD', 'INITRD_LIVE', 'ISODIR'))
         with open(path) as envfile:
             content = dict(line.split("=", 1) for line in envfile)
             # test if variables used by wic present in the .env file
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +1 -1
index a8a5dc0..fd25190 100644
@@ -144,7 +144,7 @@ class IsoImagePlugin(SourcePlugin):
         Create path for initramfs image
         """
 
-        initrd = get_bitbake_var("INITRD")
+        initrd = get_bitbake_var("INITRD_LIVE") or get_bitbake_var("INITRD")
         if not initrd:
             initrd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
             if not initrd_dir:
Signature · 1 line
2.1.4
author
#16 lore raw

PATCH v3 3/11 wic: isoimage-isohybrid: stop using HDDDIR

In reply to Ed Bartosh

Stop using HDDDIR in isoimage-isohybrid wic plugin. This variable is set by hddimg code, which is going to be removed soon.

All required artifacts should be available from ISODIR. wic-image.bbclass has been modified to build iso artifacts, so it should be safe to remove usage of HDDDIR.

[YOCTO #10835]

---
 scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +2 -8
index fd25190..a637ce5 100644
@@ -249,12 +249,8 @@ class IsoImagePlugin(SourcePlugin):
         part.rootfs_dir = rootfs_dir
 
         # Prepare rootfs.img
-        hdd_dir = get_bitbake_var("HDDDIR")
         img_iso_dir = get_bitbake_var("ISODIR")
-
-        rootfs_img = "%s/rootfs.img" % hdd_dir
-        if not os.path.isfile(rootfs_img):
-            rootfs_img = "%s/rootfs.img" % img_iso_dir
+        rootfs_img = "%s/rootfs.img" % img_iso_dir
         if not os.path.isfile(rootfs_img):
             # check if rootfs.img is in deploydir
             deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
@@ -283,9 +279,7 @@ class IsoImagePlugin(SourcePlugin):
             os.remove(part.source_file)
 
         # Prepare initial ramdisk
-        initrd = "%s/initrd" % hdd_dir
-        if not os.path.isfile(initrd):
-            initrd = "%s/initrd" % img_iso_dir
+        initrd = "%s/initrd" % img_iso_dir
         if not os.path.isfile(initrd):
             initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir)
 
Signature · 1 line
2.1.4
author
#17 lore raw

PATCH v3 4/11 image-wic: remove HDDDIR from WICVARS

In reply to Ed Bartosh

Removed HDDDIR as it's not used by wic anymore.
Stopped usage of HDDDIR in wic test suite.

---
 meta/classes/image-wic.bbclass | 2 +-
 meta/lib/oeqa/selftest/wic.py  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
meta/classes/image-wic.bbclass +1 -1
index ab2e541..bd79073 100644
@@ -1,7 +1,7 @@
 # The WICVARS variable is used to define list of bitbake variables used in wic code
 # variables from this list is written to <image>.env file
 WICVARS ?= "\
-           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD HDDDIR IMAGE_BASENAME IMAGE_BOOT_FILES \
+           BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILES \
            IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR MACHINE_ARCH \
            RECIPE_SYSROOT_NATIVE ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS"
 
meta/lib/oeqa/selftest/wic.py +2 -2
index 8eb77ae..ebbb280 100644
@@ -372,8 +372,8 @@ class Wic(oeSelfTest):
 
         wicvars = set(get_bb_var('WICVARS', image).split())
         # filter out optional variables
-        wicvars = wicvars.difference(('HDDDIR', 'IMAGE_BOOT_FILES',
-                                      'INITRD', 'INITRD_LIVE', 'ISODIR'))
+        wicvars = wicvars.difference(('IMAGE_BOOT_FILES', 'INITRD',
+                                      'INITRD_LIVE', 'ISODIR'))
         with open(path) as envfile:
             content = dict(line.split("=", 1) for line in envfile)
             # test if variables used by wic present in the .env file
Signature · 1 line
2.1.4
author
#18 lore raw

PATCH v3 5/11 wic: Look for image artifacts in a common location

In reply to Ed Bartosh

From: Tom Zanussi <[email protected]>

Rather than have each image type look for artifacts in image-specific locations, move towards having them look for artifacts in a common location, in this case DEPLOY_DIR_IMAGE

Use the existing deploy.bbclass to have the bootloaders put their binaries in DEPLOY_DIR_IMAGE and then wic will find them and place them in the image

---
 meta/lib/oeqa/selftest/wic.py                      |  4 +--
 scripts/lib/wic/plugins/source/bootimg-efi.py      | 39 ++++++++++++++++------
 .../lib/wic/plugins/source/isoimage-isohybrid.py   | 18 +++++++---
 3 files changed, 45 insertions(+), 16 deletions(-)
meta/lib/oeqa/selftest/wic.py +2 -2
index ebbb280..da68e25 100644
@@ -372,8 +372,8 @@ class Wic(oeSelfTest):
 
         wicvars = set(get_bb_var('WICVARS', image).split())
         # filter out optional variables
-        wicvars = wicvars.difference(('IMAGE_BOOT_FILES', 'INITRD',
-                                      'INITRD_LIVE', 'ISODIR'))
+        wicvars = wicvars.difference(('DEPLOY_DIR_IMAGE', 'IMAGE_BOOT_FILES',
+                                      'INITRD', 'INITRD_LIVE', 'ISODIR'))
         with open(path) as envfile:
             content = dict(line.split("=", 1) for line in envfile)
             # test if variables used by wic present in the .env file
scripts/lib/wic/plugins/source/bootimg-efi.py +29 -10
index 305e910..74a1557 100644
@@ -42,7 +42,7 @@ class BootimgEFIPlugin(SourcePlugin):
     name = 'bootimg-efi'
 
     @classmethod
-    def do_configure_grubefi(cls, hdddir, creator, cr_workdir):
+    def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
         """
         Create loader-specific (grub-efi) config
         """
@@ -82,7 +82,7 @@ class BootimgEFIPlugin(SourcePlugin):
         cfg.close()
 
     @classmethod
-    def do_configure_systemdboot(cls, hdddir, creator, cr_workdir):
+    def do_configure_systemdboot(cls, hdddir, creator, cr_workdir, source_params):
         """
         Create loader-specific systemd-boot/gummiboot config
         """
@@ -98,6 +98,19 @@ class BootimgEFIPlugin(SourcePlugin):
         loader_conf += "default boot\n"
         loader_conf += "timeout %d\n" % bootloader.timeout
 
+        initrd = source_params.get('initrd')
+
+        if initrd:
+            # obviously we need to have a common common deploy var
+            bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+            if not bootimg_dir:
+                msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
+
+            cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
+            exec_cmd(cp_cmd, True)
+        else:
+            msger.debug("Ignoring missing initrd")
+
         msger.debug("Writing systemd-boot config %s/hdd/boot/loader/loader.conf" \
                         % cr_workdir)
         cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
@@ -127,6 +140,9 @@ class BootimgEFIPlugin(SourcePlugin):
             boot_conf += "options LABEL=Boot root=%s %s\n" % \
                              (creator.rootdev, bootloader.append)
 
+            if initrd:
+                boot_conf += "initrd /%s\n" % initrd
+
         msger.debug("Writing systemd-boot config %s/hdd/boot/loader/entries/boot.conf" \
                         % cr_workdir)
         cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
@@ -148,9 +164,9 @@ class BootimgEFIPlugin(SourcePlugin):
 
         try:
             if source_params['loader'] == 'grub-efi':
-                cls.do_configure_grubefi(hdddir, creator, cr_workdir)
+                cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
             elif source_params['loader'] == 'systemd-boot':
-                cls.do_configure_systemdboot(hdddir, creator, cr_workdir)
+                cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
             else:
                 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
         except KeyError:
@@ -167,9 +183,9 @@ class BootimgEFIPlugin(SourcePlugin):
         In this case, prepare content for an EFI (grub) boot partition.
         """
         if not bootimg_dir:
-            bootimg_dir = get_bitbake_var("HDDDIR")
+            bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
             if not bootimg_dir:
-                msger.error("Couldn't find HDDDIR, exiting\n")
+                 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
             # just so the result notes display it
             creator.set_bootimg_dir(bootimg_dir)
 
@@ -181,17 +197,20 @@ class BootimgEFIPlugin(SourcePlugin):
             (staging_kernel_dir, hdddir)
         exec_cmd(install_cmd)
 
+
         try:
             if source_params['loader'] == 'grub-efi':
                 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
                                 "%s/grub.cfg" % cr_workdir)
-                cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir)
-                exec_cmd(cp_cmd, True)
+                for mod in [x for x in os.listdir(bootimg_dir) if x.startswith("grub-efi-")]:
+                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[9:])
+                    exec_cmd(cp_cmd, True)
                 shutil.move("%s/grub.cfg" % cr_workdir,
                             "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
             elif source_params['loader'] == 'systemd-boot':
-                cp_cmd = "cp %s/EFI/BOOT/* %s/EFI/BOOT" % (bootimg_dir, hdddir)
-                exec_cmd(cp_cmd, True)
+                for mod in [x for x in os.listdir(bootimg_dir) if x.startswith("systemd-")]:
+                    cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (bootimg_dir, mod, hdddir, mod[8:])
+                    exec_cmd(cp_cmd, True)
             else:
                 msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader'])
         except KeyError:
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +14 -4
index a637ce5..b54a229 100644
@@ -249,6 +249,7 @@ class IsoImagePlugin(SourcePlugin):
         part.rootfs_dir = rootfs_dir
 
         # Prepare rootfs.img
+        hdd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
         img_iso_dir = get_bitbake_var("ISODIR")
         rootfs_img = "%s/rootfs.img" % img_iso_dir
         if not os.path.isfile(rootfs_img):
@@ -278,10 +279,19 @@ class IsoImagePlugin(SourcePlugin):
         if os.path.isfile(part.source_file):
             os.remove(part.source_file)
 
-        # Prepare initial ramdisk
-        initrd = "%s/initrd" % img_iso_dir
-        if not os.path.isfile(initrd):
-            initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir)
+        # Support using a different initrd other than default
+        if source_params.get('initrd'):
+            initrd = source_params['initrd']
+            if not hdd_dir:
+                msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
+            cp_cmd = "cp %s/%s %s" % (hdd_dir, initrd, cr_workdir)
+        else:
+            # Prepare initial ramdisk
+            initrd = "%s/initrd" % hdd_dir
+            if not os.path.isfile(initrd):
+                initrd = "%s/initrd" % img_iso_dir
+            if not os.path.isfile(initrd):
+                initrd = cls._build_initramfs_path(rootfs_dir, cr_workdir)
 
         install_cmd = "install -m 0644 %s %s/initrd" \
             % (initrd, isodir)
Signature · 1 line
2.1.4
author
#19 lore raw

PATCH v3 6/11 isoimage-isohybrid: use TRANSLATED_TARGET_ARCH instead of MACHINE_ARCH

In reply to Ed Bartosh

isoimage-sihybrid plugin uses MACHINE_ARCH to get the name of initrd image. It doesn't work for all machines, for example for quemux86-64 machine MACHINE_ARCH is quemux86_64 and initrd name is core-image-minimal-initramfs-qemux86-64.cpio.gz

Used TRANSLATED_TARGET_ARCH variable to get the initrd image name. Replaced MACHINE_ARCH->TRANSLATED_TARGET_ARCH in WICVARS variable to make it available from <image>.env file.

---
 meta/classes/image-wic.bbclass                       | 4 ++--
 scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)
meta/classes/image-wic.bbclass +2 -2
index bd79073..3e98959 100644
@@ -2,8 +2,8 @@
 # variables from this list is written to <image>.env file
 WICVARS ?= "\
            BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILES \
-           IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR MACHINE_ARCH \
-           RECIPE_SYSROOT_NATIVE ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS"
+           IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \
+           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH"
 
 WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
 WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +4 -4
index b54a229..e4637a3 100644
@@ -158,11 +158,11 @@ class IsoImagePlugin(SourcePlugin):
             if not image_type:
                 msger.error("Couldn't find INITRAMFS_FSTYPES, exiting.\n")
 
-            machine_arch = get_bitbake_var("MACHINE_ARCH")
-            if not machine_arch:
-                msger.error("Couldn't find MACHINE_ARCH, exiting.\n")
+            target_arch = get_bitbake_var("TRANSLATED_TARGET_ARCH")
+            if not target_arch:
+                msger.error("Couldn't find TRANSLATED_TARGET_ARCH, exiting.\n")
 
-            initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, machine_arch, image_type))[0]
+            initrd = glob.glob('%s/%s*%s.%s' % (initrd_dir, image_name, target_arch, image_type))[0]
 
         if not os.path.exists(initrd):
             # Create initrd from rootfs directory
Signature · 1 line
2.1.4
author
#20 lore raw

PATCH v3 7/11 selftest: stop using hddimg in the wic test suite

In reply to Ed Bartosh

Removed hddimg from IMAGE_FEATURES as wic code doesn't use hddimg anymore.

[YOCTO #10835]

---
 meta/lib/oeqa/selftest/wic.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
meta/lib/oeqa/selftest/wic.py +1 -2
index da68e25..dce83ba 100644
@@ -42,8 +42,7 @@ class Wic(oeSelfTest):
 
     def setUpLocal(self):
         """This code is executed before each test method."""
-        self.write_config('IMAGE_FSTYPES += " hddimg"\n'
-                          'MACHINE_FEATURES_append = " efi"\n')
+        self.write_config('MACHINE_FEATURES_append = " efi"\n')
 
         # Do this here instead of in setUpClass as the base setUp does some
         # clean up which can result in the native tools built earlier in
Signature · 1 line
2.1.4
author
#21 lore raw

PATCH v3 8/11 selftest: wic: fix test_iso_image test case

In reply to Ed Bartosh

Added "iso" to IMAGE_FSTYPES to build iso artifacts required to fix test of isoimage-isohybrid wic plugin.

---
 meta/lib/oeqa/selftest/wic.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/lib/oeqa/selftest/wic.py +2 -1
index dce83ba..6a6b54c 100644
@@ -42,7 +42,8 @@ class Wic(oeSelfTest):
 
     def setUpLocal(self):
         """This code is executed before each test method."""
-        self.write_config('MACHINE_FEATURES_append = " efi"\n')
+        self.write_config('IMAGE_FSTYPES = "iso"\n'
+                          'MACHINE_FEATURES_append = " efi"\n')
 
         # Do this here instead of in setUpClass as the base setUp does some
         # clean up which can result in the native tools built earlier in
Signature · 1 line
2.1.4
author
#22 lore raw

PATCH v3 9/11 grub-efi.bbclass: use 'grub-efi-' prefix

In reply to Ed Bartosh

grub-efi recipe added 'grub-efi-' prefix to the file name of efi binary. Changed grub-efi.bbclass accordingly.

---
 meta/classes/grub-efi.bbclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/classes/grub-efi.bbclass +6 -4
index 3dc9146..8adda09 100644
@@ -40,13 +40,15 @@ efi_populate() {
 
 	install -d ${DEST}${EFIDIR}
 
-	GRUB_IMAGE="bootia32.efi"
+	GRUB_IMAGE="grub-efi-bootia32.efi"
+	DEST_IMAGE="bootia32.efi"
 	if [ "${TARGET_ARCH}" = "x86_64" ]; then
-		GRUB_IMAGE="bootx64.efi"
+		GRUB_IMAGE="grub-efi-bootx64.efi"
+		DEST_IMAGE="bootx64.efi"
 	fi
-	install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}
+	install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}/${DEST_IMAGE}
 	EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
-	printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" >${DEST}/startup.nsh
+	printf 'fs0:%s\%s\n' "$EFIPATH" "$DEST_IMAGE" >${DEST}/startup.nsh
 
 	install -m 0644 ${GRUB_CFG} ${DEST}${EFIDIR}/grub.cfg
 }
Signature · 1 line
2.1.4
author
#23 lore raw

PATCH v3 10/11 wic-tools: add dependency to systemd-boot

In reply to Ed Bartosh

Added systemd-boot to the list of dependencies of wic-tools as wic bootimg-efi plugin depends on it.

---
 meta/recipes-core/meta/wic-tools.bb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/recipes-core/meta/wic-tools.bb +2 -2
index aa09c82..1d9ea9c 100644
@@ -3,8 +3,8 @@ SUMMARY = "A meta recipe to build native tools used by wic."
 LICENSE = "MIT"
 
 DEPENDS = "parted-native syslinux-native gptfdisk-native dosfstools-native mtools-native bmap-tools-native grub-efi-native cdrtools-native"
-DEPENDS_append_x86 = " syslinux grub-efi"
-DEPENDS_append_x86-64 = " syslinux grub-efi"
+DEPENDS_append_x86 = " syslinux grub-efi systemd-boot"
+DEPENDS_append_x86-64 = " syslinux grub-efi systemd-boot"
 
 INHIBIT_DEFAULT_DEPS = "1"
 inherit nopackages
Signature · 1 line
2.1.4
author
#24 lore raw

PATCH v3 11/11 isoimage-isohybrid: renamed variable hdd_dir

In reply to Ed Bartosh

Renamed variable hdd_dir to deploy_dir as this variable is assigned to the value of DEPLOY_DIR_IMAGE.

---
 scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/lib/wic/plugins/source/isoimage-isohybrid.py +4 -4
index e4637a3..bceaa84 100644
@@ -249,7 +249,7 @@ class IsoImagePlugin(SourcePlugin):
         part.rootfs_dir = rootfs_dir
 
         # Prepare rootfs.img
-        hdd_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+        deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
         img_iso_dir = get_bitbake_var("ISODIR")
         rootfs_img = "%s/rootfs.img" % img_iso_dir
         if not os.path.isfile(rootfs_img):
@@ -282,12 +282,12 @@ class IsoImagePlugin(SourcePlugin):
         # Support using a different initrd other than default
         if source_params.get('initrd'):
             initrd = source_params['initrd']
-            if not hdd_dir:
+            if not deploy_dir:
                 msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n")
-            cp_cmd = "cp %s/%s %s" % (hdd_dir, initrd, cr_workdir)
+            cp_cmd = "cp %s/%s %s" % (deploy_dir, initrd, cr_workdir)
         else:
             # Prepare initial ramdisk
-            initrd = "%s/initrd" % hdd_dir
+            initrd = "%s/initrd" % deploy_dir
             if not os.path.isfile(initrd):
                 initrd = "%s/initrd" % img_iso_dir
             if not os.path.isfile(initrd):
Signature · 1 line
2.1.4
#25 lore raw

✗ patchtest: failure for Fix for #10835 - WIC should not rely on hddimg creation for finding all needed artifacts (rev3)

In reply to Ed Bartosh

== Series Details ==

Series: Fix for #10835 - WIC should not rely on hddimg creation for finding all needed artifacts (rev3)
Revision: 3
URL : https://patchwork.openembedded.org/series/4802/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 3a617a4c66)

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe