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 . "$(dirname "$0")/chromeos-common.sh" | 13 . "$(dirname "$0")/chromeos-common.sh" |
| 14 . "$(dirname "$0")/lib/cros_vm_constants.sh" |
14 | 15 |
15 get_default_board | 16 get_default_board |
16 assert_inside_chroot | 17 assert_inside_chroot |
17 | 18 |
18 DEFAULT_MEM="1024" | |
19 DEFAULT_VMDK="ide.vmdk" | |
20 DEFAULT_VMX="chromiumos.vmx" | |
21 DEFAULT_VBOX_DISK="os.vdi" | |
22 DEFAULT_QEMU_IMAGE="chromiumos_qemu_image.bin" | |
23 | |
24 # Minimum sizes for full size vm images -- needed for update. | |
25 MIN_VDISK_SIZE_FULL=6072 | |
26 MIN_STATEFUL_FS_SIZE_FULL=2048 | |
27 | |
28 MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" | |
29 | |
30 # Flags | 19 # Flags |
31 DEFINE_string board "${DEFAULT_BOARD}" \ | 20 DEFINE_string board "${DEFAULT_BOARD}" \ |
32 "Board for which the image was built" | 21 "Board for which the image was built" |
33 DEFINE_boolean factory $FLAGS_FALSE \ | 22 DEFINE_boolean factory $FLAGS_FALSE \ |
34 "Modify the image for manufacturing testing" | 23 "Modify the image for manufacturing testing" |
35 DEFINE_boolean factory_install $FLAGS_FALSE \ | 24 DEFINE_boolean factory_install $FLAGS_FALSE \ |
36 "Modify the image for factory install shim" | 25 "Modify the image for factory install shim" |
37 DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image" | 26 DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image" |
38 DEFINE_string format "qemu" \ | 27 DEFINE_string format "qemu" \ |
39 "Output format, either qemu, vmware or virtualbox" | 28 "Output format, either qemu, vmware or virtualbox" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 ( [[ ${FLAGS_vdisk_size} < ${MIN_VDISK_SIZE_FULL} ]] || \ | 67 ( [[ ${FLAGS_vdisk_size} < ${MIN_VDISK_SIZE_FULL} ]] || \ |
79 [[ ${FLAGS_statefulfs_size} < ${MIN_STATEFUL_FS_SIZE_FULL} ]]); then | 68 [[ ${FLAGS_statefulfs_size} < ${MIN_STATEFUL_FS_SIZE_FULL} ]]); then |
80 die "Disk is too small for full, please select a vdisk size greater than \ | 69 die "Disk is too small for full, please select a vdisk size greater than \ |
81 ${MIN_VDISK_SIZE_FULL} and statefulfs size greater than \ | 70 ${MIN_VDISK_SIZE_FULL} and statefulfs size greater than \ |
82 ${MIN_STATEFUL_FS_SIZE_FULL}." | 71 ${MIN_STATEFUL_FS_SIZE_FULL}." |
83 fi | 72 fi |
84 | 73 |
85 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 74 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
86 # Default to the most recent image | 75 # Default to the most recent image |
87 if [ -z "${FLAGS_from}" ] ; then | 76 if [ -z "${FLAGS_from}" ] ; then |
88 FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR | head -1)" | 77 FLAGS_from="$(./get_latest_image.sh)" |
89 else | 78 else |
90 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd | 79 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd |
91 fi | 80 fi |
92 if [ -z "${FLAGS_to}" ] ; then | 81 if [ -z "${FLAGS_to}" ] ; then |
93 FLAGS_to="${FLAGS_from}" | 82 FLAGS_to="${FLAGS_from}" |
94 fi | 83 fi |
95 | 84 |
96 # Use this image as the source image to copy | 85 # Use this image as the source image to copy |
97 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 86 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" |
98 | 87 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 echo "${VMX_CONFIG}" | 277 echo "${VMX_CONFIG}" |
289 fi | 278 fi |
290 | 279 |
291 | 280 |
292 if [ "${FLAGS_format}" == "qemu" ]; then | 281 if [ "${FLAGS_format}" == "qemu" ]; then |
293 echo "If you have qemu-kvm installed, you can start the image by:" | 282 echo "If you have qemu-kvm installed, you can start the image by:" |
294 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic " \ | 283 echo "sudo kvm -m ${FLAGS_mem} -vga std -pidfile /tmp/kvm.pid -net nic " \ |
295 "-net user,hostfwd=tcp::922-:22 \\" | 284 "-net user,hostfwd=tcp::922-:22 \\" |
296 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" | 285 echo " -hda ${FLAGS_to}/${DEFAULT_QEMU_IMAGE}" |
297 fi | 286 fi |
OLD | NEW |