Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime
@ 2021-01-10  8:37 olafmersmann
  2021-01-10 11:29 ` [PR REVIEW] " sgn
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-10  8:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 746 bytes --]

There is a new pull request by olafmersmann against master on the void-packages repository

https://github.com/olafmersmann/void-packages feat_localtime
https://github.com/void-linux/void-packages/pull/27803

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, this commit resolves the
symlink, creates the required file below /usr/share/zoneinfo and then
symlinks it to /etc/localtime inside the chroot.

[1]: https://www.freedesktop.org/software/systemd/man/localtime.html


A patch file from https://github.com/void-linux/void-packages/pull/27803.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-feat_localtime-27803.patch --]
[-- Type: text/x-diff, Size: 2361 bytes --]

From ece1ce5c598f6b2e6899c4969918c8e9aba4c54f Mon Sep 17 00:00:00 2001
From: Olaf Mersmann <olafm@p-value.net>
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, this commit resolves the
symlink, creates the required file below /usr/share/zoneinfo and then
symlinks it to /etc/localtime inside the chroot.

[1]: https://www.freedesktop.org/software/systemd/man/localtime.html
---
 common/xbps-src/shutils/chroot.sh | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8646d758549..9b4f5ca94a8 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -106,11 +106,30 @@ 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
+    # 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 /etc/localtime into $XBPS_MASTERDIR. Instead, copy over 
+    # the target of the link, creating any required directories along the way.
+    local tzfile=""
+    if [ -h /etc/localtime ]; then
+        tzfile=$(readlink -f /etc/localtime)
     elif [ -f /usr/share/zoneinfo/UTC ]; then
-        cp -f /usr/share/zoneinfo/UTC $XBPS_MASTERDIR/etc/localtime
+        tzfile=/usr/share/zoneinfo/UTC
+    else
+        # Should never happen.
+        msg_warn "No local timezone configuration file created."
+    fi
+    # If tzfile exists, create parent directory, copy file and link to 
+    # /etc/localtime
+    if [ -f "$tzfile" ] ; then
+        mkdir -p $XBPS_MASTERDIR/$(dirname $tzfile)
+        cp /etc/localtime $XBPS_MASTERDIR/$tzfile
+        ln -sf ../$tzfile $XBPS_MASTERDIR/etc/localtime
     fi
 
     for f in dev sys proc host boot; do

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-01-20  1:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
2021-01-10 11:29 ` [PR REVIEW] " sgn
2021-01-10 15:15 ` olafmersmann
2021-01-10 15:35 ` [PR PATCH] [Updated] " olafmersmann
2021-01-14 13:50 ` ahesford
2021-01-14 14:06 ` [PR REVIEW] " ahesford
2021-01-14 22:51 ` olafmersmann
2021-01-14 22:59 ` olafmersmann
2021-01-14 23:00 ` [PR PATCH] [Updated] " olafmersmann
2021-01-14 23:03 ` olafmersmann
2021-01-20  1:13 ` [PR PATCH] [Merged]: " ericonr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).