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 14 matching lines...) Expand all Loading... |
25 DEFINE_boolean factory_install ${FLAGS_FALSE} \ | 25 DEFINE_boolean factory_install ${FLAGS_FALSE} \ |
26 "Whether to generate a factory install shim." | 26 "Whether to generate a factory install shim." |
27 DEFINE_boolean factory ${FLAGS_FALSE} \ | 27 DEFINE_boolean factory ${FLAGS_FALSE} \ |
28 "Whether to generate a factory runin image. Implies aututest and test" | 28 "Whether to generate a factory runin image. Implies aututest and test" |
29 DEFINE_boolean install_autotest ${FLAGS_FALSE} \ | 29 DEFINE_boolean install_autotest ${FLAGS_FALSE} \ |
30 "Whether to install autotest to the stateful partition." | 30 "Whether to install autotest to the stateful partition." |
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." |
33 DEFINE_boolean test_image "${FLAGS_FALSE}" \ | 33 DEFINE_boolean test_image "${FLAGS_FALSE}" \ |
34 "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." |
| 35 DEFINE_string image_name "chromiumos_image.bin" \ |
| 36 "Base name of the image" i |
35 DEFINE_string build_root "/build" \ | 37 DEFINE_string build_root "/build" \ |
36 "The root location for board sysroots." | 38 "The root location for board sysroots." |
37 | 39 |
38 # Parse command line | 40 # Parse command line |
39 FLAGS "$@" || exit 1 | 41 FLAGS "$@" || exit 1 |
40 eval set -- "${FLAGS_ARGV}" | 42 eval set -- "${FLAGS_ARGV}" |
41 | 43 |
42 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then | 44 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ] ; then |
43 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then | 45 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ] ; then |
44 echo "Factory test image is incompatible with factory install shim." | 46 echo "Factory test image is incompatible with factory install shim." |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 echo "You must specify a file or device to write to using --to." | 99 echo "You must specify a file or device to write to using --to." |
98 exit 1 | 100 exit 1 |
99 fi | 101 fi |
100 | 102 |
101 # Convert args to paths. Need eval to un-quote the string so that shell | 103 # Convert args to paths. Need eval to un-quote the string so that shell |
102 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. | 104 # chars like ~ are processed; just doing FOO=`readlink -f ${FOO}` won't work. |
103 FLAGS_from=`eval readlink -f ${FLAGS_from}` | 105 FLAGS_from=`eval readlink -f ${FLAGS_from}` |
104 FLAGS_to=`eval readlink -f ${FLAGS_to}` | 106 FLAGS_to=`eval readlink -f ${FLAGS_to}` |
105 | 107 |
106 # Use this image as the source image to copy | 108 # Use this image as the source image to copy |
107 SRC_IMAGE="${FLAGS_from}/chromiumos_image.bin" | 109 SRC_IMAGE="${FLAGS_from}/${FLAGS_image_name}" |
108 | 110 |
109 STATEFUL_DIR="${FLAGS_from}/stateful_partition" | 111 STATEFUL_DIR="${FLAGS_from}/stateful_partition" |
110 mkdir -p "${STATEFUL_DIR}" | 112 mkdir -p "${STATEFUL_DIR}" |
111 | 113 |
112 function do_cleanup { | 114 function do_cleanup { |
113 echo "Cleaning loopback devices: ${STATEFUL_LOOP_DEV}" | 115 echo "Cleaning loopback devices: ${STATEFUL_LOOP_DEV}" |
114 if [ "${STATEFUL_LOOP_DEV}" != "" ]; then | 116 if [ "${STATEFUL_LOOP_DEV}" != "" ]; then |
115 sudo umount "${STATEFUL_DIR}" | 117 sudo umount "${STATEFUL_DIR}" |
116 sudo losetup -d "${STATEFUL_LOOP_DEV}" | 118 sudo losetup -d "${STATEFUL_LOOP_DEV}" |
117 rmdir "${STATEFUL_DIR}" | 119 rmdir "${STATEFUL_DIR}" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" | 258 echo " sudo dd if=${FLAGS_to} of=/dev/sdX bs=4M" |
257 echo "where /dev/sdX is the entire drive." | 259 echo "where /dev/sdX is the entire drive." |
258 if [ ${INSIDE_CHROOT} -eq 1 ] | 260 if [ ${INSIDE_CHROOT} -eq 1 ] |
259 then | 261 then |
260 example=$(basename "${FLAGS_to}") | 262 example=$(basename "${FLAGS_to}") |
261 echo "NOTE: Since you are currently inside the chroot, and you'll need to" | 263 echo "NOTE: Since you are currently inside the chroot, and you'll need to" |
262 echo "run dd outside the chroot, the path to the USB image will be" | 264 echo "run dd outside the chroot, the path to the USB image will be" |
263 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." | 265 echo "different (ex: ~/chromeos/trunk/src/build/images/SOME_DIR/$example)." |
264 fi | 266 fi |
265 fi | 267 fi |
OLD | NEW |