aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-06-09 11:39:35 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-09 16:45:09 -0700
commitf78d29852eafba827b6c95783049a28d308e86da (patch)
tree86149d4a99b0d4c73a91c206e34aeb075b8cdca7 /binary_search_tool
parent7f3c25952c446585241f1e37a61ca61535b1197c (diff)
downloadtoolchain-utils-f78d29852eafba827b6c95783049a28d308e86da.tar.gz
Add default install script to cros_pkg
Provide install script to package bisecting tool. This script handles failed flash by prompting user to flash via usb or resetting the Chromebook. Test=A few iterations of bisecting tool run. Successfully install after initial failed flash. Change-Id: I161c697a87e87cb66ce5a2efc152505d8a2a5b8e Reviewed-on: https://chrome-internal-review.googlesource.com/263915 Commit-Ready: Cassidy Burden <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool')
-rw-r--r--binary_search_tool/cros_pkg/README.cros_pkg_triage11
-rwxr-xr-xbinary_search_tool/cros_pkg/cros_pkg_boot_test.sh34
-rwxr-xr-xbinary_search_tool/cros_pkg/cros_pkg_install.sh105
-rwxr-xr-xbinary_search_tool/cros_pkg/cros_pkg_interactive_test.sh40
4 files changed, 128 insertions, 62 deletions
diff --git a/binary_search_tool/cros_pkg/README.cros_pkg_triage b/binary_search_tool/cros_pkg/README.cros_pkg_triage
index bc050b27..78715b59 100644
--- a/binary_search_tool/cros_pkg/README.cros_pkg_triage
+++ b/binary_search_tool/cros_pkg/README.cros_pkg_triage
@@ -36,6 +36,7 @@ following:
--get_initial_items=cros_pkg_get_initial_items.sh \
--switch_to_good=cros_pkg_switch_to_good.sh \
--switch_to_bad=cros_pkg_switch_to_bad.sh \
+ --install_script=cros_pkg_install.sh \
--test_script=cros_pkg_boot_test.sh \
--file_args \
--prune
@@ -46,6 +47,7 @@ following:
--get_initial_items=cros_pkg_get_initial_items.sh \
--switch_to_good=cros_pkg_switch_to_good.sh \
--switch_to_bad=cros_pkg_switch_to_bad.sh \
+ --install_script=cros_pkg_install.sh \
--test_script=cros_pkg_interactive_test.sh \
--file_args \
--prune
@@ -76,6 +78,11 @@ FILES AND SCRIPTS:
cros_pkg_get_initial_items.sh - This script is used to determine the current
set of ChromeOS packages.
+ cros_pkg_install.sh - This script will build and flash your image to the
+ remote machine. If the flash fails, this script will
+ help the user troubleshoot by flashing through usb or
+ by retrying the flash over ethernet.
+
cros_pkg_interactive_test.sh - One of two possible scripts used to determine
if the ChromeOS image built from the packages
is good or bad. This script requires user
@@ -153,8 +160,7 @@ testing your chromeos images. cros_pkg_setup.sh will do the following:
various changes that cros_pkg_setup.sh did.
-This set of scripts comes with two alternate test scripts. Both test
-scripts build the image and push it onto the Chromebook. One test
+This set of scripts comes with two alternate test scripts. One test
script, cros_pkg_boot_test.sh, just checks to make sure that the image
booted (i.e. responds to ping) and assumes that is enough. The other
test script, cros_pkg_interactive_test.sh, is interactive and asks YOU
@@ -170,6 +176,7 @@ isolate/identify the bad package:
--get_initial_items=cros_pkg_get_initial_items.sh \
--switch_to_good=cros_pkg_switch_to_good.sh \
--switch_to_bad=cros_pkg_switch_to_bad.sh \
+ --install_script=cros_pkg_install.sh \
--test_script=cros_pkg_boots_test.sh \ # could use cros_pkg_interactive_test.sh instead
--prune
diff --git a/binary_search_tool/cros_pkg/cros_pkg_boot_test.sh b/binary_search_tool/cros_pkg/cros_pkg_boot_test.sh
index 55672c57..e95745eb 100755
--- a/binary_search_tool/cros_pkg/cros_pkg_boot_test.sh
+++ b/binary_search_tool/cros_pkg/cros_pkg_boot_test.sh
@@ -2,40 +2,18 @@
#
# Copyright 2015 Google Inc. All Rights Reserved.
#
-# This script calls build_image to generate a new ChromeOS image,
-# using whatever packages are currently in the build tree. If
-# build_images succeeeds, then it pushes the new ChromeOS image onto a
-# chromebook, then pings the chromebook to determine if it
-# successfully booted.
+# This script pings the chromebook to determine if it has successfully booted.
#
# This script is intended to be used by binary_search_state.py, as
-# part of the binary search triage on ChromeOS packages. It should
-# return '0' if the test succeeds (the image booted); '1' if the test
-# fails (the image did not boot); and '2' if it could not determine
-# (i.e. in this case, the image did not build).
+# part of the binary search triage on ChromeOS packages. It waits for the
+# install script to build and install the image, then pings the machine.
+# It should return '0' if the test succeeds (the image booted); '1' if the test
+# fails (the image did not boot); and '2' if it could not determine (does not
+# apply in this case).
#
source cros_pkg_common.sh
-pushd ~/trunk/src/scripts
-./build_image test --noeclean --board=${BOARD} --noenable_rootfs_verification
-build_status=$?
-popd
-
-if [[ ${build_status} -eq 0 ]] ; then
- echo "Pushing built image onto device."
- echo "cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin"
- cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
- cros_flash_status=$?
- if [[ ${cros_flash_status} -ne 0 ]] ; then
- echo "cros flash failed!!"
- exit 2
- fi
-else
- echo "build_image returned a non-zero status: ${build_status}"
- exit 2
-fi
-
# Send 3 pings and wait 3 seconds for any responsed (then timeout).
ping -c 3 -W 3 ${REMOTE}
retval=$?
diff --git a/binary_search_tool/cros_pkg/cros_pkg_install.sh b/binary_search_tool/cros_pkg/cros_pkg_install.sh
new file mode 100755
index 00000000..ac42d152
--- /dev/null
+++ b/binary_search_tool/cros_pkg/cros_pkg_install.sh
@@ -0,0 +1,105 @@
+#!/bin/bash -u
+#
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# This script calls build_image to generate a new ChromeOS image,
+# using whatever packages are currently in the build tree. If
+# build_images succeeeds, then it pushes the new ChromeOS image onto a
+# chromebook. If pushing the ChromeOS image onto the chromebook fails it
+# will walk the user through troubleshooting the problem.
+#
+# This script is intended to be used by binary_search_state.py, as
+# part of the binary search triage on ChromeOS packages. It should return '0'
+# if the install succeeds; and '1' if the install fails (the image could not
+# build or be flashed).
+#
+
+export PYTHONUNBUFFERED=1
+
+source cros_pkg_common.sh
+
+usb_flash()
+{
+ echo
+ echo "Insert a usb stick into the current machine"
+ echo "Note: The cros flash will take time and doesn't given much output."
+ echo " Be patient. If your usb access light is flashing it's working."
+ sleep 1
+ read -p "Press enter to continue" notused
+
+ cros flash --board=${BOARD} --clobber-stateful usb:// ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
+
+ echo
+ echo "Flash to usb complete!"
+ echo "Plug the usb into your chromebook and install the image."
+ echo "Refer to the ChromiumOS Developer's Handbook for more details."
+ echo "http://www.chromium.org/chromium-os/developer-guide#TOC-Boot-from-your-USB-disk"
+ while true; do
+ sleep 1
+ read -p "Was the installation of the image successful? " choice
+ case $choice in
+ [Yy]*) return 0;;
+ [Nn]*) return 1;;
+ *) echo "Please answer y or n.";;
+ esac
+ done
+}
+
+ethernet_flash()
+{
+ echo
+ echo "Please ensure your Chromebook is up and running Chrome so"
+ echo "cros flash may run."
+ echo "If your Chromebook has a broken image you can try:"
+ echo "1. Rebooting your Chromebook 6 times to install the last working image"
+ echo "2. Alternatively, running the following command on the Chromebook"
+ echo " will also rollback to the last working image:"
+ echo " 'update_engine_client --rollback --nopowerwash --reboot'"
+ echo "3. Flashing a new image through USB"
+ echo
+ sleep 1
+ read -p $'Press enter to continue and retry the ethernet flash' notused
+ cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
+}
+
+echo
+echo "INSTALLATION BEGIN"
+echo
+echo "BUILDING"
+pushd ~/trunk/src/scripts
+./build_image test --noeclean --board=${BOARD} --noenable_rootfs_verification
+build_status=$?
+popd
+
+if [[ ${build_status} -eq 0 ]] ; then
+ echo
+ echo "FLASHING"
+ echo "Pushing built image onto device."
+ echo "cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin"
+ cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
+ cros_flash_status=$?
+ while [[ ${cros_flash_status} -ne 0 ]] ; do
+ while true; do
+ echo
+ echo "cros flash has failed! From here you can:"
+ echo "1. Flash through USB"
+ echo "2. Retry flashing over ethernet"
+ 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) usb_flash && break;;
+ 2) ethernet_flash && break;;
+ 3) exit 1;;
+ *) echo "Please answer 1, 2, or 3.";;
+ esac
+ done
+
+ cros_flash_status=$?
+ done
+else
+ echo "build_image returned a non-zero status: ${build_status}"
+ exit 1
+fi
+
+exit 0
diff --git a/binary_search_tool/cros_pkg/cros_pkg_interactive_test.sh b/binary_search_tool/cros_pkg/cros_pkg_interactive_test.sh
index ef7c6872..5aa19f44 100755
--- a/binary_search_tool/cros_pkg/cros_pkg_interactive_test.sh
+++ b/binary_search_tool/cros_pkg/cros_pkg_interactive_test.sh
@@ -2,44 +2,20 @@
#
# Copyright 2015 Google Inc. All Rights Reserved.
#
-# This script calls build_image to generate a new ChromeOS image,
-# using whatever packages are currently in the build tree. If
-# build_images succeeeds, then it pushes the new ChromeOS image onto a
-# chromebook, then pings the chromebook to determine if it
-# successfully booted. It then asks the user if the image is good or not,
-# allowing the user to conduct whatever tests the user wishes, and waiting
-# for a response.
+# This script pings the chromebook to determine if it successfully booted.
+# It then asks the user if the image is good or not, allowing the user to
+# conduct whatever tests the user wishes, and waiting for a response.
#
# This script is intended to be used by binary_search_state.py, as
-# part of the binary search triage on ChromeOS packages. It should
-# return '0' if the test succeeds (the image is 'good'); '1' if the test
-# fails (the image is 'bad'); and '2' if it could not determine
-# (i.e. in this case, the image did not build).
+# part of the binary search triage on ChromeOS packages. It waits for the
+# install script to build and install the image, then asks the user if the
+# image is good or not. It should return '0' if the test succeeds (the image
+# is 'good'); '1' if the test fails (the image is 'bad'); and '2' if it could
+# not determine (does not apply in this case).
#
source cros_pkg_common.sh
-pushd ~/trunk/src/scripts
-./build_image test --noeclean --board=${BOARD} --noenable_rootfs_verification
-build_status=$?
-popd
-
-
-if [[ ${build_status} -eq 0 ]] ; then
- echo "Pushing built image onto device."
- echo "cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin"
- cros flash --board=${BOARD} --clobber-stateful ${REMOTE} ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin
- cros_flash_status=$?
- if [[ ${cros_flash_status} -ne 0 ]] ; then
- echo "cros flash failed!!"
- exit 2
- fi
-else
- echo "build_image returned a non-zero status: ${build_status}"
- exit 2
-fi
-
-# Send 3 pings and wait 3 seconds for any responsed (then timeout).
ping -c 3 -W 3 ${REMOTE}
retval=$?