summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-28 17:23:02 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-05 16:10:58 -0700
commitbb455cbac0c99f643f76e99b238ce337d45fc219 (patch)
treebcfa426354dddfb5497b9917becb8c1fbba16a72
parent86e12ef99dfcc71c6e4903e3ed892330e78f66ff (diff)
downloadvboot-bb455cbac0c99f643f76e99b238ce337d45fc219.tar.gz
futility: cmd_update: Add more legacy updater options
To make it easier for integration with legacy firmware updater, we want to add few options: -m, --mode MODE -d, --debug -v, --verbose BUG=chromium:875551 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I6f045db0a8e9b5c73c1f0be2b52a71a7ee2a495e Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1193043 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--futility/cmd_update.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c
index 964f071e..a6ec89be 100644
--- a/futility/cmd_update.c
+++ b/futility/cmd_update.c
@@ -1378,15 +1378,18 @@ static struct option const long_opts[] = {
{"ec_image", 1, NULL, 'e'},
{"pd_image", 1, NULL, 'P'},
{"try", 0, NULL, 't'},
+ {"mode", 1, NULL, 'm'},
{"force", 0, NULL, 'F'},
{"wp", 1, NULL, 'W'},
{"emulate", 1, NULL, 'E'},
{"sys_props", 1, NULL, 'S'},
+ {"debug", 0, NULL, 'd'},
+ {"verbose", 0, NULL, 'v'},
{"help", 0, NULL, 'h'},
{NULL, 0, NULL, 0},
};
-static const char * const short_opts = "hi:e:t";
+static const char * const short_opts = "hi:e:tm:dv";
static void print_help(int argc, char *argv[])
{
@@ -1399,12 +1402,15 @@ static void print_help(int argc, char *argv[])
"-t, --try \tTry A/B update on reboot if possible\n"
"\n"
"Legacy and compatibility options:\n"
+ "-m, --mode=MODE \tRun updater in given mode\n"
" --force \tForce update (skip checking contents)\n"
"\n"
"Debugging and testing options:\n"
" --wp=1|0 \tSpecify write protection status\n"
" --emulate=FILE \tEmulate system firmware using file\n"
" --sys_props=LIST\tList of system properties to override\n"
+ "-d, --debug \tPrint debugging messages\n"
+ "-v, --verbose \tPrint verbose messages\n"
"",
argv[0]);
}
@@ -1446,6 +1452,23 @@ static int do_update(int argc, char *argv[])
case 't':
cfg.try_update = 1;
break;
+ case 'm':
+ if (strcmp(optarg, "autoupdate") == 0) {
+ cfg.try_update = 1;
+ } else if (strcmp(optarg, "recovery") == 0) {
+ cfg.try_update = 0;
+ } else if (strcmp(optarg, "factory") == 0) {
+ cfg.try_update = 0;
+ if (!is_write_protection_enabled(&cfg)) {
+ errorcnt++;
+ Error("Mode %s needs WP disabled.\n",
+ optarg);
+ }
+ } else {
+ errorcnt++;
+ Error("Invalid mode: %s\n", optarg);
+ }
+ break;
case 'W':
r = strtol(optarg, NULL, 0);
override_system_property(SYS_PROP_WP_HW, &cfg, r);
@@ -1467,6 +1490,13 @@ static int do_update(int argc, char *argv[])
case 'S':
override_properties_from_list(optarg, &cfg);
break;
+ case 'v':
+ /* TODO(hungte) Change to better verbosity control. */
+ debugging_enabled = 1;
+ break;
+ case 'd':
+ debugging_enabled = 1;
+ break;
case 'h':
print_help(argc, argv);