summaryrefslogtreecommitdiffstats
path: root/lib/time/update.bash
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:19:13 +0000
commitccd992355df7192993c666236047820244914598 (patch)
treef00fea65147227b7743083c6148396f74cd66935 /lib/time/update.bash
parentInitial commit. (diff)
downloadgolang-1.21-ccd992355df7192993c666236047820244914598.tar.xz
golang-1.21-ccd992355df7192993c666236047820244914598.zip
Adding upstream version 1.21.8.upstream/1.21.8
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/time/update.bash')
-rwxr-xr-xlib/time/update.bash86
1 files changed, 86 insertions, 0 deletions
diff --git a/lib/time/update.bash b/lib/time/update.bash
new file mode 100755
index 0000000..605afa7
--- /dev/null
+++ b/lib/time/update.bash
@@ -0,0 +1,86 @@
+#!/bin/bash
+# Copyright 2012 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# This script rebuilds the time zone files using files
+# downloaded from the ICANN/IANA distribution.
+#
+# 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=2023c
+DATA=2023c
+
+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 -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
+
+if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then
+ cat make.out
+ exit 2
+fi
+
+cd zoneinfo
+../mkzip ../../zoneinfo.zip
+cd ../..
+
+files="update.bash zoneinfo.zip"
+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
+
+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