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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if [ "${SURE}" != "y" ] | 225 if [ "${SURE}" != "y" ] |
226 then | 226 then |
227 echo "Ok, better safe than sorry." | 227 echo "Ok, better safe than sorry." |
228 exit 1 | 228 exit 1 |
229 fi | 229 fi |
230 fi | 230 fi |
231 | 231 |
232 echo "Attempting to unmount any mounts on the USB device..." | 232 echo "Attempting to unmount any mounts on the USB device..." |
233 for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}') | 233 for i in $(mount | grep ^"${FLAGS_to}" | awk '{print $1}') |
234 do | 234 do |
235 sudo umount "$i" | 235 if sudo umount "$i" 2>&1 >/dev/null | grep "not found"; then |
| 236 echo |
| 237 echo "The device you have specified is already mounted at some point " |
| 238 echo "that is not visible from inside the chroot. Please unmount the " |
| 239 echo "device manually from outside the chroot and try again." |
| 240 echo |
| 241 exit 1 |
| 242 fi |
236 done | 243 done |
237 sleep 3 | 244 sleep 3 |
238 | 245 |
239 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." | 246 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." |
240 sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M | 247 sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M |
241 | 248 |
242 echo "Done." | 249 echo "Done." |
243 else | 250 else |
244 # Output to a file, so just make a copy. | 251 # Output to a file, so just make a copy. |
245 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." | 252 echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." |
246 cp -f "${SRC_IMAGE}" "${FLAGS_to}" | 253 cp -f "${SRC_IMAGE}" "${FLAGS_to}" |
247 | 254 |
248 echo "Done. To copy to a USB drive, outside the chroot, do something like:" | 255 echo "Done. To copy to a USB drive, outside the chroot, do something like:" |
249 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" | 256 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" |
250 echo "where /dev/sdX is the entire drive." | 257 echo "where /dev/sdX is the entire drive." |
251 if [ ${INSIDE_CHROOT} -eq 1 ] | 258 if [ ${INSIDE_CHROOT} -eq 1 ] |
252 then | 259 then |
253 example=$(basename "${FLAGS_to}") | 260 example=$(basename "${FLAGS_to}") |
254 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 261 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
255 echo "run dd outside the chroot, the path to the USB image will be" | 262 echo "run dd outside the chroot, the path to the USB image will be" |
256 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." | 263 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." |
257 fi | 264 fi |
258 fi | 265 fi |
OLD | NEW |