OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import shutil | 7 import shutil |
8 import sys | 8 import sys |
9 import subprocess | 9 import subprocess |
10 import tarfile | 10 import tarfile |
11 import tempfile | 11 import tempfile |
12 import urllib2 | 12 import urllib2 |
13 | 13 |
14 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) | 14 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) |
15 | 15 |
16 DEFAULT_VERSION = '0.12.2' | 16 DEFAULT_VERSION = '4.5.0' |
17 BUCKET = 'chromium-infra-bins' | 17 BUCKET = 'chromium-nodejs' |
18 | 18 |
19 | 19 |
20 def install_latest_node_js(version, tmp_dir): | 20 def install_latest_node_js(version, tmp_dir): |
21 target_dir = os.path.join(THIS_DIR, 'runtimes', version) | 21 target_dir = os.path.join(THIS_DIR, 'runtimes', version) |
22 version_file = os.path.join(target_dir, 'VERSION') | 22 version_file = os.path.join(target_dir, 'VERSION') |
23 | 23 |
24 if sys.platform == 'win32': | 24 if sys.platform == 'win32': |
25 bin_location = os.path.join(target_dir, 'node.exe') | 25 bin_location = os.path.join(target_dir, 'node.exe') |
26 else: | 26 else: |
27 bin_location = os.path.join(target_dir, 'bin', 'node') | 27 bin_location = os.path.join(target_dir, 'bin', 'node') |
(...skipping 11 matching lines...) Expand all Loading... |
39 if sys.platform == 'win32': | 39 if sys.platform == 'win32': |
40 target = 'node.exe' | 40 target = 'node.exe' |
41 elif sys.platform == 'darwin': | 41 elif sys.platform == 'darwin': |
42 target = 'node-v%s-darwin-x86.tar.gz' % version | 42 target = 'node-v%s-darwin-x86.tar.gz' % version |
43 elif sys.platform == 'linux2': | 43 elif sys.platform == 'linux2': |
44 target = 'node-v%s-linux-x86.tar.gz' % version | 44 target = 'node-v%s-linux-x86.tar.gz' % version |
45 else: | 45 else: |
46 raise Exception('Unrecognized platform %s' % sys.platform) | 46 raise Exception('Unrecognized platform %s' % sys.platform) |
47 | 47 |
48 dest = os.path.join(tmp_dir, 'node_download') | 48 dest = os.path.join(tmp_dir, 'node_download') |
49 url = 'https://storage.googleapis.com/%s/node/%s/%s' % ( | 49 url = 'https://storage.googleapis.com/%s/%s/%s' % ( |
50 BUCKET, version, target) | 50 BUCKET, version, target) |
51 print('Fetching %s' % url) | 51 print('Fetching %s' % url) |
52 u = urllib2.urlopen(url) | 52 u = urllib2.urlopen(url) |
53 with open(dest, 'wb') as f: | 53 with open(dest, 'wb') as f: |
54 while True: | 54 while True: |
55 chunk = u.read(2 ** 20) | 55 chunk = u.read(2 ** 20) |
56 if not chunk: | 56 if not chunk: |
57 break | 57 break |
58 f.write(chunk) | 58 f.write(chunk) |
59 | 59 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 if mode == 'npm': | 111 if mode == 'npm': |
112 # TODO(hinoka): How about Windows...? | 112 # TODO(hinoka): How about Windows...? |
113 bin_location = os.path.join(os.path.dirname(bin_location), 'npm') | 113 bin_location = os.path.join(os.path.dirname(bin_location), 'npm') |
114 | 114 |
115 return subprocess.call([bin_location, ] + sys.argv[1:]) | 115 return subprocess.call([bin_location, ] + sys.argv[1:]) |
116 | 116 |
117 | 117 |
118 if __name__ == '__main__': | 118 if __name__ == '__main__': |
119 sys.exit(main()) | 119 sys.exit(main()) |
OLD | NEW |