From 2b4d70873b67d816c050395345f969b520654f07 Mon Sep 17 00:00:00 2001 From: Olaf Mersmann Date: Sun, 10 Jan 2021 09:24:40 +0100 Subject: [PATCH] shutils/chroot.sh: create symlink for /etc/localtime Currently /etc/localtime is copied from the host to the chroot. According to [1] /etc/localtime should be a symlink and some R checks fail because it is not. Instead of copying, copy the zoneinfo for UTC into the chroot and then symlink it to /etc/localtime inside the chroot. [1]: https://www.freedesktop.org/software/systemd/man/localtime.html --- common/xbps-src/shutils/chroot.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh index 8646d758549..4ea4280b401 100644 --- a/common/xbps-src/shutils/chroot.sh +++ b/common/xbps-src/shutils/chroot.sh @@ -106,11 +106,23 @@ chroot_prepare() { msg_error "Bootstrap not installed in $XBPS_MASTERDIR, can't continue.\n" fi - # Create some required files. - if [ -f /etc/localtime ]; then - cp -f /etc/localtime $XBPS_MASTERDIR/etc - elif [ -f /usr/share/zoneinfo/UTC ]; then - cp -f /usr/share/zoneinfo/UTC $XBPS_MASTERDIR/etc/localtime + # Setup timezone information + # + # According to https://www.freedesktop.org/software/systemd/man/localtime.html: + # + # Because the timezone identifier is extracted from the symlink target + # name of /etc/localtime, this file may not be a normal file or hardlink. + # + # So we cannot just copy /etc/localtime into $XBPS_MASTERDIR. Instead, copy + # over the zoneinfo for UTC and create the /etc/localtime symlink. + if [ -f /usr/share/zoneinfo/UTC ]; then + tzfile=/usr/share/zoneinfo/UTC + mkdir -p $XBPS_MASTERDIR/usr/share/zoneinfo + cp /usr/share/zoneinfo/UTC $XBPS_MASTERDIR/usr/share/zoneinfo/UTC + ln -sf ../usr/share/zoneinfo/UTC $XBPS_MASTERDIR/etc/localtime + else + # Should never happen. + msg_warn "No local timezone configuration file created." fi for f in dev sys proc host boot; do