blob: c0fa4cddfdea9fca1173c34f389e2c1737c2f51c [file] [log] [blame]
Darin Petkov7ed561b2011-10-04 02:59:03 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
adlr@google.com3defe6a2009-12-04 20:57:17 +00002// 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 Petkov698d0412010-10-13 10:59:44 -07009#include <vector>
10
Chris Masone790e62e2010-08-12 10:41:18 -070011#include "base/logging.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000012
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
16namespace chromeos_update_engine {
17
18struct InstallPlan {
Darin Petkov7ed561b2011-10-04 02:59:03 -070019 InstallPlan(bool is_resume,
adlr@google.com3defe6a2009-12-04 20:57:17 +000020 const std::string& url,
Jay Srinivasan51dcf262012-09-13 17:24:32 -070021 uint64_t payload_size,
22 const std::string& payload_hash,
Jay Srinivasanf4318702012-09-24 11:56:24 -070023 uint64_t metadata_size,
24 const std::string& metadata_signature,
Andrew de los Reyesf9185172010-05-03 11:07:05 -070025 const std::string& install_path,
26 const std::string& kernel_install_path)
Darin Petkov7ed561b2011-10-04 02:59:03 -070027 : is_resume(is_resume),
adlr@google.com3defe6a2009-12-04 20:57:17 +000028 download_url(url),
Jay Srinivasan51dcf262012-09-13 17:24:32 -070029 payload_size(payload_size),
30 payload_hash(payload_hash),
Jay Srinivasanf4318702012-09-24 11:56:24 -070031 metadata_size(metadata_size),
32 metadata_signature(metadata_signature),
Andrew de los Reyesf9185172010-05-03 11:07:05 -070033 install_path(install_path),
Darin Petkov3aefa862010-12-07 14:45:00 -080034 kernel_install_path(kernel_install_path),
35 kernel_size(0),
Jay Srinivasan738fdf32012-12-07 17:40:54 -080036 rootfs_size(0),
37 hash_checks_mandatory(false) {}
38
39 // Default constructor: Initialize all members which don't have a class
40 // initializer.
41 InstallPlan() : is_resume(false),
42 payload_size(0),
43 metadata_size(0),
44 kernel_size(0),
45 rootfs_size(0),
46 hash_checks_mandatory(false) {}
adlr@google.com3defe6a2009-12-04 20:57:17 +000047
Darin Petkov0406e402010-10-06 21:33:11 -070048 bool is_resume;
adlr@google.com3defe6a2009-12-04 20:57:17 +000049 std::string download_url; // url to download from
Jay Srinivasan51dcf262012-09-13 17:24:32 -070050
51 uint64_t payload_size; // size of the payload
52 std::string payload_hash ; // SHA256 hash of the payload
Jay Srinivasanf4318702012-09-24 11:56:24 -070053 uint64_t metadata_size; // size of the metadata
54 std::string metadata_signature; // signature of the metadata
Jay Srinivasan51dcf262012-09-13 17:24:32 -070055 std::string install_path; // path to install device
56 std::string kernel_install_path; // path to kernel install device
Darin Petkov3aefa862010-12-07 14:45:00 -080057
58 // The fields below are used for kernel and rootfs verification. The flow is:
59 //
60 // 1. FilesystemCopierAction(verify_hash=false) computes and fills in the
61 // source partition sizes and hashes.
62 //
63 // 2. DownloadAction verifies the source partition sizes and hashes against
64 // the expected values transmitted in the update manifest. It fills in the
65 // expected applied partition sizes and hashes based on the manifest.
66 //
67 // 4. FilesystemCopierAction(verify_hashes=true) computes and verifies the
68 // applied partition sizes and hashes against the expected values.
69 uint64_t kernel_size;
70 uint64_t rootfs_size;
71 std::vector<char> kernel_hash;
72 std::vector<char> rootfs_hash;
adlr@google.com3defe6a2009-12-04 20:57:17 +000073
Jay Srinivasan738fdf32012-12-07 17:40:54 -080074 // True if payload hash checks are mandatory based on the system state and
75 // the Omaha response.
76 bool hash_checks_mandatory;
77
adlr@google.com3defe6a2009-12-04 20:57:17 +000078 bool operator==(const InstallPlan& that) const {
Darin Petkov7ed561b2011-10-04 02:59:03 -070079 return ((is_resume == that.is_resume) &&
80 (download_url == that.download_url) &&
Jay Srinivasan51dcf262012-09-13 17:24:32 -070081 (payload_size == that.payload_size) &&
82 (payload_hash == that.payload_hash) &&
Jay Srinivasanf4318702012-09-24 11:56:24 -070083 (metadata_size == that.metadata_size) &&
84 (metadata_signature == that.metadata_signature) &&
Darin Petkov7ed561b2011-10-04 02:59:03 -070085 (install_path == that.install_path) &&
86 (kernel_install_path == that.kernel_install_path));
adlr@google.com3defe6a2009-12-04 20:57:17 +000087 }
88 bool operator!=(const InstallPlan& that) const {
89 return !((*this) == that);
90 }
91 void Dump() const {
92 LOG(INFO) << "InstallPlan: "
Darin Petkov0406e402010-10-06 21:33:11 -070093 << (is_resume ? ", resume" : ", new_update")
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070094 << ", url: " << download_url
Jay Srinivasan51dcf262012-09-13 17:24:32 -070095 << ", payload size: " << payload_size
96 << ", payload hash: " << payload_hash
Jay Srinivasanf4318702012-09-24 11:56:24 -070097 << ", metadata size: " << metadata_size
98 << ", metadata signature: " << metadata_signature
Andrew de los Reyesf9185172010-05-03 11:07:05 -070099 << ", install_path: " << install_path
Jay Srinivasan738fdf32012-12-07 17:40:54 -0800100 << ", kernel_install_path: " << kernel_install_path
101 << ", hash_checks_mandatory: " << hash_checks_mandatory;
adlr@google.com3defe6a2009-12-04 20:57:17 +0000102 }
103};
104
105} // namespace chromeos_update_engine
106
107#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__