blob: 9a2ebcb697d12c4bbea877f0af1aa3d5ed106185 [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:
Darin Petkov6d5dbf62010-11-08 16:09:55 -080032 PostinstallRunnerAction() {}
adlr@google.com3defe6a2009-12-04 20:57:17 +000033 typedef ActionTraits<PostinstallRunnerAction>::InputObjectType
34 InputObjectType;
35 typedef ActionTraits<PostinstallRunnerAction>::OutputObjectType
36 OutputObjectType;
37 void PerformAction();
38
Darin Petkov6f03a3b2010-11-10 14:27:14 -080039 // Note that there's no support for terminating this action currently.
adlr@google.com3defe6a2009-12-04 20:57:17 +000040 void TerminateProcessing() { CHECK(false); }
41
42 // Debugging/logging
43 static std::string StaticType() { return "PostinstallRunnerAction"; }
44 std::string Type() const { return StaticType(); }
45
46 private:
Darin Petkov6f03a3b2010-11-10 14:27:14 -080047 // Subprocess::Exec callback.
48 void CompletePostinstall(int return_code);
49 static void StaticCompletePostinstall(int return_code,
50 const std::string& output,
51 void* p);
52
53 std::string temp_rootfs_dir_;
54
adlr@google.com3defe6a2009-12-04 20:57:17 +000055 DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
56};
57
58} // namespace chromeos_update_engine
59
60#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__