diff options
author | Hung-Te Lin <hungte@chromium.org> | 2022-07-20 10:13:49 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-21 05:07:34 +0000 |
commit | 499b1814a76303b332c49dd5efb2c84e30b973ba (patch) | |
tree | b0ed5d48887ad88b5fcd3b9488901c9f65d4d31f | |
parent | a975eed306e16947c30b48ccd25ab67a37295742 (diff) | |
download | vboot-499b1814a76303b332c49dd5efb2c84e30b973ba.tar.gz |
futility: updater: allow --fast to skip scanning archive in do_manifest
The `--manifest` (do_manifest) command needs to scan most firmware
images in the archive to build up the right information. That can be ~2s
for a 200MB archive even though we just need the version string. 2s is
usually fast enough for developers when they want to check the archive
contents, but that is too slow if the boot time scripts (for example,
CSME updater) need to collect the information.
As a result, we want to allow overriding how the updater gets the
manifest. For most systems that the firmware archive is created by the
buildbot or the signerbot, the scripts can use "--manifest --fast" to
retrieve the cached JSON manifest file.
BUG=b:238908603
TEST=make; run test
BRANCH=None
Change-Id: I5d7dead4d0a43129fd31dd035aac63deaee42a08
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3775703
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
-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( |