summaryrefslogtreecommitdiff
path: root/futility/updater.c
diff options
context:
space:
mode:
Diffstat (limited to 'futility/updater.c')
-rw-r--r--futility/updater.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/futility/updater.c b/futility/updater.c
index 17b12a2b..0d69641b 100644
--- a/futility/updater.c
+++ b/futility/updater.c
@@ -1668,13 +1668,49 @@ static int updater_load_images(struct updater_config *cfg,
}
/*
+ * Applies white label information to an existing model config.
+ * Returns 0 on success, otherwise failure.
+ */
+static int updater_apply_white_label(struct updater_config *cfg,
+ struct model_config *model,
+ const char *signature_id)
+{
+ const char *tmp_image = NULL;
+
+ assert(model->is_white_label);
+ if (!signature_id) {
+ if (cfg->image_current.data) {
+ tmp_image = updater_create_temp_file(cfg);
+ if (!tmp_image)
+ return 1;
+ if (vb2_write_file(tmp_image, cfg->image_current.data,
+ cfg->image_current.size)) {
+ ERROR("Failed writing temporary image file.");
+ return 1;
+ }
+ } else {
+ printf("Loading system firmware for white label..\n");
+ load_system_firmware(cfg, &cfg->image_current);
+ tmp_image = cfg->image_current.file_name;
+ }
+ if (!tmp_image) {
+ ERROR("Failed to get system current firmware");
+ return 1;
+ }
+ }
+ return !!model_apply_white_label(
+ model, cfg->archive, signature_id, tmp_image);
+}
+
+/*
* Setup what the updater has to do against an archive.
* Returns number of failures, or 0 on success.
*/
static int updater_setup_archive(
struct updater_config *cfg,
const struct updater_config_arguments *arg,
- struct manifest *manifest)
+ struct manifest *manifest,
+ int is_factory)
{
int errorcnt = 0;
struct archive *ar = cfg->archive;
@@ -1691,6 +1727,23 @@ static int updater_setup_archive(
if (!model)
return ++errorcnt;
+ if (model->is_white_label) {
+ /*
+ * It is fine to fail in updater_apply_white_label for factory
+ * mode so we are not checking the return value; instead we
+ * verify if the patches do contain new root key.
+ */
+ updater_apply_white_label(cfg, (struct model_config *)model,
+ arg->signature_id);
+ if (!model->patches.rootkey) {
+ if (!is_factory) {
+ ERROR("Need VPD set for white label.");
+ return ++errorcnt;
+ }
+ fprintf(stderr, "Warning: No VPD for white label.\n");
+ }
+ }
+
errorcnt += updater_load_images(
cfg, model->image, model->ec_image, model->pd_image);
errorcnt += patch_image_by_model(&cfg->image, model, ar);
@@ -1796,7 +1849,8 @@ int updater_setup_config(struct updater_config *cfg,
if (arg->archive) {
struct manifest *m = new_manifest_from_archive(cfg->archive);
if (m) {
- errorcnt += updater_setup_archive(cfg, arg, m);
+ errorcnt += updater_setup_archive(
+ cfg, arg, m, cfg->factory_update);
delete_manifest(m);
} else {
ERROR("Failure in archive: %s", arg->archive);