aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-07-27 09:44:27 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-28 10:48:16 -0700
commitd0c2d0dcecaa61a4a4d5e8d2612a8fbb457bad34 (patch)
tree53d9817def7dfdbab13c6beca24fabf615db1763 /binary_search_tool
parent2711ac8d32ff2d03a16eeef65952e3c1a1e60fd0 (diff)
downloadtoolchain-utils-d0c2d0dcecaa61a4a4d5e8d2612a8fbb457bad34.tar.gz
binary search tool: Add android install script
Add install script for android bisector. This script will build android and attempt to flash the newly built image. If flashing fails, the install script will ask the user for help. TEST=Tested each code path Change-Id: I89845edd8a2bafedc9e6cabffe7bf92f2f48bc0d Reviewed-on: https://chrome-internal-review.googlesource.com/271482 Commit-Ready: Cassidy Burden <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Caroline Tice <cmtice@google.com> Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'binary_search_tool')
-rwxr-xr-xbinary_search_tool/android/install.sh128
1 files changed, 128 insertions, 0 deletions
diff --git a/binary_search_tool/android/install.sh b/binary_search_tool/android/install.sh
new file mode 100755
index 00000000..56683e89
--- /dev/null
+++ b/binary_search_tool/android/install.sh
@@ -0,0 +1,128 @@
+#!/bin/bash
+#
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# This is the install script for generating an Android image based off the
+# current working build tree. make is called to relink the object files and
+# generate the new Android image to be flashed. The device is then rebooted into
+# bootloader mode and fastboot is used to flash the new image. The device is
+# then rebooted so the user's test script can run.
+#
+# This script is intended to be used by binary_search_state.py, as
+# part of the binary search triage on the Android source tree. It should
+# return '0' if the install succeeds; and '1' if the install fails (the image
+# could not build or be flashed).
+#
+
+source android/common.sh
+
+manual_flash()
+{
+ echo
+ echo "Please manually flash the built image to your device."
+ echo "To do so follow these steps:"
+ echo " 1. Boot your device into fastboot mode."
+ echo " 2. cd to '${BISECT_ANDROID_SRC}'"
+ echo " 2. Run 'source build/envsetup.sh'"
+ echo " 3. Run 'lunch'"
+ echo " 4. Run '${ADB_DEVICE}fastboot flashall -w'"
+ echo "Or see the following link for more in depth steps:"
+ echo "https://source.android.com/source/running.html"
+ echo
+ while true; do
+ sleep 1
+ read -p "Was the flashing of the image successful? " choice
+ case $choice in
+ [Yy]*) return 0;;
+ [Nn]*) return 1;;
+ *) echo "Please answer y or n.";;
+ esac
+ done
+}
+
+auto_flash()
+{
+ echo
+ echo "Please ensure your Android device is on and in fastboot mode so"
+ echo "fastboot flash may run."
+ echo
+ sleep 1
+ read -p $'Press enter to continue and retry the flashing' notused
+
+ " ${ADB_DEVICE}fastboot flashall -w"
+ fastboot flashall -w
+}
+
+flash()
+{
+ echo
+ echo "FLASHING"
+ echo "Rebooting device into fastboot mode."
+ echo " ${ADB_DEVICE}adb reboot-bootloader"
+ adb reboot-bootloader
+
+ echo
+ echo "Waiting for device to reach fastboot mode."
+ echo "(will timeout after 60 seconds)"
+ # fastboot will block indefinitely until device comes online.
+ # Grab random variable to test if device is online.
+ # If takes >60s then we error out and ask the user for help.
+ timeout 60 fastboot getvar 0 2>/dev/null
+ fastboot_flash_status=$?
+
+ if [[ ${fastboot_flash_status} -eq 0 ]]; then
+ echo
+ echo "Flashing image."
+ echo " ${ADB_DEVICE}fastboot flashall -w"
+ fastboot flashall -w
+ fastboot_flash_status=$?
+ fi
+
+ while [[ ${fastboot_flash_status} -ne 0 ]] ; do
+ echo
+ echo "fastboot flash has failed! From here you can:"
+ echo "1. Debug and/or flash manually"
+ echo "2. Retry flashing automatically"
+ echo "3. Abort this installation and skip this image"
+ sleep 1
+ read -p "Which method would you like to do? " choice
+ case $choice in
+ 1) manual_flash && break;;
+ 2) auto_flash && break;;
+ 3) return 1;;
+ *) echo "Please answer 1, 2, or 3.";;
+ esac
+ done
+}
+
+# Number of jobs make will use. Can be customized and played with.
+MAKE_JOBS=${BISECT_NUM_JOBS}
+
+# Set ADB_DEVICE to "ANDROID_SERIAL=${ANDROID_SERIAL}" or "" if device id not
+# set. This is used for debugging info so users can confirm which device
+# commands are being sent to.
+ADB_DEVICE=${ANDROID_SERIAL:+"ANDROID_SERIAL=${ANDROID_SERIAL} "}
+
+echo
+echo "INSTALLATION BEGIN"
+echo
+
+cd ${BISECT_ANDROID_SRC}
+
+echo "BUILDING IMAGE"
+
+make -j ${MAKE_JOBS}
+make_status=$?
+
+exit_val=0
+if [[ ${make_status} -eq 0 ]]; then
+ flash
+ exit_val=$?
+else
+ echo "ERROR:"
+ echo "make returned a non-zero status: ${make_status}. Skipping image..."
+ exit_val=1
+fi
+
+
+exit ${exit_val}