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 src_image "" \ | 13 DEFINE_string src_image "" \ |
13 "Create a delta update by passing in the image on the remote machine." | 14 "Create a delta update by passing in the image on the remote machine." |
14 DEFINE_string stateful_update_flag "" "Flags to pass to stateful update." s | 15 DEFINE_string stateful_update_flag "" "Flags to pass to stateful update." s |
15 DEFINE_string update_image_path "" "Path of the image to update to." u | 16 DEFINE_string update_image_path "" "Path of the image to update to." u |
16 DEFINE_string vm_image_path "" "Path of the VM image to update from." v | 17 DEFINE_string vm_image_path "" "Path of the VM image to update from." v |
17 | 18 |
18 set -e | 19 set -e |
19 | 20 |
20 # Parse command line. | 21 # Parse command line. |
21 FLAGS "$@" || exit 1 | 22 FLAGS "$@" || exit 1 |
22 eval set -- "${FLAGS_ARGV}" | 23 eval set -- "${FLAGS_ARGV}" |
23 | 24 |
24 [ -n "${FLAGS_update_image_path}" ] || \ | 25 [ -n "${FLAGS_update_image_path}" ] || [ -n "${FLAGS_payload}" ] || \ |
25 die "You must specify a path to an image to use as an update." | 26 die "You must specify a path to an image to use as an update." |
26 [ -n "${FLAGS_vm_image_path}" ] || \ | 27 [ -n "${FLAGS_vm_image_path}" ] || \ |
27 die "You must specify a path to a vm image." | 28 die "You must specify a path to a vm image." |
28 | 29 |
29 trap stop_kvm EXIT | 30 trap stop_kvm EXIT |
30 start_kvm "${FLAGS_vm_image_path}" | 31 start_kvm "${FLAGS_vm_image_path}" |
31 | 32 |
| 33 if [ -n "${FLAGS_update_image_path}" ]; then |
| 34 IMAGE_ARGS="--image=$(readlink -f ${FLAGS_update_image_path})" |
| 35 fi |
| 36 |
| 37 if [ -n "${FLAGS_payload}" ]; then |
| 38 IMAGE_ARGS="--payload="${FLAGS_payload}"" |
| 39 fi |
| 40 |
32 $(dirname $0)/../image_to_live.sh \ | 41 $(dirname $0)/../image_to_live.sh \ |
33 --remote=127.0.0.1 \ | 42 --remote=127.0.0.1 \ |
34 --ssh_port=${FLAGS_ssh_port} \ | 43 --ssh_port=${FLAGS_ssh_port} \ |
35 --stateful_update_flag=${FLAGS_stateful_update_flag} \ | 44 --stateful_update_flag=${FLAGS_stateful_update_flag} \ |
36 --src_image="${FLAGS_src_image}" \ | 45 --src_image="${FLAGS_src_image}" \ |
37 --verify \ | 46 --verify \ |
38 --for_vm \ | 47 --for_vm \ |
39 --image=$(readlink -f ${FLAGS_update_image_path}) | 48 ${IMAGE_ARGS} |
40 | 49 |
OLD | NEW |