| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 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 # Updates an existing vm image with another image. | 7 # Updates an existing vm image with another image. |
| 8 | 8 |
| 9 . "$(dirname $0)/../common.sh" | 9 . "$(dirname $0)/../common.sh" |
| 10 . "$(dirname $0)/../lib/cros_vm_lib.sh" | 10 . "$(dirname $0)/../lib/cros_vm_lib.sh" |
| 11 | 11 |
| 12 DEFINE_string payload "" "Full name of the payload to update with." | 12 DEFINE_string payload "" "Full name of the payload to update with." |
| 13 DEFINE_string proxy_port "" \ | 13 DEFINE_string proxy_port "" \ |
| 14 "Have the client request from this proxy instead of devserver." | 14 "Have the client request from this proxy instead of devserver." |
| 15 DEFINE_string src_image "" \ | 15 DEFINE_string src_image "" \ |
| 16 "Create a delta update by passing in the image on the remote machine." | 16 "Create a delta update by passing in the image on the remote machine." |
| 17 DEFINE_string stateful_update_flag "" "Flags to pass to stateful update." s | 17 DEFINE_string stateful_update_flag "" "Flags to pass to stateful update." s |
| 18 DEFINE_string update_image_path "" "Path of the image to update to." u | 18 DEFINE_string update_image_path "" "Path of the image to update to." u |
| 19 DEFINE_string update_url "" "Full url of an update image." |
| 19 DEFINE_string vm_image_path "" "Path of the VM image to update from." v | 20 DEFINE_string vm_image_path "" "Path of the VM image to update from." v |
| 20 | 21 |
| 21 set -e | 22 set -e |
| 22 | 23 |
| 23 # Parse command line. | 24 # Parse command line. |
| 24 FLAGS "$@" || exit 1 | 25 FLAGS "$@" || exit 1 |
| 25 eval set -- "${FLAGS_ARGV}" | 26 eval set -- "${FLAGS_ARGV}" |
| 26 | 27 |
| 27 [ -n "${FLAGS_update_image_path}" ] || [ -n "${FLAGS_payload}" ] || \ | |
| 28 die "You must specify a path to an image to use as an update." | |
| 29 [ -n "${FLAGS_vm_image_path}" ] || \ | 28 [ -n "${FLAGS_vm_image_path}" ] || \ |
| 30 die "You must specify a path to a vm image." | 29 die "You must specify a path to a vm image." |
| 31 | 30 |
| 32 trap stop_kvm EXIT | 31 trap stop_kvm EXIT |
| 33 start_kvm "${FLAGS_vm_image_path}" | 32 start_kvm "${FLAGS_vm_image_path}" |
| 34 | 33 |
| 35 if [ -n "${FLAGS_update_image_path}" ]; then | 34 if [ -n "${FLAGS_update_image_path}" ]; then |
| 36 IMAGE_ARGS="--image=$(readlink -f ${FLAGS_update_image_path})" | 35 IMAGE_ARGS="--image=$(readlink -f ${FLAGS_update_image_path})" |
| 37 fi | 36 fi |
| 38 | 37 |
| 39 if [ -n "${FLAGS_payload}" ]; then | 38 if [ -n "${FLAGS_payload}" ]; then |
| 40 IMAGE_ARGS="--payload=${FLAGS_payload}" | 39 IMAGE_ARGS="--payload=${FLAGS_payload}" |
| 41 fi | 40 fi |
| 42 | 41 |
| 43 if [ -n "${FLAGS_proxy_port}" ]; then | 42 if [ -n "${FLAGS_proxy_port}" ]; then |
| 44 IMAGE_ARGS="${IMAGE_ARGS} --proxy_port=${FLAGS_proxy_port}" | 43 IMAGE_ARGS="${IMAGE_ARGS} --proxy_port=${FLAGS_proxy_port}" |
| 45 fi | 44 fi |
| 46 | 45 |
| 47 $(dirname $0)/../image_to_live.sh \ | 46 $(dirname $0)/../image_to_live.sh \ |
| 47 --for_vm \ |
| 48 --remote=127.0.0.1 \ | 48 --remote=127.0.0.1 \ |
| 49 --ssh_port=${FLAGS_ssh_port} \ | 49 --ssh_port=${FLAGS_ssh_port} \ |
| 50 --stateful_update_flag=${FLAGS_stateful_update_flag} \ | 50 --stateful_update_flag=${FLAGS_stateful_update_flag} \ |
| 51 --src_image="${FLAGS_src_image}" \ | 51 --src_image="${FLAGS_src_image}" \ |
| 52 --update_url="${FLAGS_update_url}" \ |
| 52 --verify \ | 53 --verify \ |
| 53 --for_vm \ | |
| 54 ${IMAGE_ARGS} | 54 ${IMAGE_ARGS} |
| 55 | 55 |
| OLD | NEW |