summaryrefslogtreecommitdiffstats
path: root/src/cmd/opkg.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/opkg.sh
parentd5e46c35ea98e43b6ad380ac7fbc197b7881b220 (diff)
parente3ab87a78aafd979f6eb8bb75ef70304d87a1d6b (diff)
Merge branch 'feature/improve-error-handling'
Diffstat (limited to 'src/cmd/opkg.sh')
-rw-r--r--src/cmd/opkg.sh19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/cmd/opkg.sh b/src/cmd/opkg.sh
index 5a48fb8..b99a977 100644
--- a/src/cmd/opkg.sh
+++ b/src/cmd/opkg.sh
@@ -31,7 +31,7 @@ cmd_opkg_main()
if [ ${#} -lt 1 ]; then
print_cmd_usage 'opkg' >&2
- exit 1
+ return 1
fi
root="${1}"
@@ -40,7 +40,9 @@ cmd_opkg_main()
dev=''
if is_block "${root}"; then
dev="${root}"
- root="$(block_mount "${dev}")"
+ if ! root="$(block_mount "${dev}")"; then
+ return 2
+ fi
fi
first_arg=true
@@ -78,9 +80,16 @@ 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
+ if ! session_begin "${root}" . cmd_opkg_fini false; then
+ cmd_opkg_fini
+ [ "x${dev}" != 'x' ] && block_umount "${root}"
+ return 2
+ fi
session_exec opkg "${@}"
@@ -88,6 +97,8 @@ cmd_opkg_main()
session_end
[ "x${dev}" != 'x' ] && block_umount "${root}"
+
+ return 0
}
cmd_opkg_fini()