OLD | NEW |
1 #!/bin/sh -e | 1 #!/bin/sh -e |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 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 . "$(dirname "$0")/chromeos-common.sh" | 7 . "$(dirname "$0")/chromeos-common.sh" |
8 . "/opt/google/memento_updater/memento_updater_logging.sh" | 8 . "/opt/google/memento_updater/memento_updater_logging.sh" |
9 | 9 |
10 if [ $(id -u) -ne 0 ]; then | 10 if [ $(id -u) -ne 0 ]; then |
11 echo "You must run this as root." | 11 echo "You must run this as root." |
12 exit 1 | 12 exit 1 |
13 fi | 13 fi |
14 log "Pause to ensure ethernet connectivity" | 14 log "Pause to ensure ethernet connectivity" |
15 sleep 10 | 15 sleep 10 |
16 | 16 |
17 # TODO(adlr): pick an install device in a matter that works on x86 and ARM. | 17 # TODO(adlr): pick an install device in a matter that works on x86 and ARM. |
18 # This works on x86 only, afaik. | 18 # This works on x86 only, afaik. |
19 DST=/dev/sda | 19 DST_DRIVE=/dev/sda |
20 DST_FACTORY_PART=3 | 20 DST_FACTORY_PART=3 |
21 DST_RELEASE_PART=5 | 21 DST_RELEASE_PART=5 |
22 DST_OEM_PART=8 | 22 DST_OEM_PART=8 |
23 DST_EFI_PART=12 | 23 DST_EFI_PART=12 |
24 DST_STATE_PART=1 | 24 DST_STATE_PART=1 |
| 25 DST_FIRMWARE=/tmp/firmware.sh |
25 | 26 |
26 log "Factory Install: Setting partition table" | 27 log "Factory Install: Setting partition table" |
27 | 28 |
28 /usr/sbin/chromeos-install --dst "${DST}" --skip_rootfs --run_as_root --yes \ | 29 /usr/sbin/chromeos-install --dst "${DST_DRIVE}" --skip_rootfs --run_as_root \ |
29 2>&1 | cat >> "$MEMENTO_AU_LOG" | 30 --yes 2>&1 | cat >> "$MEMENTO_AU_LOG" |
30 | 31 |
31 # Load the new partition table. The autoupdater has trouble with loop devices. | 32 # Load the new partition table. The autoupdater has trouble with loop devices. |
32 sync | 33 sync |
33 echo 3 > /proc/sys/vm/drop_caches | 34 echo 3 > /proc/sys/vm/drop_caches |
34 /sbin/sfdisk -R "$DST" | 35 /sbin/sfdisk -R "$DST_DRIVE" |
35 | 36 |
36 FACTORY_CHANNEL_ARG='--force_track=factory-channel' | 37 FACTORY_CHANNEL_ARG='--force_track=factory-channel' |
37 RELEASE_CHANNEL_ARG='--force_track=release-channel' | 38 RELEASE_CHANNEL_ARG='--force_track=release-channel' |
38 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' | 39 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' |
39 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' | 40 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' |
40 STATE_CHANNEL_ARG='--force_track=stateimg-channel' | 41 STATE_CHANNEL_ARG='--force_track=stateimg-channel' |
| 42 FIRMWARE_CHANNEL_ARG='--force_track=firmware-channel' |
41 | 43 |
42 # Install the partitions | 44 # Install the partitions |
43 for i in EFI OEM STATE RELEASE FACTORY; do | 45 for i in EFI OEM STATE RELEASE FACTORY FIRMWARE; do |
44 PART=$(eval "echo \$DST_${i}_PART") | 46 if [ "$i" = "FIRMWARE" ]; then |
| 47 DST="${DST_FIRMWARE}" |
| 48 else |
| 49 PART=$(eval "echo \$DST_${i}_PART") |
| 50 DST="${DST_DRIVE}${PART}" |
| 51 fi |
| 52 |
| 53 log "Factory Install: Installing $i image to $DST" |
| 54 |
45 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") | 55 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") |
| 56 SKIP_POSTINST_ARG="--skip_postinst" |
46 KPART="none" | 57 KPART="none" |
47 | |
48 log "Factory Install: Installing $i partition to $PART" | |
49 | |
50 SKIP_POSTINST_ARG="--skip_postinst" | |
51 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then | 58 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then |
52 # Set up kernel partition | 59 # Set up kernel partition |
53 SKIP_POSTINST_ARG="" | 60 SKIP_POSTINST_ARG="" |
54 KPART="" | 61 KPART="" |
55 fi | 62 fi |
56 | 63 |
57 RESULT="$(/opt/google/memento_updater/memento_updater.sh --dst_partition \ | 64 RESULT="$(/opt/google/memento_updater/memento_updater.sh --dst_partition \ |
58 "${DST}${PART}" --kernel_partition "${KPART}" \ | 65 "${DST}" --kernel_partition "${KPART}" \ |
59 --allow_removable_boot $CHANNEL_ARG $SKIP_POSTINST_ARG)" | 66 --allow_removable_boot $CHANNEL_ARG $SKIP_POSTINST_ARG)" |
60 | 67 |
61 if [ "$RESULT" != "UPDATED" ]; then | 68 # Firmware update is optional; still OK if it does not be updated. |
| 69 if [ "$RESULT" != "UPDATED" -a "$i" != "FIRMWARE" ]; then |
62 log "Factory Install: AU failed" | 70 log "Factory Install: AU failed" |
63 exit 1 | 71 exit 1 |
64 fi | 72 fi |
65 done | 73 done |
66 | 74 |
67 log "All done installing." | 75 log "All done installing." |
68 | 76 |
69 shutdown -r now | 77 shutdown -r now |
70 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down | 78 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down |
OLD | NEW |