Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 2964849

Browse files
committed
build: i18n: support ICU.tgz, .bz2, etc
use tarfile to support `.tgz` or `.bz2` or whatever `tarfile` supports
1 parent 6f6d337 commit 2964849

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ parser.add_option('--with-intl',
254254
parser.add_option('--with-icu-source',
255255
action='store',
256256
dest='with_icu_source',
257-
help='Intl mode: optional path to ICU zip or existing icu directory.')
257+
help='Intl mode: optional local path to ICU source archive or existing icu directory.')
258258

259259
parser.add_option('--with-perfctr',
260260
action='store_true',

tools/configure.d/nodedownload.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import hashlib
66
import sys
77
import zipfile
8+
import tarfile
89

910
def formatSize(amt):
1011
"""Format a size as a string in MB"""
@@ -50,8 +51,23 @@ def md5sum(targetfile):
5051
chunk = f.read(1024)
5152
return digest.hexdigest()
5253

54+
def unpackWithMode(unpacker, packedfile, parent_path, mode):
55+
with unpacker.open(packedfile, mode) as icuzip:
56+
print ' Extracting source file: %s' % packedfile
57+
icuzip.extractall(parent_path)
58+
5359
def unpack(packedfile, parent_path):
5460
"""Unpack packedfile into parent_path. Assumes .zip."""
55-
with zipfile.ZipFile(packedfile, 'r') as icuzip:
56-
print ' Extracting source zip: %s' % packedfile
57-
icuzip.extractall(parent_path)
61+
packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc
62+
if zipfile.is_zipfile(packedfile):
63+
unpackWithMode(zipfile.ZipFile, packedfile, parent_path, 'r')
64+
elif tarfile.is_tarfile(packedfile):
65+
# if (packedsuffix == 'tgz') or (packedsuffix == 'gz'):
66+
# unpackWithMode(tarfile.TarFile, packedfile, parent_path, 'r:gz')
67+
# elif (packedsuffix == 'bz2') or (packedsuffix == 'tb2'):
68+
# unpackWithMode(tarfile.TarFile, packedfile, parent_path, 'r:bz2')
69+
# else:
70+
unpackWithMode(tarfile.TarFile, packedfile, parent_path, 'r')
71+
#raise Exception('Error: Don\'t know how to unpack tarfile %s with extension %s' % (packedfile, packedsuffix))
72+
else:
73+
raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix))

0 commit comments

Comments
 (0)