OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "update_engine/postinstall_runner_action.h" |
| 6 #include <sys/mount.h> |
| 7 #include <stdlib.h> |
| 8 #include "update_engine/utils.h" |
| 9 |
| 10 namespace chromeos_update_engine { |
| 11 |
| 12 using std::string; |
| 13 |
| 14 namespace { |
| 15 const string kMountPath(utils::kStatefulPartition + "/au_destination"); |
| 16 const string kPostinstallScript("/postinst"); |
| 17 } |
| 18 |
| 19 void PostinstallRunnerAction::PerformAction() { |
| 20 CHECK(HasInputObject()); |
| 21 const string install_device = GetInputObject(); |
| 22 |
| 23 int rc = mount(install_device.c_str(), kMountPath.c_str(), "ext3", 0, NULL); |
| 24 if (rc < 0) { |
| 25 LOG(ERROR) << "Unable to mount destination device " << install_device |
| 26 << " onto " << kMountPath; |
| 27 processor_->ActionComplete(this, false); |
| 28 return; |
| 29 } |
| 30 |
| 31 // run postinstall script |
| 32 rc = system((kMountPath + kPostinstallScript + " " + install_device).c_str()); |
| 33 bool success = (rc == 0); |
| 34 if (!success) { |
| 35 LOG(ERROR) << "Postinst command failed with code: " << rc; |
| 36 } |
| 37 |
| 38 rc = umount(kMountPath.c_str()); |
| 39 if (rc < 0) { |
| 40 // non-fatal |
| 41 LOG(ERROR) << "Unable to umount destination device"; |
| 42 } |
| 43 if (success && HasOutputPipe()) { |
| 44 SetOutputObject(install_device); |
| 45 } |
| 46 processor_->ActionComplete(this, success); |
| 47 } |
| 48 |
| 49 } // namespace chromeos_update_engine |
OLD | NEW |