Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2013 The Android Open Source Project |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | // |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 16 | |
| 17 | #include "update_engine/install_plan.h" |
| 18 | |
Alex Deymo | 8427b4a | 2014-11-05 14:00:32 -0800 | [diff] [blame] | 19 | #include <base/logging.h> |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 20 | |
| 21 | #include "update_engine/utils.h" |
| 22 | |
| 23 | using std::string; |
| 24 | |
| 25 | namespace chromeos_update_engine { |
| 26 | |
| 27 | InstallPlan::InstallPlan(bool is_resume, |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 28 | bool is_full_update, |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 29 | const string& url, |
| 30 | uint64_t payload_size, |
| 31 | const string& payload_hash, |
| 32 | uint64_t metadata_size, |
| 33 | const string& metadata_signature, |
| 34 | const string& install_path, |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 35 | const string& kernel_install_path, |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 36 | const string& source_path, |
| 37 | const string& kernel_source_path, |
Alex Deymo | f329b93 | 2014-10-30 01:37:48 -0700 | [diff] [blame] | 38 | const string& public_key_rsa) |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 39 | : is_resume(is_resume), |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 40 | is_full_update(is_full_update), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 41 | download_url(url), |
| 42 | payload_size(payload_size), |
| 43 | payload_hash(payload_hash), |
| 44 | metadata_size(metadata_size), |
| 45 | metadata_signature(metadata_signature), |
| 46 | install_path(install_path), |
| 47 | kernel_install_path(kernel_install_path), |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 48 | source_path(source_path), |
| 49 | kernel_source_path(kernel_source_path), |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 50 | kernel_size(0), |
| 51 | rootfs_size(0), |
| 52 | hash_checks_mandatory(false), |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 53 | powerwash_required(false), |
| 54 | public_key_rsa(public_key_rsa) {} |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 55 | |
| 56 | InstallPlan::InstallPlan() : is_resume(false), |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 57 | is_full_update(false), // play it safe. |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 58 | payload_size(0), |
| 59 | metadata_size(0), |
| 60 | kernel_size(0), |
| 61 | rootfs_size(0), |
| 62 | hash_checks_mandatory(false), |
| 63 | powerwash_required(false) {} |
| 64 | |
| 65 | |
| 66 | bool InstallPlan::operator==(const InstallPlan& that) const { |
| 67 | return ((is_resume == that.is_resume) && |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 68 | (is_full_update == that.is_full_update) && |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 69 | (download_url == that.download_url) && |
| 70 | (payload_size == that.payload_size) && |
| 71 | (payload_hash == that.payload_hash) && |
| 72 | (metadata_size == that.metadata_size) && |
| 73 | (metadata_signature == that.metadata_signature) && |
| 74 | (install_path == that.install_path) && |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 75 | (kernel_install_path == that.kernel_install_path) && |
| 76 | (source_path == that.source_path) && |
| 77 | (kernel_source_path == that.kernel_source_path)); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | bool InstallPlan::operator!=(const InstallPlan& that) const { |
| 81 | return !((*this) == that); |
| 82 | } |
| 83 | |
| 84 | void InstallPlan::Dump() const { |
| 85 | LOG(INFO) << "InstallPlan: " |
Gilad Arnold | 21504f0 | 2013-05-24 08:51:22 -0700 | [diff] [blame] | 86 | << (is_resume ? "resume" : "new_update") |
| 87 | << ", payload type: " << (is_full_update ? "full" : "delta") |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 88 | << ", url: " << download_url |
| 89 | << ", payload size: " << payload_size |
| 90 | << ", payload hash: " << payload_hash |
| 91 | << ", metadata size: " << metadata_size |
| 92 | << ", metadata signature: " << metadata_signature |
| 93 | << ", install_path: " << install_path |
| 94 | << ", kernel_install_path: " << kernel_install_path |
Allie Wood | fdf0051 | 2015-03-02 13:34:55 -0800 | [diff] [blame] | 95 | << ", source_path: " << source_path |
| 96 | << ", kernel_source_path: " << kernel_source_path |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 97 | << ", hash_checks_mandatory: " << utils::ToString( |
| 98 | hash_checks_mandatory) |
| 99 | << ", powerwash_required: " << utils::ToString( |
| 100 | powerwash_required); |
| 101 | } |
| 102 | |
| 103 | } // namespace chromeos_update_engine |