| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Installs deps for using SDK emulator for testing. | 6 """Installs deps for using SDK emulator for testing. |
| 7 | 7 |
| 8 The script will download the SDK and system images, if they are not present, and | 8 The script will download the SDK and system images, if they are not present, and |
| 9 install and enable KVM, if virtualization has been enabled in the BIOS. | 9 install and enable KVM, if virtualization has been enabled in the BIOS. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 | 12 |
| 13 import logging | 13 import logging |
| 14 import os | 14 import os |
| 15 import shutil | 15 import shutil |
| 16 import subprocess | |
| 17 import sys | 16 import sys |
| 18 | 17 |
| 19 from pylib import cmd_helper | 18 from pylib import cmd_helper |
| 20 from pylib import constants | 19 from pylib import constants |
| 21 from pylib.utils import run_tests_helper | 20 from pylib.utils import run_tests_helper |
| 22 | 21 |
| 23 # From the Android Developer's website. | 22 # From the Android Developer's website. |
| 24 SDK_BASE_URL = 'http://dl.google.com/android/adt' | 23 SDK_BASE_URL = 'http://dl.google.com/android/adt' |
| 25 SDK_ZIP = 'adt-bundle-linux-x86_64-20130219.zip' | 24 SDK_ZIP = 'adt-bundle-linux-x86_64-20130219.zip' |
| 26 | 25 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 55 | 54 |
| 56 def CheckKVM(): | 55 def CheckKVM(): |
| 57 """Check if KVM is enabled. | 56 """Check if KVM is enabled. |
| 58 | 57 |
| 59 Returns: | 58 Returns: |
| 60 True if kvm-ok returns 0 (already enabled) | 59 True if kvm-ok returns 0 (already enabled) |
| 61 """ | 60 """ |
| 62 try: | 61 try: |
| 63 return not cmd_helper.RunCmd(['kvm-ok']) | 62 return not cmd_helper.RunCmd(['kvm-ok']) |
| 64 except OSError: | 63 except OSError: |
| 64 logging.info('kvm-ok not installed') |
| 65 return False | 65 return False |
| 66 | 66 |
| 67 | 67 |
| 68 def GetSDK(): | 68 def GetSDK(): |
| 69 """Download the SDK and unzip in android_tools directory.""" | 69 """Download the SDK and unzip in android_tools directory.""" |
| 70 logging.info('Download Android SDK.') | 70 logging.info('Download Android SDK.') |
| 71 sdk_url = '%s/%s' % (SDK_BASE_URL, SDK_ZIP) | 71 sdk_url = '%s/%s' % (SDK_BASE_URL, SDK_ZIP) |
| 72 try: | 72 try: |
| 73 cmd_helper.RunCmd(['curl', '-o', '/tmp/sdk.zip', sdk_url]) | 73 cmd_helper.RunCmd(['curl', '-o', '/tmp/sdk.zip', sdk_url]) |
| 74 print 'curled unzipping...' | 74 print 'curled unzipping...' |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 logging.basicConfig(level=logging.INFO, | 126 logging.basicConfig(level=logging.INFO, |
| 127 format='# %(asctime)-15s: %(message)s') | 127 format='# %(asctime)-15s: %(message)s') |
| 128 run_tests_helper.SetLogLevel(verbose_count=1) | 128 run_tests_helper.SetLogLevel(verbose_count=1) |
| 129 | 129 |
| 130 # Calls below will download emulator SDK and/or system images only if needed. | 130 # Calls below will download emulator SDK and/or system images only if needed. |
| 131 if CheckSDK(): | 131 if CheckSDK(): |
| 132 logging.info('android_tools directory already exists (not downloading).') | 132 logging.info('android_tools directory already exists (not downloading).') |
| 133 else: | 133 else: |
| 134 GetSDK() | 134 GetSDK() |
| 135 | 135 |
| 136 logging.info('Emulator deps for ARM emulator complete.') |
| 137 |
| 136 if CheckX86Image(): | 138 if CheckX86Image(): |
| 137 logging.info('system-images directory already exists.') | 139 logging.info('system-images directory already exists.') |
| 138 else: | 140 else: |
| 139 GetX86Image() | 141 GetX86Image() |
| 140 | 142 |
| 141 # Make sure KVM packages are installed and enabled. | 143 # Make sure KVM packages are installed and enabled. |
| 142 if CheckKVM(): | 144 if CheckKVM(): |
| 143 logging.info('KVM already installed and enabled.') | 145 logging.info('KVM already installed and enabled.') |
| 144 else: | 146 else: |
| 145 InstallKVM() | 147 InstallKVM() |
| 146 | 148 |
| 147 | 149 |
| 148 if __name__ == '__main__': | 150 if __name__ == '__main__': |
| 149 sys.exit(main(sys.argv)) | 151 sys.exit(main(sys.argv)) |
| OLD | NEW |