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. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 set -e | 62 set -e |
63 | 63 |
64 if [ -z "${FLAGS_board}" ] ; then | 64 if [ -z "${FLAGS_board}" ] ; then |
65 die "--board is required." | 65 die "--board is required." |
66 fi | 66 fi |
67 | 67 |
68 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 68 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
69 # Default to the most recent image | 69 # Default to the most recent image |
70 if [ -z "${FLAGS_from}" ] ; then | 70 if [ -z "${FLAGS_from}" ] ; then |
71 FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR | head -1)" | 71 FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR | head -1)" |
| 72 else |
| 73 pushd "${FLAGS_from}" && FLAGS_from=`pwd` && popd |
72 fi | 74 fi |
73 if [ -z "${FLAGS_to}" ] ; then | 75 if [ -z "${FLAGS_to}" ] ; then |
74 FLAGS_to="${FLAGS_from}" | 76 FLAGS_to="${FLAGS_from}" |
75 fi | 77 fi |
76 | 78 |
77 # Use this image as the source image to copy | 79 # Use this image as the source image to copy |
78 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 80 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" |
79 | 81 |
80 # If we're asked to modify the image for test, then let's make a copy and | 82 # If we're asked to modify the image for test, then let's make a copy and |
81 # modify that instead. | 83 # modify that instead. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 cleanup | 165 cleanup |
164 | 166 |
165 # Make 3 GiB output image | 167 # Make 3 GiB output image |
166 TEMP_IMG=$(mktemp) | 168 TEMP_IMG=$(mktemp) |
167 # TOOD(adlr): pick a size that will for sure accomodate the partitions | 169 # TOOD(adlr): pick a size that will for sure accomodate the partitions |
168 sudo dd if=/dev/zero of="${TEMP_IMG}" bs=1 count=1 \ | 170 sudo dd if=/dev/zero of="${TEMP_IMG}" bs=1 count=1 \ |
169 seek=$((${FLAGS_vdisk_size} * 1024 * 1024 - 1)) | 171 seek=$((${FLAGS_vdisk_size} * 1024 * 1024 - 1)) |
170 | 172 |
171 # Set up the partition table | 173 # Set up the partition table |
172 install_gpt "${TEMP_IMG}" "${TEMP_ROOTFS}" "${TEMP_KERN}" "${TEMP_STATE}" \ | 174 install_gpt "${TEMP_IMG}" "${TEMP_ROOTFS}" "${TEMP_KERN}" "${TEMP_STATE}" \ |
173 "${TEMP_PMBR}" "${TEMP_ESP}" true false ${FLAGS_rootfs_partition_size} | 175 "${TEMP_PMBR}" "${TEMP_ESP}" false ${FLAGS_rootfs_partition_size} |
174 # Copy into the partition parts of the file | 176 # Copy into the partition parts of the file |
175 dd if="${TEMP_ROOTFS}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 177 dd if="${TEMP_ROOTFS}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
176 seek="${START_ROOTFS_A}" | 178 seek="${START_ROOTFS_A}" |
177 dd if="${TEMP_STATE}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 179 dd if="${TEMP_STATE}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
178 seek="${START_STATEFUL}" | 180 seek="${START_STATEFUL}" |
179 dd if="${TEMP_KERN}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 181 dd if="${TEMP_KERN}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
180 seek="${START_KERN_A}" | 182 seek="${START_KERN_A}" |
181 dd if="${TEMP_ESP}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 183 dd if="${TEMP_ESP}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
182 seek="${START_ESP}" | 184 seek="${START_ESP}" |
183 | 185 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 guestOS = \"otherlinux\" | 222 guestOS = \"otherlinux\" |
221 ethernet0.addressType = \"generated\" | 223 ethernet0.addressType = \"generated\" |
222 floppy0.present = \"FALSE\"" | 224 floppy0.present = \"FALSE\"" |
223 | 225 |
224 if [[ "${FLAGS_make_vmx}" = "${FLAGS_TRUE}" ]]; then | 226 if [[ "${FLAGS_make_vmx}" = "${FLAGS_TRUE}" ]]; then |
225 echo "${VMX_CONFIG}" > "${FLAGS_to}/${FLAGS_vmx}" | 227 echo "${VMX_CONFIG}" > "${FLAGS_to}/${FLAGS_vmx}" |
226 echo "Wrote the following config to: ${FLAGS_to}/${FLAGS_vmx}" | 228 echo "Wrote the following config to: ${FLAGS_to}/${FLAGS_vmx}" |
227 echo "${VMX_CONFIG}" | 229 echo "${VMX_CONFIG}" |
228 fi | 230 fi |
229 | 231 |
OLD | NEW |