Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |
| 7 | |
| 8 | #include <string> |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Chris Masone | 790e62e | 2010-08-12 10:41:18 -0700 | [diff] [blame] | 11 | #include "base/logging.h" |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 12 | |
| 13 | // InstallPlan is a simple struct that contains relevant info for many |
| 14 | // parts of the update system about the install that should happen. |
| 15 | |
| 16 | namespace chromeos_update_engine { |
| 17 | |
| 18 | struct InstallPlan { |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 19 | InstallPlan(bool is_resume, |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 20 | const std::string& url, |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 21 | uint64_t payload_size, |
| 22 | const std::string& payload_hash, |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 23 | uint64_t metadata_size, |
| 24 | const std::string& metadata_signature, |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 25 | const std::string& install_path, |
| 26 | const std::string& kernel_install_path) |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 27 | : is_resume(is_resume), |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 28 | download_url(url), |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 29 | payload_size(payload_size), |
| 30 | payload_hash(payload_hash), |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 31 | metadata_size(metadata_size), |
| 32 | metadata_signature(metadata_signature), |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 33 | install_path(install_path), |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 34 | kernel_install_path(kernel_install_path), |
| 35 | kernel_size(0), |
| 36 | rootfs_size(0) {} |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 37 | InstallPlan() : is_resume(false), payload_size(0), metadata_size(0) {} |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 38 | |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame] | 39 | bool is_resume; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 40 | std::string download_url; // url to download from |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 41 | |
| 42 | uint64_t payload_size; // size of the payload |
| 43 | std::string payload_hash ; // SHA256 hash of the payload |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 44 | uint64_t metadata_size; // size of the metadata |
| 45 | std::string metadata_signature; // signature of the metadata |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 46 | std::string install_path; // path to install device |
| 47 | std::string kernel_install_path; // path to kernel install device |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 48 | |
| 49 | // The fields below are used for kernel and rootfs verification. The flow is: |
| 50 | // |
| 51 | // 1. FilesystemCopierAction(verify_hash=false) computes and fills in the |
| 52 | // source partition sizes and hashes. |
| 53 | // |
| 54 | // 2. DownloadAction verifies the source partition sizes and hashes against |
| 55 | // the expected values transmitted in the update manifest. It fills in the |
| 56 | // expected applied partition sizes and hashes based on the manifest. |
| 57 | // |
| 58 | // 4. FilesystemCopierAction(verify_hashes=true) computes and verifies the |
| 59 | // applied partition sizes and hashes against the expected values. |
| 60 | uint64_t kernel_size; |
| 61 | uint64_t rootfs_size; |
| 62 | std::vector<char> kernel_hash; |
| 63 | std::vector<char> rootfs_hash; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 64 | |
| 65 | bool operator==(const InstallPlan& that) const { |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 66 | return ((is_resume == that.is_resume) && |
| 67 | (download_url == that.download_url) && |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 68 | (payload_size == that.payload_size) && |
| 69 | (payload_hash == that.payload_hash) && |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 70 | (metadata_size == that.metadata_size) && |
| 71 | (metadata_signature == that.metadata_signature) && |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 72 | (install_path == that.install_path) && |
| 73 | (kernel_install_path == that.kernel_install_path)); |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 74 | } |
| 75 | bool operator!=(const InstallPlan& that) const { |
| 76 | return !((*this) == that); |
| 77 | } |
| 78 | void Dump() const { |
| 79 | LOG(INFO) << "InstallPlan: " |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame] | 80 | << (is_resume ? ", resume" : ", new_update") |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 81 | << ", url: " << download_url |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 82 | << ", payload size: " << payload_size |
| 83 | << ", payload hash: " << payload_hash |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame^] | 84 | << ", metadata size: " << metadata_size |
| 85 | << ", metadata signature: " << metadata_signature |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 86 | << ", install_path: " << install_path |
| 87 | << ", kernel_install_path: " << kernel_install_path; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 88 | } |
| 89 | }; |
| 90 | |
| 91 | } // namespace chromeos_update_engine |
| 92 | |
| 93 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__ |