diff options
author | Yu-Ping Wu <yupingso@chromium.org> | 2023-04-11 14:36:17 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-12 04:19:57 +0000 |
commit | 35f62791446b10ac50f184397a9a38dbf762bddd (patch) | |
tree | 6fec56ee666a035192a1327c0cbe5f74efebfc3d /futility | |
parent | b76cd8c806a47ca42b4df67b547a1d3fb0093a22 (diff) | |
download | vboot-35f62791446b10ac50f184397a9a38dbf762bddd.tar.gz |
futility: Allow printing manifest for EC only
Currently `futility update --manifest` requires either -i/--image or
-a/--archive to be passed. There is no way to show the EC manifest
without also passing an AP image.
Extend the command by allowing `futility update --manifest -e FILE`.
Here are a few examples of valid commands:
* futility update --manifest --archive PATH
* futility update --manifest --image FILE
* futility update --manifest --image FILE --ec_image FILE
* futility update --manifest --ec_image FILE
BUG=none
TEST=make DISABLE_NDEBUG=1 futil -j
TEST=sudo emerge vboot_reference
TEST=futility update --manifest -e FILE
BRANCH=none
Change-Id: I267b90a3e5ff2891b519702558d173bb2e970052
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4413335
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Yidi Lin <yidilin@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r-- | futility/updater.c | 10 | ||||
-rw-r--r-- | futility/updater_manifest.c | 27 |
2 files changed, 26 insertions, 11 deletions
diff --git a/futility/updater.c b/futility/updater.c index b8fbcd6c..6a59a8e1 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1443,13 +1443,14 @@ int updater_setup_config(struct updater_config *cfg, /* Check incompatible options and return early. */ if (arg->do_manifest) { - if (!!arg->archive == !!arg->image) { - ERROR("--manifest needs either -a or -i\n"); + if (!arg->archive && !arg->image && !arg->ec_image) { + ERROR("--manifest needs -a, -i or -e\n"); return ++errorcnt; } - if (arg->archive && (arg->ec_image || arg->pd_image)) { + if (arg->archive + && (arg->image || arg->ec_image || arg->pd_image)) { ERROR("--manifest for archive (-a) does not accept \n" - "additional images (--ec_image, --pd_image)."); + "additional images (--image, --ec_image, --pd_image)."); return ++errorcnt; } *do_update = 0; @@ -1626,7 +1627,6 @@ int updater_setup_config(struct updater_config *cfg, .num = 1, .models = &model, }; - assert(model.image); print_json_manifest(&manifest); } diff --git a/futility/updater_manifest.c b/futility/updater_manifest.c index 22ce2262..188f5ffb 100644 --- a/futility/updater_manifest.c +++ b/futility/updater_manifest.c @@ -891,7 +891,8 @@ static const char *get_gbb_key_hash(const struct vb2_gbb_header *gbb, /* Prints the information of given image file in JSON format. */ static void print_json_image( const char *name, const char *fpath, struct model_config *m, - struct u_archive *archive, int indent, int is_host) + struct u_archive *archive, int indent, int is_host, + bool is_first) { struct firmware_image image = {0}; const struct vb2_gbb_header *gbb = NULL; @@ -899,7 +900,7 @@ static void print_json_image( return; if (load_firmware_image(&image, fpath, archive)) return; - if (!is_host) + if (!is_first) printf(",\n"); printf("%*s\"%s\": { \"versions\": { \"ro\": \"%s\", \"rw\": \"%s\" },", indent, "", name, image.ro_version, image.rw_version_a); @@ -926,17 +927,31 @@ static void print_json_image( /* Prints the information of objects in manifest (models and images) in JSON. */ void print_json_manifest(const struct manifest *manifest) { - int i, indent; + int i, j, indent; struct u_archive *ar = manifest->archive; printf("{\n"); for (i = 0, indent = 2; i < manifest->num; i++) { struct model_config *m = &manifest->models[i]; + struct { + const char *name; + const char *fpath; + bool is_host; + } images[] = { + {"host", m->image, true}, + {"ec", m->ec_image}, + {"pd", m->pd_image}, + }; + bool is_first = true; printf("%s%*s\"%s\": {\n", i ? ",\n" : "", indent, "", m->name); indent += 2; - print_json_image("host", m->image, m, ar, indent, 1); - print_json_image("ec", m->ec_image, m, ar, indent, 0); - print_json_image("pd", m->pd_image, m, ar, indent, 0); + for (j = 0; j < ARRAY_SIZE(images); j++) { + if (!images[j].fpath) + continue; + print_json_image(images[j].name, images[j].fpath, m, ar, + indent, images[j].is_host, is_first); + is_first = false; + } if (m->patches.rootkey) { struct patch_config *p = &m->patches; printf(",\n%*s\"patches\": { \"rootkey\": \"%s\", " |