OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 ############################################################################### | 2 ############################################################################### |
3 # Copyright 2015 Google Inc. | 3 # Copyright 2015 Google Inc. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
7 ############################################################################### | 7 ############################################################################### |
8 # | 8 # |
9 # android_setup.sh: Sets environment variables used by other Android scripts. | 9 # android_setup.sh: Sets environment variables used by other Android scripts. |
10 | 10 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 # adb_push_if_needed(host_src, android_dst) | 212 # adb_push_if_needed(host_src, android_dst) |
213 adb_push_if_needed() { | 213 adb_push_if_needed() { |
214 | 214 |
215 # get adb location | 215 # get adb location |
216 source $SCRIPT_DIR/utils/setup_adb.sh | 216 source $SCRIPT_DIR/utils/setup_adb.sh |
217 | 217 |
218 # read input params | 218 # read input params |
219 local HOST_SRC="$1" | 219 local HOST_SRC="$1" |
220 local ANDROID_DST="$2" | 220 local ANDROID_DST="$2" |
221 | 221 |
| 222 # disable crashing on failed commands since newer (N+) versions of Android |
| 223 # return an error when attempting to run ls on a directory or file that does |
| 224 # not exist. |
| 225 set +e |
| 226 |
222 ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` | 227 ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` |
223 HOST_LS=`ls -ld $HOST_SRC` | 228 HOST_LS=`ls -ld $HOST_SRC` |
224 if [ "${ANDROID_LS:0:1}" == "d" -a "${HOST_LS:0:1}" == "-" ]; | 229 if [ "${ANDROID_LS:0:1}" == "d" -a "${HOST_LS:0:1}" == "-" ]; |
225 then | 230 then |
226 ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})" | 231 ANDROID_DST="${ANDROID_DST}/$(basename ${HOST_SRC})" |
227 fi | 232 fi |
228 | 233 |
229 | 234 ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST 2> /dev/null` |
230 ANDROID_LS=`$ADB $DEVICE_SERIAL shell ls -ld $ANDROID_DST` | |
231 if [ "${ANDROID_LS:0:1}" == "-" ]; then | 235 if [ "${ANDROID_LS:0:1}" == "-" ]; then |
232 #get the MD5 for dst and src depending on OS and/or OS revision | 236 #get the MD5 for dst and src depending on OS and/or OS revision |
233 ANDROID_MD5_SUPPORT=`$ADB $DEVICE_SERIAL shell ls -ld /system/bin/md5` | 237 ANDROID_MD5_SUPPORT=`$ADB $DEVICE_SERIAL shell ls -ld /system/bin/md5 2> /de
v/null` |
234 if [ "${ANDROID_MD5_SUPPORT:0:15}" != "/system/bin/md5" ]; then | 238 if [ "${ANDROID_MD5_SUPPORT:0:1}" == "-" ]; then |
235 ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST` | 239 ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5 $ANDROID_DST` |
236 else | 240 else |
237 ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5sum $ANDROID_DST` | 241 ANDROID_MD5=`$ADB $DEVICE_SERIAL shell md5sum $ANDROID_DST` |
238 fi | 242 fi |
239 | 243 |
240 if [ $(uname) == "Darwin" ]; then | 244 if [ $(uname) == "Darwin" ]; then |
241 HOST_MD5=`md5 -q $HOST_SRC` | 245 HOST_MD5=`md5 -q $HOST_SRC` |
242 else | 246 else |
243 HOST_MD5=`md5sum $HOST_SRC` | 247 HOST_MD5=`md5sum $HOST_SRC` |
244 fi | 248 fi |
(...skipping 10 matching lines...) Expand all Loading... |
255 HOST_LS=`ls -ld $HOST_SRC` | 259 HOST_LS=`ls -ld $HOST_SRC` |
256 if [ "${HOST_LS:0:1}" == "d" ]; then | 260 if [ "${HOST_LS:0:1}" == "d" ]; then |
257 $ADB $DEVICE_SERIAL shell mkdir -p $ANDROID_DST | 261 $ADB $DEVICE_SERIAL shell mkdir -p $ANDROID_DST |
258 adb_push_if_needed $HOST_SRC $ANDROID_DST | 262 adb_push_if_needed $HOST_SRC $ANDROID_DST |
259 else | 263 else |
260 echo -n "$ANDROID_DST " | 264 echo -n "$ANDROID_DST " |
261 $ADB $DEVICE_SERIAL shell mkdir -p "$(dirname "$ANDROID_DST")" | 265 $ADB $DEVICE_SERIAL shell mkdir -p "$(dirname "$ANDROID_DST")" |
262 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST | 266 $ADB $DEVICE_SERIAL push $HOST_SRC $ANDROID_DST |
263 fi | 267 fi |
264 fi | 268 fi |
| 269 |
| 270 # turn error checking back on |
| 271 set -e |
265 } | 272 } |
266 | 273 |
267 setup_device "${DEVICE_ID}" | 274 setup_device "${DEVICE_ID}" |
OLD | NEW |