Elliott Hughes | d40e63e | 2011-02-17 16:20:07 -0800 | [diff] [blame] | 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. |
| 6 | set -e |
| 7 | set -u |
| 8 | |
| 9 | echo "Looking for bionic..." |
| 10 | bionic_dir=$(cd $(dirname $0)/../../.. && pwd) |
| 11 | bionic_zoneinfo_dir=$bionic_dir/libc/zoneinfo |
| 12 | bionic_zoneinfo_tools_dir=$bionic_dir/libc/tools/zoneinfo |
| 13 | if [[ ! -d "$bionic_zoneinfo_dir" || ! -d "$bionic_zoneinfo_tools_dir" ]]; then |
| 14 | echo "Can't find bionic's zoneinfo directories!" |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | echo "Switching to temporary directory..." |
| 19 | temp_dir=`mktemp -d` |
| 20 | cd $temp_dir |
| 21 | trap "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 |
| 25 | echo "Looking for new tzdata..." |
Elliott Hughes | faa7c1d | 2011-10-10 14:05:53 -0700 | [diff] [blame] | 26 | wget -N --no-verbose 'ftp://munnari.oz.au/pub/tzdata*.tar.gz' |
Elliott Hughes | d40e63e | 2011-02-17 16:20:07 -0800 | [diff] [blame] | 27 | zoneinfo_version_file=$bionic_zoneinfo_dir/zoneinfo.version |
| 28 | if [ -f "$zoneinfo_version_file" ]; then |
| 29 | current_version=tzdata`sed s/\n// < $zoneinfo_version_file` |
| 30 | else |
| 31 | current_version=missing |
| 32 | fi |
| 33 | latest_archive=`ls -r -v tzdata*.tar.gz | head -n1` |
| 34 | latest_version=`basename $latest_archive .tar.gz` |
| 35 | if [ "$current_version" == "$latest_version" ]; then |
| 36 | echo "You already have the latest tzdata ($latest_version)!" |
| 37 | exit 1 |
| 38 | fi |
| 39 | |
Elliott Hughes | bcb2eda | 2011-10-24 10:47:25 -0700 | [diff] [blame^] | 40 | md5_sum=`md5sum $latest_archive` |
| 41 | echo "MD5: $md5_sum" |
| 42 | |
Elliott Hughes | d40e63e | 2011-02-17 16:20:07 -0800 | [diff] [blame] | 43 | echo "Extracting $latest_version..." |
| 44 | mkdir $latest_version |
| 45 | tar -C $latest_version -zxf $latest_archive |
| 46 | |
| 47 | echo "Compiling $latest_version..." |
| 48 | mkdir data |
| 49 | for 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 |
| 62 | do |
| 63 | zic -d data $latest_version/$i |
| 64 | done |
| 65 | |
| 66 | echo "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 | |
| 75 | javac -d . \ |
| 76 | $bionic_zoneinfo_tools_dir/ZoneCompactor.java \ |
| 77 | $bionic_zoneinfo_tools_dir/ZoneInfo.java |
| 78 | java ZoneCompactor setup data |
| 79 | |
| 80 | echo "Updating bionic to $latest_version..." |
| 81 | mv zoneinfo.dat zoneinfo.idx $bionic_zoneinfo_dir |
| 82 | echo $latest_version | sed 's/tzdata//' > $bionic_zoneinfo_dir/zoneinfo.version |