1 // Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/recovery/step_create_recovery_file.h"
7 #include <boost/filesystem/path.hpp>
9 #include <pkgmgr-info.h>
11 #include <sys/types.h>
13 #include <tzplatform_config.h>
19 #include "common/pkgmgr_query.h"
20 #include "common/request.h"
21 #include "common/utils/file_util.h"
22 #include "common/utils/user_util.h"
23 #include "common/recovery_file.h"
25 namespace bf = boost::filesystem;
27 namespace common_installer {
30 Step::Status StepCreateRecoveryFile::process() {
31 std::string recovery_filename = context_->pkg_type.get() + "-recovery";
32 bf::path recovery_filepath = GenerateTemporaryPath(
33 context_->root_application_path.get() / recovery_filename);
35 recovery::RecoveryFile::CreateRecoveryFile(recovery_filepath,
36 context_->request_type.get());
38 LOG(ERROR) << "Failed to create recovery file";
39 return Status::CONFIG_ERROR;
41 context_->recovery_info.set(RecoveryInfo(std::move(recovery_file)));
46 Step::Status StepCreateRecoveryFile::precheck() {
47 if (context_->pkg_type.get().empty()) {
48 LOG(ERROR) << "Pkg type is not set";
49 return Status::INVALID_VALUE;
51 if (context_->root_application_path.get().empty()) {
52 LOG(ERROR) << "Root application path is not set";
53 return Status::INVALID_VALUE;
58 Step::Status StepCreateRecoveryFile::clean() {
59 // Clean up operations should not be covered by recovery
60 // as backup information is being lost during clean up
61 context_->recovery_info.get().recovery_file.reset();
66 } // namespace recovery
67 } // namespace common_installer