OLD | NEW |
1 #!/bin/sh -u | 1 #!/bin/sh -u |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # | 5 # |
6 # A script to install from removable media to hard disk. | 6 # A script to install from removable media to hard disk. |
7 | 7 |
8 # Load functions and constants for chromeos-install. | 8 # Load functions and constants for chromeos-install. |
9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 | 9 . "$(dirname "$0")/chromeos-common.sh" || exit 1 |
10 . /usr/lib/shflags || exit 1 | 10 . /usr/lib/shflags || exit 1 |
11 | 11 |
12 if [ $(uname -m) = "armv7l" ]; then | 12 if [ $(uname -m) = "armv7l" ]; then |
13 DEFAULT_DST=/dev/mmcblk0 | 13 DEFAULT_DST=/dev/mmcblk0 |
14 else | 14 else |
15 DEFAULT_DST=/dev/sda | 15 DEFAULT_DST=/dev/sda |
16 fi | 16 fi |
17 | 17 |
18 DEFINE_string dst "${DEFAULT_DST}" "Destination device" | 18 DEFINE_string dst "${DEFAULT_DST}" "Destination device" |
19 DEFINE_boolean skip_src_removable ${FLAGS_FALSE} \ | 19 DEFINE_boolean skip_src_removable ${FLAGS_FALSE} \ |
20 "Skip check to ensure source is removable" | 20 "Skip check to ensure source is removable" |
21 DEFINE_boolean skip_rootfs ${FLAGS_FALSE} \ | 21 DEFINE_boolean skip_rootfs ${FLAGS_FALSE} \ |
22 "Skip installing the rootfs; Only set up partition table" | 22 "Skip installing the rootfs; Only set up partition table" |
23 DEFINE_boolean run_as_root ${FLAGS_FALSE} \ | 23 DEFINE_boolean run_as_root ${FLAGS_FALSE} \ |
24 "Allow root to run this script (Careful, it won't prompt for a password!)" | 24 "Allow root to run this script (Careful, it won't prompt for a password!)" |
25 DEFINE_boolean yes ${FLAGS_FALSE} \ | 25 DEFINE_boolean yes ${FLAGS_FALSE} \ |
26 "Answer yes to everything" | 26 "Answer yes to everything" |
| 27 DEFINE_boolean recovery ${FLAGS_FALSE} \ |
| 28 "Install from a recovery image. Default: False" |
27 | 29 |
28 # Parse command line | 30 # Parse command line |
29 FLAGS "$@" || exit 1 | 31 FLAGS "$@" || exit 1 |
30 eval set -- "${FLAGS_ARGV}" | 32 eval set -- "${FLAGS_ARGV}" |
31 | 33 |
32 set -e | 34 set -e |
33 | 35 |
34 # Don't run this as root | 36 # Don't run this as root |
35 dont_run_as_root | 37 dont_run_as_root |
36 | 38 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 203 |
202 ############################################################################## | 204 ############################################################################## |
203 | 205 |
204 # What do we expect & require to have on the source device? | 206 # What do we expect & require to have on the source device? |
205 STATEFUL_IMG=$(make_partition_dev ${SRC} 1) | 207 STATEFUL_IMG=$(make_partition_dev ${SRC} 1) |
206 KERNEL_IMG=$(make_partition_dev ${SRC} 2) | 208 KERNEL_IMG=$(make_partition_dev ${SRC} 2) |
207 ROOTFS_IMG=$(make_partition_dev ${SRC} 3) | 209 ROOTFS_IMG=$(make_partition_dev ${SRC} 3) |
208 OEM_IMG=$(make_partition_dev ${SRC} 8) | 210 OEM_IMG=$(make_partition_dev ${SRC} 8) |
209 ESP_IMG=$(make_partition_dev ${SRC} 12) | 211 ESP_IMG=$(make_partition_dev ${SRC} 12) |
210 | 212 |
| 213 # For recovery image, copy from ROOT-B and KERN-B to destination |
| 214 if [ "$FLAGS_recovery" -eq "$FLAGS_TRUE" ]; then |
| 215 KERNEL_IMG=$(make_partition_dev ${SRC} 4) |
| 216 ROOTFS_IMG=$(make_partition_dev ${SRC} 5) |
| 217 fi |
| 218 |
211 if [ $(uname -m) = "armv7l" ]; then | 219 if [ $(uname -m) = "armv7l" ]; then |
212 PMBRCODE=/dev/zero | 220 PMBRCODE=/dev/zero |
213 else | 221 else |
214 # Steal the PMBR code from the source MBR to put on the dest MBR, for booting | 222 # Steal the PMBR code from the source MBR to put on the dest MBR, for booting |
215 # on legacy-BIOS devices. | 223 # on legacy-BIOS devices. |
216 sudo dd if=$SRC of=$PMBRCODE bs=512 count=1 | 224 sudo dd if=$SRC of=$PMBRCODE bs=512 count=1 |
217 fi | 225 fi |
218 | 226 |
219 # Create the GPT. | 227 # Create the GPT. |
220 install_gpt $FLAGS_dst $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG | 228 install_gpt $FLAGS_dst $ROOTFS_IMG $KERNEL_IMG $STATEFUL_IMG $PMBRCODE $ESP_IMG |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 --set bootcmd="mmc read 0 C0008000 0 1; autoscr C0008000" | 315 --set bootcmd="mmc read 0 C0008000 0 1; autoscr C0008000" |
308 fi | 316 fi |
309 | 317 |
310 # Force data to disk before we declare done. | 318 # Force data to disk before we declare done. |
311 sync | 319 sync |
312 | 320 |
313 echo "------------------------------------------------------------" | 321 echo "------------------------------------------------------------" |
314 echo "" | 322 echo "" |
315 echo "Installation to '$FLAGS_dst' complete." | 323 echo "Installation to '$FLAGS_dst' complete." |
316 echo "Please shutdown, remove the USB device, cross your fingers, and reboot." | 324 echo "Please shutdown, remove the USB device, cross your fingers, and reboot." |
OLD | NEW |