1#!/bin/bash 2# Run with no arguments from any directory, with no special setup required. 3 4# Abort if any command returns an error exit status, or if an undefined 5# variable is used. 6set -e 7set -u 8 9echo "Looking for bionic..." 10bionic_dir=$(cd $(dirname $0)/../../.. && pwd) 11bionic_zoneinfo_dir=$bionic_dir/libc/zoneinfo 12bionic_zoneinfo_tools_dir=$bionic_dir/libc/tools/zoneinfo 13if [[ ! -d "$bionic_zoneinfo_dir" || ! -d "$bionic_zoneinfo_tools_dir" ]]; then 14 echo "Can't find bionic's zoneinfo directories!" 15 exit 1 16fi 17 18echo "Switching to temporary directory..." 19temp_dir=`mktemp -d` 20cd $temp_dir 21trap "rm -rf $temp_dir; exit" INT TERM EXIT 22 23# URL from "Sources for Time Zone and Daylight Saving Time Data" 24# http://www.twinsun.com/tz/tz-link.htm 25echo "Looking for new tzdata..." 26wget -N --no-verbose 'ftp://munnari.oz.au/pub/tzdata*.tar.gz' 27zoneinfo_version_file=$bionic_zoneinfo_dir/zoneinfo.version 28if [ -f "$zoneinfo_version_file" ]; then 29 current_version=tzdata`sed s/\n// < $zoneinfo_version_file` 30else 31 current_version=missing 32fi 33latest_archive=`ls -r -v tzdata*.tar.gz | head -n1` 34latest_version=`basename $latest_archive .tar.gz` 35if [ "$current_version" == "$latest_version" ]; then 36 echo "You already have the latest tzdata ($latest_version)!" 37 exit 1 38fi 39 40md5_sum=`md5sum $latest_archive` 41echo "MD5: $md5_sum" 42 43echo "Extracting $latest_version..." 44mkdir $latest_version 45tar -C $latest_version -zxf $latest_archive 46 47echo "Compiling $latest_version..." 48mkdir data 49for i in \ 50 africa \ 51 antarctica \ 52 asia \ 53 australasia \ 54 etcetera \ 55 europe \ 56 factory \ 57 northamerica \ 58 solar87 \ 59 solar88 \ 60 solar89 \ 61 southamerica 62do 63 zic -d data $latest_version/$i 64done 65 66echo "Compacting $latest_version..." 67( 68 cat $latest_version/* | grep '^Link' | awk '{print $1, $2, $3}' 69 ( 70 cat $latest_version/* | grep '^Zone' | awk '{print $2}' 71 cat $latest_version/* | grep '^Link' | awk '{print $3}' 72 ) | LC_ALL="C" sort 73) | grep -v Riyadh8 > setup 74 75javac -d . \ 76 $bionic_zoneinfo_tools_dir/ZoneCompactor.java \ 77 $bionic_zoneinfo_tools_dir/ZoneInfo.java 78java ZoneCompactor setup data 79 80echo "Updating bionic to $latest_version..." 81mv zoneinfo.dat zoneinfo.idx $bionic_zoneinfo_dir 82echo $latest_version | sed 's/tzdata//' > $bionic_zoneinfo_dir/zoneinfo.version 83