From a8e57bde8d2d9ba23a8c5fc7ddc6438c0142d33f Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 17 Jan 2016 10:34:56 -0500 Subject: cmd/*: Check return value of profile_detect() Also clean up on error now. --- diff --git a/src/cmd/build.sh b/src/cmd/build.sh index d48742e..5151c46 100644 --- a/src/cmd/build.sh +++ b/src/cmd/build.sh @@ -70,7 +70,10 @@ cmd_build_main() cmd_build_pkg_dir="${arg}" done - profile_detect "${root}" + if ! profile_detect "${root}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi if ! [ -d "${cmd_build_pkg_dir}" ]; then error "$(get_msg 'cmd_build_not_a_dir')" "${cmd_build_pkg_dir}" diff --git a/src/cmd/mkinitramfs.sh b/src/cmd/mkinitramfs.sh index d319f3d..e888548 100644 --- a/src/cmd/mkinitramfs.sh +++ b/src/cmd/mkinitramfs.sh @@ -57,7 +57,10 @@ cmd_mkinitramfs_main() root="$(block_mount "${dev}")" fi - profile_detect "${root}" + if ! profile_detect "${root}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi arch="$(cat "${root}/etc/proteanos_arch")" plat="$(cat "${root}/etc/proteanos_plat")" diff --git a/src/cmd/opkg.sh b/src/cmd/opkg.sh index 712baab..cb592c9 100644 --- a/src/cmd/opkg.sh +++ b/src/cmd/opkg.sh @@ -78,7 +78,10 @@ cmd_opkg_main() fi done - profile_detect "${root}" + if ! profile_detect "${root}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi session_begin "${root}" . cmd_opkg_fini false diff --git a/src/cmd/shell.sh b/src/cmd/shell.sh index 578e5d1..d964ec5 100644 --- a/src/cmd/shell.sh +++ b/src/cmd/shell.sh @@ -37,7 +37,10 @@ cmd_shell_main() root="$(block_mount "${dev}")" fi - profile_detect "${root}" + if ! profile_detect "${root}"; then + [ "x${dev}" != 'x' ] && block_umount "${root}" + return 2 + fi session_begin "${root}" . : false if [ ${#} -eq 0 ]; then -- cgit v0.9.1