From: Bart vdr. Meulen <bartvdrmeu...@gmail.com>

Add an alternative source for the timezone info. This option can be used when
using toolchains in which the timezone info is incorrect/does not work or is
not available at all

The option build's the timezone database from the tzdata source files on the
host and installs the selected zoneinfos to the target.

Signed-off-by: Bart vdr. Meulen <bartvdrmeu...@gmail.com>
Signed-off-by: Remy Bohmer <li...@bohmer.net>
---
 rules/host-tz-database.in   |    4 ++
 rules/host-tz-database.make |  100 +++++++++++++++++++++++++++++++++++++++++++
 rules/pre/Rules.make        |    4 +-
 rules/timezone.in           |   14 +++++-
 rules/timezone.make         |    8 +++-
 scripts/make_zoneinfo.sh    |   15 ++++---
 6 files changed, 134 insertions(+), 11 deletions(-)
 create mode 100644 rules/host-tz-database.in
 create mode 100644 rules/host-tz-database.make

diff --git a/rules/host-tz-database.in b/rules/host-tz-database.in
new file mode 100644
index 0000000..c1e0252
--- /dev/null
+++ b/rules/host-tz-database.in
@@ -0,0 +1,4 @@
+## SECTION=hosttools_noprompt
+
+config HOST_TZDATABASE
+       tristate
diff --git a/rules/host-tz-database.make b/rules/host-tz-database.make
new file mode 100644
index 0000000..dc12fe6
--- /dev/null
+++ b/rules/host-tz-database.make
@@ -0,0 +1,100 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2010 by Bart vdr. Meulen <bartvdrmeu...@gmail.com>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+HOST_PACKAGES-$(PTXCONF_HOST_TZDATABASE) += host-tz-database
+
+#
+# Paths and names
+#
+TZCODE_VERSION := 2010f
+TZCODE         := tzcode$(TZCODE_VERSION)
+TZCODE_SUFFIX  := tar.gz
+TZCODE_URL     := \
+ftp://elsie.nci.nih.gov/pub/$(TZCODE).$(TZCODE_SUFFIX) \
+ftp://munnari.oz.au/pub/oldtz/$(TZCODE).$(TZCODE_SUFFIX)
+TZCODE_SOURCE  := $(SRCDIR)/$(TZCODE).$(TZCODE_SUFFIX)
+
+TZDATA_VERSION := 2010h
+TZDATA         := tzdata$(TZDATA_VERSION)
+TZDATA_SUFFIX  := tar.gz
+TZDATA_URL     := \
+ftp://elsie.nci.nih.gov/pub/$(TZDATA).$(TZDATA_SUFFIX) \
+ftp://munnari.oz.au/pub/oldtz/$(TZDATA).$(TZDATA_SUFFIX)
+TZDATA_SOURCE  := $(SRCDIR)/$(TZDATA).$(TZDATA_SUFFIX)
+
+
+HOST_TZDATABASE                := tz-database
+HOST_TZDATABASE_DIR    := $(HOST_BUILDDIR)/$(HOST_TZDATABASE)
+
+# ----------------------------------------------------------------------------
+# Get
+# ----------------------------------------------------------------------------
+$(TZCODE_SOURCE):
+       @$(call get, TZCODE)
+
+$(TZDATA_SOURCE):
+       @$(call get, TZDATA)
+
+$(STATEDIR)/host-tz-database.get: $(TZCODE_SOURCE) $(TZDATA_SOURCE)
+       @$(call targetinfo)
+       @$(call touch)
+
+# ----------------------------------------------------------------------------
+# Extract
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/host-tz-database.extract:
+       @$(call targetinfo)
+       @$(call clean, $(HOST_TZDATABASE_DIR))
+       @$(call extract, TZCODE, $(HOST_TZDATABASE_DIR))
+       @$(call extract, TZDATA, $(HOST_TZDATABASE_DIR))
+       @$(call touch)
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+HOST_TZDATABASE_PATH   := PATH=$(HOST_PATH)
+HOST_TZDATABASE_ENV    := $(HOST_ENV)
+
+$(STATEDIR)/host-tz-database.prepare:
+       @$(call targetinfo, $@)
+       @$(call touch, $@)
+
+# ----------------------------------------------------------------------------
+# Compile
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/host-tz-database.compile:
+       @$(call targetinfo)
+       cd $(HOST_TZDATABASE_DIR) && $(HOST_TZDATABASE_PATH) \
+               $(MAKE) posix_only 
TZDIR=$(PTXDIST_SYSROOT_HOST)/usr/share/zoneinfo
+       @$(call touch)
+
+# ----------------------------------------------------------------------------
+# Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/host-tz-database.install:
+       $(call targetinfo)
+       $(call touch)
+
+# ----------------------------------------------------------------------------
+# Clean
+# ----------------------------------------------------------------------------
+
+#$(STATEDIR)/host-tz-database.clean:
+#      @$(call targetinfo)
+#      @$(call clean_pkg, HOST_TZDATABASE)
+
+# vim: syntax=make
diff --git a/rules/pre/Rules.make b/rules/pre/Rules.make
index 8ffc6fd..1fd3707 100644
--- a/rules/pre/Rules.make
+++ b/rules/pre/Rules.make
@@ -386,10 +386,12 @@ add_locale =                                              
        \
 add_zoneinfo =                                                 \
        ZONEINFO_NAME=$(strip $(1));                            \
        PREF=$(strip $(2));                                     \
+       SYSROOT=$(strip $(3));                                  \
        ${CROSS_ENV_CC} $(CROSS_ENV_STRIP)                      \
        $(SCRIPTSDIR)/make_zoneinfo.sh                          \
        -n $$ZONEINFO_NAME                                      \
-       -p $$PREF
+       -p $$PREF                                               \
+       -s $$SYSROOT
 
 #
 # extract
diff --git a/rules/timezone.in b/rules/timezone.in
index 9d27789..8e15194 100644
--- a/rules/timezone.in
+++ b/rules/timezone.in
@@ -1,13 +1,13 @@
 ## SECTION=core
 
-comment "Time zone support doesn't work with OSELAS.Toolchain-1.1.0"
-comment "and prio versions, hence marked as broken for now"
+# comment "Time zone support doesn't work with OSELAS.Toolchain-1.1.0"
+# comment "and prio versions, hence marked as broken for now"
 
 menuconfig TIMEZONE
        tristate
        prompt "Timezone Files                "
        depends on GLIBC
-       depends on BROKEN
+       select HOST_TZDATABASE if TIMEZONE_LOCAL_DATABASE
        help
          installs timezone files
 
@@ -23,6 +23,14 @@ config GLIBC_LOCALTIME_LINK
          Where should /etc/localtime point to.
          (e.g. /usr/share/zoneinfo/Europe/Berlin)
 
+config TIMEZONE_LOCAL_DATABASE
+       bool
+       prompt "Use local build timezone database"
+       depends on TIMEZONE
+       help
+         Don't use the timezone info provide by the toolchain
+         but a locally build from source
+
 config TIMEZONE_AFRICA
        bool
        prompt "Africa"
diff --git a/rules/timezone.make b/rules/timezone.make
index f9c5f2e..6da0dc0 100644
--- a/rules/timezone.make
+++ b/rules/timezone.make
@@ -137,9 +137,15 @@ $(STATEDIR)/timezone.targetinstall:
        @$(call install_fixup, timezone,DEPENDS,)
        @$(call install_fixup, timezone,DESCRIPTION,missing)
 
+ifdef PTXCONF_TIMEZONE_LOCAL_DATABASE
        @for target in $(TIMEZONE-y); do \
-               $(call add_zoneinfo, $$target, $(TIMEZONE_DIR)); \
+               $(call add_zoneinfo, $$target, $(TIMEZONE_DIR), 
$(PTXDIST_SYSROOT_HOST)/usr); \
        done
+else
+       @for target in $(TIMEZONE-y); do \
+               $(call add_zoneinfo, $$target, $(TIMEZONE_DIR), ""); \
+       done
+endif
 
        @$(call install_copy, timezone, 0, 0, 0755, /usr/share/zoneinfo)
        @for d in `find ${TIMEZONE_DIR}/zoneinfo/ -type d | awk -v 
FS="zoneinfo/" '{print $$2}'`; do \
diff --git a/scripts/make_zoneinfo.sh b/scripts/make_zoneinfo.sh
index ad33675..c583aab 100755
--- a/scripts/make_zoneinfo.sh
+++ b/scripts/make_zoneinfo.sh
@@ -21,24 +21,27 @@ usage() {
 }
 
 add_zoneinfo() {
-       local PREF ZONEINFO_NAME
-       while getopts "n:p:" opt; do
+       local PREF ZONEINFO_NAME SYSROOT_USR
+       while getopts "n:p:s:" opt; do
                case "${opt}" in
                    n)
-                       ZONEINFO_NAME="${OPTARG}"
+                       ZONEINFO_NAME="${OPTARG}"
                         ;;
                     p)
                         PREF="${OPTARG}"
                         ;;
+                    s)
+                        SYSROOT_USR="${OPTARG}"
+                        ;;
                    *)
                        usage
                        ;;
                esac
        done
 
-       SYSROOT_USR=`ptxd_get_sysroot_usr`
-       [ ! -d ${SYSROOT_USR} ] && { echo "Toolchain sysroot dir not found"; 
exit 1; }
-       [ ! -d ${SYSROOT_USR}/share/zoneinfo ] && { echo "Zoneinfo dir not 
found"; exit 1; }
+       [ -z ${SYSROOT_USR} ] && SYSROOT_USR=`ptxd_get_sysroot_usr`
+       [ ! -d ${SYSROOT_USR} ] && { echo "Toolchain sysroot dir 
(${SYSROOT_USR}) not found"; exit 1; }
+       [ ! -d ${SYSROOT_USR}/share/zoneinfo ] && { echo "Zoneinfo dir 
(${SYSROOT_USR}) not found"; exit 1; }
 
        if [ ! -d ${PREF}/zoneinfo ]; then
                mkdir -p ${PREF}/zoneinfo
-- 
1.7.0.4


-- 
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to