[Buildroot] [PATCH 1/4] package/skeleton-systemd: move /var factory out of /etc
Yann E. MORIN
yann.morin.1998 at free.fr
Sat Oct 15 21:23:09 UTC 2022
From: "Yann E. MORIN" <yann.morin at orange.com>
When the rootfs is not remounted read-write (thus assuming a read-only
rootfs like squashfs), we create a tmpfiles.d factory for /var.
However, we register those in /etc/tmpfiles.d/, but /etc could also be
a tmpfs (for full state-less systems, or easy factory-reset, see [0]).
So, we move our var factory to /usr/lib/tmpfiles.d/, which is also the
location where systemd itself places its own tmpfiles, and where we
already put all our other tmpfiles (see audit, avahi, cryptsetup, dhcp,
lighttpd, nfs-utils, quagga, samba4, swupdate) and our handling of
systemd's catalog files too. We also rename the file to a better name,
so that it is obvious it is generated by us (systemd already installs a
var.conf of its own, so we want to avoid name clashing).
Last little detail: there is no need or reason to create .../tmpfiles.d/
at install time; it is only needed in the rootfs-pre-cmd hook, so we
only create it just before we need it.
[0] http://0pointer.de/blog/projects/stateless.html
Signed-off-by: Yann E. MORIN <yann.morin at orange.com>
Cc: Norbert Lange <nolange79 at gmail.com>
Cc: Romain Naour <romain.naour at smile.fr>
Cc: Jérémy Rosen <jeremy.rosen at smile.fr>
[yann.morin.1998 at free.fr:
- split original patch in two
- this one only moves out of /etc and into /usr/lib
- adapt commit log accordingly
]
Signed-off-by: Yann E. MORIN <yann.morin.1998 at free.fr>
---
package/skeleton-init-systemd/skeleton-init-systemd.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package/skeleton-init-systemd/skeleton-init-systemd.mk b/package/skeleton-init-systemd/skeleton-init-systemd.mk
index 795a171809..7b66732ef4 100644
--- a/package/skeleton-init-systemd/skeleton-init-systemd.mk
+++ b/package/skeleton-init-systemd/skeleton-init-systemd.mk
@@ -29,7 +29,6 @@ else
# a real (but empty) directory, and the "factory files" will be copied
# back there by the tmpfiles.d mechanism.
define SKELETON_INIT_SYSTEMD_ROOT_RO_OR_RW
- mkdir -p $(TARGET_DIR)/etc/systemd/tmpfiles.d
echo "/dev/root / auto ro 0 1" >$(TARGET_DIR)/etc/fstab
echo "tmpfs /var tmpfs mode=1777 0 0" >>$(TARGET_DIR)/etc/fstab
endef
@@ -38,6 +37,7 @@ define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
rm -rf $(TARGET_DIR)/usr/share/factory/var
mv $(TARGET_DIR)/var $(TARGET_DIR)/usr/share/factory/var
mkdir -p $(TARGET_DIR)/var
+ mkdir -p $(TARGET_DIR)/usr/lib/tmpfiles.d
for i in $(TARGET_DIR)/usr/share/factory/var/* \
$(TARGET_DIR)/usr/share/factory/var/lib/* \
$(TARGET_DIR)/usr/share/factory/var/lib/systemd/*; do \
@@ -51,7 +51,7 @@ define SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
printf "C! %s - - - -\n" "$${j}" \
|| exit 1; \
fi; \
- done >$(TARGET_DIR)/etc/tmpfiles.d/var-factory.conf
+ done >$(TARGET_DIR)/usr/lib/tmpfiles.d/buildroot-factory.conf
endef
SKELETON_INIT_SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SKELETON_INIT_SYSTEMD_PRE_ROOTFS_VAR
--
2.25.1
More information about the buildroot
mailing list