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 | 13 |
14 # Flags | 14 # Flags |
15 DEFINE_string board "" "Board for which the image was built" | 15 DEFINE_string board "" "Board for which the image was built" |
16 DEFINE_string from "" \ | 16 DEFINE_string from "" \ |
17 "Directory containing rootfs.image and mbr.image" | 17 "Directory containing rootfs.image and mbr.image" |
18 DEFINE_string to "" "$DEFAULT_TO_HELP" | 18 DEFINE_string to "" "$DEFAULT_TO_HELP" |
19 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" | 19 DEFINE_boolean yes $FLAGS_FALSE "Answer yes to all prompts" "y" |
20 DEFINE_boolean install_autotest $FLAGS_FALSE \ | 20 DEFINE_boolean install_autotest $FLAGS_FALSE \ |
21 "Whether to install autotest to the stateful partition." | 21 "Whether to install autotest to the stateful partition." |
| 22 DEFINE_boolean copy_kernel $FLAGS_FALSE \ |
| 23 "Copy the kernel to the fourth partition." |
22 | 24 |
23 # Parse command line | 25 # Parse command line |
24 FLAGS "$@" || exit 1 | 26 FLAGS "$@" || exit 1 |
25 eval set -- "${FLAGS_ARGV}" | 27 eval set -- "${FLAGS_ARGV}" |
26 | 28 |
27 # Inside the chroot, so output to usb.img in the same dir as the other | 29 # Inside the chroot, so output to usb.img in the same dir as the other |
28 # Script can be run either inside or outside the chroot. | 30 # Script can be run either inside or outside the chroot. |
29 if [ $INSIDE_CHROOT -eq 1 ] | 31 if [ $INSIDE_CHROOT -eq 1 ] |
30 then | 32 then |
31 AUTOTEST_SRC="/usr/local/autotest/${FLAGS_board}" | 33 AUTOTEST_SRC="/usr/local/autotest/${FLAGS_board}" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 then | 154 then |
153 sudo mount "${LOOP_DEV}" "${STATEFUL_DIR}" | 155 sudo mount "${LOOP_DEV}" "${STATEFUL_DIR}" |
154 install_autotest | 156 install_autotest |
155 fi | 157 fi |
156 sync | 158 sync |
157 sudo losetup -d "$LOOP_DEV" | 159 sudo losetup -d "$LOOP_DEV" |
158 sync | 160 sync |
159 | 161 |
160 trap - EXIT | 162 trap - EXIT |
161 | 163 |
| 164 if [ $FLAGS_copy_kernel -eq $FLAGS_TRUE ] |
| 165 then |
| 166 echo "Copying Kernel..." |
| 167 "${SCRIPTS_DIR}"/kernel_fetcher.sh \ |
| 168 --from "${FLAGS_from}" \ |
| 169 --to "${FLAGS_to}" \ |
| 170 --offset "$(( ($PART_SIZE * 3) + 512 ))" |
| 171 fi |
| 172 |
162 echo "Copying MBR..." | 173 echo "Copying MBR..." |
163 sudo "${SCRIPTS_DIR}"/file_copy.py \ | 174 sudo "${SCRIPTS_DIR}"/file_copy.py \ |
164 if="${FLAGS_from}/mbr.image" of="$FLAGS_to" | 175 if="${FLAGS_from}/mbr.image" of="$FLAGS_to" |
165 sync | 176 sync |
166 echo "Done." | 177 echo "Done." |
167 else | 178 else |
168 # Output to a file, so just cat the source images together | 179 # Output to a file, so just cat the source images together |
169 | 180 |
170 PART_SIZE=$(stat -c%s "${FLAGS_from}/rootfs.image") | 181 PART_SIZE=$(stat -c%s "${FLAGS_from}/rootfs.image") |
171 | 182 |
(...skipping 23 matching lines...) Expand all Loading... |
195 echo "Done. To copy to USB keyfob, outside the chroot, do something like:" | 206 echo "Done. To copy to USB keyfob, outside the chroot, do something like:" |
196 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" | 207 echo " sudo dd if=${FLAGS_to} of=/dev/sdb bs=4M" |
197 echo "where /dev/sdb is the entire keyfob." | 208 echo "where /dev/sdb is the entire keyfob." |
198 if [ $INSIDE_CHROOT -eq 1 ] | 209 if [ $INSIDE_CHROOT -eq 1 ] |
199 then | 210 then |
200 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 211 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
201 echo "run dd outside the chroot, the path to the USB image will be" | 212 echo "run dd outside the chroot, the path to the USB image will be" |
202 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/usb.img)." | 213 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/usb.img)." |
203 fi | 214 fi |
204 fi | 215 fi |
OLD | NEW |