summaryrefslogtreecommitdiffstats
path: root/libc/tools/zoneinfo/update-tzdata.py
diff options
context:
space:
mode:
Diffstat (limited to 'libc/tools/zoneinfo/update-tzdata.py')
-rwxr-xr-xlibc/tools/zoneinfo/update-tzdata.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/libc/tools/zoneinfo/update-tzdata.py b/libc/tools/zoneinfo/update-tzdata.py
index e800e8f..4847356 100755
--- a/libc/tools/zoneinfo/update-tzdata.py
+++ b/libc/tools/zoneinfo/update-tzdata.py
@@ -13,8 +13,11 @@ import sys
import tarfile
import tempfile
-regions = ['africa', 'antarctica', 'asia', 'australasia', 'backward',
- 'etcetera', 'europe', 'northamerica', 'southamerica']
+regions = ['africa', 'antarctica', 'asia', 'australasia',
+ 'etcetera', 'europe', 'northamerica', 'southamerica',
+ # These two deliberately come last so they override what came
+ # before (and each other).
+ 'backward', 'backzone' ]
def CheckDirExists(dir, dirname):
if not os.path.isdir(dir):
@@ -49,16 +52,16 @@ def WriteSetupFile():
fields = line.split()
if fields:
if fields[0] == 'Link':
- links.append('%s %s %s\n' % (fields[0], fields[1], fields[2]))
+ links.append('%s %s %s' % (fields[0], fields[1], fields[2]))
zones.append(fields[2])
elif fields[0] == 'Zone':
zones.append(fields[1])
zones.sort()
setup = open('setup', 'w')
- for link in links:
- setup.write(link)
- for zone in zones:
+ for link in sorted(set(links)):
+ setup.write('%s\n' % link)
+ for zone in sorted(set(zones)):
setup.write('%s\n' % zone)
setup.close()
@@ -114,27 +117,37 @@ def BuildIcuToolsAndData(data_filename):
# Build the ICU tools.
print 'Configuring ICU tools...'
subprocess.check_call(['%s/runConfigureICU' % icu_dir, 'Linux'])
- print 'Making ICU tools...'
- subprocess.check_call(['make', '-j32'])
# Run the ICU tools.
os.chdir('tools/tzcode')
+
+ # The tz2icu tool only picks up icuregions and icuzones in they are in the CWD
+ for icu_data_file in [ 'icuregions', 'icuzones']:
+ icu_data_file_source = '%s/tools/tzcode/%s' % (icu_dir, icu_data_file)
+ icu_data_file_symlink = './%s' % icu_data_file
+ os.symlink(icu_data_file_source, icu_data_file_symlink)
+
shutil.copyfile('%s/%s' % (original_working_dir, data_filename), data_filename)
print 'Making ICU data...'
+ # The Makefile assumes the existence of the bin directory.
+ os.mkdir('%s/bin' % icu_working_dir)
subprocess.check_call(['make'])
- # Copy the output files to their ultimate destination.
+ # Copy the source file to its ultimate destination.
icu_txt_data_dir = '%s/data/misc' % icu_dir
print 'Copying zoneinfo64.txt to %s ...' % icu_txt_data_dir
shutil.copy('zoneinfo64.txt', icu_txt_data_dir)
+ # Regenerate the .dat file.
os.chdir(icu_working_dir)
+ subprocess.check_call(['make', '-j32'])
+
+ # Copy the .dat file to its ultimate destination.
icu_dat_data_dir = '%s/stubdata' % icu_dir
datfiles = glob.glob('data/out/tmp/icudt??l.dat')
if len(datfiles) != 1:
print 'ERROR: Unexpectedly found %d .dat files (%s). Halting.' % (len(datfiles), datfiles)
sys.exit(1)
-
datfile = datfiles[0]
print 'Copying %s to %s ...' % (datfile, icu_dat_data_dir)
shutil.copy(datfile, icu_dat_data_dir)
@@ -162,9 +175,10 @@ def BuildBionicToolsAndData(data_filename):
print 'Calling zic(1)...'
os.mkdir('data')
- for region in regions:
- if region != 'backward':
- subprocess.check_call(['zic', '-d', 'data', 'extracted/%s' % region])
+ zic_inputs = [ 'extracted/%s' % x for x in regions ]
+ zic_cmd = ['zic', '-d', 'data' ]
+ zic_cmd.extend(zic_inputs)
+ subprocess.check_call(zic_cmd)
WriteSetupFile()