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. |
11 . "$(dirname "$0")/common.sh" | 11 . "$(dirname "$0")/common.sh" |
12 | 12 |
| 13 get_default_board |
13 | 14 |
14 # Flags | 15 # Flags |
15 DEFINE_string board "" "Board for which the image was built" | 16 DEFINE_string board "$DEFAULT_BOARD" "Board for which the image was built" |
16 DEFINE_string from "" \ | 17 DEFINE_string from "" \ |
17 "Directory containing rootfs.image and mbr.image" | 18 "Directory containing rootfs.image and mbr.image" |
18 DEFINE_string to "" "$DEFAULT_TO_HELP" | 19 DEFINE_string to "" "$DEFAULT_TO_HELP" |
19 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" | 20 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" |
20 DEFINE_boolean install_autotest $FLAGS_FALSE \ | 21 DEFINE_boolean install_autotest $FLAGS_FALSE \ |
21 "Whether to install autotest to the stateful partition." | 22 "Whether to install autotest to the stateful partition." |
22 DEFINE_boolean copy_kernel $FLAGS_FALSE \ | 23 DEFINE_boolean copy_kernel $FLAGS_FALSE \ |
23 "Copy the kernel to the fourth partition." | 24 "Copy the kernel to the fourth partition." |
24 | 25 |
25 # Parse command line | 26 # Parse command line |
26 FLAGS "$@" || exit 1 | 27 FLAGS "$@" || exit 1 |
27 eval set -- "${FLAGS_ARGV}" | 28 eval set -- "${FLAGS_ARGV}" |
28 | 29 |
29 # Inside the chroot, so output to usb.img in the same dir as the other | 30 # Inside the chroot, so output to usb.img in the same dir as the other |
30 # Script can be run either inside or outside the chroot. | 31 # Script can be run either inside or outside the chroot. |
31 if [ $INSIDE_CHROOT -eq 1 ] | 32 if [ $INSIDE_CHROOT -eq 1 ] |
32 then | 33 then |
33 AUTOTEST_SRC="/usr/local/autotest/${FLAGS_board}" | 34 AUTOTEST_SRC="/usr/local/autotest/${FLAGS_board}" |
34 else | 35 else |
35 AUTOTEST_SRC="${DEFAULT_CHROOT_DIR}/usr/local/autotest/${FLAGS_board}" | 36 AUTOTEST_SRC="${DEFAULT_CHROOT_DIR}/usr/local/autotest/${FLAGS_board}" |
36 fi | 37 fi |
37 | 38 |
38 # Die on any errors. | 39 # Die on any errors. |
39 set -e | 40 set -e |
40 | 41 |
41 # If from isn't explicitly set | 42 # No board, no default and no image set then we can't find the image |
| 43 if [ -z $FLAGS_from ] && [ -z $FLAGS_board ] ; then |
| 44 setup_board_warning |
| 45 exit 1 |
| 46 fi |
| 47 |
| 48 # We have a board name but no image set. Use image at default location |
42 if [ -z "$FLAGS_from" ]; then | 49 if [ -z "$FLAGS_from" ]; then |
43 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" | 50 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" |
44 FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)" | 51 FLAGS_from="${IMAGES_DIR}/$(ls -t $IMAGES_DIR 2>&-| head -1)" |
45 fi | 52 fi |
46 | 53 |
| 54 if [ ! -d "$FLAGS_from" ] ; then |
| 55 echo "Cannot find image directory $FLAGS_from" |
| 56 exit 1 |
| 57 fi |
| 58 |
47 # If to isn't explicitly set | 59 # If to isn't explicitly set |
48 if [ -z "$FLAGS_to" ]; then | 60 if [ -z "$FLAGS_to" ]; then |
49 # Script can be run either inside or outside the chroot. | 61 # Script can be run either inside or outside the chroot. |
50 if [ $INSIDE_CHROOT -eq 1 ] | 62 if [ $INSIDE_CHROOT -eq 1 ] |
51 then | 63 then |
52 # Inside the chroot, so output to usb.img in the same dir as the other | 64 # Inside the chroot, so output to usb.img in the same dir as the other |
53 # images. | 65 # images. |
54 FLAGS_to="${FLAGS_from}/usb.img" | 66 FLAGS_to="${FLAGS_from}/usb.img" |
55 else | 67 else |
56 # Outside the chroot, so output to the default device for a usb key. | 68 # Outside the chroot, so output to the default device for a usb key. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 echo "Done. To copy to USB keyfob, outside the chroot, do something like:" | 218 echo "Done. To copy to USB keyfob, outside the chroot, do something like:" |
207 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" | 219 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" |
208 echo "where /dev/sdb is the entire keyfob." | 220 echo "where /dev/sdb is the entire keyfob." |
209 if [ $INSIDE_CHROOT -eq 1 ] | 221 if [ $INSIDE_CHROOT -eq 1 ] |
210 then | 222 then |
211 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 223 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
212 echo "run dd outside the chroot, the path to the USB image will be" | 224 echo "run dd outside the chroot, the path to the USB image will be" |
213 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/usb.img)." | 225 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/usb.img)." |
214 fi | 226 fi |
215 fi | 227 fi |
OLD | NEW |