From 7c03445fb79f812c3f5acc9b7bbc35f5b306e888 Mon Sep 17 00:00:00 2001 From: Gaël PORTAY Date: Tue, 12 Nov 2024 20:22:14 +0100 Subject: systemd: set better sane time at startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When systemd is started, it sets the system clock to epoch to ensure the system clock is reasonably initialized if no working RTC. As init process, systemd sets epoch very early to the more recent timestamp of[1]: - the build time of systemd (-Dtime-epoch) - the modification time ("mtime") of /var/lib/systemd/timesync/clock (systemd-timesyncd) - the modification time ("mtime") of /usr/lib/clock-epoch (systemd) The first epoch timestamp is hard-coded at build-time by the systemd recipe (using either SOURCE_DATE_EPOCH, git-tag, or NEWS modification time[2]). The second epoch timestamp is maintained at run-time if the system runs systemd-timesyncd. This implements the third epoch timestamp at image build-time, by touching the timestamp file /usr/lib/clock-epoch from the package post-install script. [1]: https://github.com/systemd/systemd/commit/863098fdc9cd91e4f760085356ac02c4b7ba6df1 [2]: https://github.com/systemd/systemd/blob/v256/meson.build#L804-L825 (From OE-Core rev: 0f51fee4a5408c17cbaf827053f13d6c3b9dbc2c) Signed-off-by: Gaël PORTAY Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- meta/recipes-core/systemd/systemd_256.7.bb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meta/recipes-core/systemd/systemd_256.7.bb b/meta/recipes-core/systemd/systemd_256.7.bb index f3af4ac44d..3831baa511 100644 --- a/meta/recipes-core/systemd/systemd_256.7.bb +++ b/meta/recipes-core/systemd/systemd_256.7.bb @@ -869,6 +869,10 @@ ALTERNATIVE_TARGET[runlevel] = "${base_bindir}/systemctl" ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel" ALTERNATIVE_PRIORITY[runlevel] ?= "300" +pkg_postinst:${PN}:append () { + touch $D${libdir}/clock-epoch +} + pkg_postinst:${PN}:libc-glibc () { if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then sed -e '/^hosts:/s/\s*\//' \ -- cgit v1.2.3-54-g00ecf