OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 # |
| 4 # Use of this source code is governed by a BSD-style license |
| 5 # that can be found in the LICENSE file in the root of the source |
| 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 |
| 10 """Downloads the node binaries from WebRTC storage and unpacks it. |
| 11 |
| 12 Requires that depot_tools is installed and in the PATH. This script expects |
| 13 to run with Chrome's base dir as the working directory, e.g. where the .gclient |
| 14 file is. This is what should happen if this script is invoked as a hook action. |
| 15 """ |
| 16 |
| 17 import glob |
| 18 import os |
| 19 import sys |
| 20 import tarfile |
| 21 import zipfile |
| 22 |
| 23 import utils |
| 24 |
| 25 |
| 26 def _GetNodeArchivePathForPlatform(): |
| 27 archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz' |
| 28 return os.path.join(utils.GetPlatform(), 'node.%s' % archive_extension) |
| 29 |
| 30 |
| 31 def _StripVersionNumberFromNodeDir(): |
| 32 # The node dir will be called node-x-x-x.tar.gz, rename to just node. |
| 33 unpacked_name = glob.glob('node*') |
| 34 assert len(unpacked_name) == 1, 'Should have precisely one node!' |
| 35 os.rename(unpacked_name[0], 'node') |
| 36 |
| 37 |
| 38 def main(argv): |
| 39 if len(argv) == 1: |
| 40 return 'Usage: %s <path to webrtc.DEPS>' % argv[0] |
| 41 if not os.path.exists('.gclient'): |
| 42 return 'Invoked from wrong dir; invoke from dir with .gclient' |
| 43 |
| 44 webrtc_deps_path = argv[1] |
| 45 node_path = os.path.join(webrtc_deps_path, 'node') |
| 46 archive_path = os.path.join(node_path, _GetNodeArchivePathForPlatform()) |
| 47 old_archive_sha1 = utils.ComputeSHA1(archive_path) |
| 48 |
| 49 utils.DownloadFilesFromGoogleStorage(node_path) |
| 50 |
| 51 if (old_archive_sha1 != utils.ComputeSHA1(archive_path) |
| 52 or not os.path.exists('node')): |
| 53 utils.DeleteDirNextToGclient('node') |
| 54 utils.UnpackToWorkingDir(archive_path) |
| 55 _StripVersionNumberFromNodeDir() |
| 56 |
| 57 |
| 58 if __name__ == '__main__': |
| 59 sys.exit(main(sys.argv)) |
OLD | NEW |