Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-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 # Script to update an image onto a live running ChromiumOS instance. | 7 # Script to update an image onto a live running ChromiumOS instance. |
| 8 | 8 |
| 9 # Load common constants. This should be the first executable line. | 9 # Load common constants. This should be the first executable line. |
| 10 # The path to common.sh should be relative to your script's location. | 10 # The path to common.sh should be relative to your script's location. |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 | 322 |
| 323 if [ "${lsb_release}" = "${REMOTE_OUT}" ]; then | 323 if [ "${lsb_release}" = "${REMOTE_OUT}" ]; then |
| 324 info "Update was successful and image verified as ${lsb_release}." | 324 info "Update was successful and image verified as ${lsb_release}." |
| 325 return 0 | 325 return 0 |
| 326 else | 326 else |
| 327 warn "Image verification failed." | 327 warn "Image verification failed." |
| 328 return 1 | 328 return 1 |
| 329 fi | 329 fi |
| 330 } | 330 } |
| 331 | 331 |
| 332 function find_root_dev { | |
| 333 remote_sh "rootdev -s" | |
| 334 echo ${REMOTE_OUT} | |
| 335 } | |
| 336 | |
| 332 function main() { | 337 function main() { |
| 333 assert_outside_chroot | 338 assert_outside_chroot |
| 334 | 339 |
| 335 cd $(dirname "$0") | 340 cd $(dirname "$0") |
| 336 | 341 |
| 337 FLAGS "$@" || exit 1 | 342 FLAGS "$@" || exit 1 |
| 338 eval set -- "${FLAGS_ARGV}" | 343 eval set -- "${FLAGS_ARGV}" |
| 339 | 344 |
| 340 set -e | 345 set -e |
| 341 | 346 |
| 342 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ] && \ | 347 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ] && \ |
| 343 [ -n "${FLAGS_update_url}" ]; then | 348 [ -n "${FLAGS_update_url}" ]; then |
| 344 warn "Verify is not compatible with setting an update url." | 349 warn "Verify is not compatible with setting an update url." |
| 345 FLAGS_verify=${FLAGS_FALSE} | 350 FLAGS_verify=${FLAGS_FALSE} |
| 346 fi | 351 fi |
| 347 | 352 |
| 348 trap cleanup EXIT | 353 trap cleanup EXIT |
| 349 | 354 |
| 350 TMP=$(mktemp -d /tmp/image_to_live.XXXX) | 355 TMP=$(mktemp -d /tmp/image_to_live.XXXX) |
| 351 | 356 |
| 352 remote_access_init | 357 remote_access_init |
| 353 | 358 |
| 354 if [ "$(get_update_var CURRENT_OP)" != "${UPDATER_IDLE}" ]; then | 359 if [ "$(get_update_var CURRENT_OP)" != "${UPDATER_IDLE}" ]; then |
| 355 warn "Machine is in a bad state. Rebooting it now." | 360 warn "Machine is in a bad state. Rebooting it now." |
| 356 remote_reboot | 361 remote_reboot |
| 357 fi | 362 fi |
| 358 | 363 |
| 364 INITIAL_ROOT_DEV=$(find_root_dev) | |
|
sosa
2010/12/21 03:25:09
use a local ... local initial_root_dev=
dgarrett
2010/12/21 03:50:41
Done.
| |
| 365 | |
| 359 if [ -z "${FLAGS_update_url}" ]; then | 366 if [ -z "${FLAGS_update_url}" ]; then |
| 360 # Start local devserver if no update url specified. | 367 # Start local devserver if no update url specified. |
| 361 start_dev_server | 368 start_dev_server |
| 362 fi | 369 fi |
| 363 | 370 |
| 364 if [ ${FLAGS_update} -eq ${FLAGS_TRUE} ] && ! run_auto_update; then | 371 if [ ${FLAGS_update} -eq ${FLAGS_TRUE} ] && ! run_auto_update; then |
| 365 warn "Dumping update_engine.log for debugging and/or bug reporting." | 372 warn "Dumping update_engine.log for debugging and/or bug reporting." |
| 366 tail -n 200 "${FLAGS_update_log}" >&2 | 373 tail -n 200 "${FLAGS_update_log}" >&2 |
| 367 die "Update was not successful." | 374 die "Update was not successful." |
| 368 fi | 375 fi |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 384 fi | 391 fi |
| 385 | 392 |
| 386 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" | 393 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" |
| 387 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ]; then | 394 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ]; then |
| 388 verify_image | 395 verify_image |
| 389 else | 396 else |
| 390 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 397 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
| 391 info "Update was successful and rebooted to $release_description" | 398 info "Update was successful and rebooted to $release_description" |
| 392 fi | 399 fi |
| 393 | 400 |
| 401 if [ ${INITIAL_ROOT_DEV} -eq $(find_root_dev) ]; then | |
|
sosa
2010/12/21 03:25:09
Put this under verify image flag above ... only if
dgarrett
2010/12/21 03:50:41
Done.
| |
| 402 # At this point, the software version didn't change, but we didn't | |
| 403 # switch partitions either. Means it was an update to the same version | |
| 404 # that failed. | |
| 405 warn "The root partition did NOT change. The update failed." | |
|
sosa
2010/12/21 03:25:09
use die rather than warn + return 1 -> error messa
dgarrett
2010/12/21 03:50:41
I was following the pattern from verify_image, but
| |
| 406 return 1 | |
| 407 fi | |
| 408 | |
| 394 print_time_elapsed | 409 print_time_elapsed |
| 395 | 410 |
| 396 exit 0 | 411 exit 0 |
| 397 } | 412 } |
| 398 | 413 |
| 399 main $@ | 414 main $@ |
| OLD | NEW |