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

Side by Side Diff: stateful_update

Issue 4755001: Change update logic to be backwards compatible with old format. (Closed) Base URL: http://git.chromium.org/git/dev-util.git@master
Patch Set: Created 10 years, 1 month 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
« autoupdate.py ('K') | « autoupdate.py ('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/sh 1 #!/bin/sh
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 # This scripts performs update of stateful partition directories useful for 7 # This scripts performs update of stateful partition directories useful for
8 # dev_mode. 8 # dev_mode.
9 9
10 . /usr/lib/shflags 10 . /usr/lib/shflags
(...skipping 10 matching lines...) Expand all
21 # Die on error. 21 # Die on error.
22 set -e 22 set -e
23 23
24 remove_quotes() { 24 remove_quotes() {
25 echo "$1" | sed -e "s/^'//; s/'$//" 25 echo "$1" | sed -e "s/^'//; s/'$//"
26 } 26 }
27 27
28 update_dev_image () { 28 update_dev_image () {
29 LSB_RELEASE="/etc/lsb-release" 29 LSB_RELEASE="/etc/lsb-release"
30 STATEFUL_DIR="/mnt/stateful_partition" 30 STATEFUL_DIR="/mnt/stateful_partition"
31 WORK_DIR="${STATEFUL_DIR}/stateful_update"
32 31
33 if [ -n "${FLAGS_ARGV}" ]; then 32 if [ -n "${FLAGS_ARGV}" ]; then
34 BASE_UPDATE_URL=$(remove_quotes "${FLAGS_ARGV}") 33 BASE_UPDATE_URL=$(remove_quotes "${FLAGS_ARGV}")
35 else 34 else
36 if [ -f "${STATEFUL_DIR}${LSB_RELEASE}" ]; then 35 if [ -f "${STATEFUL_DIR}${LSB_RELEASE}" ]; then
37 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${STATEFUL_DIR}${LSB_RELEASE} | \ 36 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${STATEFUL_DIR}${LSB_RELEASE} | \
38 cut -f 2 -d '=') 37 cut -f 2 -d '=')
39 fi 38 fi
40 if [ -z "${DEVSERVER_URL}" ]; then 39 if [ -z "${DEVSERVER_URL}" ]; then
41 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${LSB_RELEASE} | cut -f 2 -d '=') 40 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${LSB_RELEASE} | cut -f 2 -d '=')
42 fi 41 fi
43 # Sanity check. 42 # Sanity check.
44 if [ -z "${DEVSERVER_URL}" ]; then 43 if [ -z "${DEVSERVER_URL}" ]; then
45 echo >&2 "No CHROMEOS_DEVSERVER URL found in lsb-release file" 44 echo >&2 "No CHROMEOS_DEVSERVER URL found in lsb-release file"
46 exit 1 45 exit 1
47 fi 46 fi
48 # Devserver URL should never contain "/update" 47 # Devserver URL should never contain "/update"
49 DEVSERVER_URL=$(echo ${DEVSERVER_URL} | sed -e 's#/update##') 48 DEVSERVER_URL=$(echo ${DEVSERVER_URL} | sed -e 's#/update##')
50 BASE_UPDATE_URL="${DEVSERVER_URL}/static" 49 BASE_UPDATE_URL="${DEVSERVER_URL}/static"
51 fi 50 fi
52 51
53 STATEFUL_UPDATE_URL="${BASE_UPDATE_URL}/stateful.tgz" 52 STATEFUL_UPDATE_URL="${BASE_UPDATE_URL}/stateful.tgz"
54 53 echo "Downloading stateful payload from ${STATEFUL_UPDATE_URL}"
55 # Prepare directories for update. 54 # Download and unzip directories onto the stateful partition.
56 rm -rf "${WORK_DIR}"
57 mkdir "${WORK_DIR}"
58
59 echo "Download stateful image from ${STATEFUL_UPDATE_URL}"
60 # Unzip mount and copy the relevant directories.
61 # Get the update.
62 eval "wget -qS -T 300 -O - \"${STATEFUL_UPDATE_URL}\"" | \ 55 eval "wget -qS -T 300 -O - \"${STATEFUL_UPDATE_URL}\"" | \
63 tar -C ${WORK_DIR} -xz 56 tar --overwrite --directory=${STATEFUL_DIR} -xz
64 echo >&2 "Successfully downloaded update" 57 echo >&2 "Successfully downloaded update"
65 58
66 if [ -d "${WORK_DIR}/var" ] && [ -d "${WORK_DIR}/dev_image" ] ; then 59 if [ -d "${STATEFUL_DIR}/var_new" ] && [ -d "${STATEFUL_DIR}/dev_image_new" ]
60 then
67 echo >&2 "Notifying startup that an update is available" 61 echo >&2 "Notifying startup that an update is available"
68 touch "${STATEFUL_DIR}/.update_available" 62 touch "${STATEFUL_DIR}/.update_available"
69 else 63 else
70 echo >&2 "No update available" 64 echo >&2 "No update available"
71 fi 65 fi
72 } 66 }
73 67
74 update_old_state () { 68 update_old_state () {
75 echo >&2 "Performing standard stateful update." 69 echo >&2 "Performing standard stateful update."
76 } 70 }
77 71
78 update_clean_state () { 72 update_clean_state () {
79 echo >&2 "Restoring state to factory_install with dev_image." 73 echo >&2 "Restoring state to factory_install with dev_image."
80 echo "fast test" > "/mnt/stateful_partition/factory_install_reset" 74 echo "fast test" > "/mnt/stateful_partition/factory_install_reset"
81 } 75 }
82 76
83 main () { 77 main () {
84 update_dev_image 78 update_dev_image
85 if [ "${FLAGS_stateful_change}" = "${OLD_STATE}" ]; then 79 if [ "${FLAGS_stateful_change}" = "${OLD_STATE}" ]; then
86 update_old_state 80 update_old_state
87 elif [ "${FLAGS_stateful_change}" = "${CLEAN_STATE}" ]; then 81 elif [ "${FLAGS_stateful_change}" = "${CLEAN_STATE}" ]; then
88 update_clean_state 82 update_clean_state
89 else 83 else
90 echo >&2 "Invalid state given to stateful update. Aborting..." 84 echo >&2 "Invalid state given to stateful update. Aborting..."
91 exit 1 85 exit 1
92 fi 86 fi
93 } 87 }
94 88
95 main $@ 89 main $@
OLDNEW
« autoupdate.py ('K') | « autoupdate.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698