OLD | NEW |
---|---|
1 #!/bin/sh -ex | 1 #!/bin/sh -ex |
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 . "/opt/google/memento_updater/find_omaha.sh" | 9 . "/opt/google/memento_updater/find_omaha.sh" |
10 | 10 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 # Ensure that flash chips are in a known good state. | 82 # Ensure that flash chips are in a known good state. |
83 clear_fwwp | 83 clear_fwwp |
84 | 84 |
85 # Ensure that we can wipe TPM if necessary. | 85 # Ensure that we can wipe TPM if necessary. |
86 clear_tpm | 86 clear_tpm |
87 fi | 87 fi |
88 fi | 88 fi |
89 | 89 |
90 log "Waiting for ethernet connectivity to install" | 90 log "Waiting for ethernet connectivity to install" |
91 log "Or disable developer mode to factory reset." | 91 log "Or disable developer mode to factory reset." |
92 while ! ifconfig eth0 | grep -q "inet addr"; do | 92 while ! ifconfig eth0 | grep -q "inet addr" && \ |
Hung-Te
2011/03/29 12:57:34
Why do we want two inet devices?
And, you don't ne
Nick Sanders
2011/03/30 00:10:44
This indicates, "loop until either eth0 or eth1 is
Che-Liang Chiou
2011/03/30 08:57:44
I changed this part, and hope that it would be mor
| |
93 ! ifconfig eth1 | grep -q "inet addr"; do | |
93 # If developer switch is flipped, go to "reset mode" instead of | 94 # If developer switch is flipped, go to "reset mode" instead of |
94 # network install mode. Make sure gpio can be read (gpio_setup may | 95 # network install mode. Make sure gpio can be read (gpio_setup may |
95 # fail if the device is not ready). | 96 # fail if the device is not ready). |
96 if [ "$(crossystem devsw_cur)" = "0" ]; then | 97 if [ "$(crossystem devsw_cur)" = "0" ]; then |
97 log "Performing factory reset" | 98 log "Performing factory reset" |
98 if ! /usr/sbin/factory_reset.sh; then | 99 if ! /usr/sbin/factory_reset.sh; then |
99 log "Factory reset failed." | 100 log "Factory reset failed." |
100 exit 1 | 101 exit 1 |
101 fi | 102 fi |
102 | 103 |
103 log "Done" | 104 log "Done" |
104 exit 0 | 105 exit 0 |
105 fi | 106 fi |
106 sleep 1 | 107 sleep 1 |
107 done | 108 done |
108 log "$(ifconfig eth0 | grep 'inet addr')" | 109 log "eth0: $(ifconfig eth0 | grep 'inet addr')" |
110 log "eth1: $(ifconfig eth1 | grep 'inet addr')" | |
109 | 111 |
110 set_time || exit 1 | 112 set_time || exit 1 |
111 | 113 |
112 # TODO(adlr): pick an install device in a matter that works on x86 and ARM. | 114 # Is there a better x86 test? |
113 # This works on x86 only, afaik. | 115 if uname -m | grep -q "^i.86\$"; then |
114 DST_DRIVE=/dev/sda | 116 ARCH="INTEL" |
117 elif [ $(uname -m ) = "x86_64" ]; then | |
118 ARCH="INTEL" | |
119 elif [ $(uname -m ) = "armv7l" ]; then | |
Hung-Te
2011/03/29 12:57:34
So we only support v71?
| |
120 ARCH="ARM" | |
121 else | |
Nick Sanders
2011/03/30 00:10:44
This has been an annoying problem in general:
http
| |
122 log "Error: Failed to auto detect architecture" | |
123 exit 1 | |
124 fi | |
125 | |
126 if [ "$ARCH" = "INTEL" ]; then | |
127 DST_DRIVE=/dev/sda | |
128 else | |
129 DST_DRIVE=/dev/mmcblk0 | |
130 fi | |
115 DST_FACTORY_PART=3 | 131 DST_FACTORY_PART=3 |
116 DST_RELEASE_PART=5 | 132 DST_RELEASE_PART=5 |
117 DST_OEM_PART=8 | 133 DST_OEM_PART=8 |
118 DST_EFI_PART=12 | 134 DST_EFI_PART=12 |
119 DST_STATE_PART=1 | 135 DST_STATE_PART=1 |
120 DST_FIRMWARE=/tmp/firmware.sh | 136 DST_FIRMWARE=/tmp/firmware.sh |
121 | 137 |
122 # Light up screen in case you can't see our splash image. | 138 # Light up screen in case you can't see our splash image. |
123 LIGHTUP_SCREEN="/usr/sbin/lightup_screen" | 139 LIGHTUP_SCREEN="/usr/sbin/lightup_screen" |
124 if [ -x /usr/sbin/lightup_screen ]; then | 140 if [ -x "${LIGHTUP_SCREEN}" ]; then |
125 ${LIGHTUP_SCREEN} | 141 ${LIGHTUP_SCREEN} |
126 else | 142 else |
127 log "${LIGHTUP_SCREEN} does not exist or not executable" | 143 log "${LIGHTUP_SCREEN} does not exist or not executable" |
128 fi | 144 fi |
129 | 145 |
130 log "Factory Install: Setting partition table" | 146 log "Factory Install: Setting partition table" |
131 | 147 |
132 INST_FLAGS="--dst ${DST_DRIVE} --skip_rootfs --run_as_root --yes" | 148 INST_FLAGS="--dst ${DST_DRIVE} --skip_rootfs --run_as_root --yes" |
133 | 149 |
134 # in factory mode, we need both GPT_LAYOUT and PMBR_CODE always generated. | 150 # in factory mode, we need both GPT_LAYOUT and PMBR_CODE always generated. |
(...skipping 13 matching lines...) Expand all Loading... | |
148 log "FACTORY INSTALLER STOPPED." | 164 log "FACTORY INSTALLER STOPPED." |
149 exit 1 | 165 exit 1 |
150 fi | 166 fi |
151 | 167 |
152 /usr/sbin/chromeos-install $INST_FLAGS 2>&1 | cat >> "$MEMENTO_AU_LOG" | 168 /usr/sbin/chromeos-install $INST_FLAGS 2>&1 | cat >> "$MEMENTO_AU_LOG" |
153 | 169 |
154 # Load the new partition table. The autoupdater has trouble with loop devices. | 170 # Load the new partition table. The autoupdater has trouble with loop devices. |
155 sync | 171 sync |
156 echo 3 > /proc/sys/vm/drop_caches | 172 echo 3 > /proc/sys/vm/drop_caches |
157 /sbin/sfdisk -R "$DST_DRIVE" | 173 /sbin/sfdisk -R "$DST_DRIVE" |
174 partprobe # inform the OS of partition table changes | |
158 | 175 |
159 log "Done preparing disk" | 176 log "Done preparing disk" |
160 | 177 |
161 FACTORY_CHANNEL_ARG='--force_track=factory-channel' | 178 FACTORY_CHANNEL_ARG='--force_track=factory-channel' |
162 RELEASE_CHANNEL_ARG='--force_track=release-channel' | 179 RELEASE_CHANNEL_ARG='--force_track=release-channel' |
163 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' | 180 OEM_CHANNEL_ARG='--force_track=oempartitionimg-channel' |
164 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' | 181 EFI_CHANNEL_ARG='--force_track=efipartitionimg-channel' |
165 STATE_CHANNEL_ARG='--force_track=stateimg-channel' | 182 STATE_CHANNEL_ARG='--force_track=stateimg-channel' |
166 FIRMWARE_CHANNEL_ARG='--force_track=firmware-channel' | 183 FIRMWARE_CHANNEL_ARG='--force_track=firmware-channel' |
167 | 184 |
168 # Install the partitions | 185 # Install the partitions |
169 for i in EFI OEM STATE RELEASE FACTORY FIRMWARE; do | 186 for i in EFI OEM STATE RELEASE FACTORY FIRMWARE; do |
170 if [ "$i" = "FIRMWARE" ]; then | 187 if [ "$i" = "FIRMWARE" ]; then |
171 DST="${DST_FIRMWARE}" | 188 DST="${DST_FIRMWARE}" |
172 else | 189 else |
173 PART=$(eval "echo \$DST_${i}_PART") | 190 PART=$(eval "echo \$DST_${i}_PART") |
174 DST="${DST_DRIVE}${PART}" | 191 DST="$(make_partition_dev ${DST_DRIVE} ${PART})" |
175 fi | 192 fi |
176 | 193 |
177 log "Factory Install: Installing $i image to $DST" | 194 log "Factory Install: Installing $i image to $DST" |
178 | 195 |
179 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") | 196 CHANNEL_ARG=$(eval "echo \$${i}_CHANNEL_ARG") |
180 KPART="none" | 197 KPART="none" |
181 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then | 198 if [ "$i" = "FACTORY" -o "$i" = "RELEASE" ]; then |
182 # Set up kernel partition | 199 # Set up kernel partition |
183 KPART="" | 200 KPART="" |
184 fi | 201 fi |
(...skipping 24 matching lines...) Expand all Loading... | |
209 fi | 226 fi |
210 done | 227 done |
211 | 228 |
212 # Release image is not allowed to boot unless the factory test is passed | 229 # Release image is not allowed to boot unless the factory test is passed |
213 # otherwise the wipe and final verification can be skipped. | 230 # otherwise the wipe and final verification can be skipped. |
214 # TODO(hungte) do this in memento_updater or postinst may be better | 231 # TODO(hungte) do this in memento_updater or postinst may be better |
215 # TODO(hungte) make a better way to find location of cgpt | 232 # TODO(hungte) make a better way to find location of cgpt |
216 if ! cgpt add -i $((${DST_RELEASE_PART} - 1)) -P 0 -T 0 -S 0 ${DST_DRIVE}; then | 233 if ! cgpt add -i $((${DST_RELEASE_PART} - 1)) -P 0 -T 0 -S 0 ${DST_DRIVE}; then |
217 log "Factory Install: failed to lock release image. Destroy all kernels." | 234 log "Factory Install: failed to lock release image. Destroy all kernels." |
218 # Destroy kernels otherwise the system is still bootable. | 235 # Destroy kernels otherwise the system is still bootable. |
219 dd if=/dev/zero of=${DST_DRIVE}$((${DST_RELEASE_PART} - 1)) | 236 DST_RELEASE=$(make_partition_dev ${DST_DRIVE} $((${DST_RELEASE_PART} - 1))) |
220 dd if=/dev/zero of=${DST_DRIVE}$((${DST_FACTORY_PART} - 1)) | 237 DST_FACTORY=$(make_partition_dev ${DST_DRIVE} $((${DST_FACTORY_PART} - 1))) |
238 dd if=/dev/zero of=$DST_RELEASE | |
239 dd if=/dev/zero of=$DST_FACTORY | |
221 exit 1 | 240 exit 1 |
222 fi | 241 fi |
223 | 242 |
224 log "All done installing." | 243 log "All done installing." |
225 | 244 |
226 sleep 3 | 245 sleep 3 |
227 shutdown -r now | 246 shutdown -r now |
228 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down | 247 sleep 1d # sleep indefinitely to avoid respawning rather than shutting down |
OLD | NEW |