update.bash 1.3 KB

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