Merge pull request #166 from cloudbuilders/get_uec_image
Beef up error handling (#886666)
This commit is contained in:
commit
f0f1f69d1e
@ -14,6 +14,9 @@ MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
|
||||
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 @@ cleanup() {
|
||||
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 @@ case $DIST_NAME in
|
||||
;;
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user