Allow update_engine to skip post-install
The postinstall steps take long time to finish, even though most of them
are optional. Therefore, reuse the flag run_post_install in InstallPlan
to allow skipping optional postinstalls.
Bug: 136185424
Test: cancel the update during post-install, apply again with the header
"RUN_POST_INSTALL=0", check the optional post-installs are skipped
Change-Id: Ic5ab89b079dfd547714fd3d1664e044900f9eebe
diff --git a/payload_consumer/postinstall_runner_action.cc b/payload_consumer/postinstall_runner_action.cc
index c0c3956..0f48493 100644
--- a/payload_consumer/postinstall_runner_action.cc
+++ b/payload_consumer/postinstall_runner_action.cc
@@ -70,10 +70,17 @@
partition_weight_.resize(install_plan_.partitions.size());
total_weight_ = 0;
for (size_t i = 0; i < install_plan_.partitions.size(); ++i) {
+ auto& partition = install_plan_.partitions[i];
+ if (!install_plan_.run_post_install && partition.postinstall_optional) {
+ partition.run_postinstall = false;
+ LOG(INFO) << "Skipping optional post-install for partition "
+ << partition.name << " according to install plan.";
+ }
+
// TODO(deymo): This code sets the weight to all the postinstall commands,
// but we could remember how long they took in the past and use those
// values.
- partition_weight_[i] = install_plan_.partitions[i].run_postinstall;
+ partition_weight_[i] = partition.run_postinstall;
total_weight_ += partition_weight_[i];
}
accumulated_weight_ = 0;
@@ -83,11 +90,6 @@
}
void PostinstallRunnerAction::PerformPartitionPostinstall() {
- if (!install_plan_.run_post_install) {
- LOG(INFO) << "Skipping post-install according to install plan.";
- return CompletePostinstall(ErrorCode::kSuccess);
- }
-
if (install_plan_.download_url.empty()) {
LOG(INFO) << "Skipping post-install during rollback";
return CompletePostinstall(ErrorCode::kSuccess);