mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
Updated image_to_vmware.sh to generate an VMware configuration file. This is useful for VMplayer.
BUG=None Test=Run "vmplayer chromeos.vmx" on and verify that the VM boots. Review URL: http://codereview.chromium.org/657027
This commit is contained in:
parent
89ae722a21
commit
e609f19d4a
@ -4,7 +4,8 @@
|
|||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
# Script to convert the output of build_image.sh to a VMware image.
|
# Script to convert the output of build_image.sh to a VMware image and write a
|
||||||
|
# corresponding VMware config file.
|
||||||
|
|
||||||
# Load common constants. This should be the first executable line.
|
# Load common constants. This should be the first executable line.
|
||||||
# The path to common.sh should be relative to your script's location.
|
# The path to common.sh should be relative to your script's location.
|
||||||
@ -13,13 +14,25 @@
|
|||||||
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
|
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images"
|
||||||
# Default to the most recent image
|
# Default to the most recent image
|
||||||
DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`"
|
DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`"
|
||||||
DEFAULT_TO="${DEFAULT_FROM}/ide.vmdk"
|
DEFAULT_TO="${DEFAULT_FROM}"
|
||||||
|
DEFAULT_VMDK="ide.vmdk"
|
||||||
|
DEFAULT_VMX="chromeos.vmx"
|
||||||
|
# Memory units are in MBs
|
||||||
|
DEFAULT_MEM="1024"
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
DEFINE_string from "$DEFAULT_FROM" \
|
DEFINE_string from "$DEFAULT_FROM" \
|
||||||
"Directory containing rootfs.image and mbr.image"
|
"Directory containing rootfs.image and mbr.image"
|
||||||
DEFINE_string to "$DEFAULT_TO" \
|
DEFINE_string to "$DEFAULT_TO" \
|
||||||
"Destination file for VMware image"
|
"Destination folder for VMware files"
|
||||||
|
DEFINE_boolean make_vmx true \
|
||||||
|
"Create a vmx file for use with vmplayer."
|
||||||
|
DEFINE_string vmdk "$DEFAULT_VMDK" \
|
||||||
|
"Filename for the vmware disk image"
|
||||||
|
DEFINE_string vmx "$DEFAULT_VMX" \
|
||||||
|
"Filename for the vmware config"
|
||||||
|
DEFINE_integer mem "$DEFAULT_MEM" \
|
||||||
|
"Memory size for the vmware config in MBs."
|
||||||
|
|
||||||
# Parse command line
|
# Parse command line
|
||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
@ -46,9 +59,35 @@ mkfs.ext3 -F -L C-STATE "${FLAGS_from}/state.image"
|
|||||||
qemu-img convert -f raw \
|
qemu-img convert -f raw \
|
||||||
"${FLAGS_from}/mbr.image" "${FLAGS_from}/state.image" \
|
"${FLAGS_from}/mbr.image" "${FLAGS_from}/state.image" \
|
||||||
"${FLAGS_from}/empty.image" "${FLAGS_from}/rootfs.image" \
|
"${FLAGS_from}/empty.image" "${FLAGS_from}/rootfs.image" \
|
||||||
-O vmdk "${FLAGS_to}"
|
-O vmdk "${FLAGS_to}/${FLAGS_vmdk}"
|
||||||
|
|
||||||
rm -f "${FLAGS_from}/empty.image" "${FLAGS_from}/state.image"
|
rm -f "${FLAGS_from}/empty.image" "${FLAGS_from}/state.image"
|
||||||
|
|
||||||
echo "Done. Created VMware image ${FLAGS_to}"
|
echo "Created VMware image ${FLAGS_to}"
|
||||||
|
|
||||||
|
# Generate the vmware config file
|
||||||
|
# A good reference doc: http://www.sanbarrow.com/vmx.html
|
||||||
|
VMX_CONFIG=$(cat <<END
|
||||||
|
#!/usr/bin/vmware
|
||||||
|
.encoding = "UTF-8"
|
||||||
|
config.version = "8"
|
||||||
|
virtualHW.version = "4"
|
||||||
|
memsize = "${FLAGS_mem}"
|
||||||
|
ide0:0.present = "TRUE"
|
||||||
|
ide0:0.fileName = "${FLAGS_vmdk}"
|
||||||
|
ethernet0.present = "TRUE"
|
||||||
|
usb.present = "TRUE"
|
||||||
|
sound.present = "TRUE"
|
||||||
|
sound.virtualDev = "es1371"
|
||||||
|
displayName = "ChromeOS"
|
||||||
|
guestOS = "otherlinux"
|
||||||
|
ethernet0.addressType = "generated"
|
||||||
|
floppy0.present = "FALSE"
|
||||||
|
END)
|
||||||
|
|
||||||
|
if [[ ${FLAGS_make_vmx} ]]; then
|
||||||
|
echo "${VMX_CONFIG}" > "${FLAGS_to}/${FLAGS_vmx}"
|
||||||
|
echo "Wrote the following config to: ${FLAGS_to}/${FLAGS_vmx}"
|
||||||
|
echo "${VMX_CONFIG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user