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/installer-pc.sh') diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh index f9fd509..348838e 100644 --- a/src/cmd/installer-pc.sh +++ b/src/cmd/installer-pc.sh @@ -33,26 +33,28 @@ cmd_installer_pc_main() if ! get_options "${@}"; then print_cmd_usage 'installer-pc' >&2 - exit 1 + return 1 fi shift $(($OPTIND - 1)) if [ "x${cmd_installer_pc_opt_a-}" = 'x' ]; then print_cmd_usage 'installer-pc' >&2 - exit 1 + return 1 fi if [ "x${cmd_installer_pc_opt_p-}" = 'x' ]; then print_cmd_usage 'installer-pc' >&2 - exit 1 + return 1 fi if [ ${#} -ne 2 ]; then print_cmd_usage 'installer-pc' >&2 - exit 1 + return 1 fi suite="${1}" dev="${2}" - check_block "${dev}" + if ! check_block "${dev}"; then + return 2 + fi if [ "x${suite%%:*}" != "x${suite}" ]; then profile="${suite%%:*}" @@ -60,15 +62,23 @@ cmd_installer_pc_main() else profile='proteanos' fi - profile_set "${profile}" + if ! profile_set "${profile}"; then + return 2 + fi suite="$(profile_normalize_suite "${suite}")" cmd_installer_pc_make_partition_and_fs "${dev}" - root="$(block_mount "${dev}1")" + if ! root="$(block_mount "${dev}1")"; then + return 2 + fi - install_system "${cmd_installer_pc_opt_m-}" "${suite}" \ - "${cmd_installer_pc_opt_a-}" "${cmd_installer_pc_opt_p-}" \ - "${root}" false + if ! install_system "${cmd_installer_pc_opt_m-}" "${suite}" \ + "${cmd_installer_pc_opt_a-}" \ + "${cmd_installer_pc_opt_p-}" \ + "${root}" false; then + block_umount "${root}" + return 1 + fi if [ -f "${root}/sbin/lilo" ]; then read b4 b3 b2 b1 <<-EOF @@ -76,13 +86,18 @@ cmd_installer_pc_main() EOF # This ln command won't be needed once lilo 24.1-1 is uploaded. ln "${root}/boot/vmlinuz" "${root}/boot/vmlinuz.old" - session_begin "${root}" . : false + if ! session_begin "${root}" . : false + block_umount "${root}" + return 2 + fi session_exec install-lilo \ "${dev}" "PARTUUID=${b1}${b2}${b3}${b4}-01" session_end fi block_umount "${root}" + + return 0 } cmd_installer_pc_make_partition_and_fs() -- cgit v0.9.1