Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/cvd/cuttlefish/host/commands/cvd/fetch/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ cf_cc_library(
"//cuttlefish/host/commands/cvd/fetch:de_android_sparse",
"//cuttlefish/host/commands/cvd/fetch:fetch_tracer",
"//cuttlefish/host/commands/cvd/fetch:target_directories",
"//cuttlefish/host/libs/avb",
"//cuttlefish/host/libs/config:fetcher_config",
"//cuttlefish/host/libs/config:file_source",
"//cuttlefish/host/libs/web:android_build",
Expand All @@ -201,6 +202,7 @@ cf_cc_library(
"//cuttlefish/posix:remove",
"//cuttlefish/result",
"//libbase",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/strings",
"@fmt",
],
Expand Down
32 changes: 32 additions & 0 deletions base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <variant>
#include <vector>

#include "absl/log/log.h"
#include "absl/strings/match.h"
#include "absl/strings/strip.h"
#include "android-base/file.h"
Expand All @@ -36,6 +37,7 @@
#include "cuttlefish/host/commands/cvd/fetch/de_android_sparse.h"
#include "cuttlefish/host/commands/cvd/fetch/fetch_tracer.h"
#include "cuttlefish/host/commands/cvd/fetch/target_directories.h"
#include "cuttlefish/host/libs/avb/avb.h"
#include "cuttlefish/host/libs/config/fetcher_config.h"
#include "cuttlefish/host/libs/config/file_source.h"
#include "cuttlefish/host/libs/web/android_build.h"
Expand All @@ -53,6 +55,28 @@ static constexpr mode_t kRwxAllMode = S_IRWXU | S_IRWXG | S_IRWXO;

using android::base::Dirname;

namespace {

bool IsVbmetaImage(std::string_view path) {
return absl::EndsWith(path, "/vbmeta.img") ||
absl::EndsWith(path, "/vbmeta_system.img") ||
absl::EndsWith(path, "/vbmeta_system_dlkm.img") ||
absl::EndsWith(path, "/vbmeta_vendor_dlkm.img");
}
Comment thread
3405691582 marked this conversation as resolved.

void PadVbmetaImage(const std::string& path) {
/*
* Try enforcing the vbmeta size now. If it fails, then let
* `assemble_cvd` trip on it later; don't fail the fetch.
*/
if (Result<void> result = EnforceVbMetaSize(path); !result.has_value()) {
LOG(WARNING) << "PadVbmetaImage: failed padding " << path << ": "
<< result.error();
}
}

} // namespace

FetchArtifact::FetchArtifact(FetchBuildContext& context,
std::string artifact_name)
: fetch_build_context_(context), artifact_name_(artifact_name) {}
Expand Down Expand Up @@ -87,6 +111,10 @@ Result<void> FetchArtifact::DownloadTo(std::string local_path) {
CF_EXPECT(Copy(downloaded_path_, new_path));
}

if (IsVbmetaImage(new_path)) {
PadVbmetaImage(new_path);
}

CF_EXPECT(fetch_build_context_.AddFileToConfig(downloaded_path_));

return {};
Expand Down Expand Up @@ -151,6 +179,10 @@ Result<void> FetchArtifact::ExtractOneTo(const std::string& member_name,
// TODO: b/471069557 - diagnose unused
Result<void> unused = fetch_build_context_.DesparseFiles({local_path});

if (IsVbmetaImage(extract_path)) {
PadVbmetaImage(extract_path);
}

return {};
}

Expand Down
Loading