github.com/miolini/go@v0.0.0-20160405192216-fca68c8cb408/lib/time/update.bash (about)

     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  # Consult http://www.iana.org/time-zones for the latest versions.
     9  
    10  # Versions to use.
    11  CODE=2016a
    12  DATA=2016a
    13  
    14  set -e
    15  rm -rf work
    16  mkdir work
    17  cd work
    18  mkdir zoneinfo
    19  curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
    20  curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
    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  
    28  make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
    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.
    33  size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
    34  if [ $size -gt 1200 ]; then
    35  	echo 'zone file too large; 64-bit edit failed?' >&2
    36  	exit 2
    37  fi
    38  
    39  cd zoneinfo
    40  rm -f ../../zoneinfo.zip
    41  zip -0 -r ../../zoneinfo.zip *
    42  cd ../..
    43  
    44  echo
    45  if [ "$1" == "-work" ]; then 
    46  	echo Left workspace behind in work/.
    47  else
    48  	rm -rf work
    49  fi
    50  echo New time zone files in zoneinfo.zip.
    51