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