According to localtime(5) (installed by systemd): > It should be an absolute or relative symbolic link pointing to /usr/share/zoneinfo/ […] > > Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file may not be a normal file or hardlink. However, in our stages (both OpenRC and systemd stages), /etc/localtime is a regular file. And of course, since people already started assuming systemd is the golden standard, e.g. newer experimental API in libc++ throws an exception if it's not a symlink. I think we should update it to be a symlink for the best compatibility (but I have filed a bug upstream anyway).
I would not expect /etc/localtime to exist at all in stage3 tarballs. I wonder what creates it.
Ah, it might be this hook in stage1: https://gitweb.gentoo.org/proj/catalyst.git/tree/targets/stage1/preclean-chroot.sh
Gentle ping.
Testing with this change now: diff --git a/targets/stage1/preclean-chroot.sh b/targets/stage1/preclean-chroot.sh index 2dc761e9..193a12f9 100755 --- a/targets/stage1/preclean-chroot.sh +++ b/targets/stage1/preclean-chroot.sh @@ -15,7 +15,7 @@ setup_binutils if [ -d "${ROOT}/usr/share/zoneinfo" ] then rm -f "${ROOT}/etc/localtime" - cp "${ROOT}/usr/share/zoneinfo/Factory" "${ROOT}/etc/localtime" + ln -s ../usr/share/zoneinfo/Factory "${ROOT}/etc/localtime" else echo UTC > "${ROOT}/etc/TZ" fi
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e574dbd24c74cedd7f59263859a6551b914410a4 commit e574dbd24c74cedd7f59263859a6551b914410a4 Author: Ben Kohler <bkohler@gentoo.org> AuthorDate: 2024-10-10 01:06:11 +0000 Commit: Ben Kohler <bkohler@gentoo.org> CommitDate: 2024-10-10 01:06:11 +0000 targets/stage1/preclean-chroot.sh: use symlink for /etc/localtime This should be a symlink on modern systems. Bug: https://bugs.gentoo.org/938309 Signed-off-by: Ben Kohler <bkohler@gentoo.org> targets/stage1/preclean-chroot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Could we update that hook to not create any file/link at all? Having a symlink to the bogus "Factory" zone is pretty useless. If /etc/localtime does not exist, libc and timedatedtl will default to UTC, which seems reasonable.
I suppose we should check that new libc++ API to see how it handles /etc/localtime not existing at all.
(In reply to Mike Gilbert from comment #7) > I suppose we should check that new libc++ API to see how it handles > /etc/localtime not existing at all. Make a guess :) https://github.com/llvm/llvm-project/blob/7da0a698526ff657c2348a6e4bb835fc764177da/libcxx/src/experimental/tzdb.cpp#L727