aboutsummaryrefslogtreecommitdiff
path: root/lib/time/update.bash
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-12-05 23:07:54 -0500
committerGopher Robot <gobot@golang.org>2022-12-07 00:25:27 +0000
commit10bb003401060a48d5836c3af483de562f980ac5 (patch)
tree83647461fce8cc062fa904b99fc4232488b9e1be /lib/time/update.bash
parent7dc9fcb13de7bb20b11f6a526865545cc9142c2c (diff)
downloadgo-10bb003401060a48d5836c3af483de562f980ac5.tar.gz
go-10bb003401060a48d5836c3af483de562f980ac5.zip
lib/time: update to 2022g/2022g
Commit generated by update.bash. For #22487. Change-Id: I6a995a3baea7c511b9bd5155f81d8b8e2cdff09d Reviewed-on: https://go-review.googlesource.com/c/go/+/455356 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'lib/time/update.bash')
-rwxr-xr-xlib/time/update.bash70
1 files changed, 59 insertions, 11 deletions
diff --git a/lib/time/update.bash b/lib/time/update.bash
index d49127b275..48606b9de4 100755
--- a/lib/time/update.bash
+++ b/lib/time/update.bash
@@ -5,35 +5,83 @@
# This script rebuilds the time zone files using files
# downloaded from the ICANN/IANA distribution.
-# Consult https://www.iana.org/time-zones for the latest versions.
+#
+# To prepare an update for a new Go release,
+# consult https://www.iana.org/time-zones for the latest versions,
+# update CODE and DATA below, and then run
+#
+# ./update.bash -commit
+#
+# That will prepare the files and create the commit.
+#
+# To review such a commit (as the reviewer), use:
+#
+# git codereview change NNNNNN # CL number
+# cd lib/time
+# ./update.bash
+#
+# If it prints "No updates needed.", then the generated files
+# in the CL match the update.bash in the CL.
# Versions to use.
-CODE=2022f
-DATA=2022f
+CODE=2022g
+DATA=2022g
set -e
+
+cd $(dirname $0)
rm -rf work
mkdir work
+go build -o work/mkzip mkzip.go # build now for correct paths in build errors
cd work
mkdir zoneinfo
-curl -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
-curl -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
+curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz
+curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz
tar xzf tzcode$CODE.tar.gz
tar xzf tzdata$DATA.tar.gz
-make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only
+if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then
+ cat make.out
+ exit 2
+fi
cd zoneinfo
-rm -f ../../zoneinfo.zip
-zip -0 -r ../../zoneinfo.zip *
+../mkzip ../../zoneinfo.zip
cd ../..
-
go generate time/tzdata
-echo
+files="update.bash zoneinfo.zip ../../src/time/tzdata/zipdata.go"
+modified=true
+if git diff --quiet $files; then
+ modified=false
+fi
+
if [ "$1" = "-work" ]; then
echo Left workspace behind in work/.
+ shift
else
rm -rf work
fi
-echo New time zone files in zoneinfo.zip.
+
+if ! $modified; then
+ echo No updates needed.
+ exit 0
+fi
+
+echo Updated for $CODE/$DATA: $files
+
+commitmsg="lib/time: update to $CODE/$DATA
+
+Commit generated by update.bash.
+
+For #22487.
+"
+
+if [ "$1" = "-commit" ]; then
+ echo "Creating commit. Run 'git reset HEAD^' to undo commit."
+ echo
+ git commit -m "$commitmsg" $files
+ echo
+ git log -n1 --stat
+ echo
+fi