From patchwork Tue Jan 30 11:56:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Moessbauer X-Patchwork-Id: 13537542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF8E0C46CD2 for ; Tue, 30 Jan 2024 13:15:36 +0000 (UTC) Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) by mx.groups.io with SMTP id smtpd.web11.16381.1706615835970746692 for ; Tue, 30 Jan 2024 03:57:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=felix.moessbauer@siemens.com header.s=fm1 header.b=RQUbU+fu; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.64.226, mailfrom: fm-1321639-20240130115712dc58b9870d3c9619ab-ffzqkd@rts-flowmailer.siemens.com) Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 20240130115712dc58b9870d3c9619ab for ; Tue, 30 Jan 2024 12:57:12 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=8caep5UdD3VelXITjoYujXnByGEKFiX6P4bv0pZhQdU=; b=RQUbU+fuaKEOdTWUhCUqRex1lkku6E19DNj6oY8wDKKYApTVqo2sxgUpoHCkPMhvhqa8OU /FQkwhZ6l0MqhFmSzHlGj4KtfRJhKc59dlBKHXV/2CZM2vU9MjWagUpx3v4itlShGPDAnxSU NbOUY3ZFNVRkHPgjJxS7VzR1BUrlI=; From: Felix Moessbauer To: cip-dev@lists.cip-project.org Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, shivanand.kunijadar@toshiba-tsip.com, Felix Moessbauer Subject: [isar-cip-core][RFC 1/2] copy and symlink dpkg db to ro-rootfs Date: Tue, 30 Jan 2024 12:56:47 +0100 Message-Id: <20240130115648.311177-2-felix.moessbauer@siemens.com> In-Reply-To: <20240130115648.311177-1-felix.moessbauer@siemens.com> References: <20240130115648.311177-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1321639:519-21489:flowmailer List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 30 Jan 2024 13:15:36 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/14496 The dpkg database is located on the var partition, but this partition is not updated (and might not even be deployed). To still have information about what is installed, we relocate the database to /usr/share and create a symlink using tmpdirs.d. Note, that this is only enabled on debian bookworm, as the proper packaging of tmpdirs files is only supported from debhelper-compat 13 on. Signed-off-by: Felix Moessbauer --- classes/read-only-rootfs.bbclass | 10 +++++++ .../cip-read-only-rootfs_0.1.bb | 26 +++++++++++++++++++ .../files/cip-read-only-rootfs.tmpfiles | 1 + .../cip-read-only-rootfs/files/control | 11 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb create mode 100644 recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles create mode 100644 recipes-core/cip-read-only-rootfs/files/control diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-rootfs.bbclass index 6f91f66..14ed85d 100644 --- a/classes/read-only-rootfs.bbclass +++ b/classes/read-only-rootfs.bbclass @@ -17,6 +17,16 @@ do_image_wic[depends] += "${INITRAMFS_RECIPE}:do_build" IMAGE_INSTALL += "home-fs" IMAGE_INSTALL += "tmp-fs" +# For pre bookworm images, empty /var is not usable +IMAGE_INSTALL:append:bookworm = " cip-read-only-rootfs" + +ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" cip_copy_dpkg_state" +cip_copy_dpkg_state() { + IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/cip/var/lib" + sudo mkdir -p "$IMMUTABLE_VAR_LIB" + sudo cp -a ${ROOTFSDIR}/var/lib/dpkg "$IMMUTABLE_VAR_LIB/" +} + image_configure_fstab() { sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF # Begin /etc/fstab diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb new file mode 100644 index 0000000..76453ab --- /dev/null +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb @@ -0,0 +1,26 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2024 +# +# Authors: +# Felix Moessbauer +# +# SPDX-License-Identifier: MIT + +# Note: This requires debhelper-compat 13, which limits it to bookworm + +inherit dpkg + +SRC_URI = " \ + file://${BPN}.tmpfiles \ + file://control" + +do_prepare_build[cleandirs] += "${S}/debian" +do_prepare_build() { + deb_debianize + rm -f ${S}/debian/compat + cp ${WORKDIR}/control \ + ${WORKDIR}/${BPN}.tmpfiles \ + ${S}/debian/ +} diff --git a/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles new file mode 100644 index 0000000..16a91bd --- /dev/null +++ b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles @@ -0,0 +1 @@ +L /var/lib/dpkg - - - - /usr/share/cip/var/lib/dpkg diff --git a/recipes-core/cip-read-only-rootfs/files/control b/recipes-core/cip-read-only-rootfs/files/control new file mode 100644 index 0000000..55eec25 --- /dev/null +++ b/recipes-core/cip-read-only-rootfs/files/control @@ -0,0 +1,11 @@ +Source: cip-read-only-rootfs +Section: misc +Priority: optional +Standards-Version: 4.6.1 +Maintainer: Felix Moessbauer +Build-Depends: debhelper-compat (= 13) + +Package: cip-read-only-rootfs +Architecture: all +Depends: ${misc:Depends} +Description: Config to link volatile data to immutable copies From patchwork Tue Jan 30 11:56:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Moessbauer X-Patchwork-Id: 13537544 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3E47C47DDF for ; Tue, 30 Jan 2024 13:15:46 +0000 (UTC) Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net [185.136.65.227]) by mx.groups.io with SMTP id smtpd.web10.16634.1706615835591534326 for ; Tue, 30 Jan 2024 03:57:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=felix.moessbauer@siemens.com header.s=fm1 header.b=Pp6sF3R9; spf=pass (domain: rts-flowmailer.siemens.com, ip: 185.136.65.227, mailfrom: fm-1321639-20240130115713a912580a496df7102b-lix8jq@rts-flowmailer.siemens.com) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20240130115713a912580a496df7102b for ; Tue, 30 Jan 2024 12:57:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=felix.moessbauer@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=9J7z+PeGMQsgZhgGanY+EEtbsD4fFPed9o6Ro3EiNd8=; b=Pp6sF3R9lCm0zH5ReOHxgCVmNLHDJNcS54RCzZ5F57tLSe1yN8fE3CkYLknlWS1kV7Sp1+ xUiiEFrRbXY7zputlvMcinF7O+OKDkgTW2KVbTTCvKv+jQlukE9CULvR5Vmm5AsmAOLBYvLE C+TsaUHM4OLHSSoWunornZvZQONb8=; From: Felix Moessbauer To: cip-dev@lists.cip-project.org Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, shivanand.kunijadar@toshiba-tsip.com, Felix Moessbauer Subject: [isar-cip-core][RFC 2/2] swupdate images: initially deploy empty var part Date: Tue, 30 Jan 2024 12:56:48 +0100 Message-Id: <20240130115648.311177-3-felix.moessbauer@siemens.com> In-Reply-To: <20240130115648.311177-1-felix.moessbauer@siemens.com> References: <20240130115648.311177-1-felix.moessbauer@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1321639:519-21489:flowmailer List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 30 Jan 2024 13:15:46 -0000 X-Groupsio-URL: https://lists.cip-project.org/g/cip-dev/message/14498 Previously to this patch, the /var partition is only populated on the initial image deployment. Further updates via swupdate do not update the data on the partition. This is problematic, as issues w.r.t. missing directories or packages that do not support this scheme are only detected in the field or during update testing. To avoid these late failures, we now always deploy an empty /var partition. By that, potential issues can be spotted without the need to run an update. Signed-off-by: Felix Moessbauer --- wic/bbb-efibootguard.wks.in | 2 +- wic/hihope-rzg2m-efibootguard.wks.in | 2 +- wic/qemu-amd64-efibootguard-secureboot.wks.in | 2 +- wic/qemu-arm64-efibootguard-secureboot.wks.in | 2 +- wic/qemu-arm64-efibootguard.wks.in | 2 +- wic/qemu-riscv64-efibootguard.wks.in | 2 +- wic/x86-efibootguard.wks.in | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wic/bbb-efibootguard.wks.in b/wic/bbb-efibootguard.wks.in index 6c62846..e9c04b9 100644 --- a/wic/bbb-efibootguard.wks.in +++ b/wic/bbb-efibootguard.wks.in @@ -16,6 +16,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt --append="rootwait console=ttyO0,115200 omap_wdt.early_enable=1 omap_wdt.nowayout=1 watchdog.handle_boot_enabled=0" diff --git a/wic/hihope-rzg2m-efibootguard.wks.in b/wic/hihope-rzg2m-efibootguard.wks.in index a9742cc..9227a71 100644 --- a/wic/hihope-rzg2m-efibootguard.wks.in +++ b/wic/hihope-rzg2m-efibootguard.wks.in @@ -9,6 +9,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --extra-space=100M --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --extra-space=100M --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt --append="console=tty0 console=ttySC0,115200 rootwait earlyprintk" diff --git a/wic/qemu-amd64-efibootguard-secureboot.wks.in b/wic/qemu-amd64-efibootguard-secureboot.wks.in index f6d3243..ef40d70 100644 --- a/wic/qemu-amd64-efibootguard-secureboot.wks.in +++ b/wic/qemu-amd64-efibootguard-secureboot.wks.in @@ -5,6 +5,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt --append="console=tty0 console=ttyS0,115200 rootwait earlyprintk watchdog.handle_boot_enabled=0 iTCO_wdt.nowayout=1 panic=5" diff --git a/wic/qemu-arm64-efibootguard-secureboot.wks.in b/wic/qemu-arm64-efibootguard-secureboot.wks.in index 9baaa47..01f395d 100644 --- a/wic/qemu-arm64-efibootguard-secureboot.wks.in +++ b/wic/qemu-arm64-efibootguard-secureboot.wks.in @@ -5,6 +5,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt --append="panic=5" diff --git a/wic/qemu-arm64-efibootguard.wks.in b/wic/qemu-arm64-efibootguard.wks.in index e96853e..942c3e1 100644 --- a/wic/qemu-arm64-efibootguard.wks.in +++ b/wic/qemu-arm64-efibootguard.wks.in @@ -8,6 +8,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt diff --git a/wic/qemu-riscv64-efibootguard.wks.in b/wic/qemu-riscv64-efibootguard.wks.in index 24e9acd..6934977 100644 --- a/wic/qemu-riscv64-efibootguard.wks.in +++ b/wic/qemu-riscv64-efibootguard.wks.in @@ -8,6 +8,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt diff --git a/wic/x86-efibootguard.wks.in b/wic/x86-efibootguard.wks.in index 60897be..6382ff7 100644 --- a/wic/x86-efibootguard.wks.in +++ b/wic/x86-efibootguard.wks.in @@ -9,6 +9,6 @@ part --source empty --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B} # home and var are extra partitions part /home --source rootfs --change-directory=home --fstype=ext4 --label home --align 1024 --size 1G --extra-space=100M --fsuuid 1f55d66a-40d8-11ee-be56-0242ac120002 -part /var --source rootfs --change-directory=var --fstype=ext4 --label var --align 1024 --size 2G --extra-space=100M --fsuuid 96be3374-4258-11ee-be56-0242ac120002 +part /var --fstype=ext4 --label var --align 1024 --fixed-size 2G --fsuuid 96be3374-4258-11ee-be56-0242ac120002 bootloader --ptable gpt --append="console=tty0 console=ttyS0,115200 rootwait earlyprintk watchdog.handle_boot_enabled=0 iTCO_wdt.nowayout=1 "