Text file
lib/time/update.bash
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.
27 CODE=2023d
28 DATA=2023d
29
30 set -e
31
32 cd $(dirname $0)
33 rm -rf work
34 mkdir work
35 go build -o work/mkzip mkzip.go # build now for correct paths in build errors
36 cd work
37 mkdir zoneinfo
38 curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
39 curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
40 tar xzf tzcode$CODE.tar.gz
41 tar xzf tzdata$DATA.tar.gz
42
43 if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then
44 cat make.out
45 exit 2
46 fi
47
48 cd zoneinfo
49 ../mkzip ../../zoneinfo.zip
50 cd ../..
51
52 files="update.bash zoneinfo.zip"
53 modified=true
54 if git diff --quiet $files; then
55 modified=false
56 fi
57
58 if [ "$1" = "-work" ]; then
59 echo Left workspace behind in work/.
60 shift
61 else
62 rm -rf work
63 fi
64
65 if ! $modified; then
66 echo No updates needed.
67 exit 0
68 fi
69
70 echo Updated for $CODE/$DATA: $files
71
72 commitmsg="lib/time: update to $CODE/$DATA
73
74 Commit generated by update.bash.
75
76 For #22487.
77 "
78
79 if [ "$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
86 fi
87
View as plain text