Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: build/install-build-deps-android.sh

Issue 8144012: Upstream: The script to install Android SDK, NDK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
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 set -e
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 temporary directory used to store the downloaded file.
35 TEMPDIR=$(mktemp -d)
36 cleanup() {
37 local status=${?}
38 trap - EXIT
39 rm -rf "${TEMPDIR}"
40 exit ${status}
41 }
42 trap cleanup EXIT
43
44 ##########################################################
45 # Download and install a tgz package by wget and tar -xvf.
46 # The current directory is changed in this function.
47 # Arguments:
48 # local_file_name, the name of downloaded file.
49 # download_url, the url to download the package.
50 # md5, the package's md5 which could be found in download page.
51 # install_path, where the package should be installed.
52 # Returns:
53 # None
54 ##########################################################
55 install_dev_kit() {
56 local local_file_name="${1}"
57 local download_url="${2}"
58 local md5="${3}"
59 local install_path="${4}"
60
61 cd "${TEMPDIR}"
62 wget "${download_url}"
63
64 local computed_md5=$(md5sum "${local_file_name}" | cut -d' ' -f1)
65 if [[ "${computed_md5}" != "${md5}" ]]; then
66 echo "Downloaded ${local_file_name} has bad md5sum, which is expected" >& 2
67 echo "to be ${md5} but was ${computed_md5}" >& 2
68 exit 1
69 fi
70
71 echo "Install ${local_file_name}"
72 mv "${local_file_name}" "${install_path}"
73 cd "${install_path}"
74 tar -xvf "${local_file_name}"
75 }
76
77 if [[ -z "${ANDROID_SDK_ROOT}" ]]; then
78 echo "Please set ANDROID_SDK_ROOT to where they should installed to." >& 2
79 echo "For example: /usr/local/android-sdk-linux_x86" >& 2
80 exit 1
81 fi
82
83 if [[ -z "${ANDROID_NDK_ROOT}" ]]; then
84 echo "Please set ANDROID_NDK_ROOT to where they should installed to." >& 2
85 echo "For example: /usr/local/android-ndk-r6b" >& 2
86 exit 1
87 fi
88
89 # Install Android SDK if it doesn't exist.
90 if [[ ! -d "${ANDROID_SDK_ROOT}" ]]; then
91 echo 'Install ANDROID SDK ...'
92 (install_dev_kit "${SDK_FILE_NAME}" "${SDK_DOWNLOAD_URL}" "${SDK_MD5SUM}" \
93 $(dirname "${ANDROID_SDK_ROOT}"))
94 fi
95
96 # Install the target if it doesn't exist. The package installed above contains
97 # no platform, platform-tool or tool, all those should be installed by
98 # ${ANDROID_SDK_ROOT}/tools/android.
99 if [[ ! $("${ANDROID_SDK_ROOT}/tools/android" list targets \
100 | grep -q "${SDK_TARGET_ID}") ]]; then
101 # Updates the SDK by installing the necessary components.
102 # From current configuration, all android platforms will be installed.
103 # This will take a little bit long time.
104 echo "Install platform, platform-tool and tool ..."
105 "${ANDROID_SDK_ROOT}"/tools/android update sdk --no-ui \
106 --filter platform,platform-tool,tool
107 fi
108
109 # Create a Android Virtual Device named 'buildbot' with default hardware
110 # configuration and override the existing one, since there is no easy way to
111 # check whether current AVD has correct configuration and it takes almost no
112 # time to create a new one.
113 "${ANDROID_SDK_ROOT}/tools/android" --silent create avd --name buildbot \
114 --target ${SDK_TARGET_ID} --force <<< "no"
115
116 # Install Android NDK if it doesn't exist.
117 if [[ ! -d "${ANDROID_NDK_ROOT}" ]]; then
118 echo 'Install ANDROID NDK ...'
119 (install_dev_kit "${NDK_FILE_NAME}" "${NDK_DOWNLOAD_URL}" "${NDK_MD5SUM}" \
120 $(dirname "${ANDROID_NDK_ROOT}"))
121 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698