| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 | |
| 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 | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Script to convert the output of build_image.sh to a VirtualBox image. | |
| 8 | |
| 9 # --- BEGIN COMMON.SH BOILERPLATE --- | |
| 10 # Load common CrOS utilities. Inside the chroot this file is installed in | |
| 11 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's | |
| 12 # location. | |
| 13 find_common_sh() { | |
| 14 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) | |
| 15 local path | |
| 16 | |
| 17 SCRIPT_ROOT= | |
| 18 for path in "${common_paths[@]}"; do | |
| 19 if [ -r "${path}/common.sh" ]; then | |
| 20 SCRIPT_ROOT=${path} | |
| 21 break | |
| 22 fi | |
| 23 done | |
| 24 } | |
| 25 | |
| 26 find_common_sh | |
| 27 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) | |
| 28 # --- END COMMON.SH BOILERPLATE --- | |
| 29 | |
| 30 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images" | |
| 31 # Default to the most recent image | |
| 32 DEFAULT_FROM="${IMAGES_DIR}/`ls -t $IMAGES_DIR | head -1`" | |
| 33 DEFAULT_TO="${DEFAULT_FROM}/os.vdi" | |
| 34 TEMP_IMAGE="${IMAGES_DIR}/temp.img" | |
| 35 | |
| 36 # Flags | |
| 37 DEFINE_string from "$DEFAULT_FROM" \ | |
| 38 "Directory containing rootfs.image and mbr.image" | |
| 39 DEFINE_string to "$DEFAULT_TO" \ | |
| 40 "Destination file for VirtualBox image" | |
| 41 | |
| 42 # Parse command line | |
| 43 FLAGS "$@" || exit 1 | |
| 44 eval set -- "${FLAGS_ARGV}" | |
| 45 | |
| 46 # Die on any errors. | |
| 47 set -e | |
| 48 | |
| 49 # Convert args to paths. Need eval to un-quote the string so that shell | |
| 50 # chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work. | |
| 51 FLAGS_from=`eval readlink -f $FLAGS_from` | |
| 52 FLAGS_to=`eval readlink -f $FLAGS_to` | |
| 53 | |
| 54 # Check if qemu-img and VBoxManage are available. | |
| 55 for EXTERNAL_tools in qemu-img VBoxManage; do | |
| 56 if ! type ${EXTERNAL_tools} >/dev/null 2>&1; then | |
| 57 echo "Error: This script requires ${EXTERNAL_tools}." | |
| 58 exit 1 | |
| 59 fi | |
| 60 done | |
| 61 | |
| 62 "${SCRIPTS_DIR}/image_to_vmware.sh" --format=virtualbox --from="$FLAGS_from" \ | |
| 63 --to="$(dirname "$FLAGS_to")" --vbox_disk="$(basename "$FLAGS_to")" | |
| OLD | NEW |