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 # 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 "" "${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 factory_install ${FLAGS_FALSE} \ |
| 26 "Whether to generate a factory install shim." |
25 DEFINE_boolean factory ${FLAGS_FALSE} \ | 27 DEFINE_boolean factory ${FLAGS_FALSE} \ |
26 "Whether to generate a factory runin image. Implies aututest and test" | 28 "Whether to generate a factory runin image. Implies aututest and test" |
27 DEFINE_boolean install_autotest ${FLAGS_FALSE} \ | 29 DEFINE_boolean install_autotest ${FLAGS_FALSE} \ |
28 "Whether to install autotest to the stateful partition." | 30 "Whether to install autotest to the stateful partition." |
29 DEFINE_boolean copy_kernel ${FLAGS_FALSE} \ | 31 DEFINE_boolean copy_kernel ${FLAGS_FALSE} \ |
30 "Copy the kernel to the fourth partition." | 32 "Copy the kernel to the fourth partition." |
31 DEFINE_boolean test_image "${FLAGS_FALSE}" \ | 33 DEFINE_boolean test_image "${FLAGS_FALSE}" \ |
32 "Copies normal image to chromiumos_test_image.bin, modifies it for test." | 34 "Copies normal image to chromiumos_test_image.bin, modifies it for test." |
33 DEFINE_string build_root "/build" \ | 35 DEFINE_string build_root "/build" \ |
34 "The root location for board sysroots." | 36 "The root location for board sysroots." |
35 | 37 |
36 # Parse command line | 38 # Parse command line |
37 FLAGS "$@" || exit 1 | 39 FLAGS "$@" || exit 1 |
38 eval set -- "${FLAGS_ARGV}" | 40 eval set -- "${FLAGS_ARGV}" |
39 | 41 |
| 42 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then |
| 43 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
| 44 echo "Factory test image is incompatible with factory install shim." |
| 45 exit 1 |
| 46 fi |
| 47 fi |
| 48 |
40 # Require autotest for manucaturing image. | 49 # Require autotest for manucaturing image. |
41 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | 50 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then |
42 echo "Factory image requires --install_autotest and --test_image, setting." | 51 echo "Factory image requires --install_autotest and --test_image, setting." |
43 FLAGS_install_autotest=${FLAGS_TRUE} | 52 FLAGS_install_autotest=${FLAGS_TRUE} |
44 FLAGS_test_image=${FLAGS_TRUE} | 53 FLAGS_test_image=${FLAGS_TRUE} |
45 fi | 54 fi |
46 | 55 |
| 56 # Require test for for factory install shim. |
| 57 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
| 58 echo "Factory install shim requires --test_image, setting." |
| 59 FLAGS_test_image=${FLAGS_TRUE} |
| 60 fi |
| 61 |
| 62 |
47 # Inside the chroot, so output to usb.img in the same dir as the other | 63 # Inside the chroot, so output to usb.img in the same dir as the other |
48 # Script can be run either inside or outside the chroot. | 64 # Script can be run either inside or outside the chroot. |
49 if [ ${INSIDE_CHROOT} -eq 1 ] | 65 if [ ${INSIDE_CHROOT} -eq 1 ] |
50 then | 66 then |
51 SYSROOT="${FLAGS_build_root}/${FLAGS_board}" | 67 SYSROOT="${FLAGS_build_root}/${FLAGS_board}" |
52 else | 68 else |
53 SYSROOT="${DEFAULT_CHROOT_DIR}${FLAGS_build_root}/${FLAGS_board}" | 69 SYSROOT="${DEFAULT_CHROOT_DIR}${FLAGS_build_root}/${FLAGS_board}" |
54 echo "Caching sudo authentication" | 70 echo "Caching sudo authentication" |
55 sudo -v | 71 sudo -v |
56 echo "Done" | 72 echo "Done" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 # modify that instead. | 168 # modify that instead. |
153 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then | 169 if [ ${FLAGS_test_image} -eq ${FLAGS_TRUE} ] ; then |
154 if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \ | 170 if [ ! -f "${FLAGS_from}/chromiumos_test_image.bin" ] || \ |
155 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then | 171 [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ] ; then |
156 # Copy it. | 172 # Copy it. |
157 echo "Creating test image from original..." | 173 echo "Creating test image from original..." |
158 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" | 174 cp -f "${SRC_IMAGE}" "${FLAGS_from}/chromiumos_test_image.bin" |
159 | 175 |
160 # Check for manufacturing image. | 176 # Check for manufacturing image. |
161 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | 177 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then |
162 FACTORY_ARGS="--factory" | 178 EXTRA_ARGS="--factory" |
| 179 fi |
| 180 |
| 181 # Check for instqall shim. |
| 182 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
| 183 EXTRA_ARGS="--factory_install" |
163 fi | 184 fi |
164 | 185 |
165 # Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we | 186 # Modify it. Pass --yes so that mod_image_for_test.sh won't ask us if we |
166 # really want to modify the image; the user gave their assent already with | 187 # really want to modify the image; the user gave their assent already with |
167 # --test-image and the original image is going to be preserved. | 188 # --test-image and the original image is going to be preserved. |
168 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \ | 189 "${SCRIPTS_DIR}/mod_image_for_test.sh" --image \ |
169 "${FLAGS_from}/chromiumos_test_image.bin" ${FACTORY_ARGS} --yes | 190 "${FLAGS_from}/chromiumos_test_image.bin" ${EXTRA_ARGS} --yes |
170 echo "Done with mod_image_for_test." | 191 echo "Done with mod_image_for_test." |
171 else | 192 else |
172 echo "Using cached test image." | 193 echo "Using cached test image." |
173 fi | 194 fi |
174 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" | 195 SRC_IMAGE="${FLAGS_from}/chromiumos_test_image.bin" |
175 echo "Source test image is: ${SRC_IMAGE}" | 196 echo "Source test image is: ${SRC_IMAGE}" |
176 fi | 197 fi |
177 | 198 |
178 | 199 |
179 # Let's do it. | 200 # Let's do it. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" | 249 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" |
229 echo "where /dev/sdX is the entire drive." | 250 echo "where /dev/sdX is the entire drive." |
230 if [ ${INSIDE_CHROOT} -eq 1 ] | 251 if [ ${INSIDE_CHROOT} -eq 1 ] |
231 then | 252 then |
232 example=$(basename "${FLAGS_to}") | 253 example=$(basename "${FLAGS_to}") |
233 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 254 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
234 echo "run dd outside the chroot, the path to the USB image will be" | 255 echo "run dd outside the chroot, the path to the USB image will be" |
235 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." | 256 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." |
236 fi | 257 fi |
237 fi | 258 fi |
OLD | NEW |