Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: image_to_usb.sh

Issue 3212012: image_to_usb: List available disks when /dev/sdX is specified (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git
Patch Set: Just change the default Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
11 . "$(dirname "$0")/common.sh" 11 . "$(dirname "$0")/common.sh"
12 12
13 # Load functions and constants for chromeos-install 13 # Load functions and constants for chromeos-install
14 . "$(dirname "$0")/chromeos-common.sh" 14 . "$(dirname "$0")/chromeos-common.sh"
15 15
16 get_default_board 16 get_default_board
17 17
18 # Flags 18 # Flags
19 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built" 19 DEFINE_string board "${DEFAULT_BOARD}" "Board for which the image was built"
20 DEFINE_string from "" \ 20 DEFINE_string from "" \
21 "Directory containing chromiumos_image.bin" 21 "Directory containing chromiumos_image.bin"
22 DEFINE_string to "" "${DEFAULT_TO_HELP}" 22 DEFINE_string to "/dev/sdX" "${DEFAULT_TO_HELP}"
23 DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y" 23 DEFINE_boolean yes ${FLAGS_FALSE} "Answer yes to all prompts" "y"
24 DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image" 24 DEFINE_boolean force_copy ${FLAGS_FALSE} "Always rebuild test image"
25 DEFINE_boolean force_non_usb ${FLAGS_FALSE} \ 25 DEFINE_boolean force_non_usb ${FLAGS_FALSE} \
26 "Write out image even if target (--to) doesn't look like a USB disk" 26 "Write out image even if target (--to) doesn't look like a USB disk"
27 DEFINE_boolean factory_install ${FLAGS_FALSE} \ 27 DEFINE_boolean factory_install ${FLAGS_FALSE} \
28 "Whether to generate a factory install shim." 28 "Whether to generate a factory install shim."
29 DEFINE_boolean factory ${FLAGS_FALSE} \ 29 DEFINE_boolean factory ${FLAGS_FALSE} \
30 "Whether to generate a factory runin image. Implies aututest and test" 30 "Whether to generate a factory runin image. Implies aututest and test"
31 DEFINE_boolean copy_kernel ${FLAGS_FALSE} \ 31 DEFINE_boolean copy_kernel ${FLAGS_FALSE} \
32 "Copy the kernel to the fourth partition." 32 "Copy the kernel to the fourth partition."
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if [ -z "${FLAGS_from}" ]; then 74 if [ -z "${FLAGS_from}" ]; then
75 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" 75 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
76 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)" 76 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)"
77 fi 77 fi
78 78
79 if [ ! -d "${FLAGS_from}" ] ; then 79 if [ ! -d "${FLAGS_from}" ] ; then
80 echo "Cannot find image directory ${FLAGS_from}" 80 echo "Cannot find image directory ${FLAGS_from}"
81 exit 1 81 exit 1
82 fi 82 fi
83 83
84 if [ -z "${FLAGS_to}" ]; then 84 if [ "${FLAGS_to}" == "/dev/sdX" ]; then
85 echo "You must specify a file or device to write to using --to." 85 echo "You must specify a file or device to write to using --to."
86 disks=$(list_usb_disks) 86 disks=$(list_usb_disks)
87 if [ -n "$disks" ]; then 87 if [ -n "$disks" ]; then
88 echo "Available USB disks:" 88 echo "Available USB disks:"
89 for disk in $disks; do 89 for disk in $disks; do
90 echo " /dev/$disk:" 90 echo " /dev/$disk:"
91 echo " Manufacturer: $(get_disk_info $disk manufacturer)" 91 echo " Manufacturer: $(get_disk_info $disk manufacturer)"
92 echo " Product: $(get_disk_info $disk product)" 92 echo " Product: $(get_disk_info $disk product)"
93 echo " Size: $[$(cat /sys/block/$disk/size) * 512] bytes" 93 echo " Size: $[$(cat /sys/block/$disk/size) * 512] bytes"
94 done 94 done
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" 227 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M"
228 echo "where /dev/sdX is the entire drive." 228 echo "where /dev/sdX is the entire drive."
229 if [ ${INSIDE_CHROOT} -eq 1 ] 229 if [ ${INSIDE_CHROOT} -eq 1 ]
230 then 230 then
231 example=$(basename "${FLAGS_to}") 231 example=$(basename "${FLAGS_to}")
232 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"
233 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"
234 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." 234 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)."
235 fi 235 fi
236 fi 236 fi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698