summaryrefslogtreecommitdiffstats
path: root/src/cmd/build.sh
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2016-01-17 16:10:31 (EST)
committer P. J. McDermott <pj@pehjota.net>2016-01-17 16:10:31 (EST)
commit09c583248e7c0aa5a833ec01262b8b4a7980234b (patch)
treee3ecd4028e888d6eb587d9703ace4d90396a624a /src/cmd/build.sh
parentd5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff)
parente3ab87a78aafd979f6eb8bb75ef70304d87a1d6b (diff)
Merge branch 'feature/improve-error-handling'
Diffstat (limited to 'src/cmd/build.sh')
-rw-r--r--src/cmd/build.sh30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/cmd/build.sh b/src/cmd/build.sh
index dbfd910..1d0ad52 100644
--- a/src/cmd/build.sh
+++ b/src/cmd/build.sh
@@ -34,7 +34,7 @@ cmd_build_main()
if [ ${#} -lt 2 ]; then
print_cmd_usage 'build' >&2
- exit 1
+ return 1
fi
root="${1}"
@@ -43,7 +43,9 @@ cmd_build_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
cmd_build_root="${root}"
@@ -70,16 +72,28 @@ 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 2 "$(get_msg 'cmd_build_not_a_dir')" \
- "${cmd_build_pkg_dir}"
+ error "$(get_msg 'cmd_build_not_a_dir')" "${cmd_build_pkg_dir}"
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
+ if ! package_init "${cmd_build_pkg_dir}"; then
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
fi
- package_init "${cmd_build_pkg_dir}"
package_set_substvars "${arch}" "${plat}"
- session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false
+ if ! session_begin "${root}" "${cmd_build_pkg_dir}" cmd_build_fini false
+ then
+ cmd_build_fini
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
cmd_build_build_deps="$(package_get_build_deps "${arch}" "${plat}")"
if [ "x${cmd_build_build_deps}" != 'x' ]; then
@@ -94,6 +108,8 @@ cmd_build_main()
session_end
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_build_make_deps_pkg()