mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-27 08:31:04 +02:00
Merge pull request #211 from polvi/iso
feat(iso): add iso image format to image_to_vm
This commit is contained in:
commit
c15791ebea
@ -7,6 +7,7 @@ VM_IMAGE=
|
||||
VM_KERNEL=
|
||||
VM_INITRD=
|
||||
VM_MEMORY=
|
||||
VM_CDROM=
|
||||
VM_NCPUS="`grep -c ^processor /proc/cpuinfo`"
|
||||
SSH_PORT=2222
|
||||
SSH_KEYS=""
|
||||
@ -102,6 +103,10 @@ if [ -n "${VM_UUID}" ]; then
|
||||
set -- -uuid "$VM_UUID" "$@"
|
||||
fi
|
||||
|
||||
if [ -n "${VM_CDROM}" ]; then
|
||||
set -- -cdrom "$VM_CDROM" "$@"
|
||||
fi
|
||||
|
||||
# Default to KVM, fall back on full emulation
|
||||
# ${METADATA} will be mounted in CoreOS as /media/metadata
|
||||
qemu-system-x86_64 \
|
||||
|
@ -8,6 +8,7 @@
|
||||
VALID_IMG_TYPES=(
|
||||
ami
|
||||
pxe
|
||||
iso
|
||||
openstack
|
||||
qemu
|
||||
qemu_no_kexec
|
||||
@ -117,6 +118,11 @@ IMG_pxe_DISK_FORMAT=cpio
|
||||
IMG_pxe_PARTITIONED_IMG=0
|
||||
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
|
||||
IMG_gce_DISK_LAYOUT=vm
|
||||
IMG_gce_CONF_FORMAT=gce
|
||||
@ -292,9 +298,7 @@ _write_vmdk_scsi_disk() {
|
||||
qemu-img convert -f raw "$1" -O vmdk -o adapter_type=lsilogic "$2"
|
||||
}
|
||||
|
||||
# The cpio "disk" is a bit special,
|
||||
# consists of a kernel+initrd not a block device
|
||||
_write_cpio_disk() {
|
||||
_write_cpio_common() {
|
||||
local cpio_target="${VM_TMP_DIR}/rootcpio"
|
||||
local dst_dir=$(_dst_dir)
|
||||
local vmlinuz_name="$(_dst_name ".vmlinuz")"
|
||||
@ -350,11 +354,50 @@ EOF
|
||||
find . | cpio -o -H newc | gzip > "$2"
|
||||
popd >/dev/null
|
||||
|
||||
}
|
||||
|
||||
# The cpio "disk" is a bit special,
|
||||
# consists of a kernel+initrd not a block device
|
||||
_write_cpio_disk() {
|
||||
local base_dir="${VM_TMP_ROOT}/usr"
|
||||
local dst_dir=$(_dst_dir)
|
||||
local vmlinuz_name="$(_dst_name ".vmlinuz")"
|
||||
_write_cpio_common $@
|
||||
# Pull the kernel out of the filesystem
|
||||
cp "${base_dir}"/boot/vmlinuz "${dst_dir}/${vmlinuz_name}"
|
||||
VM_GENERATED_FILES+=( "${dst_dir}/${vmlinuz_name}" )
|
||||
}
|
||||
|
||||
_write_iso_disk() {
|
||||
local base_dir="${VM_TMP_ROOT}/usr"
|
||||
local iso_target="${VM_TMP_DIR}/rootiso"
|
||||
local dst_dir=$(_dst_dir)
|
||||
local vmlinuz_name="$(_dst_name ".vmlinuz")"
|
||||
|
||||
mkdir "${iso_target}"
|
||||
pushd "${iso_target}" >/dev/null
|
||||
mkdir isolinux syslinux coreos
|
||||
_write_cpio_common "$1" "${iso_target}/coreos/cpio.gz"
|
||||
cp "${base_dir}"/boot/vmlinuz "${iso_target}/coreos/vmlinuz"
|
||||
cp -R /usr/share/syslinux/* isolinux/
|
||||
cat<<EOF > isolinux/isolinux.cfg
|
||||
INCLUDE /syslinux/syslinux.cfg
|
||||
EOF
|
||||
cat<<EOF > syslinux/syslinux.cfg
|
||||
default coreos
|
||||
prompt 1
|
||||
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!
|
||||
write_vm_conf() {
|
||||
local conf_format=$(_get_vm_opt CONF_FORMAT)
|
||||
@ -420,6 +463,13 @@ When using -nographic or -serial you must also enable the serial console:
|
||||
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
|
||||
# A good reference doc: http://www.sanbarrow.com/vmx.html
|
||||
_write_vmx_conf() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user