From d81444a57489e3e5c3564e32906d20c82bb05885 Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Mon, 8 Nov 2021 08:39:18 +0100 Subject: [PATCH] swu-images: fix support to preinstallation script in swu update package Since commit 11558352 ("swu-images: add "installed-directly" flag to sw-description") the swu package images are streamed into the target without any temporary copy to support devices with low memory available, that forces a different order according with the swupdate documentation because scripts should packed before the rest. This means that all the pre, post and shell scripts will be executed after the images will be installed. This behavior breaks the current support to mount the cryptorootfs node before install an encrypted rootfs. This commit moves the shell script to mount the cryptorootfs node to the recovery initramfs and modifies the swupdate command line to call the shell script before the images installation. https://onedigi.atlassian.net/browse/CC8X-320 Signed-off-by: Arturo Buzarra --- meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb | 4 ++++ .../recovery/recovery-initramfs/mount_cryptrootfs.sh} | 0 .../recovery/recovery-initramfs/recovery-initramfs-init | 3 ++- meta-digi-dey/recipes-digi/swu-images/files/sw-description | 3 +-- meta-digi-dey/recipes-digi/swu-images/swu.inc | 7 ------- 5 files changed, 7 insertions(+), 10 deletions(-) rename meta-digi-dey/{recipes-digi/swu-images/files/preinstall_swu.sh => recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh} (100%) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb index a05db3d71..34e1c5607 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs.bb @@ -16,6 +16,7 @@ SRC_URI = " \ file://automount_block.sh \ file://automount_mtd.sh \ file://mdev.conf \ + ${@bb.utils.contains('STORAGE_MEDIA', 'mmc', 'file://mount_cryptrootfs.sh', '', d)} \ " S = "${WORKDIR}" @@ -24,6 +25,9 @@ do_install() { install -d ${D}${sysconfdir} install -m 0755 ${WORKDIR}/recovery-initramfs-init ${D}/init install -m 0644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir} + if [ "${STORAGE_MEDIA}" = "mmc" ]; then + install -m 0755 ${WORKDIR}/mount_cryptrootfs.sh ${D}${sysconfdir} + fi install -d ${D}${base_libdir}/mdev install -m 0755 ${WORKDIR}/automount_block.sh ${D}${base_libdir}/mdev/automount_block.sh install -m 0755 ${WORKDIR}/automount_mtd.sh ${D}${base_libdir}/mdev/automount_mtd.sh diff --git a/meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh similarity index 100% rename from meta-digi-dey/recipes-digi/swu-images/files/preinstall_swu.sh rename to meta-digi-dey/recipes-core/recovery/recovery-initramfs/mount_cryptrootfs.sh diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 740739c4a..a092bfcc8 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -833,7 +833,8 @@ if [ -n "${update_package_bool}" ]; then progress -wp & # Execute the software update. if [ -f "${PUBLIC_KEY}" ]; then - swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" -k "${PUBLIC_KEY}" + [ "${ENCRYPT_ROOTFS}" = "yes" ] && SWUPDATE_PREUPDATE_CMD="-P /etc/mount_cryptrootfs.sh" + swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" -k "${PUBLIC_KEY}" ${SWUPDATE_PREUPDATE_CMD} else swupdate -e "${SWUPDATE_IMAGE_SET}" -f "${SW_CONFIG}" -i "${update_package}" fi diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/sw-description index 498ac549b..447de9884 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description @@ -22,8 +22,7 @@ software = installed-directly = true; } ); - } - ##PREINSTALL_SCRIPT## + }; }; mtd = { platform: { diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 78aa76d3f..7559903b1 100644 --- a/meta-digi-dey/recipes-digi/swu-images/swu.inc +++ b/meta-digi-dey/recipes-digi/swu-images/swu.inc @@ -5,9 +5,6 @@ LICENSE = "GPL-2.0" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" SRC_URI = "file://sw-description" -SRC_URI_append_ccimx6 = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" -SRC_URI_append_ccimx8x = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" -SRC_URI_append_ccimx8m = " ${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', 'file://preinstall_swu.sh', '')}" inherit swupdate @@ -32,9 +29,6 @@ ROOTFS_DEV_NAME_ccimx6ul ?= "rootfs" ROOTFS_ENC_DEV = "/dev/mapper/cryptrootfs" ROOTFS_ENC_DEV_ccimx6ul = "${ROOTFS_DEV_NAME}" ROOTFS_DEV_NAME_FINAL = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', '${ROOTFS_ENC_DEV}', '${ROOTFS_DEV_NAME}')}" -PREINST_SCRIPT_TEMPLATE = "scripts: ( { filename = \\"preinstall_swu.sh\\"; type = \\"preinstall\\"; sha256 = \\"@preinstall_swu.sh\\"; \\x7D );" -PREINST_SCRIPT_DESC = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS', True) == '1', '${PREINST_SCRIPT_TEMPLATE}', '')}" -PREINST_SCRIPT_DESC_ccimx6ul = "" python () { img_fstypes = d.getVar('BOOTFS_EXT', True) + " " + d.getVar('ROOTFS_EXT', True) @@ -61,5 +55,4 @@ fill_description() { sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description" sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description" sed -i -e "s,##DESCRIPTION##,${DESCRIPTION},g" "${WORKDIR}/sw-description" - sed -i -e "s/##PREINSTALL_SCRIPT##/${PREINST_SCRIPT_DESC}/g" "${WORKDIR}/sw-description" }