]> Cypherpunks.ru repositories - gostls13.git/blob - lib/time/update.bash
caa8450fa6e11f60359dcfcb64a51c7d9bae3479
[gostls13.git] / lib / time / update.bash
1 #!/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.
10 CODE=2014j
11 DATA=2014j
12
13 set -e
14 rm -rf work
15 mkdir work
16 cd work
17 mkdir zoneinfo
18 curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
19 curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
20 tar xzf tzcode$CODE.tar.gz
21 tar xzf tzdata$DATA.tar.gz
22
23 # Turn off 64-bit output in time zone files.
24 # We don't need those until 2037.
25 perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c
26
27 make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
28
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.
32 size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
33 if [ $size -gt 1200 ]; then
34         echo 'zone file too large; 64-bit edit failed?' >&2
35         exit 2
36 fi
37
38 cd zoneinfo
39 rm -f ../../zoneinfo.zip
40 zip -0 -r ../../zoneinfo.zip *
41 cd ../..
42
43 echo
44 if [ "$1" == "-work" ]; then 
45         echo Left workspace behind in work/.
46 else
47         rm -rf work
48 fi
49 echo New time zone files in zoneinfo.zip.
50