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 | |
| 18 | class PostinstallRunnerAction; |
| 19 | class NoneType; |
| 20 | |
| 21 | template<> |
| 22 | class ActionTraits<PostinstallRunnerAction> { |
| 23 | public: |
| 24 | // Takes the device path as input |
Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 25 | typedef InstallPlan InputObjectType; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 26 | // Passes the device path as output |
Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 27 | typedef InstallPlan OutputObjectType; |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | class PostinstallRunnerAction : public Action<PostinstallRunnerAction> { |
| 31 | public: |
Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame^] | 32 | PostinstallRunnerAction() |
| 33 | : powerwash_marker_created_(false) {} |
| 34 | |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 35 | typedef ActionTraits<PostinstallRunnerAction>::InputObjectType |
| 36 | InputObjectType; |
| 37 | typedef ActionTraits<PostinstallRunnerAction>::OutputObjectType |
| 38 | OutputObjectType; |
| 39 | void PerformAction(); |
| 40 | |
Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 41 | // Note that there's no support for terminating this action currently. |
adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 42 | 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 Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 49 | // 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 Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame^] | 57 | // 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.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 61 | DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction); |
| 62 | }; |
| 63 | |
| 64 | } // namespace chromeos_update_engine |
| 65 | |
| 66 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H__ |