update.bash 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # This script rebuilds the time zone files using files
  6. # downloaded from the ICANN/IANA distribution.
  7. # Versions to use.
  8. CODE=2014d
  9. DATA=2014d
  10. set -e
  11. rm -rf work
  12. mkdir work
  13. cd work
  14. mkdir zoneinfo
  15. curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
  16. curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
  17. tar xzf tzcode$CODE.tar.gz
  18. tar xzf tzdata$DATA.tar.gz
  19. # Turn off 64-bit output in time zone files.
  20. # We don't need those until 2037.
  21. perl -p -i -e 's/pass <= 2/pass <= 1/' zic.c
  22. make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
  23. # America/Los_Angeles should not be bigger than 1100 bytes.
  24. # If it is, we probably failed to disable the 64-bit output, which
  25. # triples the size of the files.
  26. size=$(ls -l zoneinfo/America/Los_Angeles | awk '{print $5}')
  27. if [ $size -gt 1200 ]; then
  28. echo 'zone file too large; 64-bit edit failed?' >&2
  29. exit 2
  30. fi
  31. cd zoneinfo
  32. rm -f ../../zoneinfo.zip
  33. zip -0 -r ../../zoneinfo.zip *
  34. cd ../..
  35. echo
  36. if [ "$1" == "-work" ]; then
  37. echo Left workspace behind in work/.
  38. else
  39. rm -rf work
  40. fi
  41. echo New time zone files in zoneinfo.zip.