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

Unified Diff: pack_dist/updater.sh

Issue 6677151: chromeos-firmware: refine 'incompatibility mode' customization design (Closed) Base URL: ssh://gitrw.chromium.org:9222/firmware.git@master
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« pack_dist/common.sh ('K') | « pack_dist/common.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pack_dist/updater.sh
diff --git a/pack_dist/updater.sh b/pack_dist/updater.sh
index 33d348b1539fd08b92d91557432d74f636132347..b2ea9e4c178c14ea440716de07d267e2150e90cd 100644
--- a/pack_dist/updater.sh
+++ b/pack_dist/updater.sh
@@ -33,6 +33,12 @@ CUSTOMIZATION_SCRIPT="updater_custom.sh"
# You have to define a function with this name to run your customization.
CUSTOMIZATION_MAIN="updater_custom_main"
+# Customization script "compatibility check" function.
+# Overrides this with any function names to test if current system is compatible
+# with this updater.
+# Returns $FLAGS_FALSE if not compatible (i.e., need incompatible_mode)
+CUSTOMIZATION_COMPATIBILITY_CHECK=""
+
# Override this with the name with RO_FWID prefix.
# Updater will stop and give error if the platform does not match.
TARGET_PLATFORM=""
@@ -78,7 +84,7 @@ PLATFORM="$(crossystem ro_fwid 2>/dev/null | sed 's/\..*//' || true)"
DEFINE_string mode "" \
"Updater mode ( startup | bootok | autoupdate | todev | recovery |"\
-" factory_install | factory_final )" "m"
+" factory_install | factory_final | incompatible_update )" "m"
Randall Spangler 2011/04/05 16:42:38 Why are we adding a new mode?
Hung-Te 2011/04/06 02:02:51 Since an incompatible RW update needs different lo
DEFINE_boolean debug $FLAGS_FALSE "Enable debug messages." "d"
DEFINE_boolean verbose $FLAGS_TRUE "Enable verbose messages." "v"
DEFINE_boolean dry_run $FLAGS_FALSE "Enable dry-run mode." ""
@@ -95,9 +101,10 @@ DEFINE_boolean update_ro_ec $FLAGS_FALSE \
DEFINE_boolean check_keys $FLAGS_TRUE "Check firmware keys before updating." ""
DEFINE_boolean check_wp $FLAGS_TRUE \
"Check if write protection is enabled before updating RO sections" ""
+DEFINE_boolean check_incompatible $FLAGS_TRUE \
+ "Check if an incompatible update should be triggered or scheduled" ""
Randall Spangler 2011/04/05 16:42:38 This sounds confusing. Why would we ever trigger
Hung-Te 2011/04/06 02:02:51 Done.
DEFINE_boolean check_devfw $FLAGS_TRUE \
- "Check if developer firmware is activated and bypass updates" ""
-
+ "Bypass firmware updates if active firmware type is developer" ""
# Required for factory compatibility
DEFINE_boolean factory $FLAGS_FALSE "Equivalent to --mode=factory_install"
@@ -547,6 +554,43 @@ mode_incompatible_update() {
# ----------------------------------------------------------------------------
# Main Entry
+main_check_compatibility() {
+ local try_autoupdate="$1"
+ if [ "${FLAGS_check_incompatible}" = "${FLAGS_FALSE}" ]; then
+ verbose_msg "Bypassed compatbility check. You're on your own."
+ return $FLAGS_TRUE
+ fi
+
+ if [ -n "$CUSTOMIZATION_COMPATIBILITY_CHECK" ]; then
+ debug_msg "No compatibility check rules defined in customization."
+ return $FLAGS_TRUE
+ fi
+
+ local is_compatible="${FLAGS_TRUE}"
+ "$CUSTOMIZATION_COMPATIBILITY_CHECK" || is_compatible="${FLAGS_FALSE}"
+ if [ "$is_compatible" = "${FLAGS_TRUE}" ]; then
+ return $FLAGS_TRUE
+ fi
+
+ verbose_msg "Incompatible firmware detected. Need incompatible mode update."
Randall Spangler 2011/04/05 16:42:38 RW firmware update is not compatible with current
Hung-Te 2011/04/06 02:02:51 Done.
+
+ if [ "$try_autoupdate" = "$FLAGS_FALSE" ]; then
+ # No need to print anything in this case.
+ return $FLAGS_FALSE
+ fi
+
+ if is_developer_firmware; then
+ try_autoupdate=$FLAGS_FALSE
+ verbose_msg "Developer firmware detected - not scheduling auto updates."
+ else
+ # Try to schedule an autoupdate.
+ (cros_set_startup_update_tries 6) || try_autoupdate="${FLAGS_FALSE}"
+ fi
+
+ alert_incompatible_firmware "$try_autoupdate"
+ return $FLAGS_FALSE
+}
+
main() {
if [ -r /tmp/chromeos-firmwareupdate-running ]; then
err_die "chromeos-firmwareupdate is already running. Please retry later."
@@ -595,9 +639,26 @@ main() {
fi
case "${FLAGS_mode}" in
- startup | bootok | autoupdate | todev | recovery | \
- incompatible_update | factory_install | factory_final )
- debug_msg "mode: ${FLAGS_mode}"
+ # Modes that are allowed to trigger incompatible mode updates
Randall Spangler 2011/04/05 16:42:38 Modes which can attempt to update RO if RO+RW are
Hung-Te 2011/04/06 02:02:51 Done.
+ startup | recovery )
+ debug_msg "mode allowing compatibility update: ${FLAGS_mode}"
+ if main_check_compatibility $FLAGS_FALSE; then
+ mode_"${FLAGS_mode}"
+ else
+ verbose_msg "Starting an incompatible mode update..."
+ mode_incompatible_update
+ fi
+ ;;
+ # Modes with incompatible checks
Randall Spangler 2011/04/05 16:42:38 Modes which update RW firmware only; these need to
Hung-Te 2011/04/06 02:02:51 Done.
+ autoupdate | bootok | todev )
+ debug_msg "mode with compatibility check: ${FLAGS_mode}"
+ if main_check_compatibility $FLAGS_TRUE; then
+ mode_"${FLAGS_mode}"
+ fi
+ ;;
+ # Modes without incompatible checks
Randall Spangler 2011/04/05 16:42:38 Modes which don't mix existing RO firmware with ne
Hung-Te 2011/04/06 02:02:51 Done.
+ factory_install | factory_final | incompatible_update )
+ debug_msg "mode without incompatible checks: ${FLAGS_mode}"
mode_"${FLAGS_mode}"
;;
"" )
« pack_dist/common.sh ('K') | « pack_dist/common.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698