diff mbox series

[meta-swupdate] Add SWUPDATE_LIST_FOR_CPIO to allow explicit SWU file inclusion

Message ID 08a8c3e4-2fcc-401c-9cc6-e5f744244ef7@googlegroups.com
State Changes Requested
Headers show
Series [meta-swupdate] Add SWUPDATE_LIST_FOR_CPIO to allow explicit SWU file inclusion | expand

Commit Message

'Darko Komljenovic' via swupdate March 29, 2019, 2:31 a.m. UTC
By default, swupdate.bbclass includes all files fetched by the Yocto
recipe in the SWU cpio archive.  This change adds a new variable
SWUPDATE_LIST_FOR_CPIO which, when specified, allows for explicit
control of which additional files are added to the SWU image

This is useful when the default fetch file list isn't suitable for
inclusion in the SWU image.

Signed-off-by: Austin Phillips <austin.phillips@planetinnovation.com.au>
---
 README                   | 42 ++++++++++++++++++++++++++++++++++++++++++
 classes/swupdate.bbclass | 12 ++++++++++--
 2 files changed, 52 insertions(+), 2 deletions(-)

Comments

'Darko Komljenovic' via swupdate March 29, 2019, 2:41 a.m. UTC | #1
Hi,

This patch is a proof-of-concept which allows us to be a little more explicit about what gets included in a SWU image during the assembly process.

When using swupdate.bbclass, I ran into an issue which resulted in additional files being included in the SWU.  I had a sw-description.conf in SRC_URI and was injecting hardware/software information as a part of a pre-swuimage build step to create sw-description which could be processed by the swimage build step.  This worked as expected, except that the SWU image included both sw-description and sw-description.conf as the list of files to include was sourced by the fetch url list.

This is not always the right assumption to make, so addition of a SWUPDATE_LIST_FOR_CPIO variable allows for the list to be controlled explicitly.  This can be set to a blank value to prevent automatic inclusion of any additional files which are not already required for the SWU. e.g. sw-description will always be included.

I've attempted to make this change backwards compatible.  If SWUPDATE_LIST_FOR_CPIO is not specified, swupdate.bbclass reverts to inclusion of files fetched from SRC_URI.

I've updated the README with an example of intended use.

Feedback welcome.

Regards,
Austin
diff mbox series

Patch

diff --git a/README b/README
index ffc8f33..31baa11 100644
--- a/README
+++ b/README
@@ -57,6 +57,48 @@  which is included in the SWU file.
 Encrypted private keys are not currently supported since a secure
 mechanism must exist to provide the passphrase.
 
+SWU image contents
+----------
+By default the SWU image will include all files fetched by the Yocto
+fetcher as specified in recipe SRC_URI variable.  If this behaviour is not
+suitable, an explicit list of file inclusions can be specified by
+setting `SWUPDATE_LIST_FOR_CPIO` to a list of source file paths to be
+included in the SWU image.
+
+This may be useful in cases where additional build steps are
+introduced prior to the swuimage task to pre-process fetched source files
+or files are generated as part of the recipe for inclusion in the SWU
+image.
+
+e.g.
+
+Let's assume an additional pre-processing step is required to
+inject some content to sw-description before its inclusion in the SWU.
+
+A Yocto recipe may include a configuration like the following:
+
+...
+
+SRC_URI := "\
+    file://sw-description.conf" \
+    file://my-version-file \
+"
+
+inherit swupdate
+
+python do_swuimage_prepend () {
+    # Preprocess sw-description.conf, injecting version information
+    # from my-version-file to produce sw-description.
+    # Generate another file 'foo' for inclusion in SWU.
+}
+
+# Explicit list of additional files to include in SWU archive.
+# Prevent sw-description.conf and my-version-file from being included
+# in the archive by using an explicit list of file inclusions.
+# sw-description is included by default.
+SWUPDATE_LIST_FOR_CPIO = "${WORKDIR}/foo"
+
+
 Maintainer
 ----------
 
diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 1d74eef..027d579 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -74,8 +74,16 @@  python do_swuimage () {
     if d.getVar('SWUPDATE_SIGNING', True):
         list_for_cpio.append('sw-description.sig')
 
-    for url in fetch.urls:
-        local = fetch.localpath(url)
+    # Default to obtaining list of additional cpio members from fetch sources.
+    # The SWUPDATE_LIST_FOR_CPIO can be used to override the default list
+    # to specify a custom set of cpio members.
+    swupdate_list_for_cpio = d.getVar('SWUPDATE_LIST_FOR_CPIO', True)
+    if swupdate_list_for_cpio is None:
+        swupdate_list_for_cpio = [fetch.localpath(url) for url in fetch.urls]
+    else:
+        swupdate_list_for_cpio = swupdate_list_for_cpio.split()
+
+    for local in swupdate_list_for_cpio:
         filename = os.path.basename(local)
         if (filename != 'sw-description'):
             shutil.copyfile(local, os.path.join(s, "%s" % filename ))