blob: caa8450fa6e11f60359dcfcb64a51c7d9bae3479 [file] [log] [blame]
Russ Cox228d9412012-02-18 20:33:58 -05001#!/bin/sh
2# Copyright 2012 The Go Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file.
5
6# This script rebuilds the time zone files using files
7# downloaded from the ICANN/IANA distribution.
8
9# Versions to use.
Rob Pikeb2950a22014-12-03 20:07:48 -080010CODE=2014j
11DATA=2014j
Russ Cox228d9412012-02-18 20:33:58 -050012
13set -e
Russ Coxcb5e1812012-02-19 03:16:20 -050014rm -rf work
15mkdir work
Russ Cox228d9412012-02-18 20:33:58 -050016cd work
Russ Coxcb5e1812012-02-19 03:16:20 -050017mkdir zoneinfo
Russ Cox228d9412012-02-18 20:33:58 -050018curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
19curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
20tar xzf tzcode$CODE.tar.gz
21tar xzf tzdata$DATA.tar.gz
22
23# Turn off 64-bit output in time zone files.
24# We don't need those until 2037.
25perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c
26
Russ Coxcb5e1812012-02-19 03:16:20 -050027make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
Russ Cox228d9412012-02-18 20:33:58 -050028
29# America/Los_Angeles should not be bigger than 1100 bytes.
30# If it is, we probably failed to disable the 64-bit output, which
31# triples the size of the files.
Russ Coxcb5e1812012-02-19 03:16:20 -050032size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
Russ Cox228d9412012-02-18 20:33:58 -050033if [ $size -gt 1200 ]; then
34 echo 'zone file too large; 64-bit edit failed?' >&2
35 exit 2
36fi
37
Russ Coxcb5e1812012-02-19 03:16:20 -050038cd zoneinfo
39rm -f ../../zoneinfo.zip
40zip -0 -r ../../zoneinfo.zip *
41cd ../..
42
Russ Cox228d9412012-02-18 20:33:58 -050043echo
44if [ "$1" == "-work" ]; then
45 echo Left workspace behind in work/.
46else
47 rm -rf work
48fi
Russ Coxcb5e1812012-02-19 03:16:20 -050049echo New time zone files in zoneinfo.zip.
50