summaryrefslogtreecommitdiffstats
path: root/src/cmd/opkg.sh
diff options
context:
space:
mode:
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()