Skip to content

Instantly share code, notes, and snippets.

@ppdeassis
Forked from tgirardi/os-x-update-tzdata.sh
Last active October 22, 2019 16:36
Show Gist options
  • Save ppdeassis/23dc60f8414e7bc7f3b7470c7e4692ee to your computer and use it in GitHub Desktop.
Save ppdeassis/23dc60f8414e7bc7f3b7470c7e4692ee to your computer and use it in GitHub Desktop.
Update tzdata and ICU data on OS X to fix problems with outdated DST information (needs reboot)
#!/bin/bash
# author: Pedro de Assis
# Based on Tomás Girardi
# Based on http://helw.net/2011/04/28/updating-osx-for-egypts-dst-changes/ by Ahmed El-Helw
set -ex
# CHANGE THIS:
# go to https://www.iana.org/time-zones and get the URL for the last DATA
# release
TZDATAFILENAME=tzdata2019c.tar.gz
URLTZDATASRC="https://data.iana.org/time-zones/releases/${TZDATAFILENAME}"
# BACKUP your current icu file first
cp /usr/share/icu/*.dat ~
ICUVERSION=`ls /usr/share/icu/*.dat | grep -o "\(\d\d\)l\.dat" | grep -o "^\d\d"`
URLICUSRC="http://download.icu-project.org/files/icu4c/${ICUVERSION}.1/icu4c-${ICUVERSION}_1-src.zip"
### update tzdata
cd /tmp
mkdir -p tzdata
cd tzdata
wget "${URLTZDATASRC}"
tar -xzf "${TZDATAFILENAME}"
set +e
sudo zic africa
sudo zic antarctica
sudo zic asia
sudo zic australasia
sudo zic backward
sudo zic etcetera
sudo zic europe
sudo zic factory
sudo zic northamerica
sudo zic pacificnew
sudo zic southamerica
sudo zic systemv
set -e
### update ICU data
cd /tmp
mkdir -p icu4c
cd icu4c
wget "${URLICUSRC}" -O icusrc.tar.gz
tar xzf icusrc.tar.gz
cd icu/source/tools/tzcode
# ./icuSources/tools/tzcode/readme.txt tells us that placing a tzdata
# file in the tzcode directory will compile with that zoneinfo database
# download latest tzdata
wget "${URLTZDATASRC}"
cd ../..
# compile
./runConfigureICU MacOSX --with-data-packaging=archive
gnumake
# replace the data file only
sudo install -o root -g wheel -m 0644 -Sp "data/out/icudt${ICUVERSION}l.dat" "/usr/share/icu/icudt${ICUVERSION}l.dat"
# NOW REBOOT!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment