OLD | NEW |
---|---|
1 #!/bin/bash | 1 # Copyright 2015 Google Inc. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
3 | 5 |
4 UTIL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | 6 UTIL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
5 | 7 |
6 if [ "$(which adb)" != "" ]; then | 8 if [ "$(which adb)" != "" ]; then |
7 ADB="$(which adb)" | 9 ADB="$(which adb)" |
8 elif [ -d "$ANDROID_SDK_ROOT" ]; then | 10 elif [ -d "$ANDROID_SDK_ROOT" ]; then |
9 ADB="${ANDROID_SDK_ROOT}/platform-tools/adb" | 11 ADB="${ANDROID_SDK_ROOT}/platform-tools/adb" |
10 else | 12 else |
11 echo $ANDROID_SDK_ROOT | 13 echo $ANDROID_SDK_ROOT |
12 echo "No ANDROID_SDK_ROOT set (check that android_setup.sh was properly source d)" | 14 echo "No ANDROID_SDK_ROOT set (check that android_setup.sh was properly source d)" |
13 exit 1 | 15 exit 1 |
14 fi | 16 fi |
15 | 17 |
16 if [ ! -x $ADB ]; then | 18 if [ ! -x $ADB ]; then |
17 echo "The adb binary is not executable" | 19 echo "The adb binary is not executable" |
18 exit 1 | 20 exit 1 |
19 fi | 21 fi |
20 | 22 |
21 if [ $(uname) == "Linux" ]; then | 23 if [ $(uname) == "Linux" ]; then |
22 ADB_REQUIRED="1.0.32" | 24 ADB_REQUIRED="1.0.32" |
23 elif [ $(uname) == "Darwin" ]; then | 25 elif [ $(uname) == "Darwin" ]; then |
24 ADB_REQUIRED="1.0.31 or 1.0.32" | 26 ADB_REQUIRED="1.0.31 or 1.0.32" |
25 fi | 27 fi |
26 | 28 |
27 # get the version and then truncate it to be just the version numbers | 29 # get the version string as an array, use just the version numbers |
28 ADB_VERSION="$($ADB version)" | 30 ADB_VERSION="$($ADB version)" |
29 ADB_VERSION="${ADB_VERSION##* }" | 31 ADB_VERSION=($ADB_VERSION) |
32 ADB_VERSION=${ADB_VERSION[4]} | |
djsollen
2016/01/13 14:32:04
I think this will break backwards compatibility fo
Kimmo Kinnunen
2016/01/13 15:19:50
The intention is exactly getting the 5th element.
| |
30 | 33 |
31 if [[ "$ADB_REQUIRED" != *"$ADB_VERSION"* ]]; then | 34 if [[ "$ADB_REQUIRED" != *"$ADB_VERSION"* ]]; then |
32 echo "WARNING: Your ADB version is out of date!" | 35 echo "WARNING: Your ADB version is out of date!" |
33 echo " Expected ADB Version: ${ADB_REQUIRED}" | 36 echo " Expected ADB Version: ${ADB_REQUIRED}" |
34 echo " Actual ADB Version: ${ADB_VERSION}" | 37 echo " Actual ADB Version: ${ADB_VERSION}" |
35 fi | 38 fi |
OLD | NEW |