| 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 usb image. | 7 # Script to convert the output of build_image.sh to a usb image. |
| 8 | 8 |
| 9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
| 10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if [ -z "${FLAGS_from}" ]; then | 70 if [ -z "${FLAGS_from}" ]; then |
| 71 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 71 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
| 72 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)" | 72 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)" |
| 73 fi | 73 fi |
| 74 | 74 |
| 75 if [ ! -d "${FLAGS_from}" ] ; then | 75 if [ ! -d "${FLAGS_from}" ] ; then |
| 76 echo "Cannot find image directory ${FLAGS_from}" | 76 echo "Cannot find image directory ${FLAGS_from}" |
| 77 exit 1 | 77 exit 1 |
| 78 fi | 78 fi |
| 79 | 79 |
| 80 # If to isn't explicitly set | |
| 81 if [ -z "${FLAGS_to}" ]; then | 80 if [ -z "${FLAGS_to}" ]; then |
| 82 # Script can be run either inside or outside the chroot. | 81 echo "You must specify a file or device to write to using --to." |
| 83 if [ ${INSIDE_CHROOT} -eq 1 ] | 82 exit 1 |
| 84 then | |
| 85 # Inside the chroot, we'll only output to a file, and we probably already | |
| 86 # have a valid image. Make the user specify a filename. | |
| 87 echo "ERROR: Inside the chroot, you must specify a --to FILE to create." | |
| 88 exit 1 | |
| 89 else | |
| 90 # Outside the chroot, so output to the default device for a usb key. | |
| 91 FLAGS_to="/dev/sdb" | |
| 92 fi | |
| 93 fi | 83 fi |
| 94 | 84 |
| 95 # Convert args to paths. Need eval to un-quote the string so that shell | 85 # Convert args to paths. Need eval to un-quote the string so that shell |
| 96 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. | 86 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. |
| 97 FLAGS_from=`eval readlink -f ${FLAGS_from}` | 87 FLAGS_from=`eval readlink -f ${FLAGS_from}` |
| 98 FLAGS_to=`eval readlink -f ${FLAGS_to}` | 88 FLAGS_to=`eval readlink -f ${FLAGS_to}` |
| 99 | 89 |
| 100 # Use this image as the source image to copy | 90 # Use this image as the source image to copy |
| 101 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 91 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" |
| 102 | 92 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 216 |
| 227 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." | 217 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." |
| 228 sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M | 218 sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M |
| 229 | 219 |
| 230 echo "Done." | 220 echo "Done." |
| 231 else | 221 else |
| 232 # Output to a file, so just make a copy. | 222 # Output to a file, so just make a copy. |
| 233 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." | 223 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." |
| 234 cp -f "${SRC_IMAGE}" "${FLAGS_to}" | 224 cp -f "${SRC_IMAGE}" "${FLAGS_to}" |
| 235 | 225 |
| 236 echo "Done. To copy to USB keyfob, outside the chroot, do something like:" | 226 echo "Done. To copy to a USB drive, outside the chroot, do something like:" |
| 237 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" | 227 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" |
| 238 echo "where /dev/sdb is the entire keyfob." | 228 echo "where /dev/sdX is the entire drive." |
| 239 if [ ${INSIDE_CHROOT} -eq 1 ] | 229 if [ ${INSIDE_CHROOT} -eq 1 ] |
| 240 then | 230 then |
| 241 example=$(basename "${FLAGS_to}") | 231 example=$(basename "${FLAGS_to}") |
| 242 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 232 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
| 243 echo "run dd outside the chroot, the path to the USB image will be" | 233 echo "run dd outside the chroot, the path to the USB image will be" |
| 244 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." | 234 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." |
| 245 fi | 235 fi |
| 246 fi | 236 fi |
| OLD | NEW |