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 6# This script rebuilds the time zone files using files 7# downloaded from the ICANN/IANA distribution. 8# 9# To prepare an update for a new Go release, 10# consult https://www.iana.org/time-zones for the latest versions, 11# update CODE and DATA below, and then run 12# 13# ./update.bash -commit 14# 15# That will prepare the files and create the commit. 16# 17# To review such a commit (as the reviewer), use: 18# 19# git codereview change NNNNNN # CL number 20# cd lib/time 21# ./update.bash 22# 23# If it prints "No updates needed.", then the generated files 24# in the CL match the update.bash in the CL. 25 26# Versions to use. 27CODE=2024a 28DATA=2024a 29 30set -e 31 32cd $(dirname $0) 33rm -rf work 34mkdir work 35go build -o work/mkzip mkzip.go # build now for correct paths in build errors 36cd work 37mkdir zoneinfo 38curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz 39curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz 40tar xzf tzcode$CODE.tar.gz 41tar xzf tzdata$DATA.tar.gz 42 43if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then 44 cat make.out 45 exit 2 46fi 47 48cd zoneinfo 49../mkzip ../../zoneinfo.zip 50cd ../.. 51 52files="update.bash zoneinfo.zip" 53modified=true 54if git diff --quiet $files; then 55 modified=false 56fi 57 58if [ "$1" = "-work" ]; then 59 echo Left workspace behind in work/. 60 shift 61else 62 rm -rf work 63fi 64 65if ! $modified; then 66 echo No updates needed. 67 exit 0 68fi 69 70echo Updated for $CODE/$DATA: $files 71 72commitmsg="lib/time: update to $CODE/$DATA 73 74Commit generated by update.bash. 75 76For #22487. 77" 78 79if [ "$1" = "-commit" ]; then 80 echo "Creating commit. Run 'git reset HEAD^' to undo commit." 81 echo 82 git commit -m "$commitmsg" $files 83 echo 84 git log -n1 --stat 85 echo 86fi 87