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 local initial_root_dev=$(find_root_dev) |
| 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 10 matching lines...) Expand all Loading... |
379 cp "${known_hosts}" "${known_hosts}~" | 386 cp "${known_hosts}" "${known_hosts}~" |
380 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" | 387 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" |
381 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" | 388 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" |
382 chmod 0640 "${known_hosts}" | 389 chmod 0640 "${known_hosts}" |
383 info "New updated in ${known_hosts}, backup made." | 390 info "New updated in ${known_hosts}, backup made." |
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 |
| 396 |
| 397 if [ "${initial_root_dev}" == "$(find_root_dev)" ]; then |
| 398 # At this point, the software version didn't change, but we didn't |
| 399 # switch partitions either. Means it was an update to the same version |
| 400 # that failed. |
| 401 die "The root partition did NOT change. The update failed." |
| 402 fi |
389 else | 403 else |
390 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 404 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
391 info "Update was successful and rebooted to $release_description" | 405 info "Update was successful and rebooted to $release_description" |
392 fi | 406 fi |
393 | 407 |
394 print_time_elapsed | 408 print_time_elapsed |
395 | 409 |
396 exit 0 | 410 exit 0 |
397 } | 411 } |
398 | 412 |
399 main $@ | 413 main $@ |
OLD | NEW |