github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/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  
     9  # NOTE: As of Oct, 2013, the C files will not build on Macs but will build on Linux.
    10  
    11  # Versions to use.
    12  CODE=2013g
    13  DATA=2013g
    14  
    15  set -e
    16  rm -rf work
    17  mkdir work
    18  cd work
    19  mkdir zoneinfo
    20  curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
    21  curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
    22  tar xzf tzcode$CODE.tar.gz
    23  tar xzf tzdata$DATA.tar.gz
    24  
    25  # Turn off 64-bit output in time zone files.
    26  # We don't need those until 2037.
    27  perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c
    28  
    29  make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
    30  
    31  # America/Los_Angeles should not be bigger than 1100 bytes.
    32  # If it is, we probably failed to disable the 64-bit output, which
    33  # triples the size of the files.
    34  size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
    35  if [ $size -gt 1200 ]; then
    36  	echo 'zone file too large; 64-bit edit failed?' >&2
    37  	exit 2
    38  fi
    39  
    40  cd zoneinfo
    41  rm -f ../../zoneinfo.zip
    42  zip -0 -r ../../zoneinfo.zip *
    43  cd ../..
    44  
    45  echo
    46  if [ "$1" == "-work" ]; then 
    47  	echo Left workspace behind in work/.
    48  else
    49  	rm -rf work
    50  fi
    51  echo New time zone files in zoneinfo.zip.
    52