From 74b0f7cce0cb52d0095d461edfd5731f4d45157f Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 22 May 2019 13:59:57 -0700 Subject: Implement the TargetFile and BuildInfo The TargetFile class parses a target-file and provides functions to read its contents. And the BuildInfo tries to simulate the device with files on host. Some work it does includes parsing the build properties, and extracting the image files for partitions specified in the fstab. Bug: 131911365 Test: unit tests pass, run simulator with cuttlefish, wear devices and from extracted TF. Change-Id: Iefe4a96d619d2e4b3d038e31480f11a0f9a70afa --- updater/update_simulator_main.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'updater/update_simulator_main.cpp') diff --git a/updater/update_simulator_main.cpp b/updater/update_simulator_main.cpp index d10453c2f..94924e783 100644 --- a/updater/update_simulator_main.cpp +++ b/updater/update_simulator_main.cpp @@ -22,9 +22,10 @@ #include "otautil/error_code.h" #include "otautil/paths.h" #include "updater/blockimg.h" +#include "updater/build_info.h" +#include "updater/dynamic_partitions.h" #include "updater/install.h" #include "updater/simulator_runtime.h" -#include "updater/target_files.h" #include "updater/updater.h" int main(int argc, char** argv) { @@ -34,7 +35,7 @@ int main(int argc, char** argv) { if (argc != 3 && argc != 4) { LOG(ERROR) << "unexpected number of arguments: " << argc << std::endl << "Usage: " << argv[0] << " "; - return 1; + return EXIT_FAILURE; } // TODO(xunchang) implement a commandline parser, e.g. it can take an oem property so that the @@ -57,17 +58,21 @@ int main(int argc, char** argv) { Paths::Get().set_stash_directory_base(temp_stash_base.path); TemporaryFile cmd_pipe; - TemporaryDir source_temp_dir; - TargetFiles source(source_target_file, source_temp_dir.path); - Updater updater(std::make_unique(&source)); + BuildInfo source_build_info(source_temp_dir.path); + if (!source_build_info.ParseTargetFile(source_target_file, false)) { + LOG(ERROR) << "Failed to parse the target file " << source_target_file; + return EXIT_FAILURE; + } + + Updater updater(std::make_unique(&source_build_info)); if (!updater.Init(cmd_pipe.release(), package_name, false)) { - return 1; + return EXIT_FAILURE; } if (!updater.RunUpdate()) { - return 1; + return EXIT_FAILURE; } LOG(INFO) << "\nscript succeeded, result: " << updater.GetResult(); -- cgit v1.2.3