From e3063f4e5520caa84f48896cf9127d97fd2796ba Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 5 Nov 2012 08:53:28 -0800 Subject: [PATCH] Upgrade to tzdata2012i. Also support GPG signature verification of updates, and fix remaining pylint complaints. The 2012i release of the tz data reflects the following changes recently circulated on the tz mailing list: * Cuba switches from DST [2012-11-04] at 01:00. (Thanks to Steffen Thorsen.) Change-Id: Ie81d395afa40aa217a0196aad8ca1f9a870bbc31 --- libc/tools/zoneinfo/generate | 46 ++++++++++++++++++++++------------- libc/zoneinfo/tzdata | Bin 548234 -> 548234 bytes 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/libc/tools/zoneinfo/generate b/libc/tools/zoneinfo/generate index 27d023fdb..ba8ea0dff 100755 --- a/libc/tools/zoneinfo/generate +++ b/libc/tools/zoneinfo/generate @@ -32,22 +32,22 @@ regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward', def GetCurrentTzDataVersion(): - return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\0', 1)[0] + return open('%s/tzdata' % bionic_libc_zoneinfo_dir).read().split('\x00', 1)[0] def WriteSetupFile(): + """Writes the list of zones that ZoneCompactor should process.""" links = [] zones = [] for region in regions: for line in open('extracted/%s' % region): fields = line.split() - if len(fields) == 0: - continue - elif fields[0] == 'Link': - links.append('%s %s %s\n' % (fields[0], fields[1], fields[2])) - zones.append(fields[2]) - elif fields[0] == 'Zone': - zones.append(fields[1]) + if fields: + if fields[0] == 'Link': + links.append('%s %s %s\n' % (fields[0], fields[1], fields[2])) + zones.append(fields[2]) + elif fields[0] == 'Zone': + zones.append(fields[1]) zones.sort() setup = open('setup', 'w') @@ -58,20 +58,34 @@ def WriteSetupFile(): setup.close() -def UpgradeTo(ftp, filename): - new_version = re.search('(tzdata.+)\.tar\.gz', filename).group(1) +def Retrieve(ftp, filename): + ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write) + + +def UpgradeTo(ftp, data_filename): + """Downloads and repackages the given data from the given FTP server.""" + + new_version = re.search('(tzdata.+)\\.tar\\.gz', data_filename).group(1) + signature_filename = '%s.sign' % data_filename # Switch to a temporary directory. tmp_dir = tempfile.mkdtemp('-tzdata') os.chdir(tmp_dir) print 'Created temporary directory "%s"...' % tmp_dir - print 'Downloading...' - ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write) + print 'Downloading data and signature...' + Retrieve(ftp, data_filename) + Retrieve(ftp, signature_filename) + + print 'Verifying signature...' + # If this fails for you, you probably need to import Paul Eggert's public key: + # gpg --recv-keys ED97E90E62AA7E34 + subprocess.check_call(['gpg', '--trusted-key=ED97E90E62AA7E34', + '--verify', signature_filename, data_filename]) print 'Extracting...' os.mkdir('extracted') - tar = tarfile.open(filename, 'r') + tar = tarfile.open(data_filename, 'r') tar.extractall('extracted') print 'Calling zic(1)...' @@ -94,17 +108,15 @@ def UpgradeTo(ftp, filename): # Run with no arguments from any directory, with no special setup required. +# See http://www.iana.org/time-zones/ for more about the source of this data. def main(): - # URL from "Sources for Time Zone and Daylight Saving Time Data" - # http://www.twinsun.com/tz/tz-link.htm - print 'Looking for new tzdata...' ftp = ftplib.FTP('ftp.iana.org') ftp.login() ftp.cwd('tz/releases') tzdata_filenames = [] for filename in ftp.nlst(): - if filename.startswith('tzdata20'): + if filename.startswith('tzdata20') and filename.endswith('.tar.gz'): tzdata_filenames.append(filename) tzdata_filenames.sort() diff --git a/libc/zoneinfo/tzdata b/libc/zoneinfo/tzdata index 272b18cd091de06b8c0707b7b4044328cfda782c..367c0f9b50b47c39596395886e190d580c280247 100644 GIT binary patch delta 708 zcmW;JPe{{o7{~G7Pi-Am6oga=(k^;(ZKBX2GP-n7@hSgcrL)y!Y+Ckb4V&f&qLr5p zQooAulywqMF-h=}(J6W^ktZShb15$yNf1cS`#bpZ8o%4;{miaJW>+HNTp^XrC0k?h z*38}To3P*ftN3_Z&Ky4=XK$@bZ^Iwy>whbK|GvmT`wJQPUe&?IWgT4mtmk%~>-m>u zy|6K@L-(HP@M=O6sVNe73i=-b z9x@S`iA;6cTx7D-W+T&`HXliVWI$3NIglhs7A(?+KlDKwA)Sy`NH3(B)4Cz;oYoI% z=(LVVOQa{#6zOUdJ=*etzDQ%FGtwIAjWl;!cci`3`Xe`R+8vNvAooCSg51UP4tgHP z;R6RkJCgXp*9HGn&`|LgL-A-l8ap}{UpgGby8Jz*YQ?u#W3Sd;oxNT5Lgi{@caZ%L D7xD18 delta 704 zcmW;JPe_w-9LMqJu{jSjL_#E_&77NHIjhv<#}S$RR@9fNc6qgx*HolIoHtor*T!<