Skip to content

Commit 43392f7

Browse files
author
Dean Troyer
committed
Beef up error handling (#886666)
1 parent 49946a1 commit 43392f7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tools/get_uec_image.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
1414
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
1515
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
1616

17+
# exit on error to stop unexpected errors
18+
set -o errexit
19+
1720
usage() {
1821
echo "Usage: $0 - Prepare Ubuntu images"
1922
echo ""
@@ -44,6 +47,14 @@ cleanup() {
4447
trap 2; kill -2 $$
4548
}
4649

50+
# apt-get wrapper to just get arguments set correctly
51+
function apt_get() {
52+
local sudo="sudo"
53+
[ "$(id -u)" = "0" ] && sudo="env"
54+
$sudo DEBIAN_FRONTEND=noninteractive apt-get \
55+
--option "Dpkg::Options::=--force-confold" --assume-yes "$@"
56+
}
57+
4758
while getopts f:hmr: c; do
4859
case $c in
4960
f) FORMAT=$OPTARG
@@ -107,7 +118,14 @@ case $DIST_NAME in
107118
;;
108119
esac
109120

110-
trap cleanup SIGHUP SIGINT SIGTERM
121+
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT
122+
123+
# Check for dependencies
124+
125+
if [ ! -x "`which qemu-img`" -o ! -x "`which qemu-nbd`" ]; then
126+
# Missing KVM?
127+
apt_get install qemu-kvm
128+
fi
111129

112130
# Prepare the base image
113131

0 commit comments

Comments
 (0)