diff mbox series

[isar-cip-core,2/3] swupdate: add support to disable compression

Message ID 20230414091348.676809-2-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 feature is useful for artifacts which are already compressed (like
squashfs). By that, double compression can be avoided, which speeds up
the deployment and also reduces the memory consumption.

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

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 0e738d7..16c615a 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -14,9 +14,9 @@  inherit template
 
 SWU_ROOTFS_TYPE ?= "squashfs"
 SWU_ROOTFS_NAME ?= "${IMAGE_FULLNAME}"
-# compression type as defined by swupdate (zlib or zstd)
+# compression type as defined by swupdate (zlib or zstd). Set to empty string to disable compression
 SWU_COMPRESSION_TYPE ?= "zlib"
-SWU_ROOTFS_PARTITION_NAME ?= "${SWU_ROOTFS_NAME}.${SWU_ROOTFS_TYPE}.${@get_swu_compression_type(d)}"
+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
@@ -31,7 +31,7 @@  SWU_SIGNATURE_TYPE ?= "rsa"
 
 SWU_BUILDCHROOT_IMAGE_FILE ?= "${PP_DEPLOY}/${@os.path.basename(d.getVar('SWU_IMAGE_FILE'))}"
 
-IMAGE_TYPEDEP:swu = "wic ${SWU_ROOTFS_TYPE}.${@get_swu_compression_type(d)}"
+IMAGE_TYPEDEP:swu = "wic ${SWU_ROOTFS_TYPE}${@get_swu_compression_type(d)}"
 IMAGER_INSTALL:swu += "cpio ${@'openssl' if bb.utils.to_boolean(d.getVar('SWU_SIGNED')) else ''}"
 
 IMAGE_SRC_URI:swu = "file://${SWU_DESCRIPTION_FILE}.tmpl"
@@ -41,8 +41,8 @@  IMAGE_TEMPLATE_VARS:swu = " \
     TARGET_IMAGE_UUID \
     ABROOTFS_PART_UUID_A \
     ABROOTFS_PART_UUID_B \
-    SWU_COMPRESSION_TYPE \
     SWU_HW_COMPAT_NODE \
+    SWU_COMPRESSION_NODE \
     SWU_VERSION \
     SWU_NAME"
 
@@ -55,13 +55,22 @@  python(){
             'hardware-compatibility: [ ' + hw_entries +' ];')
     else:
         d.setVar('SWU_HW_COMPAT_NODE', '')
+    
+    # create SWU_COMPRESSION_NODE node if compression is enabled
+    calgo = d.getVar('SWU_COMPRESSION_TYPE')
+    if calgo:
+        d.setVar('SWU_COMPRESSION_NODE', 'compressed = "' + calgo + '";')
+    else:
+        d.setVar('SWU_COMPRESSION_NODE', '')
 }
 
 
 # convert between swupdate compressor name and imagetype extension
 def get_swu_compression_type(d):
     swu_ct = d.getVar('SWU_COMPRESSION_TYPE', True)
-    swu_to_image = {'zlib': 'gz', 'zstd': 'zst'}
+    if not swu_ct:
+        return ''
+    swu_to_image = {'zlib': '.gz', 'zstd': '.zst'}
     if swu_ct not in swu_to_image:
         bb.fatal('requested SWU_COMPRESSION_TYPE is not supported by swupdate')
     return swu_to_image[swu_ct]
diff --git a/recipes-core/images/swu/sw-description.tmpl b/recipes-core/images/swu/sw-description.tmpl
index 8d43568..6b53a3c 100644
--- a/recipes-core/images/swu/sw-description.tmpl
+++ b/recipes-core/images/swu/sw-description.tmpl
@@ -17,7 +17,7 @@  software =
             filename = "${SWU_ROOTFS_PARTITION_NAME}";
             device = "C:BOOT0:linux.efi->${ABROOTFS_PART_UUID_A},C:BOOT1:linux.efi->${ABROOTFS_PART_UUID_B}";
             type = "roundrobin";
-            compressed = "${SWU_COMPRESSION_TYPE}";
+            ${SWU_COMPRESSION_NODE}
             properties: {
                         subtype = "image";
                         configfilecheck = "/etc/os-release@not_match@IMAGE_UUID=${TARGET_IMAGE_UUID}";