diff options
author | A. Cody Schuffelen <schuffelen@google.com> | 2020-06-02 16:16:05 -0700 |
---|---|---|
committer | A. Cody Schuffelen <schuffelen@google.com> | 2020-06-03 13:53:06 -0700 |
commit | d423b56964efb98e2e5d16dcb3cfc51f77a2a13f (patch) | |
tree | be4ab24c5a6dbafba1954a8210e13b47499f3eef | |
parent | 907b7dd4c0cf99ae9f469b2042221a7bc630ff79 (diff) | |
download | cuttlefish-d423b56964efb98e2e5d16dcb3cfc51f77a2a13f.tar.gz |
Extract build.prop files during assemble_cvd.
These are now necessary for build_super_image.py from otatools.
Additionally, "import" statements are logged for future reference.
Test: Mix two aosp-master images.
Bug: 157883945
Merged-In: If025fac93f3f4059d82be46ea006a03ccd61444d
Change-Id: If025fac93f3f4059d82be46ea006a03ccd61444d
(cherry picked from commit 6115d3decce9a1e10c23c2f23717dd3c1bfe1ea2)
-rw-r--r-- | host/commands/assemble_cvd/super_image_mixer.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/host/commands/assemble_cvd/super_image_mixer.cc b/host/commands/assemble_cvd/super_image_mixer.cc index 23df66b43..011aadde6 100644 --- a/host/commands/assemble_cvd/super_image_mixer.cc +++ b/host/commands/assemble_cvd/super_image_mixer.cc @@ -64,6 +64,21 @@ const std::set<std::string> kDefaultTargetImages = { "IMAGES/vbmeta.img", "IMAGES/vendor.img", }; +const std::set<std::string> kDefaultTargetBuildProp = { + "ODM/etc/build.prop", + "VENDOR/build.prop", +}; + +void FindImports(cvd::Archive* archive, const std::string& build_prop_file) { + auto contents = archive->ExtractToMemory(build_prop_file); + auto lines = android::base::Split(contents, "\n"); + for (const auto& line : lines) { + auto parts = android::base::Split(line, " "); + if (parts.size() >= 2 && parts[0] == "import") { + LOG(INFO) << build_prop_file << ": " << line; + } + } +} bool CombineTargetZipFiles(const std::string& default_target_zip, const std::string& system_target_zip, @@ -149,6 +164,19 @@ bool CombineTargetZipFiles(const std::string& default_target_zip, return false; } } + for (const auto& name : default_target_contents) { + if (!android::base::EndsWith(name, "build.prop")) { + continue; + } else if (kDefaultTargetBuildProp.count(name) == 0) { + continue; + } + FindImports(&default_target_archive, name); + LOG(INFO) << "Writing " << name; + if (!default_target_archive.ExtractFiles({name}, output_path)) { + LOG(ERROR) << "Failed to extract " << name << " from the default target zip"; + return false; + } + } for (const auto& name : system_target_contents) { if (!android::base::StartsWith(name, "IMAGES/")) { @@ -164,6 +192,19 @@ bool CombineTargetZipFiles(const std::string& default_target_zip, return false; } } + for (const auto& name : system_target_contents) { + if (!android::base::EndsWith(name, "build.prop")) { + continue; + } else if (kDefaultTargetBuildProp.count(name) > 0) { + continue; + } + FindImports(&default_target_archive, name); + LOG(INFO) << "Writing " << name; + if (!default_target_archive.ExtractFiles({name}, output_path)) { + LOG(ERROR) << "Failed to extract " << name << " from the default target zip"; + return false; + } + } return true; } |