Merge "Allow users to override output format in create-training-box.sh"

This commit is contained in:
Zuul 2018-08-31 14:48:33 +00:00 committed by Gerrit Code Review
commit d438cb0811
1 changed files with 21 additions and 10 deletions

View File

@ -2,22 +2,33 @@
set -e
VMDK=upstream-training-disk001.vmdk
# Create a VMDK image by default. Override with
# "create-training-box.sh <FORMAT>", where FORMAT can be any format
# that qemu-img understands.
FORMAT=${1:-vmdk}
DISK=upstream-training-disk001.$FORMAT
export ELEMENTS_PATH=./elements/
mkdir -p tmp
DIB_OPTIONS="-o tmp/$DISK -t $FORMAT --image-size 40"
if [ "$FORMAT" = "vmdk" ]; then
DIB_OPTIONS="$DIB_OPTIONS --qemu-img-options subformat=streamOptimized"
fi
disk-image-create \
-o "tmp/$VMDK" \
-t vmdk \
--qemu-img-options subformat=streamOptimized \
--image-size 40 \
$DIB_OPTIONS \
upstream-training
DIST="dist/upstream-training-$(date +%Y%m%d-%H%M).ova"
# If we're configured to create a VMDK or VDI image, assume that we're
# building for VirtualBox and also create an OVA tarball
if [ "$FORMAT" = "vmdk" ] || [ "$FORMAT" = "vdi" ]; then
DIST="dist/upstream-training-$(date +%Y%m%d-%H%M).ova"
cp upstream-training.ovf tmp/
cp upstream-training.ovf tmp/
pushd tmp/
tar -cf "../$DIST" upstream-training.ovf "$VMDK"
popd
pushd tmp/
tar -cf "../$DIST" upstream-training.ovf "$DISK"
popd
fi