All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Moessbauer <felix.moessbauer@siemens.com>
To: cip-dev@lists.cip-project.org
Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com,
	shivanand.kunijadar@toshiba-tsip.com,
	Felix Moessbauer <felix.moessbauer@siemens.com>
Subject: [isar-cip-core][RFC v4 3/3] copy and symlink dpkg db to ro-rootfs
Date: Mon, 19 Feb 2024 14:28:50 +0100	[thread overview]
Message-ID: <20240219132850.68686-4-felix.moessbauer@siemens.com> (raw)
In-Reply-To: <20240219132850.68686-1-felix.moessbauer@siemens.com>

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 <felix.moessbauer@siemens.com>
---
 classes/read-only-rootfs.bbclass              | 10 ++++++++
 .../files/immutable-rootfs.tmpfiles           |  1 +
 .../immutable-rootfs/immutable-rootfs_0.1.bb  | 23 +++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 recipes-core/immutable-rootfs/files/immutable-rootfs.tmpfiles
 create mode 100644 recipes-core/immutable-rootfs/immutable-rootfs_0.1.bb

diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-rootfs.bbclass
index 6f91f66..bb8ab9a 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 = " immutable-rootfs"
+
+ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" copy_dpkg_state"
+copy_dpkg_state() {
+    IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/immutable-data/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/immutable-rootfs/files/immutable-rootfs.tmpfiles b/recipes-core/immutable-rootfs/files/immutable-rootfs.tmpfiles
new file mode 100644
index 0000000..d180bc5
--- /dev/null
+++ b/recipes-core/immutable-rootfs/files/immutable-rootfs.tmpfiles
@@ -0,0 +1 @@
+L /var/lib/dpkg - - - - /usr/share/immutable-data/var/lib/dpkg
diff --git a/recipes-core/immutable-rootfs/immutable-rootfs_0.1.bb b/recipes-core/immutable-rootfs/immutable-rootfs_0.1.bb
new file mode 100644
index 0000000..2dbda6d
--- /dev/null
+++ b/recipes-core/immutable-rootfs/immutable-rootfs_0.1.bb
@@ -0,0 +1,23 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2024
+#
+# Authors:
+#  Felix Moessbauer <felix.moessbauer@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+
+# Note: This requires debhelper-compat 13, which limits it to bookworm
+
+inherit dpkg-raw
+
+MAINTAINER = "Felix Moessbauer <felix.moessbauer@siemens.com>"
+DESCRIPTION = "Config to link volatile data to immutable copies"
+
+SRC_URI = "file://${BPN}.tmpfiles"
+DPKG_ARCH = "all"
+
+do_prepare_build:append() {
+    cp ${WORKDIR}/${BPN}.tmpfiles ${S}/debian/
+}
-- 
2.39.2



      parent reply	other threads:[~2024-02-19 14:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 13:28 [isar-cip-core][RFC v4 0/3] Deploy swupdate images with empty var partition Felix Moessbauer
2024-02-19 13:28 ` [isar-cip-core][RFC v4 1/3] update ISAR to latest next for dh-compat improvements Felix Moessbauer
2024-02-20 17:21   ` Jan Kiszka
2024-02-19 13:28 ` [isar-cip-core][RFC v4 2/3] swupdate images: initially deploy empty var part Felix Moessbauer
2024-02-19 13:28 ` Felix Moessbauer [this message]

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=20240219132850.68686-4-felix.moessbauer@siemens.com \
    --to=felix.moessbauer@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=jan.kiszka@siemens.com \
    --cc=quirin.gylstorff@siemens.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.