1#!/bin/bash 2# 3# A script that generates an ICU data file containing just timezone rules data. 4# The file can be used to provide time zone rules updates for compatible 5# devices. Note: Only the rules are contained and new timezones will not have 6# the translations. 7# 8# Usage: 9# ./createIcuUpdateResources.sh <tzdata tar.gz file> <ICU version> 10# 11# e.g. 12# ./createIcuUpdateResources.sh ~/Downloads/tzdata2015b.tar.gz 55 13# 14# After execution the file is generated. 15 16if (( $# != 2 )); then 17 echo "Missing arguments" 18 echo "Usage:" 19 echo "./createIcuUpdateResources.sh <tzdata tar.gz file> <ICU version>" 20 exit 1 21fi 22 23if [[ -z "${ANDROID_BUILD_TOP}" ]]; then 24 echo "Configure your environment with build/envsetup.sh and lunch" 25 exit 1 26fi 27 28TZ_DATA_FILE=$1 29ICU_VERSION=$2 30 31if [[ ! -f ${TZ_DATA_FILE} ]]; then 32 echo "${TZ_DATA_FILE} not found" 33 exit 1 34fi 35 36# Keep track of the original working dir. Must be the "tools" dir. 37START_DIR=`pwd` 38ICU_DIR=${ANDROID_BUILD_TOP}/external/icu/icu4c/source 39BUILD_DIR=${START_DIR}/icu_build 40 41# Fail if anything below fails 42set -e 43 44rm -rf ${BUILD_DIR} 45mkdir -p ${BUILD_DIR} 46cd ${BUILD_DIR} 47 48# Configure the build 49${ICU_DIR}/runConfigureICU Linux 50mkdir -p ${BUILD_DIR}/bin 51cd ${BUILD_DIR}/tools/tzcode 52ln -s ${ICU_DIR}/tools/tzcode/icuregions ./icuregions 53ln -s ${ICU_DIR}/tools/tzcode/icuzones ./icuzones 54cp ${TZ_DATA_FILE} . 55 56# Make the tools 57make 58 59# Then make the whole thing 60cd ${BUILD_DIR} 61make -j32 62 63# Generate the tzdata.lst file used to configure which files are included. 64ICU_LIB_DIR=${BUILD_DIR}/lib 65BIN_DIR=${BUILD_DIR}/bin 66TZ_FILES=tzdata.lst 67 68echo metaZones.res > ${TZ_FILES} 69echo timezoneTypes.res >> ${TZ_FILES} 70echo windowsZones.res >> ${TZ_FILES} 71echo zoneinfo64.res >> ${TZ_FILES} 72 73# Copy all the .res files we need here a from, e.g. ./data/out/build/icudt55l 74RES_DIR=data/out/build/icudt${ICU_VERSION}l 75cp ${RES_DIR}/metaZones.res ${BUILD_DIR} 76cp ${RES_DIR}/timezoneTypes.res ${BUILD_DIR} 77cp ${RES_DIR}/windowsZones.res ${BUILD_DIR} 78cp ${RES_DIR}/zoneinfo64.res ${BUILD_DIR} 79 80# This is the package name required for the .dat file to be accepted by ICU. 81# This also affects the generated file name. 82ICU_PACKAGE=icudt${ICU_VERSION}l 83 84# Create the file 85LD_LIBRARY_PATH=${ICU_LIB_DIR} ${BIN_DIR}/pkgdata -F -m common -v -T . -d . -p ${ICU_PACKAGE} ${TZ_FILES} 86cp ${ICU_PACKAGE}.dat ${START_DIR}/icu_tzdata.dat 87 88# Copy the file to the original working dir. 89echo File can be found here: ${START_DIR}/icu_tzdata.dat 90