Skip to contentSkip to conversation

system/timezone: check localtime exists

PATCH New Yann E. MORIN 2 participants 2 messages May 22, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 system/timezone: check localtime exists

From: "Yann E. MORIN" <[email protected]>

When installing a localtime, check it is a valid timezone.

---
 package/tz/tz.mk         | 5 +++++
 package/tzdata/tzdata.mk | 5 +++++
 2 files changed, 10 insertions(+)
package/tz/tz.mk +5 -0
index 865ba3b..3198db7 100644
@@ -27,6 +27,11 @@ 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 \
+	        printf "'%s' is not a valid timezone\n"                 \
+	               "$(TZDATA_LOCALTIME)";                           \
+	        exit 1;                                                 \
+	    fi;                                                         \
 	    cd $(TARGET_DIR)/etc;                                       \
 	    ln -sf ../usr/share/zoneinfo/uclibc/$(TZDATA_LOCALTIME) TZ; \
 	fi
package/tzdata/tzdata.mk +5 -0
index a498d10..c394dd2 100644
@@ -44,6 +44,11 @@ define TZDATA_INSTALL_TARGET_CMDS
 	    ln -sfn "$${zone}" "$${zone##*/}";  \
 	done
 	if [ -n "$(TZDATA_LOCALTIME)" ]; then                           \
+	    if [ ! -f $(TARGET_DIR)/usr/share/zoneinfo/$(TZDATA_LOCALTIME) ]; then \
+	        printf "'%s' is not a valid timezone\n"                 \
+	               "$(TZDATA_LOCALTIME)";                           \
+	        exit 1;                                                 \
+	    fi;                                                         \
 	    cd $(TARGET_DIR)/etc;                                       \
 	    ln -sf ../usr/share/zoneinfo/$(TZDATA_LOCALTIME) localtime; \
 	    echo "$(TZDATA_LOCALTIME)" >timezone;                       \
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/1 system/timezone: check localtime exists

Quoted 17 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

From: "Yann E. MORIN" <[email protected]> When installing a localtime, check it is a valid timezone.

---
 package/tz/tz.mk         | 5 +++++
 package/tzdata/tzdata.mk | 5 +++++
 2 files changed, 10 insertions(+)
package/tz/tz.mk +0 -0
index 865ba3b..3198db7 100644

package/tz/tz.mk define TZ_INSTALL_TARGET_CMDS · line 32

Quoted 6 lines
package/tz/tz.mk +3 -0
@@ -27,6 +27,11 @@ 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 \
+	        printf "'%s' is not a valid timezone\n"                 \
+	               "$(TZDATA_LOCALTIME)";                           \

I have extended this to make it a bit more clear what the user should change:

- printf "'%s' is not a valid timezone\n" \
+ printf "Error: '%s' is not a valid timezone, check your BR2_TARGET_LOCALTIME setting\n" \

And committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard