summaryrefslogtreecommitdiff
path: root/postinstall_runner_action.cc
diff options
context:
space:
mode:
authoradlr@google.com <adlr@google.com@06c00378-0e64-4dae-be16-12b19f9950a1>2009-12-04 20:57:17 +0000
committeradlr@google.com <adlr@google.com@06c00378-0e64-4dae-be16-12b19f9950a1>2009-12-04 20:57:17 +0000
commit3defe6acb3609e70e851a6eff062577d25a2af9d (patch)
tree341e979027fde117dd8906483db7a5c703a2e1cf /postinstall_runner_action.cc
parentc98a7edf648aad88b3f66df3b5a7d43d6a6d7fa9 (diff)
Missed new files in last commit
Review URL: http://codereview.chromium.org/465067 git-svn-id: svn://chrome-svn/chromeos/trunk@336 06c00378-0e64-4dae-be16-12b19f9950a1
Diffstat (limited to 'postinstall_runner_action.cc')
-rw-r--r--postinstall_runner_action.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/postinstall_runner_action.cc b/postinstall_runner_action.cc
new file mode 100644
index 00000000..41228607
--- /dev/null
+++ b/postinstall_runner_action.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "update_engine/postinstall_runner_action.h"
+#include <sys/mount.h>
+#include <stdlib.h>
+#include "update_engine/utils.h"
+
+namespace chromeos_update_engine {
+
+using std::string;
+
+namespace {
+const string kMountPath(utils::kStatefulPartition + "/au_destination");
+const string kPostinstallScript("/postinst");
+}
+
+void PostinstallRunnerAction::PerformAction() {
+ CHECK(HasInputObject());
+ const string install_device = GetInputObject();
+
+ int rc = mount(install_device.c_str(), kMountPath.c_str(), "ext3", 0, NULL);
+ if (rc < 0) {
+ LOG(ERROR) << "Unable to mount destination device " << install_device
+ << " onto " << kMountPath;
+ processor_->ActionComplete(this, false);
+ return;
+ }
+
+ // run postinstall script
+ rc = system((kMountPath + kPostinstallScript + " " + install_device).c_str());
+ bool success = (rc == 0);
+ if (!success) {
+ LOG(ERROR) << "Postinst command failed with code: " << rc;
+ }
+
+ rc = umount(kMountPath.c_str());
+ if (rc < 0) {
+ // non-fatal
+ LOG(ERROR) << "Unable to umount destination device";
+ }
+ if (success && HasOutputPipe()) {
+ SetOutputObject(install_device);
+ }
+ processor_->ActionComplete(this, success);
+}
+
+} // namespace chromeos_update_engine