Move InstallPlan partitions to a list of partitions.
This patch changes the InstallPlan instance from having hard-coded
rootfs and kernel paritions to have a list of partitions with a
name, source and target information.
The FilesystemVerifierAction, DeltaPerformer and PostInstallAction were
adapter to use the list of partitions instead.
In delta payloads (only supported in the current major version 1) the
list of operations is still fixed: the rootfs first and the kernel.
This list is now populated by the FilesystemVerifierAction including
the size of these partitions, until the whole source partition hash
checking is deprecated (b/23182225).
The PostIntallAction now relies on the DeltaPerformer to populate the
post-install information from the payload. This means that in rollback
we won't run any device-specific post-install operation, and will
simply flip the slots in the bootloader.
Bug: 24667689
Test: Updated unittests. Tested on a dragonboard and a link.
Change-Id: I8277e3190ac74e57832a58dc0730e3713f48af8a
diff --git a/install_plan.cc b/install_plan.cc
index ec2ee93..fa6dff7 100644
--- a/install_plan.cc
+++ b/install_plan.cc
@@ -16,7 +16,9 @@
#include "update_engine/install_plan.h"
+#include <base/format_macros.h>
#include <base/logging.h>
+#include <base/strings/stringprintf.h>
#include "update_engine/payload_constants.h"
#include "update_engine/utils.h"
@@ -32,10 +34,6 @@
const string& payload_hash,
uint64_t metadata_size,
const string& metadata_signature,
- const string& install_path,
- const string& kernel_install_path,
- const string& source_path,
- const string& kernel_source_path,
const string& public_key_rsa)
: is_resume(is_resume),
is_full_update(is_full_update),
@@ -44,12 +42,6 @@
payload_hash(payload_hash),
metadata_size(metadata_size),
metadata_signature(metadata_signature),
- install_path(install_path),
- kernel_install_path(kernel_install_path),
- source_path(source_path),
- kernel_source_path(kernel_source_path),
- kernel_size(0),
- rootfs_size(0),
hash_checks_mandatory(false),
powerwash_required(false),
public_key_rsa(public_key_rsa) {}
@@ -65,10 +57,7 @@
(metadata_signature == that.metadata_signature) &&
(source_slot == that.source_slot) &&
(target_slot == that.target_slot) &&
- (install_path == that.install_path) &&
- (kernel_install_path == that.kernel_install_path) &&
- (source_path == that.source_path) &&
- (kernel_source_path == that.kernel_source_path));
+ (partitions == that.partitions));
}
bool InstallPlan::operator!=(const InstallPlan& that) const {
@@ -76,6 +65,13 @@
}
void InstallPlan::Dump() const {
+ string partitions_str;
+ for (const auto& partition : partitions) {
+ partitions_str += base::StringPrintf(
+ ", part: %s (source_size: %" PRIu64 ", target_size %" PRIu64 ")",
+ partition.name.c_str(), partition.source_size, partition.target_size);
+ }
+
LOG(INFO) << "InstallPlan: "
<< (is_resume ? "resume" : "new_update")
<< ", payload type: " << (is_full_update ? "full" : "delta")
@@ -86,10 +82,7 @@
<< ", payload hash: " << payload_hash
<< ", metadata size: " << metadata_size
<< ", metadata signature: " << metadata_signature
- << ", install_path: " << install_path
- << ", kernel_install_path: " << kernel_install_path
- << ", source_path: " << source_path
- << ", kernel_source_path: " << kernel_source_path
+ << partitions_str
<< ", hash_checks_mandatory: " << utils::ToString(
hash_checks_mandatory)
<< ", powerwash_required: " << utils::ToString(
@@ -98,26 +91,34 @@
bool InstallPlan::LoadPartitionsFromSlots(SystemState* system_state) {
bool result = true;
- if (source_slot != BootControlInterface::kInvalidSlot) {
- result = system_state->boot_control()->GetPartitionDevice(
- kLegacyPartitionNameRoot, source_slot, &source_path) && result;
- result = system_state->boot_control()->GetPartitionDevice(
- kLegacyPartitionNameKernel, source_slot, &kernel_source_path) && result;
- } else {
- source_path.clear();
- kernel_source_path.clear();
- }
+ for (Partition& partition : partitions) {
+ if (source_slot != BootControlInterface::kInvalidSlot) {
+ result = system_state->boot_control()->GetPartitionDevice(
+ partition.name, source_slot, &partition.source_path) && result;
+ } else {
+ partition.source_path.clear();
+ }
- if (target_slot != BootControlInterface::kInvalidSlot) {
- result = system_state->boot_control()->GetPartitionDevice(
- kLegacyPartitionNameRoot, target_slot, &install_path) && result;
- result = system_state->boot_control()->GetPartitionDevice(
- kLegacyPartitionNameKernel, target_slot, &kernel_install_path) && result;
- } else {
- install_path.clear();
- kernel_install_path.clear();
+ if (target_slot != BootControlInterface::kInvalidSlot) {
+ result = system_state->boot_control()->GetPartitionDevice(
+ partition.name, target_slot, &partition.target_path) && result;
+ } else {
+ partition.target_path.clear();
+ }
}
return result;
}
+bool InstallPlan::Partition::operator==(
+ const InstallPlan::Partition& that) const {
+ return (name == that.name &&
+ source_path == that.source_path &&
+ source_size == that.source_size &&
+ source_hash == that.source_hash &&
+ target_path == that.target_path &&
+ target_size == that.target_size &&
+ target_hash == that.target_hash &&
+ run_postinstall == that.run_postinstall);
+}
+
} // namespace chromeos_update_engine