* commit '062240853d75a795db956965cacd4ab09a959ce7': Upgrade to tzdata2012i.
This commit is contained in:
commit
dc20297f8d
@ -32,22 +32,22 @@ regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward',
|
|||||||
|
|
||||||
|
|
||||||
def GetCurrentTzDataVersion():
|
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():
|
def WriteSetupFile():
|
||||||
|
"""Writes the list of zones that ZoneCompactor should process."""
|
||||||
links = []
|
links = []
|
||||||
zones = []
|
zones = []
|
||||||
for region in regions:
|
for region in regions:
|
||||||
for line in open('extracted/%s' % region):
|
for line in open('extracted/%s' % region):
|
||||||
fields = line.split()
|
fields = line.split()
|
||||||
if len(fields) == 0:
|
if fields:
|
||||||
continue
|
if fields[0] == 'Link':
|
||||||
elif fields[0] == 'Link':
|
links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
|
||||||
links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
|
zones.append(fields[2])
|
||||||
zones.append(fields[2])
|
elif fields[0] == 'Zone':
|
||||||
elif fields[0] == 'Zone':
|
zones.append(fields[1])
|
||||||
zones.append(fields[1])
|
|
||||||
zones.sort()
|
zones.sort()
|
||||||
|
|
||||||
setup = open('setup', 'w')
|
setup = open('setup', 'w')
|
||||||
@ -58,20 +58,34 @@ def WriteSetupFile():
|
|||||||
setup.close()
|
setup.close()
|
||||||
|
|
||||||
|
|
||||||
def UpgradeTo(ftp, filename):
|
def Retrieve(ftp, filename):
|
||||||
new_version = re.search('(tzdata.+)\.tar\.gz', filename).group(1)
|
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.
|
# Switch to a temporary directory.
|
||||||
tmp_dir = tempfile.mkdtemp('-tzdata')
|
tmp_dir = tempfile.mkdtemp('-tzdata')
|
||||||
os.chdir(tmp_dir)
|
os.chdir(tmp_dir)
|
||||||
print 'Created temporary directory "%s"...' % tmp_dir
|
print 'Created temporary directory "%s"...' % tmp_dir
|
||||||
|
|
||||||
print 'Downloading...'
|
print 'Downloading data and signature...'
|
||||||
ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write)
|
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...'
|
print 'Extracting...'
|
||||||
os.mkdir('extracted')
|
os.mkdir('extracted')
|
||||||
tar = tarfile.open(filename, 'r')
|
tar = tarfile.open(data_filename, 'r')
|
||||||
tar.extractall('extracted')
|
tar.extractall('extracted')
|
||||||
|
|
||||||
print 'Calling zic(1)...'
|
print 'Calling zic(1)...'
|
||||||
@ -94,17 +108,15 @@ def UpgradeTo(ftp, filename):
|
|||||||
|
|
||||||
|
|
||||||
# Run with no arguments from any directory, with no special setup required.
|
# 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():
|
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...'
|
print 'Looking for new tzdata...'
|
||||||
ftp = ftplib.FTP('ftp.iana.org')
|
ftp = ftplib.FTP('ftp.iana.org')
|
||||||
ftp.login()
|
ftp.login()
|
||||||
ftp.cwd('tz/releases')
|
ftp.cwd('tz/releases')
|
||||||
tzdata_filenames = []
|
tzdata_filenames = []
|
||||||
for filename in ftp.nlst():
|
for filename in ftp.nlst():
|
||||||
if filename.startswith('tzdata20'):
|
if filename.startswith('tzdata20') and filename.endswith('.tar.gz'):
|
||||||
tzdata_filenames.append(filename)
|
tzdata_filenames.append(filename)
|
||||||
tzdata_filenames.sort()
|
tzdata_filenames.sort()
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user