Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 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 | 31 |
| 32 if [ -n "${FLAGS_ARGV}" ]; then | 32 if [ -n "${FLAGS_ARGV}" ]; then |
| 33 BASE_UPDATE_URL=$(remove_quotes "${FLAGS_ARGV}") | 33 BASE_UPDATE_URL=$(remove_quotes "${FLAGS_ARGV}") |
| 34 else | 34 else |
| 35 if [ -f "${STATEFUL_DIR}${LSB_RELEASE}" ]; then | 35 if [ -f "${STATEFUL_DIR}${LSB_RELEASE}" ]; then |
| 36 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${STATEFUL_DIR}${LSB_RELEASE} | \ | 36 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${STATEFUL_DIR}${LSB_RELEASE} | \ |
|
petkov
2011/03/04 23:31:57
no need for trailing \
| |
| 37 cut -f 2 -d '=') | 37 cut -f 2 -d '=') |
| 38 fi | 38 fi |
| 39 if [ -z "${DEVSERVER_URL}" ]; then | 39 if [ -z "${DEVSERVER_URL}" ]; then |
| 40 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${LSB_RELEASE} | cut -f 2 -d '=') | 40 DEVSERVER_URL=$(grep CHROMEOS_DEVSERVER ${LSB_RELEASE} | cut -f 2 -d '=') |
| 41 fi | 41 fi |
| 42 # Sanity check. | 42 # Sanity check. |
| 43 if [ -z "${DEVSERVER_URL}" ]; then | 43 if [ -z "${DEVSERVER_URL}" ]; then |
| 44 echo >&2 "No CHROMEOS_DEVSERVER URL found in lsb-release file" | 44 echo >&2 "No CHROMEOS_DEVSERVER URL found in lsb-release file" |
| 45 exit 1 | 45 exit 1 |
| 46 fi | 46 fi |
| 47 # Devserver URL should never contain "/update" | 47 # Devserver URL should never contain "/update" |
| 48 DEVSERVER_URL=$(echo ${DEVSERVER_URL} | sed -e 's#/update##') | 48 DEVSERVER_URL=$(echo ${DEVSERVER_URL} | sed -e 's#/update##') |
| 49 BASE_UPDATE_URL="${DEVSERVER_URL}/static" | 49 BASE_UPDATE_URL="${DEVSERVER_URL}/static" |
| 50 fi | 50 fi |
| 51 | 51 |
| 52 STATEFUL_UPDATE_URL="${BASE_UPDATE_URL}/stateful.tgz" | 52 STATEFUL_UPDATE_URL="${BASE_UPDATE_URL}/stateful.tgz" |
| 53 echo "Downloading stateful payload from ${STATEFUL_UPDATE_URL}" | 53 echo "Downloading stateful payload from ${STATEFUL_UPDATE_URL}" |
| 54 # Download and unzip directories onto the stateful partition. | 54 # Download and unzip directories onto the stateful partition. |
| 55 eval "wget -qS -T 300 -O - \"${STATEFUL_UPDATE_URL}\"" | \ | 55 eval "wget -qS -T 300 -O - \"${STATEFUL_UPDATE_URL}\"" | \ |
| 56 tar --ignore-command-error --overwrite --directory=${STATEFUL_DIR} -xz | 56 tar --ignore-command-error --overwrite --directory=${STATEFUL_DIR} -xz |
| 57 echo >&2 "Successfully downloaded update" | 57 echo >&2 "Successfully downloaded update" |
| 58 | 58 |
| 59 if [ -d "${STATEFUL_DIR}/var_new" ] && [ -d "${STATEFUL_DIR}/dev_image_new" ] | 59 if [ ! -d "${STATEFUL_DIR}/var_new" ] || \ |
|
petkov
2011/03/04 23:31:57
no need for trailing \
| |
| 60 then | 60 [ ! -d "${STATEFUL_DIR}/dev_image_new" ]; then |
| 61 echo >&2 "Notifying startup that an update is available" | 61 echo >&2 "Missing var or dev_image in stateful payload." |
| 62 touch "${STATEFUL_DIR}/.update_available" | 62 return 1 |
| 63 else | |
| 64 echo >&2 "No update available" | |
| 65 fi | 63 fi |
| 66 } | 64 } |
| 67 | 65 |
| 68 update_old_state () { | 66 update_old_state () { |
| 69 echo >&2 "Performing standard stateful update." | 67 echo >&2 "Performing standard stateful update." |
| 68 touch "${STATEFUL_DIR}/.update_available" | |
|
petkov
2011/03/04 23:31:57
echo -n "" > .update_available
| |
| 70 } | 69 } |
| 71 | 70 |
| 72 update_clean_state () { | 71 update_clean_state () { |
| 73 echo >&2 "Restoring state to factory_install with dev_image." | 72 echo >&2 "Restoring state to factory_install with dev_image." |
| 74 echo "fast test" > "/mnt/stateful_partition/factory_install_reset" | 73 echo "clobber" > "${STATEFUL_DIR}/.update_available" |
| 75 } | 74 } |
| 76 | 75 |
| 77 main () { | 76 main () { |
| 78 update_dev_image | 77 if update_dev_image; then |
| 79 if [ "${FLAGS_stateful_change}" = "${OLD_STATE}" ]; then | 78 if [ "${FLAGS_stateful_change}" = "${OLD_STATE}" ]; then |
| 80 update_old_state | 79 update_old_state |
| 81 elif [ "${FLAGS_stateful_change}" = "${CLEAN_STATE}" ]; then | 80 elif [ "${FLAGS_stateful_change}" = "${CLEAN_STATE}" ]; then |
| 82 update_clean_state | 81 update_clean_state |
| 82 else | |
| 83 echo >&2 "Invalid state given to stateful update. Aborting..." | |
| 84 return 1 | |
| 85 fi | |
| 83 else | 86 else |
| 84 echo >&2 "Invalid state given to stateful update. Aborting..." | 87 return 1 |
| 85 exit 1 | |
| 86 fi | 88 fi |
| 87 } | 89 } |
| 88 | 90 |
| 89 main $@ | 91 main $@ |
| OLD | NEW |