]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
systemd: set better sane time at startup
authorGaël PORTAY <gael.portay+rtone@gmail.com>
Tue, 12 Nov 2024 19:22:14 +0000 (20:22 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 19 Nov 2024 11:26:22 +0000 (11:26 +0000)
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

Signed-off-by: Gaël PORTAY <gael.portay+rtone@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/systemd/systemd_256.7.bb

index f3af4ac44dc7e54cf3d20290c4ecbf27120dc456..3831baa511b786a5582d9fd493fba875589f9442 100644 (file)
@@ -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*\<myhostname\>//' \