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