diff mbox series

[isar-cip-core,1/3] make name, version and hw-compat available via bb

Message ID 20230414091348.676809-1-felix.moessbauer@siemens.com (mailing list archive)
State Accepted
Headers show
Series [isar-cip-core,1/3] make name, version and hw-compat available via bb | expand

Commit Message

MOESSBAUER, Felix April 14, 2023, 9:13 a.m. UTC
This patch adds bitbake variables to control the corresponding entries
in the sw-description file. The following variables are added:

- SWU_NAME: software->name
- SWU_VERSION: software->version
- SWU_HW_COMPAT: software->compatibility (only if non empty)

By providing these variables, downstream users more often can use the
default sw-description file. This makes it easier to maintain and evolve
the swupdate infrastructure without breaking downstream use-cases.
It also brings as closer to the way swupdate is integrated into yocto.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 classes/swupdate.bbclass                    | 21 ++++++++++++++++++++-
 recipes-core/images/swu/sw-description.tmpl |  5 +++--
 2 files changed, 23 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index e12a4d2..0e738d7 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -17,6 +17,10 @@  SWU_ROOTFS_NAME ?= "${IMAGE_FULLNAME}"
 # compression type as defined by swupdate (zlib or zstd)
 SWU_COMPRESSION_TYPE ?= "zlib"
 SWU_ROOTFS_PARTITION_NAME ?= "${SWU_ROOTFS_NAME}.${SWU_ROOTFS_TYPE}.${@get_swu_compression_type(d)}"
+SWU_VERSION ?= "0.2"
+SWU_NAME ?= "cip software update"
+# space separated list of supported hw. Leave empty to leave out
+SWU_HW_COMPAT ?= ""
 
 SWU_IMAGE_FILE ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.swu"
 SWU_DESCRIPTION_FILE ?= "sw-description"
@@ -37,7 +41,22 @@  IMAGE_TEMPLATE_VARS:swu = " \
     TARGET_IMAGE_UUID \
     ABROOTFS_PART_UUID_A \
     ABROOTFS_PART_UUID_B \
-    SWU_COMPRESSION_TYPE"
+    SWU_COMPRESSION_TYPE \
+    SWU_HW_COMPAT_NODE \
+    SWU_VERSION \
+    SWU_NAME"
+
+python(){
+    # create SWU_HW_COMPAT_NODE based on list of supported hw
+    hw_compat = d.getVar('SWU_HW_COMPAT')
+    if hw_compat:
+        hw_entries = ', '. join(['"' + h + '"' for h in hw_compat.split()])
+        d.setVar('SWU_HW_COMPAT_NODE',
+            'hardware-compatibility: [ ' + hw_entries +' ];')
+    else:
+        d.setVar('SWU_HW_COMPAT_NODE', '')
+}
+
 
 # convert between swupdate compressor name and imagetype extension
 def get_swu_compression_type(d):
diff --git a/recipes-core/images/swu/sw-description.tmpl b/recipes-core/images/swu/sw-description.tmpl
index cade7c3..8d43568 100644
--- a/recipes-core/images/swu/sw-description.tmpl
+++ b/recipes-core/images/swu/sw-description.tmpl
@@ -10,8 +10,9 @@ 
 #
 software =
 {
-    version = "0.2";
-    name = "cip software update";
+    version = "${SWU_VERSION}";
+    name = "${SWU_NAME}";
+    ${SWU_HW_COMPAT_NODE}
     images: ({
             filename = "${SWU_ROOTFS_PARTITION_NAME}";
             device = "C:BOOT0:linux.efi->${ABROOTFS_PART_UUID_A},C:BOOT1:linux.efi->${ABROOTFS_PART_UUID_B}";