summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaël PORTAY <gael.portay+rtone@gmail.com>2024-11-12 20:22:14 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-11-19 11:26:24 +0000
commit7c03445fb79f812c3f5acc9b7bbc35f5b306e888 (patch)
tree89402eade41b7fdd293903eb4f35b687b55abe1f
parentb6f5bc7bc79cec7b0adc1b1540d9f43e015241f7 (diff)
downloadpoky-7c03445fb79f812c3f5acc9b7bbc35f5b306e888.tar.gz
systemd: set better sane time at startup
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 <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>
-rw-r--r--meta/recipes-core/systemd/systemd_256.7.bb4
1 files changed, 4 insertions, 0 deletions
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"
869ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel" 869ALTERNATIVE_LINK_NAME[runlevel] = "${base_sbindir}/runlevel"
870ALTERNATIVE_PRIORITY[runlevel] ?= "300" 870ALTERNATIVE_PRIORITY[runlevel] ?= "300"
871 871
872pkg_postinst:${PN}:append () {
873 touch $D${libdir}/clock-epoch
874}
875
872pkg_postinst:${PN}:libc-glibc () { 876pkg_postinst:${PN}:libc-glibc () {
873 if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then 877 if ${@bb.utils.contains('PACKAGECONFIG', 'myhostname', 'true', 'false', d)}; then
874 sed -e '/^hosts:/s/\s*\<myhostname\>//' \ 878 sed -e '/^hosts:/s/\s*\<myhostname\>//' \