@@ -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
new file mode 100644
@@ -0,0 +1 @@
+L /var/lib/dpkg - - - - /usr/share/immutable-data/var/lib/dpkg
new file mode 100644
@@ -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/
+}
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