summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-11-21 08:47:37 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-11-24 19:21:28 -0800
commitd21a596fdb606917565512ef99f468be65a53512 (patch)
treefa547f8d18c83b5f7017886bf409ca3f1d6be5a4
parent04bc3d9fdeb33856660f42f9e75f1d0646f3a0e6 (diff)
downloadvboot-d21a596fdb606917565512ef99f468be65a53512.tar.gz
futility: updater: Load quirks immediately after host image is loaded
There may be quirks needed during image archive setup (for example loading white label tags) so we have to move quirks setup to some earlier place. BUG=chromium:906962 TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility BRANCH=None Change-Id: I1f6eddb0119c64098df75bad72809ba8366625c7 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1345609 Reviewed-by: Youcheng Syu <youcheng@chromium.org>
-rw-r--r--futility/updater.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/futility/updater.c b/futility/updater.c
index 01aa13af..2f7a29cb 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -1708,11 +1708,33 @@ static int save_from_stdin(const char *output)
}
/*
+ * Setup quirks for updating current image.
+ *
+ * Quirks must be loaded after image loaded because we use image contents to
+ * decide default quirks to load. Also, we have to load default quirks first so
+ * user can override them using command line.
+ *
+ * Returns 0 on success, otherwise number of failures.
+ */
+static int updater_setup_quirks(struct updater_config *cfg,
+ const struct updater_config_arguments *arg)
+{
+ int errorcnt = 0;
+ const char *quirks = updater_get_default_quirks(cfg);
+
+ if (quirks)
+ errorcnt += !!setup_config_quirks(quirks, cfg);
+ if (arg->quirks)
+ errorcnt += !!setup_config_quirks(arg->quirks, cfg);
+ return errorcnt;
+}
+
+/*
* Loads images into updater configuration.
* Returns 0 on success, otherwise number of failures.
*/
static int updater_load_images(struct updater_config *cfg,
- int host_only,
+ const struct updater_config_arguments *arg,
const char *image,
const char *ec_image,
const char *pd_image)
@@ -1728,8 +1750,10 @@ static int updater_load_images(struct updater_config *cfg,
errorcnt += !!save_from_stdin(image);
}
errorcnt += !!load_firmware_image(&cfg->image, image, ar);
+ if (!errorcnt)
+ errorcnt += updater_setup_quirks(cfg, arg);
}
- if (cfg->emulation || host_only)
+ if (cfg->emulation || arg->host_only)
return errorcnt;
if (!cfg->ec_image.data && ec_image)
@@ -1841,7 +1865,7 @@ static int updater_setup_archive(
}
errorcnt += updater_load_images(
- cfg, arg->host_only, model->image, model->ec_image,
+ cfg, arg, model->image, model->ec_image,
model->pd_image);
errorcnt += patch_image_by_model(&cfg->image, model, ar);
return errorcnt;
@@ -1858,7 +1882,6 @@ int updater_setup_config(struct updater_config *cfg,
int errorcnt = 0;
int check_single_image = 0, check_wp_disabled = 0;
int do_output = 0;
- const char *default_quirks = NULL;
const char *archive_path = arg->archive;
/* Setup values that may change output or decision of other argument. */
@@ -1942,8 +1965,7 @@ int updater_setup_config(struct updater_config *cfg,
/* Always load images specified from command line directly. */
errorcnt += updater_load_images(
- cfg, arg->host_only, arg->image, arg->ec_image,
- arg->pd_image);
+ cfg, arg, arg->image, arg->ec_image, arg->pd_image);
if (!archive_path)
archive_path = ".";
@@ -2004,14 +2026,11 @@ int updater_setup_config(struct updater_config *cfg,
}
/*
- * Quirks must be loaded after images are loaded because we use image
- * contents to decide default quirks to load. Also, we have to load
- * default quirks first so user can override them using command line.
+ * Images should be loaded now (either in first updater_load_images or
+ * second call from updater_setup_archive) and quirks should be loaded.
+ * For invocation without image, we want to get quirks now.
*/
- default_quirks = updater_get_default_quirks(cfg);
- if (default_quirks)
- errorcnt += !!setup_config_quirks(default_quirks, cfg);
- if (arg->quirks)
+ if (!cfg->image.data && arg->quirks)
errorcnt += !!setup_config_quirks(arg->quirks, cfg);
/* Additional checks. */