Skip to contentSkip to conversation

SWUpdate-related cleanups

PATCH In review Jan Kiszka 2 participants 5 messages Mar 10, 2022 – Mar 11, 2022

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover SWUpdate-related cleanups

Primarily auto-compression for SWU_ADDITIONAL_FILES.

Jan

Jan Kiszka (2):
Drop redundant SWU_DESCRIPTION_FILE assignment
swupdate-img: Add support for automatically compressing files

 classes/compress_swupdate_rootfs.bbclass | 21 ---------------------
 classes/secure-swupdate-img.bbclass      |  4 +---
 classes/swupdate-img.bbclass             | 15 +++++++++++++++
 classes/wic-swu-img.bbclass              |  5 +----
 recipes-core/images/secureboot.inc       |  4 +---
 recipes-core/images/swupdate.inc         |  4 ++--
 6 files changed, 20 insertions(+), 33 deletions(-)
 delete mode 100644 classes/compress_swupdate_rootfs.bbclass
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 Drop redundant SWU_DESCRIPTION_FILE assignment

From: Jan Kiszka <[email protected]>

Already set as default in swupdate-img.bbclass.

---
 recipes-core/images/secureboot.inc | 1 -
 1 file changed, 1 deletion(-)
recipes-core/images/secureboot.inc +0 -1
index b619b50..950b41a 100644
@@ -19,5 +19,4 @@ TEMPLATE_FILES += "sw-description.tmpl"
 
 TEMPLATE_VARS += "PN ROOTFS_PARTITION_NAME"
 
-SWU_DESCRIPTION_FILE = "sw-description"
 SWU_ADDITIONAL_FILES += "linux.signed.efi ${ROOTFS_PARTITION_NAME}"
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/2 swupdate-img: Add support for automatically compressing files

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Automatically gzip files specified in SWU_ADDITIONAL_FILES if they end on .gz and there is an uncompressed version (without .gz suffix) in the search path. This obsoletes the extra compress_swupdate_rootfs class and makes the usage more convenient.

---
 classes/compress_swupdate_rootfs.bbclass | 21 ---------------------
 classes/secure-swupdate-img.bbclass      |  4 +---
 classes/swupdate-img.bbclass             | 15 +++++++++++++++
 classes/wic-swu-img.bbclass              |  5 +----
 recipes-core/images/secureboot.inc       |  3 +--
 recipes-core/images/swupdate.inc         |  4 ++--
 6 files changed, 20 insertions(+), 32 deletions(-)
 delete mode 100644 classes/compress_swupdate_rootfs.bbclass
classes/compress_swupdate_rootfs.bbclass deleted +0 -21
deleted file mode 100644
index 2a01e59..0000000
@@ -1,21 +0,0 @@
-#
-# CIP Core, generic profile
-#
-# Copyright (c) Siemens AG, 2022
-#
-# Authors:
-#  Quirin Gylstorff <[email protected]>
-#
-# SPDX-License-Identifier: MIT
-#
-
-EXTRACT_PARTITIONS ?= "${IMAGE_FULLNAME}.wic.img.p4"
-
-do_compress_swupdate_rootfs () {
-    for PARTITION in ${EXTRACT_PARTITIONS}; do
-        if [ -e ${DEPLOY_DIR_IMAGE}/${PARTITION} ]; then
-            rm -f ${DEPLOY_DIR_IMAGE}/${PARTITION}.gz
-            gzip ${DEPLOY_DIR_IMAGE}/${PARTITION}
-        fi
-    done
-}
classes/secure-swupdate-img.bbclass +1 -3
index 1715c8a..330f619 100644
@@ -21,12 +21,10 @@ INITRD_IMAGE = "${INITRAMFS_RECIPE}-${DISTRO}-${MACHINE}.initrd.img"
 
 inherit verity-img
 inherit wic-img
-inherit compress_swupdate_rootfs
 inherit swupdate-img
 
 SOURCE_IMAGE_FILE = "${WIC_IMAGE_FILE}"
 
 addtask do_verity_image after do_${SECURE_IMAGE_FSTYPE}_image
 addtask do_wic_image after do_verity_image
-addtask do_compress_swupdate_rootfs after do_wic_image
-addtask do_swupdate_image after do_compress_swupdate_rootfs
+addtask do_swupdate_image after do_wic_image
classes/swupdate-img.bbclass +15 -0
index 7b7154f..97e833e 100644
@@ -24,6 +24,21 @@ do_swupdate_image() {
     rm -f '${SWU_IMAGE_FILE}'
     cp '${WORKDIR}/${SWU_DESCRIPTION_FILE}' '${WORKDIR}/swu/${SWU_DESCRIPTION_FILE}'
 
+    # Compress files if requested
+    for file in ${SWU_ADDITIONAL_FILES}; do
+        basefile=$(basename "$file" .gz)
+        if [ "$basefile" = "$file" ]; then
+            continue
+        fi
+        for uncompressed in "${WORKDIR}/$basefile" "${DEPLOY_DIR_IMAGE}/$basefile"; do
+            if [ -e "$uncompressed" ]; then
+                rm  -f "$uncompressed.gz"
+                gzip "$uncompressed"
+                break
+            fi
+        done
+    done
+
     # Create symlinks for files used in the update image
     for file in ${SWU_ADDITIONAL_FILES}; do
         if [ -e "${WORKDIR}/$file" ]; then
classes/wic-swu-img.bbclass +1 -4
index 3a09721..5e6de40 100644
@@ -9,12 +9,9 @@
 # SPDX-License-Identifier: MIT
 #
 
-
 inherit wic-img
-inherit compress_swupdate_rootfs
 inherit swupdate-img
 
 SOURCE_IMAGE_FILE = "${WIC_IMAGE_FILE}"
 
-addtask do_compress_swupdate_rootfs after do_wic_image
-addtask do_swupdate_image after do_compress_swupdate_rootfs
+addtask do_swupdate_image after do_wic_image
recipes-core/images/secureboot.inc +1 -2
index 950b41a..3e6eef8 100644
@@ -11,8 +11,7 @@
 
 FILESEXTRAPATHS_prepend := "${THISDIR}/files/secure-boot:"
 
-EXTRACT_PARTITIONS = "${IMAGE_FULLNAME}.wic.img.p4"
-ROOTFS_PARTITION_NAME="${IMAGE_FULLNAME}.wic.img.p4.gz"
+ROOTFS_PARTITION_NAME = "${IMAGE_FULLNAME}.wic.img.p4.gz"
 
 SRC_URI += "file://sw-description.tmpl"
 TEMPLATE_FILES += "sw-description.tmpl"
recipes-core/images/swupdate.inc +2 -2
index 2e9094a..c23c103 100644
@@ -11,11 +11,11 @@
 
 FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
 
-EXTRACT_PARTITIONS = "${IMAGE_FULLNAME}.wic.img.p4"
-ROOTFS_PARTITION_NAME="${IMAGE_FULLNAME}.wic.img.p4.gz"
+ROOTFS_PARTITION_NAME = "${IMAGE_FULLNAME}.wic.img.p4.gz"
 
 SRC_URI += "file://sw-description.tmpl"
 TEMPLATE_FILES += "sw-description.tmpl"
+
 TEMPLATE_VARS += "PN ROOTFS_PARTITION_NAME KERNEL_IMAGE INITRD_IMAGE"
 
 SWU_ADDITIONAL_FILES += "${INITRD_IMAGE} ${KERNEL_IMAGE} ${ROOTFS_PARTITION_NAME}"
Signature · 1 line
2.34.1
author
#3 lore raw

[isar-cip-core][PATCH 3/2] swupdate-img: Use pigz where available

From: Jan Kiszka <[email protected]>

Accelerates the compression by using multiple cores.

---
 classes/swupdate-img.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
classes/swupdate-img.bbclass +5 -1
index 97e833e..1437c07 100644
@@ -33,7 +33,11 @@ do_swupdate_image() {
         for uncompressed in "${WORKDIR}/$basefile" "${DEPLOY_DIR_IMAGE}/$basefile"; do
             if [ -e "$uncompressed" ]; then
                 rm  -f "$uncompressed.gz"
-                gzip "$uncompressed"
+                if [ -x "$(command -v pigz)" ]; then
+                    pigz "$uncompressed"
+                else
+                    gzip "$uncompressed"
+                fi
                 break
             fi
         done
Signature · 1 line
2.34.1
#4 lore raw
In reply to Jan Kiszka
Quoted 8 lines · Jan Kiszka

Primarily auto-compression for SWU_ADDITIONAL_FILES.

Jan

Jan Kiszka (2):
Drop redundant SWU_DESCRIPTION_FILE assignment
swupdate-img: Add support for automatically compressing files

Quoted 9 lines
  classes/compress_swupdate_rootfs.bbclass | 21 ---------------------
  classes/secure-swupdate-img.bbclass      |  4 +---
  classes/swupdate-img.bbclass             | 15 +++++++++++++++
  classes/wic-swu-img.bbclass              |  5 +----
  recipes-core/images/secureboot.inc       |  4 +---
  recipes-core/images/swupdate.inc         |  4 ++--
  6 files changed, 20 insertions(+), 33 deletions(-)

delete mode 100644 classes/compress_swupdate_rootfs.bbclass

Looks good to me.

Quirin