diff options
author | Hung-Te Lin <hungte@chromium.org> | 2018-10-17 12:03:24 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-10-24 13:03:18 -0700 |
commit | e1cc2b8ef8d27945043daf0e961fa1ddd40acfd4 (patch) | |
tree | 81fc8437a622068c8e2ac844690f145c3e6370f9 /futility/updater.c | |
parent | 9262fdd9651c44a0f1ca28ccd876543396baf1ce (diff) | |
download | vboot-e1cc2b8ef8d27945043daf0e961fa1ddd40acfd4.tar.gz |
futility: updater: Support --repack and --unpack
In order to make the firmware updater package more consistent file
contents (for example, we don't want time stamps, and better if the
files are always physically located in same order) we want to create and
manipulate the ZIP based package directly using updater.
BUG=chromium:875551
TEST=TEST=make futil; tests/futility/run_test_scripts.sh $(pwd)/build/futility
BRANCH=None
Change-Id: Ie4c5aafe51f633729de2879c73bf7074a695151f
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1286173
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Diffstat (limited to 'futility/updater.c')
-rw-r--r-- | futility/updater.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/futility/updater.c b/futility/updater.c index 4ddf53db..d63549a4 100644 --- a/futility/updater.c +++ b/futility/updater.c @@ -1816,6 +1816,13 @@ int updater_setup_config(struct updater_config *cfg, } *do_update = 0; } + if (arg->repack || arg->unpack) { + if (!arg->archive) { + ERROR("--{re,un}pack needs --archive."); + return ++errorcnt; + } + *do_update = 0; + } /* Setup update mode. */ if (arg->try_update) @@ -1882,6 +1889,29 @@ int updater_setup_config(struct updater_config *cfg, return ++errorcnt; } + /* Process archives which may not have valid contents. */ + if (arg->repack || arg->unpack) { + const char *work_name = arg->repack ? arg->repack : arg->unpack; + struct archive *from, *to, *work; + + work = archive_open(work_name); + if (arg->repack) { + from = work; + to = cfg->archive; + } else { + to = work; + from = cfg->archive; + } + if (!work) { + ERROR("Failed to open: %s", work_name); + return ++errorcnt; + } + errorcnt += !!archive_copy(from, to); + /* TODO(hungte) Update manifest after copied. */ + archive_close(work); + return errorcnt; + } + /* Load images from archive. */ if (arg->archive) { struct manifest *m = new_manifest_from_archive(cfg->archive); |