Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: src/platform/memento_softwareupdate/memento_updater.sh

Issue 1520028: New Full AU Format w/ support for kernel partition. (Closed)
Patch Set: fixes for review Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 # This is the autoupdater for Memento. When called it consults Omaha to see 7 # This is the autoupdater for Memento. When called it consults Omaha to see
8 # if there's an update available. If so, it downloads it to the other 8 # if there's an update available. If so, it downloads it to the other
9 # partition on the Memento USB stick, then alters the MBR and partitions 9 # partition on the Memento USB stick, then alters the MBR and partitions
10 # as needed so the next reboot will boot into the newly installed partition. 10 # as needed so the next reboot will boot into the newly installed partition.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 INSTALL_DEV="${FLAGS_dst_partition}" 139 INSTALL_DEV="${FLAGS_dst_partition}"
140 else 140 else
141 INSTALL_DEV=$(echo $LOCAL_DEV | tr '35' '53') 141 INSTALL_DEV=$(echo $LOCAL_DEV | tr '35' '53')
142 fi 142 fi
143 NEW_PART_NUM=${INSTALL_DEV##*/*[a-z]} 143 NEW_PART_NUM=${INSTALL_DEV##*/*[a-z]}
144 # The kernel needs to be installed to its own partition. We'll handle that in 144 # The kernel needs to be installed to its own partition. We'll handle that in
145 # the postinst script (from the new rootfs). partitions 2&3 are image A, 145 # the postinst script (from the new rootfs). partitions 2&3 are image A,
146 # partitions 4&5 are image B. 146 # partitions 4&5 are image B.
147 KINSTALL_DEV=$(echo $INSTALL_DEV | tr '35' '24') 147 KINSTALL_DEV=$(echo $INSTALL_DEV | tr '35' '24')
148 148
149 if [ "$KINSTALL_DEV" = "$INSTALL_DEV" ]; then
150 log "kernel install partition the same as rootfs install partition!"
151 log " (${KINSTALL_DEV})"
152 exit 1
153 fi
154
149 # Find whole disk device. 155 # Find whole disk device.
150 ROOT_DEV=${INSTALL_DEV%%[0-9]*} 156 ROOT_DEV=${INSTALL_DEV%%[0-9]*}
151 157
152 # Do some device sanity checks. 158 # Do some device sanity checks.
153 if ! expr match "$LOCAL_DEV" '^/dev/[a-z][a-z]*[12345]$' > /dev/null 159 if ! expr match "$LOCAL_DEV" '^/dev/[a-z][a-z]*[12345]$' > /dev/null
154 then 160 then
155 log "didnt find good local device. local: $LOCAL_DEV install: $INSTALL_DEV" 161 log "didnt find good local device. local: $LOCAL_DEV install: $INSTALL_DEV"
156 exit 1 162 exit 1
157 fi 163 fi
158 if ! expr match "$INSTALL_DEV" '^/dev/[a-z][a-z]*[12345]$' > /dev/null 164 if ! expr match "$INSTALL_DEV" '^/dev/[a-z][a-z]*[12345]$' > /dev/null
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 # wget - fetch file, send to stdout 196 # wget - fetch file, send to stdout
191 # tee - save a copy off to device, also send to stdout 197 # tee - save a copy off to device, also send to stdout
192 # openssl - calculate the sha1 hash of stdin, send checksum to stdout 198 # openssl - calculate the sha1 hash of stdin, send checksum to stdout
193 # tr - convert trailing newline to a space 199 # tr - convert trailing newline to a space
194 # pipestatus - append return codes for all prior commands. should all be 0 200 # pipestatus - append return codes for all prior commands. should all be 0
195 201
196 CHECKSUM_FILE="/tmp/memento_autoupdate_checksum" 202 CHECKSUM_FILE="/tmp/memento_autoupdate_checksum"
197 RETURNED_CODES=$(wget -O - --load-cookies <(echo "$COOKIES") \ 203 RETURNED_CODES=$(wget -O - --load-cookies <(echo "$COOKIES") \
198 "$IMG_URL" 2>> "$MEMENTO_AU_LOG" | \ 204 "$IMG_URL" 2>> "$MEMENTO_AU_LOG" | \
199 tee >(openssl sha1 -binary | openssl base64 > "$CHECKSUM_FILE") | \ 205 tee >(openssl sha1 -binary | openssl base64 > "$CHECKSUM_FILE") | \
200 gzip -d > "$INSTALL_DEV" ; echo ${PIPESTATUS[*]}) 206 gzip -d | $(dirname "$0")/split_write "$KINSTALL_DEV" "$INSTALL_DEV" ; \
207 echo ${PIPESTATUS[*]})
201 208
202 EXPECTED_CODES="0 0 0" 209 EXPECTED_CODES="0 0 0 0"
203 CALCULATED_CS=$(cat "$CHECKSUM_FILE") 210 CALCULATED_CS=$(cat "$CHECKSUM_FILE")
204 rm -f "$CHECKSUM_FILE" 211 rm -f "$CHECKSUM_FILE"
205 212
206 if [[ ("$CALCULATED_CS" == "$CHECKSUM") && \ 213 if [[ ("$CALCULATED_CS" == "$CHECKSUM") && \
207 ("$RETURNED_CODES" == "$EXPECTED_CODES") ]] 214 ("$RETURNED_CODES" == "$EXPECTED_CODES") ]]
208 then 215 then
209 # wonderful 216 # wonderful
210 log download success 217 log download success
211 else 218 else
212 # either checksum mismatch or ran out of space. 219 # either checksum mismatch or ran out of space.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 version_number_greater_than "$APP_VERSION" "$NEW_VERSION" 264 version_number_greater_than "$APP_VERSION" "$NEW_VERSION"
258 then 265 then
259 log "Can't upgrade to older version: " "$NEW_VERSION" 266 log "Can't upgrade to older version: " "$NEW_VERSION"
260 umount "$MOUNTPOINT" 267 umount "$MOUNTPOINT"
261 rmdir "$MOUNTPOINT" 268 rmdir "$MOUNTPOINT"
262 exit 1 269 exit 1
263 fi 270 fi
264 fi 271 fi
265 fi 272 fi
266 273
267 "$MOUNTPOINT"/postinst "$INSTALL_DEV" "$KINSTALL_DEV" 2>&1 | \ 274 "$MOUNTPOINT"/postinst "$INSTALL_DEV" 2>&1 | cat >> "$MEMENTO_AU_LOG"
268 cat >> "$MEMENTO_AU_LOG"
269 [ "${PIPESTATUS[*]}" = "0 0" ] 275 [ "${PIPESTATUS[*]}" = "0 0" ]
270 POSTINST_RETURN_CODE=$? 276 POSTINST_RETURN_CODE=$?
271 umount "$MOUNTPOINT" 277 umount "$MOUNTPOINT"
272 rmdir "$MOUNTPOINT" 278 rmdir "$MOUNTPOINT"
273 279
274 # $1 is return code, $2 is command 280 # $1 is return code, $2 is command
275 function abort_update_if_cmd_failed_long { 281 function abort_update_if_cmd_failed_long {
276 if [ "$1" -ne "0" ] 282 if [ "$1" -ne "0" ]
277 then 283 then
278 log "$2 failed with error code $1 . aborting update" 284 log "$2 failed with error code $1 . aborting update"
(...skipping 30 matching lines...) Expand all
309 abort_update_if_cmd_failed 315 abort_update_if_cmd_failed
310 316
311 if [ -z "${FLAGS_dst_partition}" ]; then 317 if [ -z "${FLAGS_dst_partition}" ]; then
312 # mark update as complete so we don't try to update again 318 # mark update as complete so we don't try to update again
313 touch "$UPDATED_COMPLETED_FILE" 319 touch "$UPDATED_COMPLETED_FILE"
314 fi 320 fi
315 321
316 # tell user to reboot 322 # tell user to reboot
317 log Autoupdate applied. You should now reboot 323 log Autoupdate applied. You should now reboot
318 echo UPDATED 324 echo UPDATED
OLDNEW
« no previous file with comments | « src/platform/memento_softwareupdate/Makefile ('k') | src/platform/memento_softwareupdate/split_write.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698