Beef up error handling (#886666)
diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh
index cb59b9a..7b95aab 100755
--- a/tools/get_uec_image.sh
+++ b/tools/get_uec_image.sh
@@ -14,6 +14,9 @@
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
+# exit on error to stop unexpected errors
+set -o errexit
+
usage() {
echo "Usage: $0 - Prepare Ubuntu images"
echo ""
@@ -44,6 +47,14 @@
trap 2; kill -2 $$
}
+# apt-get wrapper to just get arguments set correctly
+function apt_get() {
+ local sudo="sudo"
+ [ "$(id -u)" = "0" ] && sudo="env"
+ $sudo DEBIAN_FRONTEND=noninteractive apt-get \
+ --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
+}
+
while getopts f:hmr: c; do
case $c in
f) FORMAT=$OPTARG
@@ -107,7 +118,14 @@
;;
esac
-trap cleanup SIGHUP SIGINT SIGTERM
+trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT
+
+# Check for dependencies
+
+if [ ! -x "`which qemu-img`" -o ! -x "`which qemu-nbd`" ]; then
+ # Missing KVM?
+ apt_get install qemu-kvm
+fi
# Prepare the base image