]> git.cameronkatri.com Git - apple_cmds.git/blob - system_cmds/zic.tproj/generate_zoneinfo.sh
file_cmds: Fix BINDIRs again
[apple_cmds.git] / system_cmds / 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 ZONEINFO="${BUILT_PRODUCTS_DIR}/zoneinfo"
26 DATFILES="${BUILT_PRODUCTS_DIR}/datfiles"
27 PRIVATEDIR="${BUILT_PRODUCTS_DIR}/private"
28
29 # ftp://elsie.nci.nih.gov/pub/tzdata*.tar.gz
30 # the tzdata*.tar.gz file is automatically unpacked and a version file created
31 # /usr/local/share/tz/tzdata*.tar.gz is installed by the TimeZoneData project
32 TARBALL="${SDKROOT}"/usr/local/share/tz/latest_tzdata.tar.gz
33 if [ ! -L "$TARBALL" ]; then
34 echo "error: ${TARBALL} is not a symbolic link" 1>&2
35 exit 1
36 fi
37 if [ ! -r "$TARBALL" ]; then
38 echo "error: ${TARBALL} does not point to a valid file" 1>&2
39 exit 1
40 fi
41 DATVERS=`readlink ${TARBALL} | cut -d. -f1 | sed -e 's/^tzdata//'`
42 VERSIONFILE="${ZONEINFO}/+VERSION"
43
44 mkdir -p "${DATFILES}"
45 mkdir -p "${ZONEINFO}"
46 tar zxf "${TARBALL}" -C "${DATFILES}"
47 ZONE_FILES="$("${SRCROOT}"/zic.tproj/generate_zone_file_list.sh "${DATFILES}")"
48 for tz in ${ZONE_FILES}; do
49 if [ ${tz} = "northamerica" ]; then
50 ARG="-p America/New_York"
51 else
52 ARG=""
53 fi
54 "${ZICHOST}" ${ARG} -L /dev/null -d "${ZONEINFO}" \
55 -y "${DATFILES}/yearistype.sh" "${DATFILES}/${tz}" || exit 1
56 done
57
58 if [ $? -ne 0 ]; then
59 exit 1
60 fi
61
62 chmod -R og-w "${ZONEINFO}"
63 for f in "zone.tab" "iso3166.tab" "leapseconds"; do
64 install -m 0444 "${DATFILES}/$f" "${ZONEINFO}/$f" || exit 1
65 done
66 if [ $? -ne 0 ]; then
67 exit 1
68 fi
69
70 if [ -n "$RC_BRIDGE" ]; then
71 ACTUAL_PLATFORM_NAME="bridgeos"
72 else
73 ACTUAL_PLATFORM_NAME="${PLATFORM_NAME}"
74 fi
75
76 case "$ACTUAL_PLATFORM_NAME" in
77 bridge*)
78 LOCALTIME="GMT"
79 ;;
80 esac
81
82 case "$ACTUAL_PLATFORM_NAME" in
83 iphone*|appletv*|watch*|bridge*)
84 mkdir -p "${PRIVATEDIR}/var/db"
85 mkdir -p -m a+rx "${PRIVATEDIR}/var/db/timezone"
86
87 # This link must precisely start with TZDIR followed by a slash. radar:13532660
88 ln -hfs "/var/db/timezone/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/var/db/timezone/localtime"
89 ;;
90 macosx)
91 mkdir -p "${PRIVATEDIR}/etc"
92 ln -hfs "/var/db/timezone/zoneinfo/${LOCALTIME}" "${PRIVATEDIR}/etc/localtime"
93 ;;
94 *)
95 echo "Unsupported platform: $ACTUAL_PLATFORM_NAME"
96 exit 1
97 ;;
98 esac
99
100 rm -f "${VERSIONFILE}"
101 echo ${DATVERS} > "${VERSIONFILE}"
102 chmod 444 "${VERSIONFILE}"
103 touch "${ZONEINFO}"
104 touch "${PRIVATEDIR}"
105