Chromium Code Reviews| 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 # Load common constants. This should be the first executable line. | 10 # Load common constants. This should be the first executable line. |
| 11 # The path to common.sh should be relative to your script's location. | 11 # The path to common.sh should be relative to your script's location. |
| 12 . "$(dirname "$0")/common.sh" | 12 . "$(dirname "$0")/common.sh" |
| 13 | |
| 14 # Load functions and constants for chromeos-install | |
| 13 . "$(dirname "$0")/chromeos-common.sh" | 15 . "$(dirname "$0")/chromeos-common.sh" |
| 14 . "$(dirname "$0")/lib/cros_vm_constants.sh" | 16 . "$(dirname "$0")/lib/cros_vm_constants.sh" |
| 15 | 17 |
| 16 get_default_board | 18 get_default_board |
| 17 assert_inside_chroot | 19 assert_inside_chroot |
| 18 | 20 |
| 19 # Flags | 21 # Flags |
| 20 DEFINE_string board "${DEFAULT_BOARD}" \ | 22 DEFINE_string board "${DEFAULT_BOARD}" \ |
| 21 "Board for which the image was built" | 23 "Board for which the image was built" |
| 22 DEFINE_boolean factory $FLAGS_FALSE \ | 24 DEFINE_boolean factory $FLAGS_FALSE \ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 33 "Create a vmx file for use with vmplayer (vmware only)." | 35 "Create a vmx file for use with vmplayer (vmware only)." |
| 34 DEFINE_integer mem "${DEFAULT_MEM}" \ | 36 DEFINE_integer mem "${DEFAULT_MEM}" \ |
| 35 "Memory size for the vm config in MBs (vmware only)." | 37 "Memory size for the vm config in MBs (vmware only)." |
| 36 DEFINE_integer rootfs_partition_size 1024 \ | 38 DEFINE_integer rootfs_partition_size 1024 \ |
| 37 "rootfs parition size in MBs." | 39 "rootfs parition size in MBs." |
| 38 DEFINE_string state_image "" \ | 40 DEFINE_string state_image "" \ |
| 39 "Stateful partition image (defaults to creating new statful partition)" | 41 "Stateful partition image (defaults to creating new statful partition)" |
| 40 DEFINE_integer statefulfs_size 2048 \ | 42 DEFINE_integer statefulfs_size 2048 \ |
| 41 "Stateful partition size in MBs." | 43 "Stateful partition size in MBs." |
| 42 DEFINE_boolean test_image "${FLAGS_FALSE}" \ | 44 DEFINE_boolean test_image "${FLAGS_FALSE}" \ |
| 43 "Copies normal image to chromiumos_test_image.bin, modifies it for test." | 45 "Copies normal image to ${CHROMEOS_TEST_IMAGE_NAME}, modifies it for test." |
| 44 DEFINE_string to "" \ | 46 DEFINE_string to "" \ |
| 45 "Destination folder for VM output file(s)" | 47 "Destination folder for VM output file(s)" |
| 46 DEFINE_string vbox_disk "${DEFAULT_VBOX_DISK}" \ | 48 DEFINE_string vbox_disk "${DEFAULT_VBOX_DISK}" \ |
| 47 "Filename for the output disk (virtualbox only)." | 49 "Filename for the output disk (virtualbox only)." |
| 48 DEFINE_integer vdisk_size 3072 \ | 50 DEFINE_integer vdisk_size 3072 \ |
| 49 "virtual disk size in MBs." | 51 "virtual disk size in MBs." |
| 50 DEFINE_string vmdk "${DEFAULT_VMDK}" \ | 52 DEFINE_string vmdk "${DEFAULT_VMDK}" \ |
| 51 "Filename for the vmware disk image (vmware only)." | 53 "Filename for the vmware disk image (vmware only)." |
| 52 DEFINE_string vmx "${DEFAULT_VMX}" \ | 54 DEFINE_string vmx "${DEFAULT_VMX}" \ |
| 53 "Filename for the vmware config (vmware only)." | 55 "Filename for the vmware config (vmware only)." |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 78 if [ -z "${FLAGS_from}" ] ; then | 80 if [ -z "${FLAGS_from}" ] ; then |
| 79 FLAGS_from="$(./get_latest_image.sh --board=${FLAGS_board})" | 81 FLAGS_from="$(./get_latest_image.sh --board=${FLAGS_board})" |
| 80 else | 82 else |
| 81 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd | 83 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd |
| 82 fi | 84 fi |
| 83 if [ -z "${FLAGS_to}" ] ; then | 85 if [ -z "${FLAGS_to}" ] ; then |
| 84 FLAGS_to="${FLAGS_from}" | 86 FLAGS_to="${FLAGS_from}" |
| 85 fi | 87 fi |
| 86 | 88 |
| 87 # Use this image as the source image to copy | 89 # Use this image as the source image to copy |
| 88 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 90 SRC_IMAGE="${FLAGS_from}/${CHROMEOS_IMAGE_NAME}" |
| 89 | 91 |
| 90 # If we're asked to modify the image for test, then let's make a copy and | |
| 91 # modify that instead. | |
| 92 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then | 92 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then |
| 93 if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \ | 93 # make a test image as requested, this will modify SRC_IMAGE |
|
sosa
2010/11/30 22:01:43
again same question
| |
| 94 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | 94 prepare_test_image |
| 95 # Copy it. | |
| 96 echo "Creating test image from original..." | |
| 97 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" | |
| 98 | |
| 99 # Check for manufacturing image. | |
| 100 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | |
| 101 EXTRA_ARGS="--factory" | |
| 102 fi | |
| 103 | |
| 104 # Check for install shim. | |
| 105 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then | |
| 106 EXTRA_ARGS="--factory_install" | |
| 107 fi | |
| 108 | |
| 109 # Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we | |
| 110 # really want to modify the image; the user gave their assent already with | |
| 111 # --test-image and the original image is going to be preserved. | |
| 112 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} --image \ | |
| 113 "${FLAGS_from}/chromiumos_test_image.bin" ${EXTRA_ARGS} --yes | |
| 114 echo "Done with mod_image_for_test." | |
| 115 else | |
| 116 echo "Using cached test image." | |
| 117 fi | |
| 118 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" | |
| 119 echo "Source test image is: ${SRC_IMAGE}" | |
| 120 fi | 95 fi |
| 121 | 96 |
| 122 # Memory units are in MBs | 97 # Memory units are in MBs |
| 123 TEMP_IMG="$(dirname ${SRC_IMAGE})/vm_temp_image.bin" | 98 TEMP_IMG="$(dirname ${SRC_IMAGE})/vm_temp_image.bin" |
| 124 | 99 |
| 125 # If we're not building for VMWare, don't build the vmx | 100 # If we're not building for VMWare, don't build the vmx |
| 126 if [ "${FLAGS_format}" != "vmware" ]; then | 101 if [ "${FLAGS_format}" != "vmware" ]; then |
| 127 FLAGS_make_vmx="${FLAGS_FALSE}" | 102 FLAGS_make_vmx="${FLAGS_FALSE}" |
| 128 fi | 103 fi |
| 129 | 104 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 echo "${VMX_CONFIG}" | 256 echo "${VMX_CONFIG}" |
| 282 fi | 257 fi |
| 283 | 258 |
| 284 | 259 |
| 285 if [ "${FLAGS_format}" == "qemu" ]; then | 260 if [ "${FLAGS_format}" == "qemu" ]; then |
| 286 echo "If you have qemu-kvm installed, you can start the image by:" | 261 echo "If you have qemu-kvm installed, you can start the image by:" |
| 287 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic,model=e 1000 " \ | 262 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic,model=e 1000 " \ |
| 288 "-net user,hostfwd=tcp::9222-:22 \\" | 263 "-net user,hostfwd=tcp::9222-:22 \\" |
| 289 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" | 264 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" |
| 290 fi | 265 fi |
| OLD | NEW |