codekingpro/portable-devtools
114k
1#!/bin/bash2# Copyright 2012 The Go Authors. All rights reserved.3# Use of this source code is governed by a BSD-style4# license that can be found in the LICENSE file.5 6# This script rebuilds the time zone files using files7# 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 run12#13# ./update.bash -commit14#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 number20# cd lib/time21# ./update.bash22#23# If it prints "No updates needed.", then the generated files24# in the CL match the update.bash in the CL.25 26# Versions to use.27CODE=2025c28DATA=2025c29 30set -e31 32cd $(dirname $0)33rm -rf work34mkdir work35go build -o work/mkzip mkzip.go # build now for correct paths in build errors36cd work37mkdir zoneinfo38curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz39curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz40tar xzf tzcode$CODE.tar.gz41tar xzf tzdata$DATA.tar.gz42 43# The PACKRATLIST and PACKRATDATA options are copied from Ubuntu:44# https://git.launchpad.net/ubuntu/+source/tzdata/tree/debian/rules?h=debian/sid45#46# You can see the description of these make variables in the tzdata Makefile:47# https://github.com/eggert/tz/blob/main/Makefile48if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo PACKRATDATA=backzone PACKRATLIST=zone.tab posix_only >make.out 2>&1; then49 cat make.out50 exit 251fi52 53cd zoneinfo54../mkzip ../../zoneinfo.zip55cd ../..56 57files="update.bash zoneinfo.zip"58modified=true59if git diff --quiet $files; then60 modified=false61fi62 63if [ "$1" = "-work" ]; then64 echo Left workspace behind in work/.65 shift66else67 rm -rf work68fi69 70if ! $modified; then71 echo No updates needed.72 exit 073fi74 75echo Updated for $CODE/$DATA: $files76 77commitmsg="lib/time: update to $CODE/$DATA78 79Commit generated by update.bash.80 81For #22487.82"83 84if [ "$1" = "-commit" ]; then85 echo "Creating commit. Run 'git reset HEAD^' to undo commit."86 echo87 git commit -m "$commitmsg" $files88 echo89 git log -n1 --stat90 echo91fi92 