blob: 6979975d0a0716bc16de07a218bc05359af442c8 [file] [log] [blame]
Darin Petkov6d5dbf62010-11-08 16:09:55 -08001// Copyright (c) 2010 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_POSTINSTALL_RUNNER_ACTION_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__
7
8#include <string>
Darin Petkov6f03a3b2010-11-10 14:27:14 -08009
adlr@google.com3defe6a2009-12-04 20:57:17 +000010#include "update_engine/action.h"
Andrew de los Reyesf9714432010-05-04 10:21:23 -070011#include "update_engine/install_plan.h"
adlr@google.com3defe6a2009-12-04 20:57:17 +000012
13// The Postinstall Runner Action is responsible for running the postinstall
14// script of a successfully downloaded update.
15
16namespace chromeos_update_engine {
17
18class PostinstallRunnerAction;
19class NoneType;
20
21template<>
22class ActionTraits<PostinstallRunnerAction> {
23 public:
24 // Takes the device path as input
Andrew de los Reyesf9714432010-05-04 10:21:23 -070025 typedef InstallPlan InputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000026 // Passes the device path as output
Andrew de los Reyesf9714432010-05-04 10:21:23 -070027 typedef InstallPlan OutputObjectType;
adlr@google.com3defe6a2009-12-04 20:57:17 +000028};
29
30class PostinstallRunnerAction : public Action<PostinstallRunnerAction> {
31 public:
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070032 PostinstallRunnerAction()
33 : powerwash_marker_created_(false) {}
34
adlr@google.com3defe6a2009-12-04 20:57:17 +000035 typedef ActionTraits<PostinstallRunnerAction>::InputObjectType
36 InputObjectType;
37 typedef ActionTraits<PostinstallRunnerAction>::OutputObjectType
38 OutputObjectType;
39 void PerformAction();
40
Darin Petkov6f03a3b2010-11-10 14:27:14 -080041 // Note that there's no support for terminating this action currently.
adlr@google.com3defe6a2009-12-04 20:57:17 +000042 void TerminateProcessing() { CHECK(false); }
43
44 // Debugging/logging
45 static std::string StaticType() { return "PostinstallRunnerAction"; }
46 std::string Type() const { return StaticType(); }
47
48 private:
Darin Petkov6f03a3b2010-11-10 14:27:14 -080049 // Subprocess::Exec callback.
50 void CompletePostinstall(int return_code);
51 static void StaticCompletePostinstall(int return_code,
52 const std::string& output,
53 void* p);
54
55 std::string temp_rootfs_dir_;
56
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070057 // True if Powerwash Marker was created before invoking post-install script.
58 // False otherwise. Used for cleaning up if post-install fails.
59 bool powerwash_marker_created_;
60
adlr@google.com3defe6a2009-12-04 20:57:17 +000061 DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
62};
63
64} // namespace chromeos_update_engine
65
66#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__