| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to convert the output of build_image.sh to a VMware image and write a | 7 # Script to convert the output of build_image.sh to a VMware image and write a |
| 8 # corresponding VMware config file. | 8 # corresponding VMware config file. |
| 9 | 9 |
| 10 # --- BEGIN COMMON.SH BOILERPLATE --- | 10 # --- BEGIN COMMON.SH BOILERPLATE --- |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 get_default_board | 41 get_default_board |
| 42 | 42 |
| 43 # Flags | 43 # Flags |
| 44 DEFINE_string board "${DEFAULT_BOARD}" \ | 44 DEFINE_string board "${DEFAULT_BOARD}" \ |
| 45 "Board for which the image was built" | 45 "Board for which the image was built" |
| 46 DEFINE_boolean factory $FLAGS_FALSE \ | 46 DEFINE_boolean factory $FLAGS_FALSE \ |
| 47 "Modify the image for manufacturing testing" | 47 "Modify the image for manufacturing testing" |
| 48 DEFINE_boolean factory_install $FLAGS_FALSE \ | 48 DEFINE_boolean factory_install $FLAGS_FALSE \ |
| 49 "Modify the image for factory install shim" | 49 "Modify the image for factory install shim" |
| 50 DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image" | 50 |
| 51 # We default to TRUE so the buildbot gets its image. Note this is different |
| 52 # behavior from image_to_usb.sh |
| 53 DEFINE_boolean force_copy ${FLAGS_TRUE} "Always rebuild test image" |
| 51 DEFINE_string format "qemu" \ | 54 DEFINE_string format "qemu" \ |
| 52 "Output format, either qemu, vmware or virtualbox" | 55 "Output format, either qemu, vmware or virtualbox" |
| 53 DEFINE_string from "" \ | 56 DEFINE_string from "" \ |
| 54 "Directory containing rootfs.image and mbr.image" | 57 "Directory containing rootfs.image and mbr.image" |
| 55 DEFINE_boolean full "${FLAGS_FALSE}" "Build full image with all partitions." | 58 DEFINE_boolean full "${FLAGS_FALSE}" "Build full image with all partitions." |
| 56 DEFINE_boolean make_vmx ${FLAGS_TRUE} \ | 59 DEFINE_boolean make_vmx ${FLAGS_TRUE} \ |
| 57 "Create a vmx file for use with vmplayer (vmware only)." | 60 "Create a vmx file for use with vmplayer (vmware only)." |
| 58 DEFINE_integer mem "${DEFAULT_MEM}" \ | 61 DEFINE_integer mem "${DEFAULT_MEM}" \ |
| 59 "Memory size for the vm config in MBs (vmware only)." | 62 "Memory size for the vm config in MBs (vmware only)." |
| 60 DEFINE_integer rootfs_partition_size 1024 \ | 63 DEFINE_integer rootfs_partition_size 1024 \ |
| 61 "rootfs parition size in MBs." | 64 "rootfs parition size in MBs." |
| 62 DEFINE_string state_image "" \ | 65 DEFINE_string state_image "" \ |
| 63 "Stateful partition image (defaults to creating new statful partition)" | 66 "Stateful partition image (defaults to creating new statful partition)" |
| 64 DEFINE_integer statefulfs_size 2048 \ | 67 DEFINE_integer statefulfs_size 2048 \ |
| 65 "Stateful partition size in MBs." | 68 "Stateful partition size in MBs." |
| 66 DEFINE_boolean test_image "${FLAGS_FALSE}" \ | 69 DEFINE_boolean test_image "${FLAGS_FALSE}" \ |
| 67 "Copies normal image to chromiumos_test_image.bin, modifies it for test." | 70 "Copies normal image to ${CHROMEOS_TEST_IMAGE_NAME}, modifies it for test." |
| 68 DEFINE_string to "" \ | 71 DEFINE_string to "" \ |
| 69 "Destination folder for VM output file(s)" | 72 "Destination folder for VM output file(s)" |
| 70 DEFINE_string vbox_disk "${DEFAULT_VBOX_DISK}" \ | 73 DEFINE_string vbox_disk "${DEFAULT_VBOX_DISK}" \ |
| 71 "Filename for the output disk (virtualbox only)." | 74 "Filename for the output disk (virtualbox only)." |
| 72 DEFINE_integer vdisk_size 3072 \ | 75 DEFINE_integer vdisk_size 3072 \ |
| 73 "virtual disk size in MBs." | 76 "virtual disk size in MBs." |
| 74 DEFINE_string vmdk "${DEFAULT_VMDK}" \ | 77 DEFINE_string vmdk "${DEFAULT_VMDK}" \ |
| 75 "Filename for the vmware disk image (vmware only)." | 78 "Filename for the vmware disk image (vmware only)." |
| 76 DEFINE_string vmx "${DEFAULT_VMX}" \ | 79 DEFINE_string vmx "${DEFAULT_VMX}" \ |
| 77 "Filename for the vmware config (vmware only)." | 80 "Filename for the vmware config (vmware only)." |
| (...skipping 23 matching lines...) Expand all Loading... |
| 101 # Default to the most recent image | 104 # Default to the most recent image |
| 102 if [ -z "${FLAGS_from}" ] ; then | 105 if [ -z "${FLAGS_from}" ] ; then |
| 103 FLAGS_from="$(./get_latest_image.sh --board=${FLAGS_board})" | 106 FLAGS_from="$(./get_latest_image.sh --board=${FLAGS_board})" |
| 104 else | 107 else |
| 105 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd | 108 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd |
| 106 fi | 109 fi |
| 107 if [ -z "${FLAGS_to}" ] ; then | 110 if [ -z "${FLAGS_to}" ] ; then |
| 108 FLAGS_to="${FLAGS_from}" | 111 FLAGS_to="${FLAGS_from}" |
| 109 fi | 112 fi |
| 110 | 113 |
| 111 # Use this image as the source image to copy | |
| 112 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | |
| 113 | |
| 114 # If we're asked to modify the image for test, then let's make a copy and | |
| 115 # modify that instead. | |
| 116 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then | 114 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then |
| 117 if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \ | 115 # Make a test image - this returns the test filename in CHROMEOS_RETURN_VAL |
| 118 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | 116 prepare_test_image "${FLAGS_from}" "${CHROMEOS_IMAGE_NAME}" |
| 119 # Copy it. | 117 SRC_IMAGE="${CHROMEOS_RETURN_VAL}" |
| 120 echo "Creating test image from original..." | 118 else |
| 121 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" | 119 # Use the standard image |
| 122 | 120 SRC_IMAGE="${FLAGS_from}/${CHROMEOS_IMAGE_NAME}" |
| 123 # Check for manufacturing image. | |
| 124 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | |
| 125 EXTRA_ARGS="--factory" | |
| 126 fi | |
| 127 | |
| 128 # Check for install shim. | |
| 129 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then | |
| 130 EXTRA_ARGS="--factory_install" | |
| 131 fi | |
| 132 | |
| 133 # Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we | |
| 134 # really want to modify the image; the user gave their assent already with | |
| 135 # --test-image and the original image is going to be preserved. | |
| 136 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image \ | |
| 137 "${FLAGS_from}/chromiumos_test_image.bin" ${EXTRA_ARGS} --yes | |
| 138 echo "Done with mod_image_for_test." | |
| 139 else | |
| 140 echo "Using cached test image." | |
| 141 fi | |
| 142 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" | |
| 143 echo "Source test image is: ${SRC_IMAGE}" | |
| 144 fi | 121 fi |
| 145 | 122 |
| 146 # Memory units are in MBs | 123 # Memory units are in MBs |
| 147 TEMP_IMG="$(dirname "${SRC_IMAGE}")/vm_temp_image.bin" | 124 TEMP_IMG="$(dirname "${SRC_IMAGE}")/vm_temp_image.bin" |
| 148 | 125 |
| 149 # If we're not building for VMWare, don't build the vmx | 126 # If we're not building for VMWare, don't build the vmx |
| 150 if [ "${FLAGS_format}" != "vmware" ]; then | 127 if [ "${FLAGS_format}" != "vmware" ]; then |
| 151 FLAGS_make_vmx="${FLAGS_FALSE}" | 128 FLAGS_make_vmx="${FLAGS_FALSE}" |
| 152 fi | 129 fi |
| 153 | 130 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 echo "${VMX_CONFIG}" | 282 echo "${VMX_CONFIG}" |
| 306 fi | 283 fi |
| 307 | 284 |
| 308 | 285 |
| 309 if [ "${FLAGS_format}" == "qemu" ]; then | 286 if [ "${FLAGS_format}" == "qemu" ]; then |
| 310 echo "If you have qemu-kvm installed, you can start the image by:" | 287 echo "If you have qemu-kvm installed, you can start the image by:" |
| 311 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic,model=v
irtio " \ | 288 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic,model=v
irtio " \ |
| 312 "-net user,hostfwd=tcp::9222-:22 \\" | 289 "-net user,hostfwd=tcp::9222-:22 \\" |
| 313 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" | 290 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" |
| 314 fi | 291 fi |
| OLD | NEW |