Skip to contentSkip to conversation

system: default to using Etc/UTC as a timezone

PATCH New Yann E. MORIN 2 participants 5 messages Jul 4, 2017

lore
Share & tools
lore
#0 lore raw

v2 cover system: default to using Etc/UTC as a timezone

Hello All!

A tiemzone is required by systemd, so we must have one defined. See the second commit log for more details.

Changes v1 -> v2:
- don't accept empty as default (Arnout)
- don't sneak whitespace cleanups, tell about them ;-) (Arnout)

Regards,
Yann E. MORIN.

The following changes since commit 417ade5f2bbd6941d717d40af309f638abc108d5

  pkg-rebar: remove redundant / in front of $($(PKG)_ERLANG_LIBDIR) (2017-07-04 08:35:09 +0200)

are available in the git repository at:

git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 4928890759713fe0a785e193fa843dcff9805ed6

system: use Etc/UTC as default timezone (2017-07-04 08:45:13 +0200)

----------------------------------------------------------------
Yann E. MORIN (2):
package/tz: fix variable name
system: use Etc/UTC as default timezone

 package/tz/tz.mk         | 13 +++++--------
 package/tzdata/tzdata.mk | 15 ++++++---------
 system/Config.in         |  4 +---
 3 files changed, 12 insertions(+), 20 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/2 package/tz: fix variable name

The tz packages mizes its own variable with the one fro the tzdata package...

Fix the variable name in tz.

Cc Alexandre BELLONI <[email protected]>
---
 package/tz/tz.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
package/tz/tz.mk +3 -3
index 4d1c8c4d61..6b1f9f4d24 100644
@@ -26,13 +26,13 @@ define TZ_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/usr/share/zoneinfo/uclibc
 	cp -a $(@D)/output/* $(TARGET_DIR)/usr/share/zoneinfo/uclibc
 	if [ -n "$(TZ_LOCALTIME)" ]; then \
-		if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/uclibc/$(TZDATA_LOCALTIME) ]; then \
+		if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) ]; then \
 			printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \
-			"$(TZDATA_LOCALTIME)"; \
+				"$(TZ_LOCALTIME)"; \
 			exit 1; \
 		fi; \
 		cd $(TARGET_DIR)/etc; \
-		ln -sf ../usr/share/zoneinfo/uclibc/$(TZDATA_LOCALTIME) TZ; \
+		ln -sf ../usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) TZ; \
 	fi
 endef
 
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 1/2 package/tz: fix variable name

Hello,

Quoted 10 lines · Yann E. MORIN

The tz packages mizes its own variable with the one fro the tzdata package...

Fix the variable name in tz.

Cc Alexandre BELLONI <[email protected]>
---
 package/tz/tz.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to master, after fixing the typos in the commit log. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 2/2 system: use Etc/UTC as default timezone

In reply to Yann E. MORIN

Even though no timezone implicitly means UTC, systemd is not all that happy when it does not have a timezone set. This is all fine on a RW filesystem because systemd will create a symlink on its own (to Etc/UTC), but not so much on a RO filesystem, causing all kind of issues at boot time (up to the point that the system is unusable).

We fix that by requiring that the timezone is actually set. The check is done by verifying that the timezone file is an actual file; if not set, the test would find a directory and would thus fail.

Update the help entry accordingly.

Also fix indentation in tzdata.

Cc Richard Braun <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Martin Bark <[email protected]>
Cc Maxime Hadjinlian <[email protected]>

---
Changes v1 -> v2:
- don't accept an empty value as meaning the default; enforce that (Arnout)
- comit log mentions indentation cleanups (Arnout)

Note: our packaging of systemd currently does not support running on a RO filesystem. This patch is part of the on-going effort to make it so.

---
 package/tz/tz.mk         | 13 +++++--------
 package/tzdata/tzdata.mk | 15 ++++++---------
 system/Config.in         |  4 +---
 3 files changed, 12 insertions(+), 20 deletions(-)
package/tz/tz.mk +5 -8
index 6b1f9f4d24..7386361088 100644
@@ -25,15 +25,12 @@ define TZ_INSTALL_TARGET_CMDS
 		$(TARGET_DIR)/usr/share/zoneinfo/iso3166.tab
 	mkdir -p $(TARGET_DIR)/usr/share/zoneinfo/uclibc
 	cp -a $(@D)/output/* $(TARGET_DIR)/usr/share/zoneinfo/uclibc
-	if [ -n "$(TZ_LOCALTIME)" ]; then \
-		if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) ]; then \
-			printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \
-				"$(TZ_LOCALTIME)"; \
-			exit 1; \
-		fi; \
-		cd $(TARGET_DIR)/etc; \
-		ln -sf ../usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) TZ; \
+	if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) ]; then \
+		printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \
+			"$(TZ_LOCALTIME)"; \
+		exit 1; \
 	fi
+	ln -sf ../usr/share/zoneinfo/uclibc/$(TZ_LOCALTIME) $(TARGET_DIR)/etc/TZ
 endef
 
 $(eval $(generic-package))
package/tzdata/tzdata.mk +6 -9
index 802d8479a3..8c8d224e4f 100644
@@ -36,16 +36,13 @@ define TZDATA_INSTALL_TARGET_CMDS
 	for zone in posix/*; do \
 	    ln -sfn "$${zone}" "$${zone##*/}"; \
 	done
-	if [ -n "$(TZDATA_LOCALTIME)" ]; then \
-	    if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/$(TZDATA_LOCALTIME) ]; then \
-	        printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \
-	               "$(TZDATA_LOCALTIME)"; \
-	        exit 1; \
-	    fi; \
-	    cd $(TARGET_DIR)/etc; \
-	    ln -sf ../usr/share/zoneinfo/$(TZDATA_LOCALTIME) localtime; \
-	    echo "$(TZDATA_LOCALTIME)" >timezone; \
+	if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/$(TZDATA_LOCALTIME) ]; then \
+		printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \
+			"$(TZDATA_LOCALTIME)"; \
+		exit 1; \
 	fi
+	ln -sf ../usr/share/zoneinfo/$(TZDATA_LOCALTIME) $(TARGET_DIR)/etc/localtime
+	echo "$(TZDATA_LOCALTIME)" >$(TARGET_DIR)/etc/timezone
 endef
 
 define HOST_TZDATA_BUILD_CMDS
system/Config.in +1 -3
index b47ae43844..858883955e 100644
@@ -448,15 +448,13 @@ config BR2_TARGET_LOCALTIME
 	help
 	  The time zone to install as the default local time, expressed as a
 	  tzdata location, such as:
+	    Etc/UTC             (the default)
 	    GMT
 	    Europe/Paris
 	    America/New_York
 	    Pacific/Wallis
 	    ...
 
-	  If empty, no local time will be set, and the dates will be
-	  expressed in UTC.
-
 endif # BR2_TARGET_TZ_INFO
 
 config BR2_ROOTFS_USERS_TABLES
Signature · 1 line
2.11.0
#4 lore raw

PATCH v2 2/2 system: use Etc/UTC as default timezone

Hello,

Quoted 20 lines · Yann E. MORIN

Even though no timezone implicitly means UTC, systemd is not all that happy when it does not have a timezone set. This is all fine on a RW filesystem because systemd will create a symlink on its own (to Etc/UTC), but not so much on a RO filesystem, causing all kind of issues at boot time (up to the point that the system is unusable).

We fix that by requiring that the timezone is actually set. The check is done by verifying that the timezone file is an actual file; if not set, the test would find a directory and would thus fail.

Update the help entry accordingly.

Also fix indentation in tzdata.

Cc Richard Braun <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Martin Bark <[email protected]>
Cc Maxime Hadjinlian <[email protected]>
Quoted 5 lines

---
Changes v1 -> v2:
- don't accept an empty value as meaning the default; enforce that (Arnout)
- comit log mentions indentation cleanups (Arnout)

As discussed IRL, I have changed the commit title. Indeed, Etc/UTC is already the default timezone. What this patch does is prevent the user from selecting an empty value for the timezone.

Applied with the commit title fixed. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com