Skip to content

Commit 8671318

Browse files
committed
Avoid substituting sensors_simulator without run_cvd
We used to substitute sensors simulator in mid 2025, but it caused compatibility issues with not substituted run_cvd. Bug: 459880764 Bug: 452945156 Signed-off-by: Dmitrii Merkurev <[email protected]>
1 parent 694afb0 commit 8671318

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

base/cvd/cuttlefish/host/commands/cvd/fetch/substitute.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,47 @@ Result<void> Substitute(const std::string& target_dir,
140140
return {};
141141
}
142142

143+
bool SubstituteCheckTargetExists(const fetch::HostPkgMigrationConfig& config,
144+
std::string_view target_keyword) {
145+
for (int j = 0; j < config.symlinks_size(); j++) {
146+
if (config.symlinks(j).target().find(target_keyword) != std::string::npos) {
147+
return true;
148+
}
149+
}
150+
return false;
151+
}
152+
143153
Result<void> SubstituteWithMarker(const std::string& target_dir,
144154
const std::string& marker_file) {
155+
static constexpr std::string_view kRunCvdKeyword = "bin/run_cvd";
156+
static constexpr std::string_view kSensorsSimulatorKeyword =
157+
"bin/sensors_simulator";
158+
145159
std::string content;
146160
CF_EXPECTF(android::base::ReadFileToString(marker_file, &content),
147161
"failed to read '{}'", marker_file);
148162
fetch::HostPkgMigrationConfig config;
149163
CF_EXPECT(google::protobuf::TextFormat::ParseFromString(content, &config),
150164
"failed parsing debian_substitution_marker file");
165+
auto run_cvd_substituted =
166+
SubstituteCheckTargetExists(config, kRunCvdKeyword);
151167
for (int j = 0; j < config.symlinks_size(); j++) {
168+
// TODO(b/452945156): The sensors simulator is launched by run_cvd, so these
169+
// two components must always be substituted together. Between May 2025 and
170+
// Oct 2025 we substituted sensors_simulator alone. Restore compatibility by
171+
// ignoring the sensors_simulator substitute when run_cvd is not
172+
// substituted. This workaround can be removed once compatibility with
173+
// mid-2025 images is no longer critical.
174+
//
175+
// Related discussion: b/459880764.
176+
if (!run_cvd_substituted &&
177+
config.symlinks(j).target().find(kSensorsSimulatorKeyword) !=
178+
std::string::npos) {
179+
LOG(WARNING) << "Sensors simulator (" << config.symlinks(j).target()
180+
<< ") cannot be substituted on its own; run_cvd must be "
181+
"substituted as well.";
182+
continue;
183+
}
152184
CF_EXPECT(Substitute(target_dir, config.symlinks(j).link_name()));
153185
}
154186
return {};

0 commit comments

Comments
 (0)