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

Commit 9f303ce

Browse files
committed
build: i18n: support --with-icu-source=URL
Allow local path or URL to .tgz/.zip/etc to be used. This completes https://github.com/srl295/node/issues/11
1 parent 2964849 commit 9f303ce

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,29 @@ pkg-config --modversion icu-i18n && ./configure --with-intl=system-icu
152152

153153
#### Build with a specific ICU:
154154

155-
First: Unpack latest ICU to `deps/icu`
156-
[icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`)
157-
as `deps/icu` (You'll have: `deps/icu/source/...`)
155+
You can find other ICU releases at [icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`)
158156

159-
Unix/Macintosh:
157+
Unix/Macintosh: from an already-unpacked ICU
160158

161159
```sh
162-
./configure --with-intl=full-icu
160+
./configure --with-intl=full-icu --with-icu-source=/path/to/icu
163161
```
164162

165-
Windows:
163+
Unix/Macintosh: from a local ICU tarball
164+
165+
```sh
166+
./configure --with-intl=full-icu --with-icu-source=/path/to/icu.tgz
167+
```
168+
169+
Unix/Macintosh: from a tarball URL
170+
171+
```sh
172+
./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz
173+
```
174+
175+
Windows: first unpack latest ICU to `deps/icu`
176+
[icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`)
177+
as `deps/icu` (You'll have: `deps/icu/source/...`)
166178

167179
```sh
168180
vcbuild full-icu

configure

Lines changed: 4 additions & 4 deletions
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 local path to ICU source archive or existing icu directory.')
257+
help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
258258

259259
parser.add_option('--with-perfctr',
260260
action='store_true',
@@ -835,9 +835,9 @@ def configure_intl(o):
835835
# it's a file. Try to unpack it.
836836
icu_tarball = with_icu_source
837837
else:
838-
# download tarball
839-
print 'file missing and cant download'
840-
sys.exit(1)
838+
# Can we download it?
839+
local = os.path.join(icu_tmp_path, with_icu_source.split('/')[-1]) # local part
840+
icu_tarball = nodedownload.retrievefile(with_icu_source, local)
841841
# continue with "icu_tarball"
842842
nodedownload.unpack(icu_tarball, icu_tmp_path)
843843
# Did it unpack correctly? Should contain 'icu'

tools/configure.d/nodedownload.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ def md5sum(targetfile):
5151
chunk = f.read(1024)
5252
return digest.hexdigest()
5353

54-
def unpackWithMode(unpacker, packedfile, parent_path, mode):
55-
with unpacker.open(packedfile, mode) as icuzip:
54+
def unpackWithMode(opener, packedfile, parent_path, mode):
55+
with opener(packedfile, mode) as icuzip:
5656
print ' Extracting source file: %s' % packedfile
5757
icuzip.extractall(parent_path)
5858

5959
def unpack(packedfile, parent_path):
60-
"""Unpack packedfile into parent_path. Assumes .zip."""
60+
"""Unpack packedfile into parent_path. Assumes .zip. Returns parent_path"""
6161
packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc
6262
if zipfile.is_zipfile(packedfile):
63-
unpackWithMode(zipfile.ZipFile, packedfile, parent_path, 'r')
63+
with zipfile.ZipFile(packedfile, 'r') as icuzip:
64+
print ' Extracting zipfile: %s' % packedfile
65+
icuzip.extractall(parent_path)
66+
return parent_path
6467
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))
68+
with tarfile.TarFile.open(packedfile, 'r') as icuzip:
69+
print ' Extracting tarfile: %s' % packedfile
70+
icuzip.extractall(parent_path)
71+
return parent_path
7272
else:
7373
raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix))

0 commit comments

Comments
 (0)