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

* Re: [PR REVIEW] shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
@ 2021-01-10 11:29 ` sgn
  2021-01-10 15:15 ` olafmersmann
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: sgn @ 2021-01-10 11:29 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#discussion_r554553328

Comment:
I would argue to always copy `/usr/share/zoneinfo/UTC` if it's exist to make the build maximum reproducible.

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

* Re: [PR REVIEW] shutils/chroot.sh: create symlink for /etc/localtime
  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
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-10 15:15 UTC (permalink / raw)
  To: ml

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

New review comment by olafmersmann on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#discussion_r554581328

Comment:
I agree, but kept the original logic for a first draft. Not sure if there are any side effects I haven't thought of if localtime is always UTC. If there are no objections, I'll simplify the patch to always set localtime to UTC inside the chroot.

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

* Re: [PR PATCH] [Updated] shutils/chroot.sh: create symlink for /etc/localtime
  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 ` olafmersmann
  2021-01-14 13:50 ` ahesford
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-10 15:35 UTC (permalink / raw)
  To: ml

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

There is an updated 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: 2154 bytes --]

From 2b4d70873b67d816c050395345f969b520654f07 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, 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

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

* Re: shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (2 preceding siblings ...)
  2021-01-10 15:35 ` [PR PATCH] [Updated] " olafmersmann
@ 2021-01-14 13:50 ` ahesford
  2021-01-14 14:06 ` [PR REVIEW] " ahesford
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2021-01-14 13:50 UTC (permalink / raw)
  To: ml

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

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#issuecomment-760208756

Comment:
Freedesktop requirements for systemd should not be the governing standard here. It also seems to me that R is doing the wrong thing by demanding that `/etc/localtime` be a symlink and reading the target to determine a timezone. For example, I have `/etc/localtime -> /usr/share/zoneinfo/America/New_York`, but there are a ton of equivalent time zones in `/usr/share/zoneinfo`; for example, `US/Eastern`, `EST5EDT`.

This doesn't mean that `/usr/share/zoneinfo` shouldn't be populated in the masterdir, but are there compelling reasons beyond R breaking because it makes fragile assumptions? R can determine zone offset programmatically or, in the shell, invoke `date +"%z"` or `date "+%Z"` to more reliably grab the information.

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

* Re: [PR REVIEW] shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (3 preceding siblings ...)
  2021-01-14 13:50 ` ahesford
@ 2021-01-14 14:06 ` ahesford
  2021-01-14 22:51 ` olafmersmann
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ahesford @ 2021-01-14 14:06 UTC (permalink / raw)
  To: ml

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

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#discussion_r557418410

Comment:
Maybe shorten the explanation to
> Some software expects /etc/localtime to be a symbolic link it can read to determine the name of the time zone, so set up the expected link structure.

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

* Re: [PR REVIEW] shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (4 preceding siblings ...)
  2021-01-14 14:06 ` [PR REVIEW] " ahesford
@ 2021-01-14 22:51 ` olafmersmann
  2021-01-14 22:59 ` olafmersmann
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-14 22:51 UTC (permalink / raw)
  To: ml

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

New review comment by olafmersmann on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#discussion_r557750270

Comment:
Done.

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

* Re: shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (5 preceding siblings ...)
  2021-01-14 22:51 ` olafmersmann
@ 2021-01-14 22:59 ` olafmersmann
  2021-01-14 23:00 ` [PR PATCH] [Updated] " olafmersmann
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-14 22:59 UTC (permalink / raw)
  To: ml

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

New comment by olafmersmann on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#issuecomment-760530105

Comment:
Tally:
* for UTC: sgn, abenson, duncaen
* for local TZ: feranur, ericonr(?)


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

* Re: [PR PATCH] [Updated] shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (6 preceding siblings ...)
  2021-01-14 22:59 ` olafmersmann
@ 2021-01-14 23:00 ` olafmersmann
  2021-01-14 23:03 ` olafmersmann
  2021-01-20  1:13 ` [PR PATCH] [Merged]: " ericonr
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-14 23:00 UTC (permalink / raw)
  To: ml

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

There is an updated 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: 1733 bytes --]

From 3b39825a13dc6909200ff0d27096c60b3760c067 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. Some
software expects /etc/localtime to be a symbolic link it can read to
determine the name of the time zone, so set up the expected link
structure.
---
 common/xbps-src/shutils/chroot.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/xbps-src/shutils/chroot.sh b/common/xbps-src/shutils/chroot.sh
index 8646d758549..73b98bc7200 100644
--- a/common/xbps-src/shutils/chroot.sh
+++ b/common/xbps-src/shutils/chroot.sh
@@ -106,11 +106,17 @@ 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
+    # Some software expects /etc/localtime to be a symbolic link it can read to
+    # determine the name of the time zone, so set up the expected link
+    # structure.
+    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

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

* Re: shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (7 preceding siblings ...)
  2021-01-14 23:00 ` [PR PATCH] [Updated] " olafmersmann
@ 2021-01-14 23:03 ` olafmersmann
  2021-01-20  1:13 ` [PR PATCH] [Merged]: " ericonr
  9 siblings, 0 replies; 11+ messages in thread
From: olafmersmann @ 2021-01-14 23:03 UTC (permalink / raw)
  To: ml

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

New comment by olafmersmann on void-packages repository

https://github.com/void-linux/void-packages/pull/27803#issuecomment-760530105

Comment:
Tally:
* for UTC: sgn, abenson, duncaen, ahesford
* for local TZ: feranur, ericonr


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

* Re: [PR PATCH] [Merged]: shutils/chroot.sh: create symlink for /etc/localtime
  2021-01-10  8:37 [PR PATCH] shutils/chroot.sh: create symlink for /etc/localtime olafmersmann
                   ` (8 preceding siblings ...)
  2021-01-14 23:03 ` olafmersmann
@ 2021-01-20  1:13 ` ericonr
  9 siblings, 0 replies; 11+ messages in thread
From: ericonr @ 2021-01-20  1:13 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

shutils/chroot.sh: create symlink for /etc/localtime
https://github.com/void-linux/void-packages/pull/27803

Description:
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


^ 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).