| OLD | NEW |
| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 else | 183 else |
| 184 # either checksum mismatch or ran out of space. | 184 # either checksum mismatch or ran out of space. |
| 185 log checksum mismatch or other error \ | 185 log checksum mismatch or other error \ |
| 186 calculated checksum: "$CALCULATED_CS" reference checksum: "$CHECKSUM" \ | 186 calculated checksum: "$CALCULATED_CS" reference checksum: "$CHECKSUM" \ |
| 187 return codes: "$RETURNED_CODES" expected codes: "$EXPECTED_CODES" | 187 return codes: "$RETURNED_CODES" expected codes: "$EXPECTED_CODES" |
| 188 # zero-out installation partition | 188 # zero-out installation partition |
| 189 dd if=/dev/zero of=$INSTALL_DEV bs=4096 count=1 | 189 dd if=/dev/zero of=$INSTALL_DEV bs=4096 count=1 |
| 190 exit 1 | 190 exit 1 |
| 191 fi | 191 fi |
| 192 | 192 |
| 193 # Return 0 if $1 > $2. |
| 194 # $1 and $2 are in "a.b.c.d" format where a, b, c, and d are base 10. |
| 193 function version_number_greater_than { | 195 function version_number_greater_than { |
| 194 # return 0 if $1 > $2 | 196 # Replace periods with spaces and strip off leading 0s (lest numbers be |
| 195 # Assumes $1, $2 are in "a.b.c.d" format where a, b, c, d are base 10 | 197 # interpreted as octal). |
| 196 EXPANDED_A=$(printf '%020d%020d%020d%020d' $(echo "$1" | sed 's/\./ /g' )) | 198 REPLACED_A=$(echo "$1" | sed -r 's/(^|\.)0*/ /g') |
| 197 EXPANDED_B=$(printf '%020d%020d%020d%020d' $(echo "$2" | sed 's/\./ /g' )) | 199 REPLACED_B=$(echo "$2" | sed -r 's/(^|\.)0*/ /g') |
| 200 EXPANDED_A=$(printf '%020d%020d%020d%020d' $REPLACED_A) |
| 201 EXPANDED_B=$(printf '%020d%020d%020d%020d' $REPLACED_B) |
| 198 # This is a string compare: | 202 # This is a string compare: |
| 199 [[ "$EXPANDED_A" > "$EXPANDED_B" ]] | 203 [[ "$EXPANDED_A" > "$EXPANDED_B" ]] |
| 200 } | 204 } |
| 201 | 205 |
| 202 # it's best not to interrupt the script from this point on out, since it | 206 # it's best not to interrupt the script from this point on out, since it |
| 203 # should really be doing these things atomically. hopefully this part will | 207 # should really be doing these things atomically. hopefully this part will |
| 204 # run rather quickly. | 208 # run rather quickly. |
| 205 | 209 |
| 206 # tell the new image to make itself "ready" | 210 # tell the new image to make itself "ready" |
| 207 log running postinst on the downloaded image | 211 log running postinst on the downloaded image |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 -e "s/\(${LOCAL_DEV//\//\\/} .*\), bootable/\1/" \ | 272 -e "s/\(${LOCAL_DEV//\//\\/} .*\), bootable/\1/" \ |
| 269 > "$LAYOUT_FILE" | 273 > "$LAYOUT_FILE" |
| 270 sfdisk --force $ROOT_DEV < "$LAYOUT_FILE" 2>&1 | cat >> "$MEMENTO_AU_LOG" | 274 sfdisk --force $ROOT_DEV < "$LAYOUT_FILE" 2>&1 | cat >> "$MEMENTO_AU_LOG" |
| 271 abort_update_if_cmd_failed | 275 abort_update_if_cmd_failed |
| 272 | 276 |
| 273 # mark update as complete so we don't try to update again | 277 # mark update as complete so we don't try to update again |
| 274 touch "$UPDATED_COMPLETED_FILE" | 278 touch "$UPDATED_COMPLETED_FILE" |
| 275 | 279 |
| 276 # tell user to reboot | 280 # tell user to reboot |
| 277 log Autoupdate applied. You should now reboot | 281 log Autoupdate applied. You should now reboot |
| OLD | NEW |