| 
									
										
										
										
											2016-07-06 00:16:05 +00:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2016-04-10 14:32:26 -07:00
										 |  |  | # Copyright 2012 The Go Authors. All rights reserved. | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | # 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. | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | # | 
					
						
							|  |  |  | # 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. | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Versions to use. | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | CODE=2022g | 
					
						
							|  |  |  | DATA=2022g | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | cd $(dirname $0) | 
					
						
							| 
									
										
										
										
											2012-02-19 03:16:20 -05:00
										 |  |  | rm -rf work | 
					
						
							|  |  |  | mkdir work | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | go build -o work/mkzip mkzip.go # build now for correct paths in build errors | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | cd work | 
					
						
							| 
									
										
										
										
											2012-02-19 03:16:20 -05:00
										 |  |  | mkdir zoneinfo | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | tar xzf tzcode$CODE.tar.gz | 
					
						
							|  |  |  | tar xzf tzdata$DATA.tar.gz | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then | 
					
						
							|  |  |  | 	cat make.out | 
					
						
							|  |  |  | 	exit 2 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 03:16:20 -05:00
										 |  |  | cd zoneinfo | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | ../mkzip ../../zoneinfo.zip | 
					
						
							| 
									
										
										
										
											2012-02-19 03:16:20 -05:00
										 |  |  | cd ../.. | 
					
						
							| 
									
										
										
										
											2020-04-13 16:48:23 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-05 23:39:49 -05:00
										 |  |  | files="update.bash zoneinfo.zip" | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | modified=true | 
					
						
							|  |  |  | if git diff --quiet $files; then | 
					
						
							|  |  |  | 	modified=false | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-23 22:11:51 -08:00
										 |  |  | if [ "$1" = "-work" ]; then | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | 	echo Left workspace behind in work/. | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | 	shift | 
					
						
							| 
									
										
										
										
											2012-02-18 20:33:58 -05:00
										 |  |  | else | 
					
						
							|  |  |  | 	rm -rf work | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2022-12-05 23:07:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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 |