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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 # Extend the original file size to the new size. | 159 # Extend the original file size to the new size. |
160 dd if=/dev/zero of="${TEMP_STATE}" bs=1 count=1 \ | 160 dd if=/dev/zero of="${TEMP_STATE}" bs=1 count=1 \ |
161 seek=$((STATEFUL_SIZE_BYTES - 1)) | 161 seek=$((STATEFUL_SIZE_BYTES - 1)) |
162 # Resize the partition. | 162 # Resize the partition. |
163 sudo losetup "${STATEFUL_LOOP_DEV}" "${TEMP_STATE}" | 163 sudo losetup "${STATEFUL_LOOP_DEV}" "${TEMP_STATE}" |
164 sudo e2fsck -f "${STATEFUL_LOOP_DEV}" | 164 sudo e2fsck -f "${STATEFUL_LOOP_DEV}" |
165 sudo resize2fs "${STATEFUL_LOOP_DEV}" | 165 sudo resize2fs "${STATEFUL_LOOP_DEV}" |
166 sudo losetup -d "${STATEFUL_LOOP_DEV}" | 166 sudo losetup -d "${STATEFUL_LOOP_DEV}" |
167 fi | 167 fi |
168 fi | 168 fi |
169 TEMP_KERN="${TEMP_DIR}"/part_2 | |
170 TEMP_PMBR="${TEMP_DIR}"/pmbr | 169 TEMP_PMBR="${TEMP_DIR}"/pmbr |
171 dd if="${SRC_IMAGE}" of="${TEMP_PMBR}" bs=512 count=1 | 170 dd if="${SRC_IMAGE}" of="${TEMP_PMBR}" bs=512 count=1 |
172 | 171 |
173 TEMP_MNT=$(mktemp -d) | 172 TEMP_MNT=$(mktemp -d) |
174 TEMP_ESP_MNT=$(mktemp -d) | 173 TEMP_ESP_MNT=$(mktemp -d) |
175 cleanup() { | 174 cleanup() { |
176 sudo umount -d "${TEMP_MNT}" | 175 sudo umount -d "${TEMP_MNT}" |
177 sudo umount -d "${TEMP_ESP_MNT}" | 176 sudo umount -d "${TEMP_ESP_MNT}" |
178 rmdir "${TEMP_MNT}" "${TEMP_ESP_MNT}" | 177 rmdir "${TEMP_MNT}" "${TEMP_ESP_MNT}" |
179 } | 178 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 trap - INT TERM EXIT | 222 trap - INT TERM EXIT |
224 cleanup | 223 cleanup |
225 | 224 |
226 # Make 3 GiB output image | 225 # Make 3 GiB output image |
227 TEMP_IMG=$(mktemp) | 226 TEMP_IMG=$(mktemp) |
228 # TOOD(adlr): pick a size that will for sure accomodate the partitions | 227 # TOOD(adlr): pick a size that will for sure accomodate the partitions |
229 sudo dd if=/dev/zero of="${TEMP_IMG}" bs=1 count=1 \ | 228 sudo dd if=/dev/zero of="${TEMP_IMG}" bs=1 count=1 \ |
230 seek=$((${FLAGS_vdisk_size} * 1024 * 1024 - 1)) | 229 seek=$((${FLAGS_vdisk_size} * 1024 * 1024 - 1)) |
231 | 230 |
232 # Set up the partition table | 231 # Set up the partition table |
233 install_gpt "${TEMP_IMG}" "${TEMP_ROOTFS}" "${TEMP_KERN}" "${TEMP_STATE}" \ | 232 install_gpt "${TEMP_IMG}" "${TEMP_ROOTFS}" "${TEMP_STATE}" \ |
234 "${TEMP_PMBR}" "${TEMP_ESP}" false ${FLAGS_rootfs_partition_size} | 233 "${TEMP_PMBR}" "${TEMP_ESP}" false ${FLAGS_rootfs_partition_size} |
235 # Copy into the partition parts of the file | 234 # Copy into the partition parts of the file |
236 dd if="${TEMP_ROOTFS}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 235 dd if="${TEMP_ROOTFS}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
237 seek="${START_ROOTFS_A}" | 236 seek="${START_ROOTFS_A}" |
238 dd if="${TEMP_STATE}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 237 dd if="${TEMP_STATE}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
239 seek="${START_STATEFUL}" | 238 seek="${START_STATEFUL}" |
240 dd if="${TEMP_KERN}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 239 dd if="${TEMP_KERN}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
241 seek="${START_KERN_A}" | 240 seek="${START_KERN_A}" |
242 dd if="${TEMP_ESP}" of="${TEMP_IMG}" conv=notrunc bs=512 \ | 241 dd if="${TEMP_ESP}" of="${TEMP_IMG}" conv=notrunc bs=512 \ |
243 seek="${START_ESP}" | 242 seek="${START_ESP}" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 guestOS = \"otherlinux\" | 280 guestOS = \"otherlinux\" |
282 ethernet0.addressType = \"generated\" | 281 ethernet0.addressType = \"generated\" |
283 floppy0.present = \"FALSE\"" | 282 floppy0.present = \"FALSE\"" |
284 | 283 |
285 if [[ "${FLAGS_make_vmx}" = "${FLAGS_TRUE}" ]]; then | 284 if [[ "${FLAGS_make_vmx}" = "${FLAGS_TRUE}" ]]; then |
286 echo "${VMX_CONFIG}" > "${FLAGS_to}/${FLAGS_vmx}" | 285 echo "${VMX_CONFIG}" > "${FLAGS_to}/${FLAGS_vmx}" |
287 echo "Wrote the following config to: ${FLAGS_to}/${FLAGS_vmx}" | 286 echo "Wrote the following config to: ${FLAGS_to}/${FLAGS_vmx}" |
288 echo "${VMX_CONFIG}" | 287 echo "${VMX_CONFIG}" |
289 fi | 288 fi |
290 | 289 |
OLD | NEW |