system: allow not setting a default, system-wide time zone
authorYann E. MORIN <yann.morin.1998@free.fr>
Sat, 16 Nov 2019 09:10:04 +0000 (10:10 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 27 Nov 2019 20:48:38 +0000 (21:48 +0100)
It is valid that there is no system-wide default time zone defined, in
which case Etc/UTC is assumed.

Fixes: #12316
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Martin Bark <martin@barkynet.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Richard Braun <rbraun@sceen.net>
Cc: Andrew Trapani <andrew.trapani@ontera.bio>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/tz/tz.mk
package/tzdata/tzdata.mk
system/Config.in

index 1e797046d2ff5f836e1a412d56445e98b28c5b10..135726c2cecb29eddb1705226205fb00c81f6cca 100644 (file)
@@ -8,6 +8,16 @@ TZ_DEPENDENCIES = host-tzdata host-tzdump
 TZ_LICENSE = Public domain
 
 TZ_LOCALTIME = $(call qstrip,$(BR2_TARGET_LOCALTIME))
+ifneq ($(TZ_LOCALTIME),)
+define TZ_SET_LOCALTIME
+       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
+endif
 
 define TZ_BUILD_CMDS
        (cd $(HOST_DIR)/share/zoneinfo/posix/; \
@@ -25,12 +35,7 @@ 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 [ ! -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
+       $(TZ_SET_LOCALTIME)
 endef
 
 $(eval $(generic-package))
index 4d097dbee91cf2e2ae29f900b4c258cb530db104..b656bc7f7f37e44771c7886b1f4c6aa127dd029a 100644 (file)
@@ -26,6 +26,17 @@ TZDATA_ZONELIST = $(call qstrip,$(BR2_TARGET_TZ_ZONELIST))
 endif
 
 TZDATA_LOCALTIME = $(call qstrip,$(BR2_TARGET_LOCALTIME))
+ifneq ($(TZDATA_LOCALTIME),)
+define TZDATA_SET_LOCALTIME
+       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
+endif
 
 # No need to extract for target, we're using the host-installed files
 TZDATA_EXTRACT_CMDS =
@@ -37,13 +48,7 @@ define TZDATA_INSTALL_TARGET_CMDS
        for zone in posix/*; do \
            ln -sfn "$${zone}" "$${zone##*/}"; \
        done
-       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
+       $(TZDATA_SET_LOCALTIME)
 endef
 
 define HOST_TZDATA_BUILD_CMDS
index c87266f4318e4a7d7d406f1eaaa45f35cb368a33..c8c5be40e0965d32e37a3ef29e2396ed6a676cfe 100644 (file)
@@ -494,6 +494,8 @@ config BR2_TARGET_LOCALTIME
            Pacific/Wallis
            ...
 
+         Set to empty to not install a default time zone.
+
 endif # BR2_TARGET_TZ_INFO
 
 config BR2_ROOTFS_USERS_TABLES