mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-30 15:02:06 +01:00
feat(iso): add iso image format to image_to_vm
This commit is contained in:
parent
e2aaed1619
commit
0d3cd4b417
@ -7,6 +7,7 @@ VM_IMAGE=
|
|||||||
VM_KERNEL=
|
VM_KERNEL=
|
||||||
VM_INITRD=
|
VM_INITRD=
|
||||||
VM_MEMORY=
|
VM_MEMORY=
|
||||||
|
VM_CDROM=
|
||||||
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
|
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
|
||||||
SSH_PORT=2222
|
SSH_PORT=2222
|
||||||
SSH_KEYS=""
|
SSH_KEYS=""
|
||||||
@ -102,6 +103,10 @@ if [ -n "${VM_UUID}" ]; then
|
|||||||
set -- -uuid "$VM_UUID" "$@"
|
set -- -uuid "$VM_UUID" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${VM_CDROM}" ]; then
|
||||||
|
set -- -cdrom "$VM_CDROM" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
# Default to KVM, fall back on full emulation
|
# Default to KVM, fall back on full emulation
|
||||||
# ${METADATA} will be mounted in CoreOS as /media/metadata
|
# ${METADATA} will be mounted in CoreOS as /media/metadata
|
||||||
qemu-system-x86_64 \
|
qemu-system-x86_64 \
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
VALID_IMG_TYPES=(
|
VALID_IMG_TYPES=(
|
||||||
ami
|
ami
|
||||||
pxe
|
pxe
|
||||||
|
iso
|
||||||
openstack
|
openstack
|
||||||
qemu
|
qemu
|
||||||
qemu_no_kexec
|
qemu_no_kexec
|
||||||
@ -117,6 +118,11 @@ IMG_pxe_DISK_FORMAT=cpio
|
|||||||
IMG_pxe_PARTITIONED_IMG=0
|
IMG_pxe_PARTITIONED_IMG=0
|
||||||
IMG_pxe_CONF_FORMAT=pxe
|
IMG_pxe_CONF_FORMAT=pxe
|
||||||
|
|
||||||
|
## pxe, which is an cpio image
|
||||||
|
IMG_iso_DISK_FORMAT=iso
|
||||||
|
IMG_iso_PARTITIONED_IMG=0
|
||||||
|
IMG_iso_CONF_FORMAT=iso
|
||||||
|
|
||||||
## gce, image tarball
|
## gce, image tarball
|
||||||
IMG_gce_DISK_LAYOUT=vm
|
IMG_gce_DISK_LAYOUT=vm
|
||||||
IMG_gce_CONF_FORMAT=gce
|
IMG_gce_CONF_FORMAT=gce
|
||||||
@ -355,6 +361,39 @@ EOF
|
|||||||
VM_GENERATED_FILES+=( "${dst_dir}/${vmlinuz_name}" )
|
VM_GENERATED_FILES+=( "${dst_dir}/${vmlinuz_name}" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_write_iso_disk() {
|
||||||
|
local iso_target="${VM_TMP_DIR}/rootiso"
|
||||||
|
local dst_dir=$(_dst_dir)
|
||||||
|
local vmlinuz_name="$(_dst_name ".vmlinuz")"
|
||||||
|
_write_cpio_disk $@
|
||||||
|
VM_GENERATED_FILES=
|
||||||
|
|
||||||
|
mkdir ${iso_target}
|
||||||
|
pushd "${iso_target}" >/dev/null
|
||||||
|
mkdir isolinux syslinux coreos
|
||||||
|
mv $2 coreos/cpio.gz
|
||||||
|
mv "${dst_dir}/${vmlinuz_name}" coreos/vmlinuz
|
||||||
|
#for file in chain.c32 libcom32.c32 libutil.c32 memdisk; do
|
||||||
|
#for file in isolinux.bin ldlinux.c32; do
|
||||||
|
cp -R /usr/share/syslinux/* isolinux/
|
||||||
|
cat<<EOF > isolinux/isolinux.cfg
|
||||||
|
INCLUDE /syslinux/syslinux.cfg
|
||||||
|
EOF
|
||||||
|
cat<<EOF > syslinux/syslinux.cfg
|
||||||
|
default coreos
|
||||||
|
prompt 0
|
||||||
|
timeout 15
|
||||||
|
|
||||||
|
label coreos
|
||||||
|
menu default
|
||||||
|
kernel /coreos/vmlinuz
|
||||||
|
append initrd=/coreos/cpio.gz coreos.autologin
|
||||||
|
EOF
|
||||||
|
mkisofs -v -l -r -J -o $2 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
|
||||||
|
isohybrid $2
|
||||||
|
popd >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# If a config format is defined write it!
|
# If a config format is defined write it!
|
||||||
write_vm_conf() {
|
write_vm_conf() {
|
||||||
local conf_format=$(_get_vm_opt CONF_FORMAT)
|
local conf_format=$(_get_vm_opt CONF_FORMAT)
|
||||||
@ -420,6 +459,13 @@ When using -nographic or -serial you must also enable the serial console:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_write_iso_conf() {
|
||||||
|
local script="$(_dst_dir)/$(_dst_name ".sh")"
|
||||||
|
local dst_name=$(basename "$VM_DST_IMG")
|
||||||
|
_write_qemu_common "${script}"
|
||||||
|
sed -e "s%^VM_CDROM=.*%VM_CDROM='${dst_name}'%" -i "${script}"
|
||||||
|
}
|
||||||
|
|
||||||
# Generate the vmware config file
|
# Generate the vmware config file
|
||||||
# A good reference doc: http://www.sanbarrow.com/vmx.html
|
# A good reference doc: http://www.sanbarrow.com/vmx.html
|
||||||
_write_vmx_conf() {
|
_write_vmx_conf() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user