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 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 5 | #ifndef UPDATE_ENGINE_INSTALL_PLAN_H_ |
| 6 | #define UPDATE_ENGINE_INSTALL_PLAN_H_ |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 7 | |
| 8 | #include <string> |
Darin Petkov | 698d041 | 2010-10-13 10:59:44 -0700 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
Ben Chan | 05735a1 | 2014-09-03 07:48:22 -0700 | [diff] [blame] | 11 | #include <base/macros.h> |
Alex Vakulenko | f68bbbc | 2015-02-09 12:53:18 -0800 | [diff] [blame] | 12 | #include <chromeos/secure_blob.h> |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 13 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 14 | #include "update_engine/action.h" |
| 15 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 16 | // InstallPlan is a simple struct that contains relevant info for many |
| 17 | // parts of the update system about the install that should happen. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 18 | namespace chromeos_update_engine { |
| 19 | |
| 20 | struct InstallPlan { |
Darin Petkov | 7ed561b | 2011-10-04 02:59:03 -0700 | [diff] [blame] | 21 | InstallPlan(bool is_resume, |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 22 | bool is_full_update, |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 23 | const std::string& url, |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 24 | uint64_t payload_size, |
| 25 | const std::string& payload_hash, |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame] | 26 | uint64_t metadata_size, |
| 27 | const std::string& metadata_signature, |
Andrew de los Reyes | f918517 | 2010-05-03 11:07:05 -0700 | [diff] [blame] | 28 | const std::string& install_path, |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 29 | const std::string& kernel_install_path, |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 30 | const std::string& source_path, |
| 31 | const std::string& kernel_source_path, |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 32 | const std::string& public_key_rsa); |
Jay Srinivasan | 738fdf3 | 2012-12-07 17:40:54 -0800 | [diff] [blame] | 33 | |
| 34 | // Default constructor: Initialize all members which don't have a class |
| 35 | // initializer. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 36 | InstallPlan(); |
| 37 | |
| 38 | bool operator==(const InstallPlan& that) const; |
| 39 | bool operator!=(const InstallPlan& that) const; |
| 40 | |
| 41 | void Dump() const; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 42 | |
Darin Petkov | 0406e40 | 2010-10-06 21:33:11 -0700 | [diff] [blame] | 43 | bool is_resume; |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 44 | bool is_full_update; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 45 | std::string download_url; // url to download from |
Chris Sosa | fb1020e | 2013-07-29 17:27:33 -0700 | [diff] [blame] | 46 | std::string version; // version we are installing. |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 47 | |
| 48 | uint64_t payload_size; // size of the payload |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 49 | std::string payload_hash; // SHA256 hash of the payload |
Jay Srinivasan | f431870 | 2012-09-24 11:56:24 -0700 | [diff] [blame] | 50 | uint64_t metadata_size; // size of the metadata |
| 51 | std::string metadata_signature; // signature of the metadata |
Jay Srinivasan | 51dcf26 | 2012-09-13 17:24:32 -0700 | [diff] [blame] | 52 | std::string install_path; // path to install device |
| 53 | std::string kernel_install_path; // path to kernel install device |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 54 | std::string source_path; // path to source device |
| 55 | std::string kernel_source_path; // path to source kernel device |
Darin Petkov | 3aefa86 | 2010-12-07 14:45:00 -0800 | [diff] [blame] | 56 | |
| 57 | // The fields below are used for kernel and rootfs verification. The flow is: |
| 58 | // |
| 59 | // 1. FilesystemCopierAction(verify_hash=false) computes and fills in the |
| 60 | // source partition sizes and hashes. |
| 61 | // |
| 62 | // 2. DownloadAction verifies the source partition sizes and hashes against |
| 63 | // the expected values transmitted in the update manifest. It fills in the |
| 64 | // expected applied partition sizes and hashes based on the manifest. |
| 65 | // |
| 66 | // 4. FilesystemCopierAction(verify_hashes=true) computes and verifies the |
| 67 | // applied partition sizes and hashes against the expected values. |
| 68 | uint64_t kernel_size; |
| 69 | uint64_t rootfs_size; |
Alex Vakulenko | f68bbbc | 2015-02-09 12:53:18 -0800 | [diff] [blame] | 70 | chromeos::Blob kernel_hash; |
| 71 | chromeos::Blob rootfs_hash; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 72 | |
Jay Srinivasan | 738fdf3 | 2012-12-07 17:40:54 -0800 | [diff] [blame] | 73 | // True if payload hash checks are mandatory based on the system state and |
| 74 | // the Omaha response. |
| 75 | bool hash_checks_mandatory; |
| 76 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 77 | // True if Powerwash is required on reboot after applying the payload. |
| 78 | // False otherwise. |
| 79 | bool powerwash_required; |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 80 | |
| 81 | // If not blank, a base-64 encoded representation of the PEM-encoded |
| 82 | // public key in the response. |
| 83 | std::string public_key_rsa; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 86 | class InstallPlanAction; |
| 87 | |
| 88 | template<> |
| 89 | class ActionTraits<InstallPlanAction> { |
| 90 | public: |
| 91 | // Takes the install plan as input |
| 92 | typedef InstallPlan InputObjectType; |
| 93 | // Passes the install plan as output |
| 94 | typedef InstallPlan OutputObjectType; |
| 95 | }; |
| 96 | |
| 97 | // Basic action that only receives and sends Install Plans. |
| 98 | // Can be used to construct an Install Plan to send to any other Action that |
| 99 | // accept an InstallPlan. |
| 100 | class InstallPlanAction : public Action<InstallPlanAction> { |
| 101 | public: |
| 102 | InstallPlanAction() {} |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 103 | explicit InstallPlanAction(const InstallPlan& install_plan): |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 104 | install_plan_(install_plan) {} |
| 105 | |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 106 | void PerformAction() override { |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 107 | if (HasOutputPipe()) { |
| 108 | SetOutputObject(install_plan_); |
| 109 | } |
Gilad Arnold | d1c4d2d | 2014-06-05 14:07:53 -0700 | [diff] [blame] | 110 | processor_->ActionComplete(this, ErrorCode::kSuccess); |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 111 | } |
| 112 | |
Chris Sosa | 76a29ae | 2013-07-11 17:59:24 -0700 | [diff] [blame] | 113 | InstallPlan* install_plan() { return &install_plan_; } |
| 114 | |
| 115 | static std::string StaticType() { return "InstallPlanAction"; } |
Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 116 | std::string Type() const override { return StaticType(); } |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 117 | |
| 118 | typedef ActionTraits<InstallPlanAction>::InputObjectType InputObjectType; |
| 119 | typedef ActionTraits<InstallPlanAction>::OutputObjectType OutputObjectType; |
| 120 | |
| 121 | private: |
| 122 | InstallPlan install_plan_; |
| 123 | |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 124 | DISALLOW_COPY_AND_ASSIGN(InstallPlanAction); |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 125 | }; |
| 126 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 127 | } // namespace chromeos_update_engine |
| 128 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 129 | #endif // UPDATE_ENGINE_INSTALL_PLAN_H_ |