summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Schuffelen <schuffelen@google.com>2019-10-16 16:22:24 -0700
committerA. Cody Schuffelen <schuffelen@google.com>2019-10-17 17:46:20 -0700
commit1148019d2a218dd1e3824f360eb964cb42293513 (patch)
treec11f2dd991a89304796b189c40feec1f6a28d0b9
parent465945af53b82652a9e8a802e38631507ac35bc5 (diff)
downloadcuttlefish_common-1148019d2a218dd1e3824f360eb964cb42293513.tar.gz
Revert "Revert "Use the output from fetch_cvd/launch_cvd in assemble_cvd.""
This reverts commit 5bb4118b1e5fc7216757762180cb87261689f293. Test: Run launch_cvd without a tty. Bug: 142768362 Change-Id: I13150a0fb07d89372668e2bef6b8403fe31ae297 (cherry picked from commit 605e685b1fd43edf7a7a9e3397baa44c5348febf)
-rw-r--r--host/commands/assemble_cvd/assemble_cvd.cc36
-rw-r--r--host/commands/assemble_cvd/flags.cc4
-rw-r--r--host/commands/assemble_cvd/flags.h4
3 files changed, 41 insertions, 3 deletions
diff --git a/host/commands/assemble_cvd/assemble_cvd.cc b/host/commands/assemble_cvd/assemble_cvd.cc
index 9efc0dda..6eab814b 100644
--- a/host/commands/assemble_cvd/assemble_cvd.cc
+++ b/host/commands/assemble_cvd/assemble_cvd.cc
@@ -17,8 +17,32 @@
#include <glog/logging.h>
+#include "common/libs/fs/shared_buf.h"
+#include "common/libs/fs/shared_fd.h"
+#include "common/libs/strings/str_split.h"
#include "host/commands/assemble_cvd/assembler_defs.h"
#include "host/commands/assemble_cvd/flags.h"
+#include "host/libs/config/fetcher_config.h"
+
+namespace {
+
+std::string kFetcherConfigFile = "fetcher_config.json";
+
+cvd::FetcherConfig FindFetcherConfig(const std::vector<std::string>& files) {
+ cvd::FetcherConfig fetcher_config;
+ for (const auto& file : files) {
+ auto expected_pos = file.size() - kFetcherConfigFile.size();
+ if (file.rfind(kFetcherConfigFile) == expected_pos) {
+ if (fetcher_config.LoadFromFile(file)) {
+ return fetcher_config;
+ }
+ LOG(ERROR) << "Could not load fetcher config file.";
+ }
+ }
+ return fetcher_config;
+}
+
+} // namespace
int main(int argc, char** argv) {
::android::base::InitLogging(argv, android::base::StderrLogger);
@@ -36,7 +60,17 @@ int main(int argc, char** argv) {
}
}
- auto config = InitFilesystemAndCreateConfig(&argc, &argv);
+ std::string input_files_str;
+ {
+ auto input_fd = cvd::SharedFD::Dup(0);
+ auto bytes_read = cvd::ReadAll(input_fd, &input_files_str);
+ if (bytes_read < 0) {
+ LOG(FATAL) << "Failed to read input files. Error was \"" << input_fd->StrError() << "\"";
+ }
+ }
+ std::vector<std::string> input_files = cvd::StrSplit(input_files_str, '\n');
+
+ auto config = InitFilesystemAndCreateConfig(&argc, &argv, FindFetcherConfig(input_files));
std::cout << GetConfigFilePath(*config) << "\n";
std::cout << std::flush;
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 710337ae..a318717d 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -14,6 +14,7 @@
#include "host/commands/assemble_cvd/data_image.h"
#include "host/commands/assemble_cvd/image_aggregator.h"
#include "host/commands/assemble_cvd/assembler_defs.h"
+#include "host/libs/config/fetcher_config.h"
#include "host/libs/vm_manager/crosvm_manager.h"
#include "host/libs/vm_manager/qemu_manager.h"
#include "host/libs/vm_manager/vm_manager.h"
@@ -733,7 +734,8 @@ void CreateCompositeDisk(const vsoc::CuttlefishConfig& config) {
} // namespace
-const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv) {
+const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
+ int* argc, char*** argv, cvd::FetcherConfig) {
if (!ParseCommandLineFlags(argc, argv)) {
LOG(ERROR) << "Failed to parse command arguments";
exit(AssemblerExitCodes::kArgumentParsingError);
diff --git a/host/commands/assemble_cvd/flags.h b/host/commands/assemble_cvd/flags.h
index e8c542ff..03733881 100644
--- a/host/commands/assemble_cvd/flags.h
+++ b/host/commands/assemble_cvd/flags.h
@@ -1,6 +1,8 @@
#pragma once
#include "host/libs/config/cuttlefish_config.h"
+#include "host/libs/config/fetcher_config.h"
-const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(int* argc, char*** argv);
+const vsoc::CuttlefishConfig* InitFilesystemAndCreateConfig(
+ int* argc, char*** argv, cvd::FetcherConfig config);
std::string GetConfigFilePath(const vsoc::CuttlefishConfig& config);