| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # All scripts should die on error unless commands are specifically excepted | 6 # All scripts should die on error unless commands are specifically excepted |
| 7 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. | 7 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. |
| 8 set -e | 8 set -e |
| 9 # Clean up on regular or error exits. | 9 # Clean up on regular or error exits. |
| 10 trap clean_temp EXIT | 10 trap clean_temp EXIT |
| 11 | 11 |
| 12 # Global variables | 12 # Global variables |
| 13 | 13 |
| 14 # Set by make_temp function and removed by clean_temp | 14 # Set by make_temp function and removed by clean_temp |
| 15 TMP_DIR= | 15 TMP_DIR= |
| 16 # Set by allow_temp_exec and will invoke unmount in clean_temp | 16 # Set by allow_temp_exec and will invoke unmount in clean_temp |
| 17 IS_NEED_UMOUNT= | 17 IS_NEED_UMOUNT= |
| 18 # Decides if we need to print verbose messages | 18 # Decides if we need to print verbose messages |
| 19 IS_VERBOSE= | 19 IS_VERBOSE= |
| 20 # The default script to be invoked from extracted resource | 20 # The default script to be invoked from extracted resource |
| 21 SCRIPT=./updater.sh | 21 SCRIPT=./updater.sh |
| 22 LEGACY_SCRIPT=./legacy_updater.sh | 22 LEGACY_SCRIPT=./legacy_updater.sh |
| 23 | 23 |
| 24 SHELLBALL_FWVERSION="REPLACE_FWVERSION" | 24 SHELLBALL_FWVERSION="REPLACE_FWVERSION" |
| 25 SHELLBALL_ECVERSION="REPLACE_ECVERSION" | 25 SHELLBALL_ECVERSION="REPLACE_ECVERSION" |
| 26 IGNORE_TAG_FILE='/root/.leave_firmware_alone' |
| 27 force_flag="" |
| 26 | 28 |
| 27 # Prints a message and return an error code. | 29 # Prints a message and return an error code. |
| 28 error_exit() { | 30 error_exit() { |
| 29 echo $1 | 31 echo $1 |
| 30 exit 1 | 32 exit 1 |
| 31 } | 33 } |
| 32 | 34 |
| 33 # Prints messages if $IS_VERBOSE is not empty. | 35 # Prints messages if $IS_VERBOSE is not empty. |
| 34 verbose_message() { | 36 verbose_message() { |
| 35 if [ -n "$IS_VERBOSE" ]; then | 37 if [ -n "$IS_VERBOSE" ]; then |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 shift | 150 shift |
| 149 ;; | 151 ;; |
| 150 -h|"-?"|--help) | 152 -h|"-?"|--help) |
| 151 echo "Shellball -- self-extract and install" | 153 echo "Shellball -- self-extract and install" |
| 152 echo "" | 154 echo "" |
| 153 echo "Usage: $SELF [options] [-- [inside-script-options]]" | 155 echo "Usage: $SELF [options] [-- [inside-script-options]]" |
| 154 echo "" | 156 echo "" |
| 155 echo "options:" | 157 echo "options:" |
| 156 echo " -h show usage help" | 158 echo " -h show usage help" |
| 157 echo " -V show version of containing files" | 159 echo " -V show version of containing files" |
| 160 echo " --force force execute and ignore $IGNORE_TAG_FILE" |
| 158 echo " --sb_check check content integrity" | 161 echo " --sb_check check content integrity" |
| 159 echo " --sb_extract extract content to temp folder" | 162 echo " --sb_extract extract content to temp folder" |
| 160 echo "" | 163 echo "" |
| 161 echo " All other parameters will be passed to the script inside." | 164 echo " All other parameters will be passed to the script inside." |
| 162 echo "" | 165 echo "" |
| 163 echo " You can invoke as '$SELF -- -h'" | 166 echo " You can invoke as '$SELF -- -h'" |
| 164 echo " to see the usage and options of inside-script." | 167 echo " to see the usage and options of inside-script." |
| 165 echo "" | 168 echo "" |
| 166 exit 1 | 169 exit 1 |
| 167 ;; | 170 ;; |
| 168 --debug | --verbose | -v) | 171 --debug | --verbose | -v) |
| 169 # do not shift here because this needs to be passed into the script | 172 # do not shift here because this needs to be passed into the script |
| 170 IS_VERBOSE=1 | 173 IS_VERBOSE=1 |
| 171 ;; | 174 ;; |
| 172 --) | 175 --) |
| 173 shift | 176 shift |
| 174 ;; | 177 ;; |
| 175 esac | 178 esac |
| 176 | 179 |
| 177 # Do nothing if we're debugging BIOS changes, unless forced | 180 # Do nothing if we're debugging BIOS changes, unless forced |
| 178 if [ -e /root/.leave_firmware_alone ] && [ -z "${force_flag:-}" ]; then | 181 if [ -e "$IGNORE_TAG_FILE" ] && [ -z "${force_flag:-}" ]; then |
| 179 echo "WARNING: $0 is disabled" | 182 echo "WARNING: $0 is disabled by $IGNORE_TAG_FILE" |
| 180 exit 0 | 183 exit 0 |
| 181 fi | 184 fi |
| 182 | 185 |
| 183 # Prepare execution environment | 186 # Prepare execution environment |
| 184 make_temp | 187 make_temp |
| 185 allow_temp_exec | 188 allow_temp_exec |
| 186 untar_and_chdir "$SELF" | 189 untar_and_chdir "$SELF" |
| 187 if [ ! -x $SCRIPT ]; then | 190 if [ ! -x $SCRIPT ]; then |
| 188 error_exit "Cannot execute $SCRIPT" | 191 error_exit "Cannot execute $SCRIPT" |
| 189 fi | 192 fi |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 fi | 228 fi |
| 226 fi | 229 fi |
| 227 | 230 |
| 228 verbose_message "Run built-in script ($SCRIPT) ..." | 231 verbose_message "Run built-in script ($SCRIPT) ..." |
| 229 if ! $SCRIPT "$@"; then | 232 if ! $SCRIPT "$@"; then |
| 230 error_exit "ERROR: $SCRIPT failed." | 233 error_exit "ERROR: $SCRIPT failed." |
| 231 fi | 234 fi |
| 232 exit 0 | 235 exit 0 |
| 233 | 236 |
| 234 # Below are uuencoded blob. Don't put code behind exit 0. | 237 # Below are uuencoded blob. Don't put code behind exit 0. |
| OLD | NEW |