Improve error detection and handling in make_factory_toolkit.sh
Check that the output directory exists and that a board has been specified.
Previously the script mysteriously aborted when cd failed, and an unspecified
board was just treated as empty.
TEST=manual
BUG=none
Change-Id: I8843bbe0200e6a1293fa116d04cf3ece459a929f
Reviewed-on: https://chromium-review.googlesource.com/202610
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: <pca@chromium.org>
Tested-by: <pca@chromium.org>
diff --git a/make_factory_toolkit.sh b/make_factory_toolkit.sh
index 4fafc04..3fc56e1 100755
--- a/make_factory_toolkit.sh
+++ b/make_factory_toolkit.sh
@@ -33,12 +33,24 @@
trap cleanup EXIT
+ # Must specify a board
+ if [[ -z "${FLAGS_board}" ]]; then
+ die "No board specified. Use the --board option."
+ fi
+
local default_dir="${CHROOT_TRUNK_DIR}/src/build/images/${FLAGS_board}/latest"
if [[ -n "${FLAGS_output_dir}" ]]; then
local output_dir="${FLAGS_output_dir}"
else
local output_dir="${default_dir}"
fi
+
+ echo "Building into directory ${output_dir}"
+ if [[ ! -d "${output_dir}" ]]; then
+ die \
+ "Output directory '${output_dir}' does not exist." \
+ "Check the --board or --output_dir options and that the image is built."
+ fi
cd "${output_dir}"
temp_pack_root="$(mktemp -d toolkit_XXXXXX)"