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 16 matching lines...) Expand all Loading... | |
27 "Path to log for the update_engine." | 27 "Path to log for the update_engine." |
28 DEFINE_boolean verify ${FLAGS_TRUE} "Verify image on device after update." | 28 DEFINE_boolean verify ${FLAGS_TRUE} "Verify image on device after update." |
29 | 29 |
30 # Flags for devserver. | 30 # Flags for devserver. |
31 DEFINE_string archive_dir "" \ | 31 DEFINE_string archive_dir "" \ |
32 "Update using the test image in the image.zip in this directory." a | 32 "Update using the test image in the image.zip in this directory." a |
33 DEFINE_integer devserver_port 8080 \ | 33 DEFINE_integer devserver_port 8080 \ |
34 "Port to use for devserver." | 34 "Port to use for devserver." |
35 DEFINE_string image "" \ | 35 DEFINE_string image "" \ |
36 "Update with this image path that is in this source checkout." i | 36 "Update with this image path that is in this source checkout." i |
37 DEFINE_string src_image "" \ | |
38 "Create a delta update by passing in the image on the remote machine." | |
37 DEFINE_boolean update_stateful ${FLAGS_TRUE} \ | 39 DEFINE_boolean update_stateful ${FLAGS_TRUE} \ |
38 "Perform update of stateful partition e.g. /var /usr/local." | 40 "Perform update of stateful partition e.g. /var /usr/local." |
39 DEFINE_string update_url "" "Full url of an update image." | 41 DEFINE_string update_url "" "Full url of an update image." |
40 | 42 |
41 # Flags for stateful update. | 43 # Flags for stateful update. |
42 DEFINE_string stateful_update_flag "" \ | 44 DEFINE_string stateful_update_flag "" \ |
43 "Flag to pass to stateful update e.g. old, clean, etc." s | 45 "Flag to pass to stateful update e.g. old, clean, etc." s |
44 | 46 |
45 UPDATER_BIN="/usr/bin/update_engine_client" | 47 UPDATER_BIN="/usr/bin/update_engine_client" |
46 UPDATER_IDLE="UPDATE_STATUS_IDLE" | 48 UPDATER_IDLE="UPDATE_STATUS_IDLE" |
(...skipping 30 matching lines...) Expand all Loading... | |
77 function get_hostname { | 79 function get_hostname { |
78 local hostname | 80 local hostname |
79 # Try to parse ifconfig for ip address | 81 # Try to parse ifconfig for ip address |
80 hostname=$(ifconfig eth0 \ | 82 hostname=$(ifconfig eth0 \ |
81 | grep 'inet addr' \ | 83 | grep 'inet addr' \ |
82 | sed 's/.\+inet addr:\(\S\+\).\+/\1/') || hostname=${HOSTNAME} | 84 | sed 's/.\+inet addr:\(\S\+\).\+/\1/') || hostname=${HOSTNAME} |
83 echo ${hostname} | 85 echo ${hostname} |
84 } | 86 } |
85 | 87 |
86 # Reinterprets path from outside the chroot for use inside. | 88 # Reinterprets path from outside the chroot for use inside. |
89 # Returns "" if "" given. | |
87 # $1 - The path to reinterpret. | 90 # $1 - The path to reinterpret. |
88 function reinterpret_path_for_chroot() { | 91 function reinterpret_path_for_chroot() { |
89 local path_abs_path=$(readlink -f "${1}") | 92 if [ -z "${1}" ]; then |
90 local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}") | 93 echo "" |
94 else | |
95 local path_abs_path=$(readlink -f "${1}") | |
96 local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}") | |
91 | 97 |
92 # Strip the repository root from the path. | 98 # Strip the repository root from the path. |
93 local relative_path=$(echo ${path_abs_path} \ | 99 local relative_path=$(echo ${path_abs_path} \ |
kmixter1
2010/10/27 17:15:52
I think you can do this with less work:
${path_ab
| |
94 | sed s:${gclient_root_abs_path}/::) | 100 | sed s:${gclient_root_abs_path}/::) |
95 | 101 |
96 if [ "${relative_path}" = "${path_abs_path}" ]; then | 102 if [ "${relative_path}" = "${path_abs_path}" ]; then |
97 die "Error reinterpreting path. Path ${1} is not within your source tree." | 103 die "Error reinterpreting path. Path ${1} is not within source tree." |
104 fi | |
105 | |
106 # Prepend the chroot repository path. | |
107 echo "/home/${USER}/trunk/${relative_path}" | |
98 fi | 108 fi |
99 | |
100 # Prepend the chroot repository path. | |
101 echo "/home/${USER}/trunk/${relative_path}" | |
102 } | 109 } |
103 | 110 |
104 function start_dev_server { | 111 function start_dev_server { |
105 kill_all_devservers | 112 kill_all_devservers |
106 local devserver_flags= | 113 local devserver_flags= |
107 # Parse devserver flags. | 114 # Parse devserver flags. |
108 if [ -n "${FLAGS_image}" ]; then | 115 if [ -n "${FLAGS_image}" ]; then |
109 devserver_flags="${devserver_flags} \ | 116 devserver_flags="${devserver_flags} \ |
110 --image $(reinterpret_path_for_chroot ${FLAGS_image})" | 117 --image $(reinterpret_path_for_chroot ${FLAGS_image})" |
111 IMAGE_PATH="${FLAGS_image}" | 118 IMAGE_PATH="${FLAGS_image}" |
112 | |
113 elif [ -n "${FLAGS_archive_dir}" ]; then | 119 elif [ -n "${FLAGS_archive_dir}" ]; then |
114 devserver_flags="${devserver_flags} \ | 120 devserver_flags="${devserver_flags} \ |
115 --archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t" | 121 --archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t" |
116 IMAGE_PATH="${FLAGS_archive_dir}/chromiumos_test_image.bin" | 122 IMAGE_PATH="${FLAGS_archive_dir}/chromiumos_test_image.bin" |
117 else | 123 else |
118 # IMAGE_PATH should be the newest image and learn the board from | 124 # IMAGE_PATH should be the newest image and learn the board from |
119 # the target. | 125 # the target. |
120 FLAGS_board="" | 126 FLAGS_board="" |
121 learn_board | 127 learn_board |
122 IMAGE_PATH="$($(dirname "$0")/get_latest_image.sh --board="${FLAGS_board}")" | 128 IMAGE_PATH="$($(dirname "$0")/get_latest_image.sh --board="${FLAGS_board}")" |
123 IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin" | 129 IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin" |
124 fi | 130 fi |
125 | 131 |
132 devserver_flags="${devserver_flags} \ | |
133 --src_image=\"$(reinterpret_path_for_chroot ${FLAGS_src_image})\"" | |
134 | |
126 info "Starting devserver with flags ${devserver_flags}" | 135 info "Starting devserver with flags ${devserver_flags}" |
127 ./enter_chroot.sh "sudo ./start_devserver ${devserver_flags} \ | 136 ./enter_chroot.sh "sudo ./start_devserver ${devserver_flags} \ |
128 --client_prefix=ChromeOSUpdateEngine \ | 137 --client_prefix=ChromeOSUpdateEngine \ |
129 --port=${FLAGS_devserver_port} > ${FLAGS_server_log} 2>&1" & | 138 --port=${FLAGS_devserver_port} > ${FLAGS_server_log} 2>&1" & |
130 | 139 |
131 echo -n "Waiting on devserver to start" | 140 echo -n "Waiting on devserver to start" |
132 until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null | 141 until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null |
133 do | 142 do |
134 sleep .5 | 143 sleep .5 |
135 echo -n "." | 144 echo -n "." |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) | 383 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) |
375 info "Update was successful and rebooted to $release_description" | 384 info "Update was successful and rebooted to $release_description" |
376 fi | 385 fi |
377 | 386 |
378 print_time_elapsed | 387 print_time_elapsed |
379 | 388 |
380 exit 0 | 389 exit 0 |
381 } | 390 } |
382 | 391 |
383 main $@ | 392 main $@ |
OLD | NEW |