
Users may want to override the generated output format, in case they want to run in a virtualization environment other than VMware or VirtualBox. Accept a positional argument enabling users to select their preferred output format, defaulting to VMDK (the previously hard-coded format). Also, make the creation of an OVA archive conditional on the user selecting a disk format commonly used with VirtualBox (that is, VDI or VMDK). Change-Id: I8829c1a21aa79de877748d9bdc3b7eef7802a6d8
35 lines
868 B
Bash
Executable File
35 lines
868 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
# 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 \
|
|
$DIB_OPTIONS \
|
|
upstream-training
|
|
|
|
# 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/
|
|
|
|
pushd tmp/
|
|
tar -cf "../$DIST" upstream-training.ovf "$DISK"
|
|
popd
|
|
fi
|