Patchwork [2/2] package/tzdata: new package

login
register
mail settings
Submitter Yann E. MORIN
Date Feb. 4, 2013, 10:49 p.m.
Message ID <3b37bfde822cb775f4f21b49052444442585fe26.1360017945.git.yann.morin.1998@free.fr>
Download mbox | patch
Permalink /patch/218104/
State Changes Requested
Headers show

Comments

Yann E. MORIN - Feb. 4, 2013, 10:49 p.m.
From: Richard Braun <rbraun@sceen.net>

This is the time zone database, used by glibc for translations between
UTC and local time.

Signed-off-by: Richard Braun <rbraun@sceen.net>
[yann.morin.1998@free.fr: use global ZIC, install posix TZ only once]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 package/Config.in        |    1 +
 package/tzdata/Config.in |   20 ++++++++++++++++++++
 package/tzdata/tzdata.mk |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 package/tzdata/Config.in
 create mode 100644 package/tzdata/tzdata.mk
Danomi Manchego - Feb. 26, 2013, 2:02 a.m.
+define TZDATA_INSTALL_TARGET_CMDS
+       mkdir -p $(TARGET_DIR)/usr/share/zoneinfo
+       cp -a $(@D)/_output/* $(TARGET_DIR)/usr/share/zoneinfo
+       cd $(TARGET_DIR)/usr/share/zoneinfo;    \
+       for zone in posix/*; do                 \
+           ln -s "$${zone}" "$${zone##*/}";    \
+       done
+endef

Yann,

Today, a co-worker applied these patches, and ran into a small problem
during the install phase.  He had made a mistake while applying the
companion zic patch, which caused the tzdata package to stop.  Then,
after he fixed his mistake, the tzdata failed to install, because the
'ln -s' failed to overwrite symlinks that already exist.  So I think
that it might be good to add an 'rm -f "$${zone##*/}";' before the 'ln
-s'.  (Or at least make it an 'ln -sf', though I personally am
distrustful of 'ln -sf' due to sometimes unexpected behavior when the
target of the symlink is a directory.)

Danomi -
Richard Braun - Feb. 26, 2013, 7:43 a.m.
On Mon, Feb 25, 2013 at 09:02:50PM -0500, Danomi Manchego wrote:
> +define TZDATA_INSTALL_TARGET_CMDS
> +       mkdir -p $(TARGET_DIR)/usr/share/zoneinfo
> +       cp -a $(@D)/_output/* $(TARGET_DIR)/usr/share/zoneinfo
> +       cd $(TARGET_DIR)/usr/share/zoneinfo;    \
> +       for zone in posix/*; do                 \
> +           ln -s "$${zone}" "$${zone##*/}";    \
> +       done
> +endef
> 
> Yann,
> 
> Today, a co-worker applied these patches, and ran into a small problem
> during the install phase.  He had made a mistake while applying the
> companion zic patch, which caused the tzdata package to stop.  Then,
> after he fixed his mistake, the tzdata failed to install, because the
> 'ln -s' failed to overwrite symlinks that already exist.  So I think
> that it might be good to add an 'rm -f "$${zone##*/}";' before the 'ln
> -s'.  (Or at least make it an 'ln -sf', though I personally am
> distrustful of 'ln -sf' due to sometimes unexpected behavior when the
> target of the symlink is a directory.)

This is best fixed with ln -sfn. Sorry for not doing it in the first
place.
Yann E. MORIN - Feb. 26, 2013, 8:52 p.m.
Danomi, Richard, All,

On Tuesday 26 February 2013 Danomi Manchego wrote:
> +define TZDATA_INSTALL_TARGET_CMDS
> +       mkdir -p $(TARGET_DIR)/usr/share/zoneinfo
> +       cp -a $(@D)/_output/* $(TARGET_DIR)/usr/share/zoneinfo
> +       cd $(TARGET_DIR)/usr/share/zoneinfo;    \
> +       for zone in posix/*; do                 \
> +           ln -s "$${zone}" "$${zone##*/}";    \
> +       done
> +endef
> 
> Yann,
> 
> Today, a co-worker applied these patches, and ran into a small problem
> during the install phase.  He had made a mistake while applying the
> companion zic patch, which caused the tzdata package to stop.  Then,
> after he fixed his mistake, the tzdata failed to install, because the
> 'ln -s' failed to overwrite symlinks that already exist.  So I think
> that it might be good to add an 'rm -f "$${zone##*/}";' before the 'ln
> -s'.  (Or at least make it an 'ln -sf', though I personally am
> distrustful of 'ln -sf' due to sometimes unexpected behavior when the
> target of the symlink is a directory.)

OK, I'll apply Richard's "ln -sfn" fix, and re-submit.
Thank you both for the feedback!

Regards,
Yann E. MORIN.

Patch

diff --git a/package/Config.in b/package/Config.in
index 2f219b6..090216e 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -566,6 +566,7 @@  source "package/protobuf/Config.in"
 source "package/schifra/Config.in"
 source "package/startup-notification/Config.in"
 source "package/liblog4c-localtime/Config.in"
+source "package/tzdata/Config.in"
 endmenu
 
 menu "Text and terminal handling"
diff --git a/package/tzdata/Config.in b/package/tzdata/Config.in
new file mode 100644
index 0000000..4e68a97
--- /dev/null
+++ b/package/tzdata/Config.in
@@ -0,0 +1,20 @@ 
+config BR2_PACKAGE_TZDATA
+	bool "tzdata"
+	depends on BR2_TOOLCHAIN_EXTERNAL_GLIBC || BR2_TOOLCHAIN_CTNG_eglibc || BR2_TOOLCHAIN_CTNG_glibc
+	help
+	  Time zone database
+
+	  http://www.iana.org/time-zones/repository/tz-link.html
+
+config BR2_PACKAGE_TZDATA_ZONELIST
+	string "Time zone list"
+	depends on BR2_PACKAGE_TZDATA
+	default "default"
+	help
+	  Space-separated list of time zones to compile.
+
+	  The value "default" includes all commonly used time zones. Note
+	  that this set consumes around 5.5M.
+
+	  The full list is the list of files in the time zone database source,
+	  not including the build and .tab files.
diff --git a/package/tzdata/tzdata.mk b/package/tzdata/tzdata.mk
new file mode 100644
index 0000000..f74898f
--- /dev/null
+++ b/package/tzdata/tzdata.mk
@@ -0,0 +1,46 @@ 
+#############################################################
+#
+# tzdata
+#
+#############################################################
+
+TZDATA_VERSION = 2012j
+TZDATA_SOURCE = tzdata$(TZDATA_VERSION).tar.gz
+TZDATA_SITE = http://www.iana.org/time-zones/repository/releases
+TZDATA_DEPENDENCIES = host-zic
+TZDATA_LICENSE = Public domain
+
+TZDATA_DEFAULT_ZONELIST = africa antarctica asia australasia backward etcetera \
+			europe factory northamerica pacificnew southamerica
+
+ifeq ($(call qstrip,$(BR2_PACKAGE_TZDATA_ZONELIST)),default)
+TZDATA_ZONELIST = $(TZDATA_DEFAULT_ZONELIST)
+else
+TZDATA_ZONELIST = $(call qstrip,$(BR2_PACKAGE_TZDATA_ZONELIST))
+endif
+
+# Don't strip any path components during extraction.
+define TZDATA_EXTRACT_CMDS
+	gzip -d -c $(DL_DIR)/$(TZDATA_SOURCE) \
+		| $(TAR) --strip-components=0 -C $(@D) -xf -
+endef
+
+define TZDATA_BUILD_CMDS
+	(cd $(@D); \
+		for zone in $(TZDATA_ZONELIST); do \
+			$(ZIC) -d _output/posix -y yearistype.sh $$zone; \
+			$(ZIC) -d _output/right -L leapseconds -y yearistype.sh $$zone; \
+		done; \
+	)
+endef
+
+define TZDATA_INSTALL_TARGET_CMDS
+	mkdir -p $(TARGET_DIR)/usr/share/zoneinfo
+	cp -a $(@D)/_output/* $(TARGET_DIR)/usr/share/zoneinfo
+	cd $(TARGET_DIR)/usr/share/zoneinfo;    \
+	for zone in posix/*; do                 \
+	    ln -s "$${zone}" "$${zone##*/}";    \
+	done
+endef
+
+$(eval $(generic-package))