break;
}
- // Record recovery file
- if (requestType == RequestType::Install ||
- requestType == RequestType::Update ||
- requestType == RequestType::Delta ||
- requestType == RequestType::MountInstall ||
- requestType == RequestType::MountUpdate) {
- std::unique_ptr<recovery::RecoveryFile> recovery_file =
- recovery::RecoveryFile::CreateRecoveryFile(
- GenerateTemporaryPath(
- context_->root_application_path.get() /
- (context_->pkg_type.get() + "-recovery")),
- requestType);
- if (!recovery_file) {
- LOG(ERROR) << "Failed to create recovery file";
- return Status::CONFIG_ERROR;
- }
- recovery_file->set_type(requestType);
-
- if (!recovery_file->WriteAndCommitFileContent()) {
- LOG(ERROR) << "Failed to write recovery file";
- return Status::CONFIG_ERROR;
- }
- context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
- }
-
return Status::OK;
}
return Status::OK;
}
-Step::Status StepConfigure::clean() {
- // Clean up operations should not be covered by recovery
- // as backup information is being lost during clean up
- context_->recovery_info.get().recovery_file.reset();
- return Status::OK;
-}
-
bool StepConfigure::SetupRootAppDirectory() {
if (context_->root_application_path.get().empty()) {
std::string root_app_path =
*
* \return Status::OK
*/
- Status clean() override;
+ Status clean() override { return Status::OK; }
Status undo() override { return Status::OK; }
--- /dev/null
+// Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "step_create_recovery_file.h"
+
+#include <boost/filesystem/path.hpp>
+
+#include <pkgmgr-info.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <tzplatform_config.h>
+
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "common/pkgmgr_query.h"
+#include "common/request.h"
+#include "common/utils/file_util.h"
+#include "common/utils/user_util.h"
+#include "common/recovery_file.h"
+
+namespace bf = boost::filesystem;
+
+namespace common_installer {
+namespace configuration {
+
+Step::Status StepCreateRecoveryFile::process() {
+ std::string recovery_filename = context_->pkg_type.get() + "-recovery";
+ bf::path recovery_filepath = GenerateTemporaryPath(
+ context_->root_application_path.get() / recovery_filename);
+ auto recovery_file =
+ recovery::RecoveryFile::CreateRecoveryFile(recovery_filepath,
+ context_->request_type.get());
+ if (!recovery_file) {
+ LOG(ERROR) << "Failed to create recovery file";
+ return Status::CONFIG_ERROR;
+ }
+ recovery_file->set_type(context_->request_type.get());
+
+ if (!recovery_file->WriteAndCommitFileContent()) {
+ LOG(ERROR) << "Failed to write recovery file";
+ return Status::CONFIG_ERROR;
+ }
+ context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
+
+ return Status::OK;
+}
+
+Step::Status StepCreateRecoveryFile::precheck() {
+ if (context_->pkg_type.get().empty()) {
+ LOG(ERROR) << "Pkg type is not set";
+ return Status::INVALID_VALUE;
+ }
+ if (context_->root_application_path.get().empty()) {
+ LOG(ERROR) << "Root application path is not set";
+ return Status::INVALID_VALUE;
+ }
+ return Status::OK;
+}
+
+Step::Status StepCreateRecoveryFile::clean() {
+ // Clean up operations should not be covered by recovery
+ // as backup information is being lost during clean up
+ context_->recovery_info.get().recovery_file.reset();
+ return Status::OK;
+}
+
+
+} // namespace configuration
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_RECOVERY_STEP_RECORD_RECOVERY_FILE_H_
+#define COMMON_STEP_RECOVERY_STEP_RECORD_RECOVERY_FILE_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+
+#include "common/pkgmgr_interface.h"
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace configuration {
+
+class StepCreateRecoveryFile : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override;
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ STEP_NAME(Configure)
+};
+
+} // namespace configuration
+} // namespace common_installer
+
+#endif // COMMON_STEP_RECOVERY_STEP_RECORD_RECOVERY_FILE_H_