| Darin Petkov | 6d5dbf6 | 2010-11-08 16:09:55 -0800 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 2 | // 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 Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 9 |  | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 10 | #include "update_engine/action.h" | 
| Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 11 | #include "update_engine/install_plan.h" | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 12 |  | 
 | 13 | // The Postinstall Runner Action is responsible for running the postinstall | 
 | 14 | // script of a successfully downloaded update. | 
 | 15 |  | 
 | 16 | namespace chromeos_update_engine { | 
 | 17 |  | 
| Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 18 | class PostinstallRunnerAction : public InstallPlanAction { | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 19 |  public: | 
| Gilad Arnold | 30dedd8 | 2013-07-03 06:19:09 -0700 | [diff] [blame] | 20 |   PostinstallRunnerAction() | 
 | 21 |       : powerwash_marker_created_(false), | 
 | 22 |         powerwash_marker_file_(NULL) {} | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 23 |  | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 24 |   void PerformAction(); | 
 | 25 |  | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 26 |   // Note that there's no support for terminating this action currently. | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 27 |   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 Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 34 |   // 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 Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 40 |   InstallPlan install_plan_; | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 41 |   std::string temp_rootfs_dir_; | 
 | 42 |  | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 43 |   // 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 Arnold | 30dedd8 | 2013-07-03 06:19:09 -0700 | [diff] [blame] | 47 |   // 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.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 58 |   DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction); | 
 | 59 | }; | 
 | 60 |  | 
 | 61 | }  // namespace chromeos_update_engine | 
 | 62 |  | 
 | 63 | #endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__ |