buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [git commit] package/systemd: add support for creating journal catalog DB
@ 2022-01-09  8:43 Arnout Vandecappelle
  0 siblings, 0 replies; only message in thread
From: Arnout Vandecappelle @ 2022-01-09  8:43 UTC (permalink / raw)
  To: buildroot

[-- Attachment #1: Type: text/plain, Size: 5076 bytes --]

commit: https://git.buildroot.net/buildroot/commit/?id=01a7e1a9f8bcfa4d7f8b1dab85f84ec53797ea2b
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

journald supports catalog files, or rather a binary database of
those.
Functionality added includes:

-   A config option allows enabling the binary database.

-   If BR2_ENABLE_LOCALE_PURGE is enabled, the catalogs not in the
    language whitelist are deleted first. This is done independently
    of the new option, since the catalogs are removed later anyway.

-   If the option is enabled, the database is built and moved to
    /usr/share/factory. This makes sure that /usr contains the entire
    system. A symlink is created in /var pointing to that file.

-   The catalog source files are deleted. They serve no purpose on the
    target once the database exists.

-   All of the above is done in a ROOTFS_PRE_CMD_HOOK rather than in the
    build/install step, because other packages than systemd itself may
    also install catalogs. This also makes sure that it is possible to
    do a re-build, because the catalog files are not removed in
    $(TARGET_DIR) itself, only in the temporary copy for rootfs creation.

-   The service normally used for creating the DB during boot is
    deleted. If the DB is not enabled, we also don't want to waste time
    and space on re-generating every boot. Conversely, if the DB is
    enabled, it is already there so doesn't need to be re-done on every
    boot either.

The new option depends on !BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW because
if the rootfs is not RW, /var is overmounted with a tmpfs. The factory
should handle this, but this only half-works [1].

[1] http://lists.busybox.net/pipermail/buildroot/2020-July/287016.html

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Reviewed-by: Jérémy Rosen <jeremy.rosen@smile.fr>
Reviewed-by: Adam Duskett <aduskett@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/systemd/Config.in  | 14 ++++++++++++++
 package/systemd/systemd.mk | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/package/systemd/Config.in b/package/systemd/Config.in
index 0148cad791..c8c5a9c47b 100644
--- a/package/systemd/Config.in
+++ b/package/systemd/Config.in
@@ -269,6 +269,20 @@ config BR2_PACKAGE_SYSTEMD_IMPORTD
 
 	  http://www.freedesktop.org/software/systemd/man/machinectl.html#Image%20Transfer%20Commands
 
+config BR2_PACKAGE_SYSTEMD_CATALOGDB
+	bool "enable journal catalog database installation"
+	depends on BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW # conflicting tmpfiles magic
+	help
+	  Build and install the journal catalog database.
+
+	  catalog files are used to provide extended and potentially
+	  localized messages for the journal.
+
+	  The original catalog files will be built into a DB at
+	  /usr/share/factory/var/lib/systemd/catalog/database.
+
+	  https://www.freedesktop.org/wiki/Software/systemd/catalog/
+
 config BR2_PACKAGE_SYSTEMD_LOCALED
 	bool "enable locale daemon"
 	help
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 17bb922f51..a2417ebe19 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -678,6 +678,44 @@ define SYSTEMD_INSTALL_INIT_SYSTEMD
 	$(SYSTEMD_INSTALL_NETWORK_CONFS)
 endef
 
+ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
+# Go through all files with scheme <basename>.<langext>.catalog
+# and remove those where <langext> is not in LOCALE_NOPURGE
+define SYSTEMD_LOCALE_PURGE_CATALOGS
+	for cfile in `find $(TARGET_DIR)/usr/lib/systemd/catalog -name '*.*.catalog'`; \
+	do \
+		basename=$${cfile##*/}; \
+		basename=$${basename%.catalog}; \
+		langext=$${basename#*.}; \
+		[ "$$langext" = "$${basename}" ] && continue; \
+		expr '$(LOCALE_NOPURGE)' : ".*\b$${langext}\b" >/dev/null && continue; \
+		rm -f "$$cfile"; \
+	done
+endef
+SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_LOCALE_PURGE_CATALOGS
+endif
+
+ifeq ($(BR2_PACKAGE_SYSTEMD_CATALOGDB),y)
+define SYSTEMD_UPDATE_CATALOGS
+	$(HOST_DIR)/bin/journalctl --root=$(TARGET_DIR) --update-catalog
+	install -D $(TARGET_DIR)/var/lib/systemd/catalog/database \
+		$(TARGET_DIR)/usr/share/factory/var/lib/systemd/catalog/database
+	rm $(TARGET_DIR)/var/lib/systemd/catalog/database
+	ln -sf /usr/share/factory/var/lib/systemd/catalog/database \
+		$(TARGET_DIR)/var/lib/systemd/catalog/database
+	grep -q '^L /var/lib/systemd/catalog/database' $(TARGET_DIR)/usr/lib/tmpfiles.d/var.conf || \
+		printf "\nL /var/lib/systemd/catalog/database\n" >> $(TARGET_DIR)/usr/lib/tmpfiles.d/var.conf
+endef
+SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_UPDATE_CATALOGS
+endif
+
+define SYSTEMD_RM_CATALOG_UPDATE_SERVICE
+	rm -rf $(TARGET_DIR)/usr/lib/systemd/catalog \
+		$(TARGET_DIR)/usr/lib/systemd/system/systemd-journal-catalog-update.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/*/systemd-journal-catalog-update.service
+endef
+SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_RM_CATALOG_UPDATE_SERVICE
+
 define SYSTEMD_PRESET_ALL
 	$(HOST_DIR)/bin/systemctl --root=$(TARGET_DIR) preset-all
 endef

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-09  8:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-09  8:43 [Buildroot] [git commit] package/systemd: add support for creating journal catalog DB Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).