meta-swupd: support rm_work.bbclass
PATCH 1/1 meta-swupd: support rm_work.bbclass
Sharing data between virtual images only worked when rm_work.bbclass was not active.
To support rm_work.bbclass, the new do_swupd_list_bundle generates the necessary information about the rootfs before do_rm_work removes the rootfs. The output files and the mega image rootfs.tar get excluded from the cleanup via the new RM_WORK_EXCLUDE_ITEMS.
While at it, some inaccurate comments get removed.
As a side effect of the more granular work split, it is now possible to make swupd images depend on exactly those bundle images that they contain. Now it is possible to build a swupd image without first having to build all swupd images, which might speed up a build (less work on the critical path).
--- classes/swupd-image.bbclass | 32 ++++++++++++++++-- classes/swupdimage.bbclass | 7 ++-- lib/swupd/bundles.py | 81 ++++++++++++++++++++++----------------------- lib/swupd/rootfs.py | 6 ++-- 4 files changed, 76 insertions(+), 50 deletions(-)
classes/swupd-image.bbclass +29 -3
@@ -123,6 +123,8 @@ inherit distro_features_check REQUIRED_DISTRO_FEATURES = "systemd" python () { + import os + ver = d.getVar('OS_VERSION', True) or 'invalid' try: ver = int(ver)
@@ -151,7 +153,15 @@ python () { mega_rootfs = d.getVar('IMAGE_ROOTFS', True) mega_rootfs = mega_rootfs.replace('/' + pn +'/', '/bundle-%s-mega/' % (pn_base or pn)) d.setVar('MEGA_IMAGE_ROOTFS', mega_rootfs) - d.setVar('MEGA_IMAGE_ARCHIVE', mega_rootfs + '.tar') + mega_archive = mega_rootfs + '.tar' + workdir = d.getVar('WORKDIR') + d.setVar('MEGA_IMAGE_ARCHIVE', mega_archive) + mega_archive_rel = os.path.relpath(mega_archive, workdir) + if os.path.sep not in mega_archive_rel: + # The mega archive is in our work directory and must be + # preserved for other virtual images even when rm_work.bbclass + # is active. + d.appendVar('RM_WORK_EXCLUDE_ITEMS', ' ' + mega_archive_rel) if pn_base is not None: # Swupd images must depend on the mega image having been
@@ -271,6 +281,19 @@ do_image_append () { swupd.rootfs.create_rootfs(d) } +# The content lists of each rootfs get stored separately and +# need to be preserved when rm_work.bbclass is active. +# That information is used by do_stage_swupd_inputs in the +# base recipe. +RM_WORK_EXCLUDE_ITEMS += "swupd${SWUPD_ROOTFS_MANIFEST_SUFFIX} swupd${SWUPD_IMAGE_MANIFEST_SUFFIX}" +python do_swupd_list_bundle () { + import swupd.bundles + + swupd.bundles.list_bundle_contents(d) +} +do_swupd_list_bundle[depends] = "${@ '${SWUPD_IMAGE_PN}:do_swupd_list_bundle' if '${SWUPD_IMAGE_PN}' != '${PN}' else '' }" +addtask do_swupd_list_bundle after do_image before do_build + # Some files should not be included in swupd manifests and therefore never be # updated on the target (i.e. certain per-device or machine-generated files in # /etc when building for a statefule OS). Add the target paths to this list to
@@ -295,9 +318,12 @@ fakeroot python do_stage_swupd_inputs () { swupd.bundles.copy_core_contents(d) swupd.bundles.copy_bundle_contents(d) } -addtask stage_swupd_inputs after do_image before do_swupd_update +addtask stage_swupd_inputs after do_swupd_list_bundle before do_swupd_update do_stage_swupd_inputs[dirs] = "${SWUPDIMAGEDIR} ${SWUPDMANIFESTDIR} ${DEPLOY_DIR_SWUPD}/maps/" -do_stage_swupd_inputs[depends] += "virtual/fakeroot-native:do_populate_sysroot" +do_stage_swupd_inputs[depends] += " \ + virtual/fakeroot-native:do_populate_sysroot \ + ${@ ' '.join(['bundle-${SWUPD_IMAGE_PN}-%s:do_swupd_list_bundle' % x for x in '${SWUPD_BUNDLES}'.split()]) } \ +" python do_fetch_swupd_inputs () { import swupd.bundles
classes/swupdimage.bbclass +5 -2
@@ -56,8 +56,11 @@ python swupdimage_virtclass_handler () { # variable triggers the creation of the IMGDEPLOYDIR that we # are going to write into. e.data.setVar("do_rootfs", " bb.utils.mkdirhier(d.getVar('IMAGE_ROOTFS', True))\n") - # Depend on complete bundle generation in the base image. - dep = ' %s:do_stage_swupd_inputs' % pn_base + # Depends on the content files from those bundles which contribute to the + # image. + imageext = d.getVar('IMAGE_BUNDLE_NAME', True) or '' + imagebundles = d.getVarFlag('SWUPD_IMAGES', imageext, True).split() if imageext else [] + dep = ' '.join(['bundle-%s-%s:do_swupd_list_bundle' % (pn_base, x) for x in imagebundles]) e.data.appendVarFlag('do_image', 'depends', dep) # Ensure update stream is generated when only building virt image dep = ' %s:do_swupd_update' % pn_base
lib/swupd/bundles.py +39 -42
126 lines not on this page · raw message
lib/swupd/rootfs.py +3 -3
@@ -39,6 +39,7 @@ def create_rootfs(d): imagebundles = d.getVarFlag('SWUPD_IMAGES', imageext, True).split() if imageext else [] rootfs = d.getVar('IMAGE_ROOTFS', True) rootfs_contents = set() + parts = d.getVar('WORKDIR', True).rsplit(pn, 1) if not pn_base: # the base image import subprocess
@@ -57,13 +58,12 @@ def create_rootfs(d): else: # non-base image, i.e. swupdimage manifest = d.expand("${DEPLOY_DIR_SWUPD}/image/${OS_VERSION}/os-core") for suffix in suffixes: - rootfs_contents.update(manifest_to_file_list(manifest + suffix)) + rootfs_contents.update(manifest_to_file_list(parts[0] + pn_base + parts[1] + '/swupd' + suffix)) bb.debug(3, 'rootfs_contents has %s entries' % (len(rootfs_contents))) for bundle in imagebundles: - manifest = d.expand("${DEPLOY_DIR_SWUPD}/image/${OS_VERSION}/") + bundle for suffix in suffixes: - rootfs_contents.update(manifest_to_file_list(manifest + suffix)) + rootfs_contents.update(manifest_to_file_list(parts[0] + ('bundle-%s-%s' % (pn_base, bundle)) + parts[1] + '/swupd' + suffix)) mega_archive = d.getVar('MEGA_IMAGE_ARCHIVE', True) bb.debug(2, 'Re-copying rootfs contents from mega image %s to %s' % (mega_archive, rootfs))
Signature · 1 line
2.11.0