diff options
-rw-r--r-- | futility/cmd_update.c | 8 | ||||
-rw-r--r-- | futility/updater.c | 21 |
2 files changed, 25 insertions, 4 deletions
diff --git a/futility/cmd_update.c b/futility/cmd_update.c index bd01cc3c..a77b2246 100644 --- a/futility/cmd_update.c +++ b/futility/cmd_update.c @@ -111,13 +111,17 @@ static void print_help(int argc, char *argv[]) " --pd_image=FILE \tPD firmware image (i.e, pd.bin)\n" "-t, --try \tTry A/B update on reboot if possible\n" "-a, --archive=PATH \tRead resources from archive\n" - " --manifest \tPrint out a JSON manifest and exit\n" " --unpack=DIR \tExtracts archive to DIR\n" "-p, --programmer=PRG\tChange AP (host) flashrom programmer\n" " --fast \tReduce read cycles and do not verify\n" " --quirks=LIST \tSpecify the quirks to apply\n" " --list-quirks \tPrint all available quirks\n" - "-m, --mode=MODE \tRun updater in specified mode\n" + "-m, --mode=MODE \tRun updater in the specified mode\n" + " --manifest \tScan the archive to print a manifest in JSON\n" + "\n" + " * If both --manifest and --fast are specified, the updater\n" + " will not scan the archive and simply dump the previously\n" + " cached manifest (may be out-dated) from the archive.\n" "\n" "Legacy and compatibility options:\n" " --factory \tAlias for --mode=factory\n" diff --git a/futility/updater.c b/futility/updater.c index c28c5bae..1a5e99d1 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1603,8 +1603,25 @@ int updater_setup_config(struct updater_config *cfg, return errorcnt; } - /* Load images from archive. */ - if (arg->archive) { + /* Process the manifest and load images from the archive. */ + if (arg->archive && arg->do_manifest && arg->fast_update) { + /* Quickly load and dump the manifest file from the archive. */ + const char *manifest_name = "manifest.json"; + uint8_t *data = NULL; + uint32_t size = 0; + + if (archive_has_entry(cfg->archive, manifest_name) && + archive_read_file(cfg->archive, manifest_name, &data, &size, + NULL) == 0) { + /* data is NUL-terminated. */ + printf("%s\n", data); + free(data); + } else { + ERROR("Failed to read the cached manifest: %s\n", + manifest_name); + errorcnt++; + } + } else if (arg->archive) { struct manifest *m = new_manifest_from_archive(cfg->archive); if (m) { errorcnt += updater_setup_archive( |