]> git.saurik.com Git - apple/system_cmds.git/blame_incremental - zic.tproj/generate_zoneinfo.sh
system_cmds-597.90.1.tar.gz
[apple/system_cmds.git] / zic.tproj / generate_zoneinfo.sh
... / ...
CommitLineData
1#!/bin/sh
2set -e
3set -x
4
5printenv | sort
6
7if [ $# -ne 5 ]; then
8 echo "Usage: $0 SRCROOT OBJROOT BUILT_PRODUCTS_DIR SDKROOT PLATFORM_NAME" 1>&2
9 exit 1
10fi
11
12SRCROOT="$1"
13OBJROOT="$2"
14BUILT_PRODUCTS_DIR="$3"
15SDKROOT="$4"
16PLATFORM_NAME="$5"
17
18ZICHOST_SYMROOT="${BUILT_PRODUCTS_DIR}/zic_host-sym"
19ZICHOST_DSTROOT="${BUILT_PRODUCTS_DIR}/zic_host-dst"
20ZICHOST="${ZICHOST_DSTROOT}/zic_host"
21
22LOCALTIME="US/Pacific"
23POSIXRULES="US/Pacific"
24
25# pacificnew is obsolete and was removed from ZONE_FILES
26ZONE_FILES="africa antarctica asia australasia europe northamerica southamerica etcetera factory backward systemv"
27ZONEINFO="${BUILT_PRODUCTS_DIR}/zoneinfo"
28DATFILES="${BUILT_PRODUCTS_DIR}/datfiles"
29PRIVATEDIR="${BUILT_PRODUCTS_DIR}/private"
30
31# ftp://elsie.nci.nih.gov/pub/tzdata*.tar.gz
32# the tzdata*.tar.gz file is automatically unpacked and a version file created
33# /usr/local/share/tz/tzdata*.tar.gz is installed by the TimeZoneData project
34TARBALL=`ls ${SDKROOT}/usr/local/share/tz/tzdata* | sort | tail -n 1`
35if [ -z "$TARBALL" ]; then
36 echo "No tzdata file found in ${SDKROOT}/usr/local/share/tz" 1>&2
37 exit 1
38fi
39DATVERS=`basename ${TARBALL} | sed -e 's,\..*,,' -e 's/^tzdata//'`
40VERSIONFILE="${ZONEINFO}/+VERSION"
41
42mkdir -p "${DATFILES}"
43mkdir -p "${ZONEINFO}"
44tar zxf "${TARBALL}" -C "${DATFILES}"
45for tz in ${ZONE_FILES}; do
46 if [ ${tz} = "northamerica" ]; then
47 ARG="-p America/New_York"
48 else
49 ARG=""
50 fi
51 ${ZICHOST} ${ARG} -L /dev/null -d "${ZONEINFO}" \
52 -y "${DATFILES}/yearistype.sh" "${DATFILES}/${tz}" || exit 1
53done
54if [ $? -ne 0 ]; then
55 exit 1
56fi
57
58chmod -R og-w "${ZONEINFO}"
59for f in "zone.tab" "iso3166.tab"; do
60 install -m 0444 "${DATFILES}/$f" "${ZONEINFO}/$f" || exit 1
61done
62if [ $? -ne 0 ]; then
63 exit 1
64fi
65
66if [ "${PLATFORM_NAME}" = "iphoneos" ]; then
67 mkdir -p "${PRIVATEDIR}/var/db"
68 mkdir -p -m a+rwx "${PRIVATEDIR}/var/db/timezone"
69
70 # This link must precisely start with TZDIR followed by a slash. radar:13532660
71 ln -hfs "/var/db/timezone/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/var/db/timezone/localtime"
72else
73 mkdir -p "${PRIVATEDIR}/etc"
74 ln -hfs "/usr/share/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/etc/localtime"
75fi
76
77rm -f "${VERSIONFILE}"
78echo ${DATVERS} > "${VERSIONFILE}"
79chmod 444 "${VERSIONFILE}"
80touch "${ZONEINFO}"
81touch "${PRIVATEDIR}"
82