From 60b242cfd58a234727f5d339e2f6fa4e91ffe1fa Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 30 Jul 2019 16:48:52 -0700 Subject: Simulator: add the argument to keep the updated images Add the command line option to select the work directory and save the updated image files. Because some people might have interested in getting updated images from an ota file. Also, fix a minor issue that the destination of package_extract_file needs to be updated if it's a block device. Otherwise, an unintended file may be extracted in the callers' directory. Test: run simulation, run unit tests Change-Id: Ic6a7db0580bc1748d6e080102e4654da4e41fd8c --- updater/update_simulator_main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'updater/update_simulator_main.cpp') diff --git a/updater/update_simulator_main.cpp b/updater/update_simulator_main.cpp index 278a44057..6c6989bac 100644 --- a/updater/update_simulator_main.cpp +++ b/updater/update_simulator_main.cpp @@ -58,12 +58,16 @@ int main(int argc, char** argv) { std::string skip_function_file; std::string source_target_file; std::string package_name; + std::string work_dir; + bool keep_images = false; constexpr struct option OPTIONS[] = { + { "keep_images", no_argument, nullptr, 0 }, { "oem_settings", required_argument, nullptr, 0 }, { "ota_package", required_argument, nullptr, 0 }, { "skip_functions", required_argument, nullptr, 0 }, { "source", required_argument, nullptr, 0 }, + { "work_dir", required_argument, nullptr, 0 }, { nullptr, 0, nullptr, 0 }, }; @@ -86,6 +90,10 @@ int main(int argc, char** argv) { source_target_file = optarg; } else if (option_name == "ota_package"s) { package_name = optarg; + } else if (option_name == "keep_images"s) { + keep_images = true; + } else if (option_name == "work_dir"s) { + work_dir = optarg; } else { Usage(argv[0]); return EXIT_FAILURE; @@ -129,8 +137,11 @@ int main(int argc, char** argv) { TemporaryFile cmd_pipe; TemporaryDir source_temp_dir; + if (work_dir.empty()) { + work_dir = source_temp_dir.path; + } - BuildInfo source_build_info(source_temp_dir.path); + BuildInfo source_build_info(work_dir, keep_images); if (!source_build_info.ParseTargetFile(source_target_file, false)) { LOG(ERROR) << "Failed to parse the target file " << source_target_file; return EXIT_FAILURE; -- cgit v1.2.3