scripts: Check if windows image is in the host

Currently script does not exit early if the image/firmware not present
in the host. We should not progress further if the images are not pre
downloaded.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam 2021-02-18 10:55:11 -08:00 committed by Rob Bradford
parent 282134a490
commit 29f924405a

View File

@ -10,6 +10,7 @@ features_build=""
features_test="--features integration_tests"
WIN_IMAGE_FILE="/root/workloads/windows-server-2019.raw"
OVMF_FW_FILE="/root/workloads/OVMF.fd"
BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}"
CFLAGS=""
TARGET_CC=""
@ -18,6 +19,12 @@ TARGET_CC="musl-gcc"
CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
fi
# Check if the images are present
if [[ ! -f ${WIN_IMAGE_FILE} || ! -f ${OVMF_FW_FILE} ]]; then
echo "Windows image/firmware not present in the host"
exit 1
fi
# Use device mapper to create a snapshot of the Windows image
img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}')
loop_device=$(losetup --find --show --read-only ${WIN_IMAGE_FILE})