update_engine: Use libchromeos to launch subprocesses.
The Subprocess class handles the execution of suprocesses in the
update_engine such as the post-install script and bspatch operations.
This patch migrates this class from using glib functions to use
libchromeos classes with equivalent functionality.
Callsites and unittests were updated to match the new interface.
BUG=chromium:499886
TEST=Unittest still pass. Deployed on link and cros flash another image
using a delta payload.
Change-Id: Ia64d39734e220675113f393a6049e9a9b0fe8409
Reviewed-on: https://chromium-review.googlesource.com/288837
Trybot-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
index f27aace..0760bd5 100644
--- a/postinstall_runner_action.cc
+++ b/postinstall_runner_action.cc
@@ -8,6 +8,8 @@
#include <sys/mount.h>
#include <vector>
+#include <base/bind.h>
+
#include "update_engine/action_processor.h"
#include "update_engine/subprocess.h"
#include "update_engine/utils.h"
@@ -83,12 +85,16 @@
command.push_back(kPostinstallScript);
}
command.push_back(install_device);
- if (!Subprocess::Get().Exec(command, StaticCompletePostinstall, this)) {
- CompletePostinstall(1);
+ if (!Subprocess::Get().Exec(command,
+ base::Bind(
+ &PostinstallRunnerAction::CompletePostinstall,
+ base::Unretained(this)))) {
+ CompletePostinstall(1, "Postinstall didn't launch");
}
}
-void PostinstallRunnerAction::CompletePostinstall(int return_code) {
+void PostinstallRunnerAction::CompletePostinstall(int return_code,
+ const string& output) {
ScopedActionCompleter completer(processor_, this);
ScopedTempUnmounter temp_unmounter(temp_rootfs_dir_);
if (return_code != 0) {
@@ -123,11 +129,4 @@
completer.set_code(ErrorCode::kSuccess);
}
-void PostinstallRunnerAction::StaticCompletePostinstall(int return_code,
- const string& output,
- void* p) {
- reinterpret_cast<PostinstallRunnerAction*>(p)->CompletePostinstall(
- return_code);
-}
-
} // namespace chromeos_update_engine