Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
|
Mark Mentovai
2011/10/05 23:09:22
You got rid of the -e but didn’t put in a “set -e”
michaelbai
2011/10/06 17:23:19
Done.
| |
| 2 | |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # The script is to install Android SDK, NDK for build chromium on Android, and | |
| 8 # doesn't need to run as root. | |
| 9 | |
| 10 # Using Android 3.2, API Level: 13 (Honeycomb). The SDK package is about 30M. | |
| 11 SDK_FILE_NAME="android-sdk_r13-linux_x86.tgz" | |
| 12 SDK_DOWNLOAD_URL="http://dl.google.com/android/android-sdk_r13-linux_x86.tgz" | |
|
Mark Mentovai
2011/10/05 23:09:22
Seems like this could end in ${SDK_FILE_NAME}. Sam
michaelbai
2011/10/06 17:23:19
Done.
| |
| 13 SDK_MD5SUM="d80d7530a46c665644ae76084a9a0dc4" | |
| 14 | |
| 15 # Using "ANDROID_SDK_ROOT/tools/android list targets" to get the matching target | |
| 16 # id which will be loaded in simulator for testing. | |
| 17 # For example: the output of the listed the target could be below, and the | |
| 18 # 'android-13' is the SDK_TARGET_ID in this case. | |
| 19 # id: 9 or "android-13" | |
| 20 # Name: Android 3.2 | |
| 21 # Type: Platform | |
| 22 # API level: 13 | |
| 23 # Revision: 1 | |
| 24 # Skins: WXGA (default) | |
| 25 SDK_TARGET_ID=android-13 | |
| 26 | |
| 27 # Using NDK r6b; The package is about 44M. | |
| 28 NDK_FILE_NAME="android-ndk-r6b-linux-x86.tar.bz2" | |
| 29 NDK_DOWNLOAD_URL="http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar .bz2" | |
| 30 NDK_MD5SUM="309f35e49b64313cfb20ac428df4cec2" | |
| 31 | |
| 32 ########################################################## | |
| 33 # Download and install a tgz package by wget and tar -xvf. | |
| 34 # Arguments: | |
| 35 # local_file_name, the name of downloaded file. | |
| 36 # download_url, the url to download the package. | |
| 37 # md5, the package's md5 which could be found in download page. | |
| 38 # install_path, where the package should be installed. | |
| 39 # Returns: | |
| 40 # None | |
| 41 ########################################################## | |
| 42 install_dev_kit() { | |
| 43 local local_file_name="${1}" | |
| 44 local download_url="${2}" | |
| 45 local md5="${3}" | |
| 46 local install_path="${4}" | |
| 47 | |
| 48 if [[ ! -f "${local_file_name}" ]]; then | |
| 49 wget "${download_url}" | |
|
Mark Mentovai
2011/10/05 23:09:22
This just drops stuff into the current directory.
michaelbai
2011/10/06 17:23:19
Done.
| |
| 50 fi | |
| 51 | |
| 52 if [[ $(md5sum "${local_file_name}" | cut -d' ' -f1) != "${md5}" ]]; then | |
| 53 echo "Bad md5sum of ${local_file_name}, " >& 2 | |
|
Mark Mentovai
2011/10/05 23:09:22
This doesn’t need to end in a comma.
You might wa
michaelbai
2011/10/06 17:23:19
Done.
| |
| 54 rm "${local_file_name}" | |
| 55 exit 1 | |
| 56 fi | |
| 57 | |
| 58 echo "Install ${local_file_name}" | |
| 59 mv "${local_file_name}" "${install_path}" | |
| 60 if [[ "$?" -ne 0 ]]; then | |
|
Mark Mentovai
2011/10/05 23:09:22
If you’re running under -e, the script will die be
michaelbai
2011/10/06 17:23:19
Done.
| |
| 61 echo "Unable to move ${local_file_name} to ${install_path}" >&2 | |
| 62 exit 1 | |
| 63 fi | |
| 64 (cd "${install_path}" && tar -xvf "${local_file_name}") | |
| 65 } | |
| 66 | |
| 67 if [[ -z "${ANDROID_SDK_ROOT}" ]]; then | |
| 68 echo "Please set ANDROID_SDK_ROOT to where they should installed to." >& 2 | |
| 69 echo "For example: /usr/local/android-sdk-linux_x86" >& 2 | |
| 70 exit 1 | |
| 71 fi | |
| 72 | |
| 73 if [[ -z "${ANDROID_NDK_ROOT}" ]]; then | |
| 74 echo "Please set ANDROID_NDK_ROOT to where they should installed to." >& 2 | |
| 75 echo "For example: /usr/local/android-ndk-r6b" >& 2 | |
| 76 exit 1 | |
| 77 fi | |
| 78 | |
| 79 # Install Android SDK if it doesn't exist. | |
| 80 if [[ ! -d "${ANDROID_SDK_ROOT}" ]]; then | |
| 81 echo 'Install ANDROID SDK ...' | |
| 82 install_dev_kit "${SDK_FILE_NAME}" "${SDK_DOWNLOAD_URL}" "${SDK_MD5SUM}" \ | |
| 83 $(dirname "${ANDROID_SDK_ROOT}") | |
| 84 fi | |
| 85 | |
| 86 # Install the target if it doesn't exist. The package installed above contains | |
| 87 # no platform, platform-tool or tool, all those should be installed by | |
| 88 # ${ANDROID_SDK_ROOT}/tools/android. | |
| 89 if [[ ! $("${ANDROID_SDK_ROOT}"/tools/android list targets \ | |
|
Mark Mentovai
2011/10/05 23:09:22
Usually you just wrap the quotes around the entire
michaelbai
2011/10/06 17:23:19
Done, Shall I know what's the difference?
On 2011
| |
| 90 | grep -q "${SDK_TARGET_ID}") ]]; then | |
| 91 # Updates the SDK by installing the necessary components. | |
| 92 # From current configuration, all android platforms will be installed. | |
| 93 # This will take a little bit long time. | |
| 94 echo "Install platform, platform-tool and tool ..." | |
| 95 "${ANDROID_SDK_ROOT}"/tools/android update sdk --no-ui \ | |
| 96 --filter platform,platform-tool,tool | |
| 97 fi | |
| 98 | |
| 99 # Create a Android Virtual Device named 'buildbot' with default hardware | |
| 100 # configuration and override the existing one, since there is no easy way to | |
| 101 # check whether current AVD has correct configuration and it takes almost no | |
| 102 # time to create a new one. | |
| 103 "${ANDROID_SDK_ROOT}"/tools/android --silent create avd --name buildbot \ | |
| 104 --target ${SDK_TARGET_ID} --force <<< "no" | |
| 105 | |
| 106 # Install Android NDK if it doesn't exist. | |
| 107 if [[ ! -d "${ANDROID_NDK_ROOT}" ]]; then | |
| 108 echo 'Install ANDROID NDK ...' | |
| 109 install_dev_kit "${NDK_FILE_NAME}" "${NDK_DOWNLOAD_URL}" "${NDK_MD5SUM}" \ | |
| 110 $(dirname "${ANDROID_NDK_ROOT}") | |
| 111 fi | |
| OLD | NEW |