Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: image_to_live.sh

Issue 6240018: This starts to fix the scripts so that they load from /usr/lib/crosutils (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: fixing bad merge Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « image_hacks.sh ('k') | image_to_usb.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # --- BEGIN COMMON.SH BOILERPLATE ---
10 # The path to common.sh should be relative to your script's location. 10 # Load common CrOS utilities. Inside the chroot this file is installed in
11 # /usr/lib/crosutils. Outside the chroot we find it relative to the script's
12 # location.
13 find_common_sh() {
14 local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
15 local path
11 16
12 . "$(dirname $0)/common.sh" 17 SCRIPT_ROOT=
13 . "$(dirname $0)/remote_access.sh" 18 for path in "${common_paths[@]}"; do
19 if [ -r "${path}/common.sh" ]; then
20 SCRIPT_ROOT=${path}
21 break
22 fi
23 done
24 }
25
26 find_common_sh
27 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1)
28 # --- END COMMON.SH BOILERPLATE ---
29
30 . "${SCRIPT_ROOT}/remote_access.sh" || die "Unable to load remote_access.sh"
14 31
15 # Flags to control image_to_live. 32 # Flags to control image_to_live.
16 DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \ 33 DEFINE_boolean ignore_hostname ${FLAGS_TRUE} \
17 "Ignore existing AU hostname on running instance use this hostname." 34 "Ignore existing AU hostname on running instance use this hostname."
18 DEFINE_boolean ignore_version ${FLAGS_TRUE} \ 35 DEFINE_boolean ignore_version ${FLAGS_TRUE} \
19 "Ignore existing version on running instance and always update." 36 "Ignore existing version on running instance and always update."
20 DEFINE_string server_log "dev_server.log" \ 37 DEFINE_string server_log "dev_server.log" \
21 "Path to log for the devserver." 38 "Path to log for the devserver."
22 DEFINE_boolean update "${FLAGS_TRUE}" \ 39 DEFINE_boolean update "${FLAGS_TRUE}" \
23 "Perform update of root partition." 40 "Perform update of root partition."
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 --image $(reinterpret_path_for_chroot ${FLAGS_image})" 140 --image $(reinterpret_path_for_chroot ${FLAGS_image})"
124 IMAGE_PATH="${FLAGS_image}" 141 IMAGE_PATH="${FLAGS_image}"
125 elif [ -n "${FLAGS_archive_dir}" ]; then 142 elif [ -n "${FLAGS_archive_dir}" ]; then
126 devserver_flags="${devserver_flags} \ 143 devserver_flags="${devserver_flags} \
127 --archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t" 144 --archive_dir $(reinterpret_path_for_chroot ${FLAGS_archive_dir}) -t"
128 IMAGE_PATH="${FLAGS_archive_dir}/chromiumos_test_image.bin" 145 IMAGE_PATH="${FLAGS_archive_dir}/chromiumos_test_image.bin"
129 else 146 else
130 # IMAGE_PATH should be the newest image and learn the board from 147 # IMAGE_PATH should be the newest image and learn the board from
131 # the target. 148 # the target.
132 learn_board 149 learn_board
133 IMAGE_PATH="$($(dirname "$0")/get_latest_image.sh --board="${FLAGS_board}")" 150 IMAGE_PATH="$(${SCRIPTS_DIR}/get_latest_image.sh --board="${FLAGS_board}")"
134 IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin" 151 IMAGE_PATH="${IMAGE_PATH}/chromiumos_image.bin"
135 devserver_flags="${devserver_flags} \ 152 devserver_flags="${devserver_flags} \
136 --image $(reinterpret_path_for_chroot ${IMAGE_PATH})" 153 --image $(reinterpret_path_for_chroot ${IMAGE_PATH})"
137 fi 154 fi
138 155
139 if [ -n "${FLAGS_payload}" ]; then 156 if [ -n "${FLAGS_payload}" ]; then
140 devserver_flags="${devserver_flags} \ 157 devserver_flags="${devserver_flags} \
141 --payload $(reinterpret_path_for_chroot ${FLAGS_payload})" 158 --payload $(reinterpret_path_for_chroot ${FLAGS_payload})"
142 fi 159 fi
143 160
144 if [ -n "${FLAGS_proxy_port}" ]; then 161 if [ -n "${FLAGS_proxy_port}" ]; then
145 devserver_flags="${devserver_flags} \ 162 devserver_flags="${devserver_flags} \
146 --proxy_port ${FLAGS_proxy_port}" 163 --proxy_port ${FLAGS_proxy_port}"
147 fi 164 fi
148 165
149 [ ${FLAGS_for_vm} -eq ${FLAGS_TRUE} ] && \ 166 [ ${FLAGS_for_vm} -eq ${FLAGS_TRUE} ] && \
150 devserver_flags="${devserver_flags} --for_vm" 167 devserver_flags="${devserver_flags} --for_vm"
151 168
152 devserver_flags="${devserver_flags} \ 169 devserver_flags="${devserver_flags} \
153 --src_image=\"$(reinterpret_path_for_chroot ${FLAGS_src_image})\"" 170 --src_image=\"$(reinterpret_path_for_chroot ${FLAGS_src_image})\""
154 171
155 info "Starting devserver with flags ${devserver_flags}" 172 info "Starting devserver with flags ${devserver_flags}"
156 ./enter_chroot.sh -- sudo sh -c "./start_devserver ${devserver_flags} \ 173 ./enter_chroot.sh -- sudo sh -c "./start_devserver ${devserver_flags} \
157 --client_prefix=ChromeOSUpdateEngine \ 174 --client_prefix=ChromeOSUpdateEngine \
158 --board=${FLAGS_board} \ 175 --board=${FLAGS_board} \
159 --port=${FLAGS_devserver_port} > ${FLAGS_server_log} 2>&1" & 176 --port=${FLAGS_devserver_port} > ${FLAGS_server_log} 2>&1" &
160 177
161 info "Waiting on devserver to start" 178 info "Waiting on devserver to start"
162 info "note: be patient as the server generates the update before starting." 179 info "note: be patient as the server generates the update before starting."
163 until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null 180 until netstat -anp 2>&1 | grep 0.0.0.0:${FLAGS_devserver_port} > /dev/null; do
164 do
165 sleep 5 181 sleep 5
166 echo -n "." 182 echo -n "."
167 if ! pgrep -f start_devserver > /dev/null; then 183 if ! pgrep -f start_devserver > /dev/null; then
168 echo "Devserver failed, see dev_server.log." 184 echo "Devserver failed, see dev_server.log."
169 exit 1 185 exit 1
170 fi 186 fi
171 done 187 done
172 echo "" 188 echo ""
173 } 189 }
174 190
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 info "Autoupdate was successful." 323 info "Autoupdate was successful."
308 return 0 324 return 0
309 else 325 else
310 warn "Autoupdate was unsuccessful. Status returned was ${update_status}." 326 warn "Autoupdate was unsuccessful. Status returned was ${update_status}."
311 return 1 327 return 1
312 fi 328 fi
313 } 329 }
314 330
315 function verify_image { 331 function verify_image {
316 info "Verifying image." 332 info "Verifying image."
317 "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname ${IMAGE_PATH})" \ 333 "${SCRIPTS_DIR}/mount_gpt_image.sh" --from "$(dirname "${IMAGE_PATH}")" \
318 --image "$(basename ${IMAGE_PATH})" \ 334 --image "$(basename ${IMAGE_PATH})" \
319 --read_only 335 --read_only
320 336
321 local lsb_release=$(cat /tmp/m/etc/lsb-release) 337 local lsb_release=$(cat /tmp/m/etc/lsb-release)
322 info "Verifying image with release:" 338 info "Verifying image with release:"
323 echo ${lsb_release} 339 echo ${lsb_release}
324 340
325 "${SCRIPTS_DIR}/mount_gpt_image.sh" --unmount 341 "${SCRIPTS_DIR}/mount_gpt_image.sh" --unmount
326 342
327 remote_sh "cat /etc/lsb-release" 343 remote_sh "cat /etc/lsb-release"
(...skipping 10 matching lines...) Expand all
338 } 354 }
339 355
340 function find_root_dev { 356 function find_root_dev {
341 remote_sh "rootdev -s" 357 remote_sh "rootdev -s"
342 echo ${REMOTE_OUT} 358 echo ${REMOTE_OUT}
343 } 359 }
344 360
345 function main() { 361 function main() {
346 assert_outside_chroot 362 assert_outside_chroot
347 363
348 cd $(dirname "$0") 364 cd "${SCRIPTS_DIR}"
349 365
350 FLAGS "$@" || exit 1 366 FLAGS "$@" || exit 1
351 eval set -- "${FLAGS_ARGV}" 367 eval set -- "${FLAGS_ARGV}"
352 368
353 set -e 369 set -e
354 370
355 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ] && \ 371 if [ ${FLAGS_verify} -eq ${FLAGS_TRUE} ] && \
356 [ -n "${FLAGS_update_url}" ]; then 372 [ -n "${FLAGS_update_url}" ]; then
357 warn "Verify is not compatible with setting an update url." 373 warn "Verify is not compatible with setting an update url."
358 FLAGS_verify=${FLAGS_FALSE} 374 FLAGS_verify=${FLAGS_FALSE}
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2) 428 local release_description=$(echo ${REMOTE_OUT} | cut -d '=' -f 2)
413 info "Update was successful and rebooted to $release_description" 429 info "Update was successful and rebooted to $release_description"
414 fi 430 fi
415 431
416 print_time_elapsed 432 print_time_elapsed
417 433
418 exit 0 434 exit 0
419 } 435 }
420 436
421 main $@ 437 main $@
OLDNEW
« no previous file with comments | « image_hacks.sh ('k') | image_to_usb.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698