blob: 26ad79d52def5731f8304397ecbca383a41c96f5 [file] [log] [blame]
Brad Fitzpatricke5ff5292016-07-06 00:16:05 +00001#!/bin/bash
Emmanuel Odeke53fd5222016-04-10 14:32:26 -07002# Copyright 2012 The Go Authors. All rights reserved.
Russ Cox228d9412012-02-18 20:33:58 -05003# 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.
Kevin Burke5158aab2018-01-23 22:11:51 -08008# Consult https://www.iana.org/time-zones for the latest versions.
Russ Cox228d9412012-02-18 20:33:58 -05009
10# Versions to use.
Tobias Klauser0e761432017-10-28 20:07:51 +020011CODE=2017c
12DATA=2017c
Russ Cox228d9412012-02-18 20:33:58 -050013
14set -e
Russ Coxcb5e1812012-02-19 03:16:20 -050015rm -rf work
16mkdir work
Russ Cox228d9412012-02-18 20:33:58 -050017cd work
Russ Coxcb5e1812012-02-19 03:16:20 -050018mkdir zoneinfo
Kevin Burke5158aab2018-01-23 22:11:51 -080019curl -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
20curl -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
Russ Cox228d9412012-02-18 20:33:58 -050021tar xzf tzcode$CODE.tar.gz
22tar xzf tzdata$DATA.tar.gz
23
24# Turn off 64-bit output in time zone files.
25# We don't need those until 2037.
26perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c
27
Russ Coxcb5e1812012-02-19 03:16:20 -050028make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
Russ Cox228d9412012-02-18 20:33:58 -050029
30# America/Los_Angeles should not be bigger than 1100 bytes.
31# If it is, we probably failed to disable the 64-bit output, which
32# triples the size of the files.
Russ Coxcb5e1812012-02-19 03:16:20 -050033size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
Russ Cox228d9412012-02-18 20:33:58 -050034if [ $size -gt 1200 ]; then
35 echo 'zone file too large; 64-bit edit failed?' >&2
36 exit 2
37fi
38
Russ Coxcb5e1812012-02-19 03:16:20 -050039cd zoneinfo
40rm -f ../../zoneinfo.zip
41zip -0 -r ../../zoneinfo.zip *
42cd ../..
43
Russ Cox228d9412012-02-18 20:33:58 -050044echo
Kevin Burke5158aab2018-01-23 22:11:51 -080045if [ "$1" = "-work" ]; then
Russ Cox228d9412012-02-18 20:33:58 -050046 echo Left workspace behind in work/.
47else
48 rm -rf work
49fi
Russ Coxcb5e1812012-02-19 03:16:20 -050050echo New time zone files in zoneinfo.zip.