]> git.saurik.com Git - apple/system_cmds.git/blob - zic.tproj/generate_zoneinfo.sh
74a43d8ff2f0a6fa97c9495202c8f27843560b81
[apple/system_cmds.git] / zic.tproj / generate_zoneinfo.sh
1 #!/bin/sh
2 set -e
3 set -x
4
5 printenv | sort
6
7 if [ $# -ne 5 ]; then
8 echo "Usage: $0 SRCROOT OBJROOT BUILT_PRODUCTS_DIR SDKROOT PLATFORM_NAME" 1>&2
9 exit 1
10 fi
11
12 SRCROOT="$1"
13 OBJROOT="$2"
14 BUILT_PRODUCTS_DIR="$3"
15 SDKROOT="$4"
16 PLATFORM_NAME="$5"
17
18 ZICHOST_SYMROOT="${BUILT_PRODUCTS_DIR}/zic_host-sym"
19 ZICHOST_DSTROOT="${BUILT_PRODUCTS_DIR}/zic_host-dst"
20 ZICHOST="${ZICHOST_DSTROOT}/zic_host"
21
22 LOCALTIME="US/Pacific"
23 POSIXRULES="US/Pacific"
24
25 # pacificnew is obsolete and was removed from ZONE_FILES
26 ZONE_FILES="africa antarctica asia australasia europe northamerica southamerica etcetera factory backward systemv solar87 solar88 solar89"
27 ZONEINFO="${BUILT_PRODUCTS_DIR}/zoneinfo"
28 DATFILES="${BUILT_PRODUCTS_DIR}/datfiles"
29 PRIVATEDIR="${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
34 TARBALL=`ls ${SDKROOT}/usr/local/share/tz/tzdata* | sort | tail -n 1`
35 if [ -z "$TARBALL" ]; then
36 echo "No tzdata file found in ${SDKROOT}/usr/local/share/tz" 1>&2
37 exit 1
38 fi
39 DATVERS=`basename ${TARBALL} | sed -e 's,\..*,,' -e 's/^tzdata//'`
40 VERSIONFILE="${ZONEINFO}/+VERSION"
41
42 mkdir -p "${DATFILES}"
43 mkdir -p "${ZONEINFO}"
44 tar zxf "${TARBALL}" -C "${DATFILES}"
45 for 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
53 done
54 if [ $? -ne 0 ]; then
55 exit 1
56 fi
57
58 chmod -R og-w "${ZONEINFO}"
59 for f in "zone.tab" "iso3166.tab"; do
60 install -m 0444 "${DATFILES}/$f" "${ZONEINFO}/$f" || exit 1
61 done
62 if [ $? -ne 0 ]; then
63 exit 1
64 fi
65
66 if [ "${PLATFORM_NAME}" = "iphoneos" ]; then
67 mkdir -p "${PRIVATEDIR}/var/db"
68 mkdir -p -m a+rwx "${PRIVATEDIR}/var/db/timezone"
69 ln -hfs "/usr/share/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/var/db/timezone/localtime"
70 else
71 mkdir -p "${PRIVATEDIR}/etc"
72 ln -hfs "/usr/share/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/etc/localtime"
73 fi
74
75 rm -f "${VERSIONFILE}"
76 echo ${DATVERS} > "${VERSIONFILE}"
77 chmod 444 "${VERSIONFILE}"
78 touch "${ZONEINFO}"
79 touch "${PRIVATEDIR}"
80