Extract the downloaded archives.
This extracts the archives using some common cuttlefish libraries, which
had to be modified slightly to support running statically on the host.
The relevant libraries were changed to support all combinations of
(host, guest) x (dynamic, static).
Bug: 137304531
Test: ./fetch_cvd
Change-Id: I5a86cfc44560d2454fa2a168c438d84a35988f3d
diff --git a/common/libs/auto_resources/Android.bp b/common/libs/auto_resources/Android.bp
index 482585e..f943211 100644
--- a/common/libs/auto_resources/Android.bp
+++ b/common/libs/auto_resources/Android.bp
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library_shared {
+cc_library {
name: "cuttlefish_auto_resources",
srcs: [
"auto_resources.cpp",
@@ -22,7 +22,7 @@
}
cc_library_static {
- name: "cuttlefish_auto_resources_static",
+ name: "cuttlefish_auto_resources_product",
srcs: [
"auto_resources.cpp",
],
diff --git a/common/libs/fs/Android.bp b/common/libs/fs/Android.bp
index 9255b4f..01e5f32 100644
--- a/common/libs/fs/Android.bp
+++ b/common/libs/fs/Android.bp
@@ -13,24 +13,40 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library_shared {
+cc_library {
name: "libcuttlefish_fs",
srcs: [
"gce_fs.cpp",
"shared_fd.cpp",
],
- shared_libs: [
- "cuttlefish_auto_resources",
- "libbase",
- "liblog",
- ],
+ shared: {
+ shared_libs: [
+ "cuttlefish_auto_resources",
+ "libbase",
+ "liblog",
+ ],
+ },
+ static: {
+ static_libs: [
+ "cuttlefish_auto_resources",
+ "libbase",
+ "liblog",
+ ],
+ },
+ target: {
+ vendor: {
+ // Liblog does not have a vendor-static variant.
+ shared_libs: ["liblog"],
+ exclude_static_libs: ["liblog"],
+ },
+ },
defaults: ["cuttlefish_host_and_guest"],
}
cc_library_static {
- name: "libcuttlefish_fs_static",
+ name: "libcuttlefish_fs_product",
static_libs: [
- "cuttlefish_auto_resources_static",
+ "cuttlefish_auto_resources_product",
],
srcs: [
"gce_fs.cpp",
diff --git a/common/libs/utils/Android.bp b/common/libs/utils/Android.bp
index 1551515..9cfa60e 100644
--- a/common/libs/utils/Android.bp
+++ b/common/libs/utils/Android.bp
@@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-cc_library_shared {
+cc_library {
name: "libcuttlefish_utils",
srcs: [
"subprocess.cpp",
@@ -26,11 +26,20 @@
header_libs: [
"cuttlefish_glog",
],
- shared_libs: [
- "libbase",
- "libcuttlefish_fs",
- "cuttlefish_auto_resources",
- ],
+ shared: {
+ shared_libs: [
+ "libbase",
+ "libcuttlefish_fs",
+ "cuttlefish_auto_resources",
+ ],
+ },
+ static: {
+ static_libs: [
+ "libbase",
+ "libcuttlefish_fs",
+ "cuttlefish_auto_resources",
+ ],
+ },
defaults: ["cuttlefish_host_and_guest"],
}
diff --git a/guest/monitoring/tombstone_transmit/Android.bp b/guest/monitoring/tombstone_transmit/Android.bp
index 891de90..1e89183 100644
--- a/guest/monitoring/tombstone_transmit/Android.bp
+++ b/guest/monitoring/tombstone_transmit/Android.bp
@@ -19,9 +19,9 @@
"tombstone_transmit.cpp",
],
static_libs: [
- "libcuttlefish_fs_static",
+ "libcuttlefish_fs_product",
"libgflags",
- "cuttlefish_auto_resources_static",
+ "cuttlefish_auto_resources_product",
"liblog",
"libbase",
"libcutils",
diff --git a/host/commands/fetcher/Android.bp b/host/commands/fetcher/Android.bp
index 30e8286..8605580 100644
--- a/host/commands/fetcher/Android.bp
+++ b/host/commands/fetcher/Android.bp
@@ -25,7 +25,10 @@
],
stl: "libc++_static",
static_libs: [
+ "cuttlefish_auto_resources",
"libbase",
+ "libcuttlefish_fs",
+ "libcuttlefish_utils",
"libcurl",
"libcrypto",
"libssl",
diff --git a/host/commands/fetcher/main.cc b/host/commands/fetcher/main.cc
index edb2947..e0fb504 100644
--- a/host/commands/fetcher/main.cc
+++ b/host/commands/fetcher/main.cc
@@ -20,6 +20,8 @@
#include <glog/logging.h>
+#include "common/libs/utils/subprocess.h"
+
#include "build_api.h"
namespace {
@@ -43,11 +45,11 @@
bool has_image_zip = false;
const std::string img_zip_name = "aosp_cf_x86_phone-img-" + build_id + ".zip";
for (const auto& artifact : artifacts) {
- has_host_package |= artifact.Name() == "cvd-host_package.tar.gz";
+ has_host_package |= artifact.Name() == HOST_TOOLS;
has_image_zip |= artifact.Name() == img_zip_name;
}
if (!has_host_package) {
- LOG(FATAL) << "Target build " << build_id << " did not have cvd-host_package.tar.gz";
+ LOG(FATAL) << "Target build " << build_id << " did not have " << HOST_TOOLS;
}
if (!has_image_zip) {
LOG(FATAL) << "Target build " << build_id << " did not have" << img_zip_name;
@@ -56,8 +58,21 @@
build_api.ArtifactToFile(build_id, TARGET, "latest",
HOST_TOOLS, HOST_TOOLS);
build_api.ArtifactToFile(build_id, TARGET, "latest",
- img_zip_name,
- "img.zip");
+ img_zip_name, img_zip_name);
+
+ if (cvd::execute({"/bin/tar", "xvf", HOST_TOOLS}) != 0) {
+ LOG(FATAL) << "Could not extract " << HOST_TOOLS;
+ }
+ if (cvd::execute({"/usr/bin/unzip", img_zip_name}) != 0) {
+ LOG(FATAL) << "Could not unzip " << img_zip_name;
+ }
+
+ if (unlink(HOST_TOOLS.c_str()) != 0) {
+ LOG(ERROR) << "Could not delete " << HOST_TOOLS;
+ }
+ if (unlink(img_zip_name.c_str()) != 0) {
+ LOG(ERROR) << "Could not delete " << img_zip_name;
+ }
}
curl_global_cleanup();
}