Brad Fitzpatrick | e5ff529 | 2016-07-06 00:16:05 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Emmanuel Odeke | 53fd522 | 2016-04-10 14:32:26 -0700 | [diff] [blame] | 2 | # Copyright 2012 The Go Authors. All rights reserved. |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 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. |
Kevin Burke | 5158aab | 2018-01-23 22:11:51 -0800 | [diff] [blame] | 8 | # Consult https://www.iana.org/time-zones for the latest versions. |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 9 | |
| 10 | # Versions to use. |
Tobias Klauser | 0e76143 | 2017-10-28 20:07:51 +0200 | [diff] [blame] | 11 | CODE=2017c |
| 12 | DATA=2017c |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 13 | |
| 14 | set -e |
Russ Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 15 | rm -rf work |
| 16 | mkdir work |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 17 | cd work |
Russ Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 18 | mkdir zoneinfo |
Kevin Burke | 5158aab | 2018-01-23 22:11:51 -0800 | [diff] [blame] | 19 | curl -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz |
| 20 | curl -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 21 | tar xzf tzcode$CODE.tar.gz |
| 22 | tar xzf tzdata$DATA.tar.gz |
| 23 | |
| 24 | # Turn off 64-bit output in time zone files. |
| 25 | # We don't need those until 2037. |
| 26 | perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c |
| 27 | |
Russ Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 28 | make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 29 | |
| 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 Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 33 | size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}') |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 34 | if [ $size -gt 1200 ]; then |
| 35 | echo 'zone file too large; 64-bit edit failed?' >&2 |
| 36 | exit 2 |
| 37 | fi |
| 38 | |
Russ Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 39 | cd zoneinfo |
| 40 | rm -f ../../zoneinfo.zip |
| 41 | zip -0 -r ../../zoneinfo.zip * |
| 42 | cd ../.. |
| 43 | |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 44 | echo |
Kevin Burke | 5158aab | 2018-01-23 22:11:51 -0800 | [diff] [blame] | 45 | if [ "$1" = "-work" ]; then |
Russ Cox | 228d941 | 2012-02-18 20:33:58 -0500 | [diff] [blame] | 46 | echo Left workspace behind in work/. |
| 47 | else |
| 48 | rm -rf work |
| 49 | fi |
Russ Cox | cb5e181 | 2012-02-19 03:16:20 -0500 | [diff] [blame] | 50 | echo New time zone files in zoneinfo.zip. |