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