fetch_cvd: add capability to download different host package
The host package is normally downloaded from the default build requested
of fetch_cvd.
To download a different host package, add a separate field for the host
package's corresponding build.
This capability is added to enable a downloaded cuttlefish build to be
launched with a different host package containing capabilities that may
not be available on the one available to the default build.
Change-Id: Ibda3d8417377c7567bebf77c0ca860809b813489
diff --git a/host/commands/cvd/fetch/fetch_cvd.cc b/host/commands/cvd/fetch/fetch_cvd.cc
index 637c4e8..851bdab 100644
--- a/host/commands/cvd/fetch/fetch_cvd.cc
+++ b/host/commands/cvd/fetch/fetch_cvd.cc
@@ -59,6 +59,7 @@
DEFINE_string(boot_artifact, "", "name of the boot image in boot_build");
DEFINE_string(bootloader_build, "", "source for the bootloader target");
DEFINE_string(otatools_build, "", "source for the host ota tools");
+DEFINE_string(host_package_build, "", "source for the host cvd tools");
DEFINE_bool(download_img_zip, true, "Whether to fetch the -img-*.zip file.");
DEFINE_bool(download_target_files_zip, false,
@@ -349,8 +350,10 @@
CF_EXPECT(DownloadHostPackage(build_api, default_build, target_dir));
CF_EXPECT(!host_package_files.empty(),
"Could not download host package for " << default_build);
- CF_EXPECT(AddFilesToConfig(FileSource::DEFAULT_BUILD, default_build,
- host_package_files, config, target_dir));
+ CF_EXPECT(AddFilesToConfig(
+ FLAGS_host_package_build != "" ? FileSource::HOST_PACKAGE_BUILD
+ : FileSource::DEFAULT_BUILD,
+ default_build, host_package_files, config, target_dir));
return {};
}
@@ -417,9 +420,15 @@
auto default_build = CF_EXPECT(ArgumentToBuild(
build_api, FLAGS_default_build, DEFAULT_BUILD_TARGET, retry_period));
- auto process_pkg_ret =
- std::async(std::launch::async, ProcessHostPackage, std::ref(build_api),
- std::cref(default_build), std::cref(target_dir), &config);
+ auto host_package_build =
+ FLAGS_host_package_build != ""
+ ? CF_EXPECT(ArgumentToBuild(build_api, FLAGS_host_package_build,
+ DEFAULT_BUILD_TARGET, retry_period))
+ : default_build;
+
+ auto process_pkg_ret = std::async(
+ std::launch::async, ProcessHostPackage, std::ref(build_api),
+ std::cref(host_package_build), std::cref(target_dir), &config);
if (FLAGS_system_build != "" || FLAGS_kernel_build != "" ||
FLAGS_otatools_build != "") {
diff --git a/host/libs/config/fetcher_config.cpp b/host/libs/config/fetcher_config.cpp
index b9729b1..9bad58d 100644
--- a/host/libs/config/fetcher_config.cpp
+++ b/host/libs/config/fetcher_config.cpp
@@ -56,6 +56,8 @@
return FileSource::BOOTLOADER_BUILD;
} else if (source == "boot_build") {
return FileSource::BOOT_BUILD;
+ } else if (source == "host_package_build") {
+ return FileSource::HOST_PACKAGE_BUILD;
} else {
return FileSource::UNKNOWN_PURPOSE;
}
@@ -76,6 +78,8 @@
return "bootloader_build";
} else if (source == FileSource::BOOT_BUILD) {
return "boot_build";
+ } else if (source == FileSource::HOST_PACKAGE_BUILD) {
+ return "host_package_build";
} else {
return "unknown";
}
diff --git a/host/libs/config/fetcher_config.h b/host/libs/config/fetcher_config.h
index d87473b..397c8f6 100644
--- a/host/libs/config/fetcher_config.h
+++ b/host/libs/config/fetcher_config.h
@@ -35,6 +35,7 @@
GENERATED,
BOOTLOADER_BUILD,
BOOT_BUILD,
+ HOST_PACKAGE_BUILD,
};
/*