| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2010 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 16 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H_ | 
|  | 18 | #define UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H_ | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 19 |  | 
|  | 20 | #include <string> | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 21 |  | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 22 | #include "update_engine/action.h" | 
| Andrew de los Reyes | f971443 | 2010-05-04 10:21:23 -0700 | [diff] [blame] | 23 | #include "update_engine/install_plan.h" | 
| Alex Deymo | 31d95ac | 2015-09-17 11:56:18 -0700 | [diff] [blame] | 24 | #include "update_engine/system_state.h" | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 25 |  | 
|  | 26 | // The Postinstall Runner Action is responsible for running the postinstall | 
|  | 27 | // script of a successfully downloaded update. | 
|  | 28 |  | 
|  | 29 | namespace chromeos_update_engine { | 
|  | 30 |  | 
| Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 31 | class PostinstallRunnerAction : public InstallPlanAction { | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 32 | public: | 
| Alex Deymo | 31d95ac | 2015-09-17 11:56:18 -0700 | [diff] [blame] | 33 | explicit PostinstallRunnerAction(SystemState* system_state) | 
|  | 34 | : PostinstallRunnerAction(system_state, nullptr) {} | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 35 |  | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 36 | void PerformAction(); | 
|  | 37 |  | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 38 | // Note that there's no support for terminating this action currently. | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 39 | void TerminateProcessing() { CHECK(false); } | 
|  | 40 |  | 
|  | 41 | // Debugging/logging | 
|  | 42 | static std::string StaticType() { return "PostinstallRunnerAction"; } | 
|  | 43 | std::string Type() const { return StaticType(); } | 
|  | 44 |  | 
|  | 45 | private: | 
| Alex Deymo | 31d95ac | 2015-09-17 11:56:18 -0700 | [diff] [blame] | 46 | friend class PostinstallRunnerActionTest; | 
|  | 47 |  | 
|  | 48 | // Special constructor used for testing purposes. | 
|  | 49 | PostinstallRunnerAction(SystemState* system_state, | 
|  | 50 | const char* powerwash_marker_file) | 
|  | 51 | : system_state_(system_state), | 
|  | 52 | powerwash_marker_file_(powerwash_marker_file) {} | 
|  | 53 |  | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 54 | // Subprocess::Exec callback. | 
| Alex Deymo | 461b259 | 2015-07-24 20:10:52 -0700 | [diff] [blame] | 55 | void CompletePostinstall(int return_code, | 
|  | 56 | const std::string& output); | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 57 |  | 
| Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 58 | InstallPlan install_plan_; | 
| Darin Petkov | 6f03a3b | 2010-11-10 14:27:14 -0800 | [diff] [blame] | 59 | std::string temp_rootfs_dir_; | 
|  | 60 |  | 
| Alex Deymo | 31d95ac | 2015-09-17 11:56:18 -0700 | [diff] [blame] | 61 | // The main SystemState singleton. | 
|  | 62 | SystemState* system_state_; | 
|  | 63 |  | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 64 | // True if Powerwash Marker was created before invoking post-install script. | 
|  | 65 | // False otherwise. Used for cleaning up if post-install fails. | 
| Alex Deymo | 31d95ac | 2015-09-17 11:56:18 -0700 | [diff] [blame] | 66 | bool powerwash_marker_created_ = false; | 
| Jay Srinivasan | 1c0fe79 | 2013-03-28 16:45:25 -0700 | [diff] [blame] | 67 |  | 
| Alex Vakulenko | 88b591f | 2014-08-28 16:48:57 -0700 | [diff] [blame] | 68 | // Non-null value will cause post-install to override the default marker | 
|  | 69 | // file name; used for testing. | 
| Gilad Arnold | 30dedd8 | 2013-07-03 06:19:09 -0700 | [diff] [blame] | 70 | const char* powerwash_marker_file_; | 
|  | 71 |  | 
| adlr@google.com | 3defe6a | 2009-12-04 20:57:17 +0000 | [diff] [blame] | 72 | DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction); | 
|  | 73 | }; | 
|  | 74 |  | 
|  | 75 | }  // namespace chromeos_update_engine | 
|  | 76 |  | 
| Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 77 | #endif  // UPDATE_ENGINE_POSTINSTALL_RUNNER_ACTION_H_ |