| 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=2025b |
| 28 |
DATA=2025b |
| 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 |
# The PACKRATLIST and PACKRATDATA options are copied from Ubuntu: |
| 44 |
# https://git.launchpad.net/ubuntu/+source/tzdata/tree/debian/rules?h=debian/sid |
| 45 |
# |
| 46 |
# You can see the description of these make variables in the tzdata Makefile: |
| 47 |
# https://github.com/eggert/tz/blob/main/Makefile |
| 48 |
if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo PACKRATDATA=backzone PACKRATLIST=zone.tab posix_only >make.out 2>&1; then |
| 49 |
cat make.out |
| 50 |
exit 2 |
| 51 |
fi |
| 52 |
|
| 53 |
cd zoneinfo |
| 54 |
../mkzip ../../zoneinfo.zip |
| 55 |
cd ../.. |
| 56 |
|
| 57 |
files="update.bash zoneinfo.zip" |
| 58 |
modified=true |
| 59 |
if git diff --quiet $files; then |
| 60 |
modified=false |
| 61 |
fi |
| 62 |
|
| 63 |
if [ "$1" = "-work" ]; then |
| 64 |
echo Left workspace behind in work/. |
| 65 |
shift |
| 66 |
else |
| 67 |
rm -rf work |
| 68 |
fi |
| 69 |
|
| 70 |
if ! $modified; then |
| 71 |
echo No updates needed. |
| 72 |
exit 0 |
| 73 |
fi |
| 74 |
|
| 75 |
echo Updated for $CODE/$DATA: $files |
| 76 |
|
| 77 |
commitmsg="lib/time: update to $CODE/$DATA |
| 78 |
|
| 79 |
Commit generated by update.bash. |
| 80 |
|
| 81 |
For #22487. |
| 82 |
" |
| 83 |
|
| 84 |
if [ "$1" = "-commit" ]; then |
| 85 |
echo "Creating commit. Run 'git reset HEAD^' to undo commit." |
| 86 |
echo |
| 87 |
git commit -m "$commitmsg" $files |
| 88 |
echo |
| 89 |
git log -n1 --stat |
| 90 |
echo |
| 91 |
fi |