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

Side by Side Diff: src/scripts/image_to_live.sh

Issue 1774021: Modifies dev server to produce stateful gzip and modify image_to_live to use it. (Closed) Base URL: ssh://git@chromiumos-git//chromeos
Patch Set: Fixes for seano Created 10 years, 7 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
« no previous file with comments | « src/scripts/build_image ('k') | no next file » | 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 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 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
27 pkill -fx ".*devserver\.py" || true 27 pkill -fx ".*devserver\.py" || true
28 } 28 }
29 29
30 function cleanup { 30 function cleanup {
31 echo "Killing dev server." 31 echo "Killing dev server."
32 kill_all_devservers 32 kill_all_devservers
33 cleanup_remote_access 33 cleanup_remote_access
34 rm -rf "${TMP}" 34 rm -rf "${TMP}"
35 } 35 }
36 36
37 function unmount_gpt {
38 ./mount_gpt_image.sh -mu
39 }
40
41 function remote_reboot_sh { 37 function remote_reboot_sh {
42 rm -f "${TMP_KNOWN_HOSTS}" 38 rm -f "${TMP_KNOWN_HOSTS}"
43 remote_sh "$@" 39 remote_sh "$@"
44 } 40 }
45 41
46 function start_dev_server { 42 function start_dev_server {
47 kill_all_devservers 43 kill_all_devservers
48 if [ ${FLAGS_verbose} -eq ${FLAGS_FALSE} ]; then 44 if [ ${FLAGS_verbose} -eq ${FLAGS_FALSE} ]; then
49 ./enter_chroot.sh "./start_devserver > /dev/null 2>&1" & 45 ./enter_chroot.sh "./start_devserver > dev_server.log 2>&1" &
50 else 46 else
51 ./enter_chroot.sh "./start_devserver" & 47 ./enter_chroot.sh "./start_devserver" &
52 fi 48 fi
53 echo -n "Waiting on devserver to start" 49 echo -n "Waiting on devserver to start"
54 until netstat -anp 2>&1 | grep 8080 > /dev/null; do 50 until netstat -anp 2>&1 | grep 8080 > /dev/null; do
55 sleep .5 51 sleep .5
56 echo -n "." 52 echo -n "."
57 done 53 done
58 echo "" 54 echo ""
59 } 55 }
60 56
61 # Copys new stateful var and developer directories to updating system. 57 # Copys stateful update script which fetches the newest stateful update
62 # chromeos_startup checks for .update_available on next boot and updates 58 # from the dev server and prepares the update. chromeos_startup finishes
63 # the stateful directories. 59 # the update on next boot.
64 function copy_stateful_tarball { 60 function copy_stateful_update {
65 echo "Starting stateful update." 61 echo "Starting stateful update."
66 # Mounts most recent image stateful dir to /tmp/s 62 local dev_dir="$(dirname $0)/../platform/dev"
67 ./mount_gpt_image.sh -m
68 trap "unmount_gpt && cleanup" EXIT
69 63
70 # Create tar files for the stateful partition. 64 # Copy over tar files.
71 if [ ! -d /tmp/s/var ] || [ ! -d /tmp/s/dev_image ] ; then 65 remote_cp "$dev_dir/stateful_update.sh" "/tmp"
72 echo "No stateful directories found to copy. Continuing update." 66 remote_sh "/tmp/stateful_update.sh"
73 else
74 pushd /tmp/s/var && sudo tar -czf /tmp/var.tgz . && popd
75 pushd /tmp/s/dev_image && sudo tar -czf /tmp/developer.tgz . && popd
76 # Copy over tar files.
77 local s_dir="/mnt/stateful_partition"
78 remote_cp /tmp/var.tgz /tmp
79 remote_cp /tmp/developer.tgz /tmp
80 remote_sh "rm -rf $s_dir/var_new $s_dir/dev_image_new &&\
81 mkdir $s_dir/var_new $s_dir/dev_image_new &&\
82 tar -xzf /tmp/var.tgz -C $s_dir/var_new &&\
83 tar -xzf /tmp/developer.tgz -C $s_dir/dev_image_new &&\
84 touch $s_dir/.update_available"
85 fi
86 # unmounts stateful partition
87 ./mount_gpt_image.sh -mu
88
89 trap cleanup EXIT
90 } 67 }
91 68
92 function prepare_update_metadata { 69 function prepare_update_metadata {
93 remote_sh "mount -norw,remount /" 70 remote_sh "mount -norw,remount /"
94 71
95 if [[ ${FLAGS_ignore_version} -eq ${FLAGS_TRUE} ]]; then 72 if [[ ${FLAGS_ignore_version} -eq ${FLAGS_TRUE} ]]; then
96 echo "Forcing update independent of the current version" 73 echo "Forcing update independent of the current version"
97 remote_sh "cat /etc/lsb-release |\ 74 remote_sh "cat /etc/lsb-release |\
98 grep -v CHROMEOS_RELEASE_VERSION > /etc/lsb-release~;\ 75 grep -v CHROMEOS_RELEASE_VERSION > /etc/lsb-release~;\
99 mv /etc/lsb-release~ /etc/lsb-release; \ 76 mv /etc/lsb-release~ /etc/lsb-release; \
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 184
208 start_dev_server 185 start_dev_server
209 186
210 prepare_update_metadata 187 prepare_update_metadata
211 188
212 if ! run_auto_update; then 189 if ! run_auto_update; then
213 echo "Update was not successful." 190 echo "Update was not successful."
214 exit 1 191 exit 1
215 fi 192 fi
216 193
217 if ! copy_stateful_tarball; then 194 if ! copy_stateful_update; then
218 echo "Stateful update was not successful." 195 echo "Stateful update was not successful."
219 fi 196 fi
220 197
221 remote_reboot 198 remote_reboot
222 199
223 if [[ ${FLAGS_update_hostkey} -eq ${FLAGS_TRUE} ]]; then 200 if [[ ${FLAGS_update_hostkey} -eq ${FLAGS_TRUE} ]]; then
224 local known_hosts="${HOME}/.ssh/known_hosts" 201 local known_hosts="${HOME}/.ssh/known_hosts"
225 cp "${known_hosts}" "${known_hosts}~" 202 cp "${known_hosts}" "${known_hosts}~"
226 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts" 203 grep -v "^${FLAGS_remote} " "${known_hosts}" > "${TMP}/new_known_hosts"
227 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}" 204 cat "${TMP}/new_known_hosts" "${TMP_KNOWN_HOSTS}" > "${known_hosts}"
228 chmod 0640 "${known_hosts}" 205 chmod 0640 "${known_hosts}"
229 echo "New updated in ${known_hosts}, backup made." 206 echo "New updated in ${known_hosts}, backup made."
230 fi 207 fi
231 208
232 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release" 209 remote_sh "grep ^CHROMEOS_RELEASE_DESCRIPTION= /etc/lsb-release"
233 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2) 210 local release_description=$(echo $REMOTE_OUT | cut -d '=' -f 2)
234 echo "Update was successful and rebooted to $release_description" 211 echo "Update was successful and rebooted to $release_description"
235 212
236 return 0 213 return 0
237 } 214 }
238 215
239 main $@ 216 main $@
OLDNEW
« no previous file with comments | « src/scripts/build_image ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698