Implement Rollback to previously booted partitions.
This CL implements rollback to whatever partition we ran from before.
We expose this functionality via dbus under AttemptRollback and expose
a new command-line option to update_engine_client that a developer can
use.
BUG=chromium:242665
TEST=Unittests, full update, update + rollback and verified.
Change-Id: Ie59f90b9a0b777dc1329592449090c70892236bf
Reviewed-on: https://gerrit.chromium.org/gerrit/58427
Commit-Queue: Chris Sosa <sosa@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
diff --git a/install_plan.h b/install_plan.h
index d6ff9e0..b070cbe 100644
--- a/install_plan.h
+++ b/install_plan.h
@@ -10,6 +10,8 @@
#include <base/basictypes.h>
+#include "update_engine/action.h"
+
// InstallPlan is a simple struct that contains relevant info for many
// parts of the update system about the install that should happen.
namespace chromeos_update_engine {
@@ -39,7 +41,7 @@
std::string download_url; // url to download from
uint64_t payload_size; // size of the payload
- std::string payload_hash ; // SHA256 hash of the payload
+ std::string payload_hash; // SHA256 hash of the payload
uint64_t metadata_size; // size of the metadata
std::string metadata_signature; // signature of the metadata
std::string install_path; // path to install device
@@ -70,6 +72,44 @@
bool powerwash_required;
};
+class InstallPlanAction;
+
+template<>
+class ActionTraits<InstallPlanAction> {
+ public:
+ // Takes the install plan as input
+ typedef InstallPlan InputObjectType;
+ // Passes the install plan as output
+ typedef InstallPlan OutputObjectType;
+};
+
+// Basic action that only receives and sends Install Plans.
+// Can be used to construct an Install Plan to send to any other Action that
+// accept an InstallPlan.
+class InstallPlanAction : public Action<InstallPlanAction> {
+ public:
+ InstallPlanAction() {}
+ InstallPlanAction(const InstallPlan& install_plan):
+ install_plan_(install_plan) {}
+
+ virtual void PerformAction() {
+ if (HasOutputPipe()) {
+ SetOutputObject(install_plan_);
+ }
+ processor_->ActionComplete(this, kErrorCodeSuccess);
+ }
+
+ virtual std::string Type() const { return "InstallPlanAction"; }
+
+ typedef ActionTraits<InstallPlanAction>::InputObjectType InputObjectType;
+ typedef ActionTraits<InstallPlanAction>::OutputObjectType OutputObjectType;
+
+ private:
+ InstallPlan install_plan_;
+
+ DISALLOW_COPY_AND_ASSIGN (InstallPlanAction);
+};
+
} // namespace chromeos_update_engine
#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_INSTALL_PLAN_H__