blob: 0136ee27af989e55d73285d77695c4ff79a35d17 [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
Chris Sosad317e402013-06-12 13:47:09 -070018class PostinstallRunnerAction : public InstallPlanAction {
adlr@google.com3defe6a2009-12-04 20:57:17 +000019 public:
Gilad Arnold30dedd82013-07-03 06:19:09 -070020 PostinstallRunnerAction()
21 : powerwash_marker_created_(false),
22 powerwash_marker_file_(NULL) {}
adlr@google.com3defe6a2009-12-04 20:57:17 +000023
adlr@google.com3defe6a2009-12-04 20:57:17 +000024 void PerformAction();
25
Darin Petkov6f03a3b2010-11-10 14:27:14 -080026 // Note that there's no support for terminating this action currently.
adlr@google.com3defe6a2009-12-04 20:57:17 +000027 void TerminateProcessing() { CHECK(false); }
28
29 // Debugging/logging
30 static std::string StaticType() { return "PostinstallRunnerAction"; }
31 std::string Type() const { return StaticType(); }
32
33 private:
Darin Petkov6f03a3b2010-11-10 14:27:14 -080034 // Subprocess::Exec callback.
35 void CompletePostinstall(int return_code);
36 static void StaticCompletePostinstall(int return_code,
37 const std::string& output,
38 void* p);
39
Chris Sosad317e402013-06-12 13:47:09 -070040 InstallPlan install_plan_;
Darin Petkov6f03a3b2010-11-10 14:27:14 -080041 std::string temp_rootfs_dir_;
42
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070043 // True if Powerwash Marker was created before invoking post-install script.
44 // False otherwise. Used for cleaning up if post-install fails.
45 bool powerwash_marker_created_;
46
Gilad Arnold30dedd82013-07-03 06:19:09 -070047 // Non-NULL value will cause post-install to override the default marker file
48 // name; used for testing.
49 const char* powerwash_marker_file_;
50
51 // Special ctor + friend declaration for testing purposes.
52 PostinstallRunnerAction(const char* powerwash_marker_file)
53 : powerwash_marker_created_(false),
54 powerwash_marker_file_(powerwash_marker_file) {}
55
56 friend class PostinstallRunnerActionTest;
57
adlr@google.com3defe6a2009-12-04 20:57:17 +000058 DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
59};
60
61} // namespace chromeos_update_engine
62
63#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__