image-builder: check format_loop return code

check format_loop return code and die if it fails

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-03-29 07:47:22 -06:00
parent 8debe95b61
commit 77fb8085f4

View File

@ -194,7 +194,9 @@ calculate_required_disk_size() {
continue continue
fi fi
format_loop "${device}" "${block_size}" "${fs_type}" > /dev/null 2>&1 if ! format_loop "${device}" "${block_size}" "${fs_type}" > /dev/null 2>&1 ; then
die "Could not format loop device: ${device}"
fi
mount "${device}p1" "${mount_dir}" mount "${device}p1" "${mount_dir}"
avail="$(df -h --output=avail "${mount_dir}" | tail -n1 | sed 's/[M ]//g')" avail="$(df -h --output=avail "${mount_dir}" | tail -n1 | sed 's/[M ]//g')"
umount "${mount_dir}" umount "${mount_dir}"
@ -317,7 +319,9 @@ create_rootfs_image() {
die "Could not setup loop device" die "Could not setup loop device"
fi fi
format_loop "${device}" "${block_size}" "${fs_type}" if ! format_loop "${device}" "${block_size}" "${fs_type}"; then
die "Could not format loop device: ${device}"
fi
info "Mounting root partition" info "Mounting root partition"
readonly mount_dir=$(mktemp -d osbuilder-mount-dir.XXXX) readonly mount_dir=$(mktemp -d osbuilder-mount-dir.XXXX)