summaryrefslogtreecommitdiff
path: root/futility/updater_manifest.c
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2023-04-11 14:36:17 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-12 04:19:57 +0000
commit35f62791446b10ac50f184397a9a38dbf762bddd (patch)
tree6fec56ee666a035192a1327c0cbe5f74efebfc3d /futility/updater_manifest.c
parentb76cd8c806a47ca42b4df67b547a1d3fb0093a22 (diff)
downloadvboot-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/updater_manifest.c')
-rw-r--r--futility/updater_manifest.c27
1 files changed, 21 insertions, 6 deletions
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\", "