| 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" |
| 15 sleep 10 |
| 14 | 16 |
| 15 # 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. |
| 16 # This works on x86 only, afaik. | 18 # This works on x86 only, afaik. |
| 17 DST=/dev/sda | 19 DST=/dev/sda |
| 18 DST_FACTORY_PART=3 | 20 DST_FACTORY_PART=3 |
| 19 DST_RELEASE_PART=5 | 21 DST_RELEASE_PART=5 |
| 20 DST_OEM_PART=8 | 22 DST_OEM_PART=8 |
| 23 DST_EFI_PART=12 |
| 21 DST_STATE_PART=1 | 24 DST_STATE_PART=1 |
| 22 | 25 |
| 23 log "Factory Install: Setting partition table" | 26 log "Factory Install: Setting partition table" |
| 24 | 27 |
| 25 /usr/sbin/chromeos-install --dst "${DST}" --skip_rootfs --run_as_root --yes \ | 28 /usr/sbin/chromeos-install --dst "${DST}" --skip_rootfs --run_as_root --yes \ |
| 26 2>&1 | cat >> "$MEMENTO_AU_LOG" | 29 2>&1 | cat >> "$MEMENTO_AU_LOG" |
| 27 | 30 |
| 28 # Load the new partition table. The autoupdater has trouble with loop devices. | 31 # Load the new partition table. The autoupdater has trouble with loop devices. |
| 29 sync | 32 sync |
| 30 echo 3 > /proc/sys/vm/drop_caches | 33 echo 3 > /proc/sys/vm/drop_caches |
| 31 /sbin/sfdisk -R "$DST" | 34 /sbin/sfdisk -R "$DST" |
| 32 | 35 |
| 33 FACTORY_CHANNEL_ARG='--force_track=factory-channel' | 36 FACTORY_CHANNEL_ARG='--force_track=factory-channel' |
| 34 RELEASE_CHANNEL_ARG='--force_track=release-channel' | 37 RELEASE_CHANNEL_ARG='--force_track=release-channel' |
| 35 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' | 38 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' |
| 39 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' |
| 36 STATE_CHANNEL_ARG='--force_track=stateimg-channel' | 40 STATE_CHANNEL_ARG='--force_track=stateimg-channel' |
| 37 | 41 |
| 38 # Install the partitions | 42 # Install the partitions |
| 39 for i in OEM STATE RELEASE FACTORY; do | 43 for i in EFI OEM STATE RELEASE FACTORY; do |
| 40 PART=$(eval "echo \$DST_${i}_PART") | 44 PART=$(eval "echo \$DST_${i}_PART") |
| 41 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") | 45 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") |
| 42 KPART="none" | 46 KPART="none" |
| 43 | 47 |
| 44 log "Factory Install: Installing $i partition to $PART" | 48 log "Factory Install: Installing $i partition to $PART" |
| 45 | 49 |
| 46 SKIP_POSTINST_ARG="--skip_postinst" | 50 SKIP_POSTINST_ARG="--skip_postinst" |
| 47 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then | 51 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then |
| 48 # Set up kernel partition | 52 # Set up kernel partition |
| 49 SKIP_POSTINST_ARG="" | 53 SKIP_POSTINST_ARG="" |
| 50 KPART="" | 54 KPART="" |
| 51 fi | 55 fi |
| 52 | 56 |
| 53 RESULT="$(/opt/google/memento_updater/memento_updater.sh --dst_partition \ | 57 RESULT="$(/opt/google/memento_updater/memento_updater.sh --dst_partition \ |
| 54 "${DST}${PART}" --kernel_partition "${KPART}" \ | 58 "${DST}${PART}" --kernel_partition "${KPART}" \ |
| 55 --allow_removable_boot $CHANNEL_ARG $SKIP_POSTINST_ARG)" | 59 --allow_removable_boot $CHANNEL_ARG $SKIP_POSTINST_ARG)" |
| 56 | 60 |
| 57 if [ "$RESULT" != "UPDATED" ]; then | 61 if [ "$RESULT" != "UPDATED" ]; then |
| 58 log "Factory Install: AU failed" | 62 log "Factory Install: AU failed" |
| 59 exit 1 | 63 exit 1 |
| 60 fi | 64 fi |
| 61 done | 65 done |
| 62 | 66 |
| 63 log "All done installing." | 67 log "All done installing." |
| 64 | 68 |
| 65 shutdown -r now | 69 shutdown -r now |
| 66 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down | 70 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down |
| OLD | NEW |