mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-27 00:21:44 +02:00
Merge pull request #337 from crawford/azure
azure: finalize azure image
This commit is contained in:
commit
a655e50510
@ -163,6 +163,24 @@ package_provided() {
|
||||
done
|
||||
}
|
||||
|
||||
assert_image_size() {
|
||||
local disk_img="$1"
|
||||
local disk_type="$2"
|
||||
|
||||
local size
|
||||
size=$(qemu-img info -f "${disk_type}" --output json "${disk_img}" | \
|
||||
gawk 'match($0, /"virtual-size": ([0-9]+),/, val) {print val[1]}' ; \
|
||||
exit ${PIPESTATUS[0]})
|
||||
if [[ $? -ne 0 ]]; then
|
||||
die_notrace "assert failed: could not read image size"
|
||||
fi
|
||||
|
||||
MiB=$((1024*1024))
|
||||
if [[ $(($size % $MiB)) -ne 0 ]]; then
|
||||
die_notrace "assert failed: image must be a multiple of 1 MiB ($size B)"
|
||||
fi
|
||||
}
|
||||
|
||||
start_image() {
|
||||
local image_name="$1"
|
||||
local disk_layout="$2"
|
||||
@ -181,6 +199,8 @@ start_image() {
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
|
||||
format "${disk_img}"
|
||||
|
||||
assert_image_size "${disk_img}" raw
|
||||
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
|
||||
mount "${disk_img}" "${root_fs_dir}"
|
||||
trap "cleanup_mounts '${root_fs_dir}' && delete_prompt" EXIT
|
||||
|
@ -76,6 +76,12 @@
|
||||
"blocks":"12689408"
|
||||
}
|
||||
},
|
||||
"azure":{
|
||||
"9":{
|
||||
"label":"ROOT",
|
||||
"blocks":"58752990"
|
||||
}
|
||||
},
|
||||
"vagrant":{
|
||||
"9":{
|
||||
"label":"ROOT",
|
||||
|
@ -211,6 +211,7 @@ IMG_exoscale_OEM_PACKAGE=oem-exoscale
|
||||
## azure
|
||||
IMG_azure_BOOT_KERNEL=0
|
||||
IMG_azure_DISK_FORMAT=vhd
|
||||
IMG_azure_DISK_LAYOUT=azure
|
||||
IMG_azure_OEM_PACKAGE=oem-azure
|
||||
|
||||
## hyper-v
|
||||
@ -331,6 +332,8 @@ setup_disk_image() {
|
||||
update "${VM_TMP_IMG}"
|
||||
fi
|
||||
|
||||
assert_image_size "${VM_TMP_IMG}" raw
|
||||
|
||||
info "Mounting image to $(relpath "${VM_TMP_ROOT}")"
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
|
||||
mount "${VM_TMP_IMG}" "${VM_TMP_ROOT}"
|
||||
@ -432,18 +435,22 @@ _write_raw_disk() {
|
||||
|
||||
_write_qcow2_disk() {
|
||||
qemu-img convert -f raw "$1" -O qcow2 "$2"
|
||||
assert_image_size "$2" qcow2
|
||||
}
|
||||
|
||||
_write_vhd_disk() {
|
||||
qemu-img convert -f raw "$1" -O vpc "$2"
|
||||
assert_image_size "$2" vpc
|
||||
}
|
||||
|
||||
_write_vmdk_ide_disk() {
|
||||
qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2"
|
||||
assert_image_size "$2" vmdk
|
||||
}
|
||||
|
||||
_write_vmdk_scsi_disk() {
|
||||
qemu-img convert -f raw "$1" -O vmdk -o adapter_type=lsilogic "$2"
|
||||
assert_image_size "$2" vmdk
|
||||
}
|
||||
|
||||
_write_cpio_common() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user