OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 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 VirtualBox image. | 7 # Script to convert the output of build_image.sh to a VirtualBox image. |
8 # Load common constants. This should be the first executable line. | 8 # Load common constants. This should be the first executable line. |
9 # The path to common.sh should be relative to your script's location. | 9 # The path to common.sh should be relative to your script's location. |
10 . "$(dirname "$0")/common.sh" | 10 . "$(dirname "$0")/common.sh" |
(...skipping 23 matching lines...) Expand all Loading... |
34 FLAGS_to=`eval readlink -f $FLAGS_to` | 34 FLAGS_to=`eval readlink -f $FLAGS_to` |
35 | 35 |
36 # Check if qemu-img and VBoxManage are available. | 36 # Check if qemu-img and VBoxManage are available. |
37 for EXTERNAL_tools in qemu-img VBoxManage; do | 37 for EXTERNAL_tools in qemu-img VBoxManage; do |
38 if ! type ${EXTERNAL_tools} >/dev/null 2>&1; then | 38 if ! type ${EXTERNAL_tools} >/dev/null 2>&1; then |
39 echo "Error: This script requires ${EXTERNAL_tools}." | 39 echo "Error: This script requires ${EXTERNAL_tools}." |
40 exit 1 | 40 exit 1 |
41 fi | 41 fi |
42 done | 42 done |
43 | 43 |
44 # Make two sparse files. One for an empty partition, another for | 44 $(dirname "$0")/image_to_vmware.sh --format=virtualbox --from=$FLAGS_from \ |
45 # stateful partition. | 45 --to=$(dirname "$FLAGS_to") --vbox_disk=$(basename "$FLAGS_to") |
46 PART_SIZE=$(stat -c%s "${FLAGS_from}/rootfs.image") | |
47 dd if=/dev/zero of="${FLAGS_from}/empty.image" bs=1 count=1 \ | |
48 seek=$(( $PART_SIZE - 1 )) | |
49 dd if=/dev/zero of="${FLAGS_from}/state.image" bs=1 count=1 \ | |
50 seek=$(( $PART_SIZE - 1 )) | |
51 mkfs.ext3 -F -L C-STATE "${FLAGS_from}/state.image" | |
52 | |
53 # Copy MBR and rootfs to output image | |
54 qemu-img convert -f raw \ | |
55 "${FLAGS_from}/mbr.image" "${FLAGS_from}/state.image" \ | |
56 "${FLAGS_from}/empty.image" "${FLAGS_from}/rootfs.image" \ | |
57 -O raw "${TEMP_IMAGE}" | |
58 VBoxManage convertdd "${TEMP_IMAGE}" "${FLAGS_to}" | |
59 | |
60 rm -f "${FLAGS_from}/empty.image" "${FLAGS_from}/state.image" "${TEMP_IMAGE}" | |
61 | |
62 echo "Done. Created VirtualBox image ${FLAGS_to}" | |
63 | |
OLD | NEW |