blob: 59fc45c3ed89f91c64deb76001efedeef4d27f30 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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 Srinivasanae4697c2013-03-18 17:08:08 -070016
17#include "update_engine/install_plan.h"
18
Alex Deymo8427b4a2014-11-05 14:00:32 -080019#include <base/logging.h>
Jay Srinivasanae4697c2013-03-18 17:08:08 -070020
21#include "update_engine/utils.h"
22
23using std::string;
24
25namespace chromeos_update_engine {
26
27InstallPlan::InstallPlan(bool is_resume,
Gilad Arnold21504f02013-05-24 08:51:22 -070028 bool is_full_update,
Jay Srinivasanae4697c2013-03-18 17:08:08 -070029 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 Zeuthene7f89172013-10-31 10:21:04 -070035 const string& kernel_install_path,
Allie Woodfdf00512015-03-02 13:34:55 -080036 const string& source_path,
37 const string& kernel_source_path,
Alex Deymof329b932014-10-30 01:37:48 -070038 const string& public_key_rsa)
Jay Srinivasanae4697c2013-03-18 17:08:08 -070039 : is_resume(is_resume),
Gilad Arnold21504f02013-05-24 08:51:22 -070040 is_full_update(is_full_update),
Jay Srinivasanae4697c2013-03-18 17:08:08 -070041 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 Woodfdf00512015-03-02 13:34:55 -080048 source_path(source_path),
49 kernel_source_path(kernel_source_path),
Jay Srinivasanae4697c2013-03-18 17:08:08 -070050 kernel_size(0),
51 rootfs_size(0),
52 hash_checks_mandatory(false),
David Zeuthene7f89172013-10-31 10:21:04 -070053 powerwash_required(false),
54 public_key_rsa(public_key_rsa) {}
Jay Srinivasanae4697c2013-03-18 17:08:08 -070055
56InstallPlan::InstallPlan() : is_resume(false),
Gilad Arnold21504f02013-05-24 08:51:22 -070057 is_full_update(false), // play it safe.
Jay Srinivasanae4697c2013-03-18 17:08:08 -070058 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
66bool InstallPlan::operator==(const InstallPlan& that) const {
67 return ((is_resume == that.is_resume) &&
Gilad Arnold21504f02013-05-24 08:51:22 -070068 (is_full_update == that.is_full_update) &&
Jay Srinivasanae4697c2013-03-18 17:08:08 -070069 (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 Woodfdf00512015-03-02 13:34:55 -080075 (kernel_install_path == that.kernel_install_path) &&
76 (source_path == that.source_path) &&
77 (kernel_source_path == that.kernel_source_path));
Jay Srinivasanae4697c2013-03-18 17:08:08 -070078}
79
80bool InstallPlan::operator!=(const InstallPlan& that) const {
81 return !((*this) == that);
82}
83
84void InstallPlan::Dump() const {
85 LOG(INFO) << "InstallPlan: "
Gilad Arnold21504f02013-05-24 08:51:22 -070086 << (is_resume ? "resume" : "new_update")
87 << ", payload type: " << (is_full_update ? "full" : "delta")
Jay Srinivasanae4697c2013-03-18 17:08:08 -070088 << ", 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 Woodfdf00512015-03-02 13:34:55 -080095 << ", source_path: " << source_path
96 << ", kernel_source_path: " << kernel_source_path
Jay Srinivasanae4697c2013-03-18 17:08:08 -070097 << ", hash_checks_mandatory: " << utils::ToString(
98 hash_checks_mandatory)
99 << ", powerwash_required: " << utils::ToString(
100 powerwash_required);
101}
102
103} // namespace chromeos_update_engine