From 09c583248e7c0aa5a833ec01262b8b4a7980234b Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 17 Jan 2016 16:10:31 -0500 Subject: Merge branch 'feature/improve-error-handling' --- (limited to 'src/cmd/install.sh') diff --git a/src/cmd/install.sh b/src/cmd/install.sh index ae26588..d32f488 100644 --- a/src/cmd/install.sh +++ b/src/cmd/install.sh @@ -30,13 +30,13 @@ cmd_install_main() if ! get_options "${@}"; then print_cmd_usage 'install' >&2 - exit 1 + return 1 fi shift $(($OPTIND - 1)) if [ ${#} -lt 2 ]; then print_cmd_usage 'install' >&2 - exit 1 + return 1 fi # TODO: Consider making suite optional, getting a default suite from the @@ -50,7 +50,9 @@ cmd_install_main() else profile='proteanos' fi - profile_set "${profile}" + if ! profile_set "${profile}"; then + return 2 + fi suite="$(profile_normalize_suite "${suite}")" if [ "x${cmd_install_opt_F+set}" = 'xset' ]; then @@ -62,14 +64,21 @@ cmd_install_main() dev='' if is_block "${root}"; then dev="${root}" - root="$(block_mount "${dev}")" + if ! root="$(block_mount "${dev}")"; then + return 2 + fi fi - install_system "${cmd_install_opt_m-}" "${suite}" \ - "${cmd_install_opt_a-}" "${cmd_install_opt_p-}" \ - "${root}" "${foreign}" + if ! install_system "${cmd_install_opt_m-}" "${suite}" \ + "${cmd_install_opt_a-}" "${cmd_install_opt_p-}" \ + "${root}" "${foreign}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 1 + fi [ "x${dev}" != 'x' ] && block_umount "${root}" + + return 0 } cmd_install_register() -- cgit v0.9.1