All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
To: cip-dev@lists.cip-project.org, jan.kiszka@siemens.com
Cc: shivanand.kunijadar@toshiba-tsip.com,
	sai.sathujoda@toshiba-tsip.com, dinesh.kumar@toshiba-tsip.com,
	kazuhiro3.hayashi@toshiba.co.jp
Subject: [isar-cip-core][RFC v1 4/6] Add Delta update support with rdiff_image and delta handler
Date: Thu,  7 Mar 2024 13:16:10 +0530	[thread overview]
Message-ID: <20240307074612.1996609-5-Adithya.Balakumar@toshiba-tsip.com> (raw)
In-Reply-To: <20240307074612.1996609-1-Adithya.Balakumar@toshiba-tsip.com>

swupdate supports delta updates with rdiff_image and delta(zchunk)
handler. This change adds support to use either of the handler
for creating delta update artifacts. The type of handler can be set
in the delta-update.yml file along with additional variables needed
for the chosen handler.

Signed-off-by: Adithya Balakumar <Adithya.Balakumar@toshiba-tsip.com>
---
 classes/delta_update.bbclass | 90 ++++++++++++++++++++++++++++++++++++
 kas/opt/delta-update.yml     | 21 +++++++++
 2 files changed, 111 insertions(+)
 create mode 100644 classes/delta_update.bbclass
 create mode 100644 kas/opt/delta-update.yml

diff --git a/classes/delta_update.bbclass b/classes/delta_update.bbclass
new file mode 100644
index 0000000..8d47081
--- /dev/null
+++ b/classes/delta_update.bbclass
@@ -0,0 +1,90 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation 2024
+#
+# Authors:
+#  Adithya Balakumar <adithya.balakumar@toshiba-tsip.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+IMAGER_INSTALL:delta_update += "fdisk zchunk rdiff"
+
+FILESEXTRAPATHS:append = ":${LAYERDIR_cip-core}"
+IMAGE_SRC_URI:delta_update += " ${@ "file://"+d.getVar('DELTA_RDIFF_REF_IMAGE') if d.getVar('DELTA_UPDATE_TYPE') == 'rdiff' and d.getVar('DELTA_RDIFF_REF_IMAGE') else '' }"
+
+do_image_delta_update[cleandirs] += "${WORKDIR}/delta_interim_artifacts"
+
+extract_root_fs() {
+    INPUT_ARTIFACT=$1
+    OUTPUT_ARTIFACT=$2
+    SECTOR_SIZE=512
+    ROOTFS_LABEL="primary"
+    ROOTFS_START_SECTOR=$(${SUDO_CHROOT} /sbin/fdisk -l -o Name,Start "${INPUT_ARTIFACT}" | awk -v name="${ROOTFS_LABEL}" '$0 ~ name {print $2}' | head -n 1)
+    SKIP_VALUE="$(expr $(expr $ROOTFS_START_SECTOR \* $SECTOR_SIZE) / $(expr 1024 \* 1024))"
+    ${SUDO_CHROOT} /bin/dd if=${INPUT_ARTIFACT} bs=1M skip=$SKIP_VALUE count=1024 of=${OUTPUT_ARTIFACT} status=none
+}
+
+do_delta_update_sw_description_template() {
+   # Since the sw-description file for delta update would not be very different from that of a 
+   # normal update, copy sw-description.tmpl as sw-description-delta.tmpl and add delta update 
+   # specific properties
+   SWU_DESCRIPTION_DELTA_UPDATE="sw-description-delta"
+   cp "${WORKDIR}/${SWU_DESCRIPTION_FILE}".tmpl "${WORKDIR}/${SWU_DESCRIPTION_DELTA_UPDATE}".tmpl
+   sed -i 's/\SWU_ROOTFS_PARTITION_NAME/SWU_DELTA_UPDATE_ARTIFACT/g' ${WORKDIR}/${SWU_DESCRIPTION_DELTA_UPDATE}.tmpl
+   sed -i '/configfilecheck =/a \                      \'$'{SWU_DELTA_UPDATE_ADDITIONAL_PROPERTIES}' ${WORKDIR}/${SWU_DESCRIPTION_DELTA_UPDATE}.tmpl
+}
+addtask do_delta_update_sw_description_template before do_transform_template after do_generate_image_uuid
+
+IMAGE_CMD:delta_update() {
+    if [ "${DELTA_UPDATE_TYPE}" != "zchunk" ] && [ "${DELTA_UPDATE_TYPE}" != "rdiff" ]; then
+        bbfatal "You must set a valid DELTA_UPDATE_TYPE (rdiff/zchunk)"
+    fi
+    
+    DELTA_ARTIFACT_SWU=""
+
+    if [ "${DELTA_UPDATE_TYPE}" = "zchunk" ]; then 
+	extract_root_fs "${PP_DEPLOY}/${IMAGE_FULLNAME}.wic" "${WORKDIR}/delta_interim_artifacts/${IMAGE_FULLNAME}.raw"
+
+    	# Create .zck file
+    	${SUDO_CHROOT} /bin/zck \
+		--output ${PP_DEPLOY}/${IMAGE_FULLNAME}.zck \
+		-u --chunk-hash-type sha256 \
+		${WORKDIR}/delta_interim_artifacts/${IMAGE_FULLNAME}.raw
+
+    	# Calculate size of zck header
+    	HSIZE="$(${SUDO_CHROOT} /bin/zck_read_header -v ${PP_DEPLOY}/${IMAGE_FULLNAME}.zck | grep "Header size" | cut -d ':' -f 2)"
+    
+    	# Extract the zck header
+    	${SUDO_CHROOT} /bin/dd if="${PP_DEPLOY}/${IMAGE_FULLNAME}".zck of="${PP_DEPLOY}/${IMAGE_FULLNAME}".zck.header bs=1 count="$HSIZE" status=none
+
+        DELTA_ARTIFACT_SWU=${IMAGE_FULLNAME}.zck.header
+
+    elif [ "${DELTA_UPDATE_TYPE}" = "rdiff" ]; then
+        if [ -z "${DELTA_RDIFF_REF_IMAGE}" ]; then
+            bbfatal "You must set DELTA_RDIFF_REF_IMAGE and provide the required files as artifacts to this recipe"
+        fi
+
+	# Extracting root partition from image1
+	extract_root_fs "${WORKDIR}/${DELTA_RDIFF_REF_IMAGE}"  "${WORKDIR}/delta_interim_artifacts/old-image-rootfs.raw"
+	
+	# Extracting root partition from image2
+	extract_root_fs "${PP_DEPLOY}/${IMAGE_FULLNAME}.wic"  "${WORKDIR}/delta_interim_artifacts/new-image-rootfs.raw"	
+
+	rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.delta
+	# create signature file with rdiff
+	${SUDO_CHROOT} /usr/bin/rdiff signature ${WORKDIR}/delta_interim_artifacts/old-image-rootfs.raw \
+		${WORKDIR}/delta_interim_artifacts/old-image-rootfs.sig
+
+        # create delta file with the signature file
+	${SUDO_CHROOT} /usr/bin/rdiff delta ${WORKDIR}/delta_interim_artifacts/old-image-rootfs.sig \
+		${WORKDIR}/delta_interim_artifacts/new-image-rootfs.raw ${PP_DEPLOY}/${IMAGE_FULLNAME}.delta
+
+	DELTA_ARTIFACT_SWU=${IMAGE_FULLNAME}.delta
+    fi
+        # create a symbolic link as IMAGE_CMD expects a *.delta_update file in deploy image directory
+        ln -sf ${DELTA_ARTIFACT_SWU} ${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.delta_update
+}
+
+addtask do_image_delta_update before do_image_swu after do_image_wic
diff --git a/kas/opt/delta-update.yml b/kas/opt/delta-update.yml
new file mode 100644
index 0000000..c7a3893
--- /dev/null
+++ b/kas/opt/delta-update.yml
@@ -0,0 +1,21 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Toshiba Corporation 2024
+#
+# Authors:
+#  Adithya Balakumar <adithya.balakumar@toshiba-tsip.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+header:
+  version: 14
+
+local_conf_header:
+  delta-update: |
+    IMAGE_CLASSES:append = " delta_update"
+    IMAGE_FSTYPES:append = " delta_update"
+    DELTA_UPDATE_TYPE = ""
+    DELTA_ZCK_URL = ""
+    DELTA_RDIFF_REF_IMAGE = "" 
-- 
2.39.2




  parent reply	other threads:[~2024-03-07  7:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  7:46 [isar-cip-core][RFC v1 0/6] Integrate Delta Update with rdiff_image and delta handler Adithya Balakumar
2024-03-07  7:46 ` [isar-cip-core][RFC v1 1/6] conf: Use bookworm backports for enabling delta handler in swupdate Adithya Balakumar
2024-03-08 10:28   ` MOESSBAUER, Felix
2024-03-08 11:35   ` Jan Kiszka
2024-03-14  7:55     ` [cip-dev] " Gylstorff Quirin
2024-03-18  5:02       ` Adithya.Balakumar
2024-03-18  9:31         ` Gylstorff Quirin
2024-03-07  7:46 ` [isar-cip-core][RFC v1 2/6] swupdate-handler-roundrobin: Increase revision for Delta Handler support Adithya Balakumar
2024-03-07  7:46 ` [isar-cip-core][RFC v1 3/6] swupdate: Enable Delta handler in swupdate Adithya Balakumar
2024-03-08 11:35   ` Jan Kiszka
2024-03-13  9:32     ` Adithya.Balakumar
2024-03-14  6:56     ` [cip-dev] " Gylstorff Quirin
2024-03-14  7:51       ` Adithya.Balakumar
2024-03-07  7:46 ` Adithya Balakumar [this message]
2024-03-08 10:52   ` [isar-cip-core][RFC v1 4/6] Add Delta update support with rdiff_image and delta handler MOESSBAUER, Felix
2024-03-08 16:43     ` Gylstorff Quirin
2024-03-13  6:11     ` Adithya.Balakumar
2024-03-13 17:19       ` Gylstorff Quirin
2024-03-18 10:28         ` MOESSBAUER, Felix
2024-03-08 11:44   ` Jan Kiszka
2024-03-13  9:20     ` Adithya.Balakumar
2024-03-13 12:29       ` Jan Kiszka
2024-03-14  7:16         ` [cip-dev] " Adithya.Balakumar
2024-03-18 11:45   ` Wang, Qi
2024-03-18 11:51   ` Wang, Qi
2024-03-07  7:46 ` [isar-cip-core][RFC v1 5/6] swupdate.bbclass: Generate swu for delta updates Adithya Balakumar
2024-03-08 10:56   ` MOESSBAUER, Felix
2024-03-13  7:03     ` Adithya.Balakumar
2024-03-13 17:15       ` [cip-dev] " Gylstorff Quirin
2024-03-14  7:41         ` Adithya.Balakumar
2024-03-14  9:26           ` Gylstorff Quirin
2024-03-15  6:45             ` Adithya.Balakumar
2024-03-15  8:42               ` Gylstorff Quirin
2024-03-18  4:59                 ` Adithya.Balakumar
2024-03-18  9:34                   ` Gylstorff Quirin
2024-03-18 10:09                     ` Adithya.Balakumar
2024-03-07  7:46 ` [isar-cip-core][RFC v1 6/6] doc/README.swupdate.md: Update steps to test Delta software Update Adithya Balakumar
2024-03-08 11:47   ` Jan Kiszka
2024-03-12 13:16   ` [cip-dev] " Gylstorff Quirin
2024-03-08 11:48 ` [isar-cip-core][RFC v1 0/6] Integrate Delta Update with rdiff_image and delta handler Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240307074612.1996609-5-Adithya.Balakumar@toshiba-tsip.com \
    --to=adithya.balakumar@toshiba-tsip.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=dinesh.kumar@toshiba-tsip.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kazuhiro3.hayashi@toshiba.co.jp \
    --cc=sai.sathujoda@toshiba-tsip.com \
    --cc=shivanand.kunijadar@toshiba-tsip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.