blob: 2308a0f2d7833a8d64bb0439100f8028445c9791 [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:
Chris Sosad317e402013-06-12 13:47:09 -070020 PostinstallRunnerAction(): powerwash_marker_created_(false) {}
adlr@google.com3defe6a2009-12-04 20:57:17 +000021
adlr@google.com3defe6a2009-12-04 20:57:17 +000022 void PerformAction();
23
Darin Petkov6f03a3b2010-11-10 14:27:14 -080024 // Note that there's no support for terminating this action currently.
adlr@google.com3defe6a2009-12-04 20:57:17 +000025 void TerminateProcessing() { CHECK(false); }
26
27 // Debugging/logging
28 static std::string StaticType() { return "PostinstallRunnerAction"; }
29 std::string Type() const { return StaticType(); }
30
31 private:
Darin Petkov6f03a3b2010-11-10 14:27:14 -080032 // Subprocess::Exec callback.
33 void CompletePostinstall(int return_code);
34 static void StaticCompletePostinstall(int return_code,
35 const std::string& output,
36 void* p);
37
Chris Sosad317e402013-06-12 13:47:09 -070038 InstallPlan install_plan_;
Darin Petkov6f03a3b2010-11-10 14:27:14 -080039 std::string temp_rootfs_dir_;
40
Jay Srinivasan1c0fe792013-03-28 16:45:25 -070041 // True if Powerwash Marker was created before invoking post-install script.
42 // False otherwise. Used for cleaning up if post-install fails.
43 bool powerwash_marker_created_;
44
adlr@google.com3defe6a2009-12-04 20:57:17 +000045 DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
46};
47
48} // namespace chromeos_update_engine
49
50#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__