--- /dev/null
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "step/mount/step_check_mount_path.h"
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+
+#include <string>
+
+#include "common/paths.h"
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+namespace common_installer {
+namespace mount {
+
+Step::Status StepCheckMountPath::process() {
+ bf::path zip_destination_path =
+ GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
+ if (!bf::exists(zip_destination_path))
+ return Status::OK;
+
+ context_->manifest_data.get()->zip_mount_file =
+ strdup(zip_destination_path.c_str());
+
+ return Status::OK;
+}
+
+Step::Status StepCheckMountPath::precheck() {
+ if (context_->root_application_path.get().empty()) {
+ LOG(ERROR) << "root_application_path attribute is empty";
+ return Step::Status::INVALID_VALUE;
+ }
+
+ if (context_->pkgid.get().empty()) {
+ LOG(ERROR) << "pkgid attribute is empty";
+ return Step::Status::PACKAGE_NOT_FOUND;
+ }
+
+ return Step::Status::OK;
+}
+
+} // namespace mount
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_MOUNT_STEP_CHECK_MOUNT_PATH_H_
+#define COMMON_STEP_MOUNT_STEP_CHECK_MOUNT_PATH_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace mount {
+
+/**
+ * \brief Responsible for checking existance of mount path to perform
+ * ManifestDirectInstall for mount installed pkg.
+ *
+ */
+class StepCheckMountPath : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ STEP_NAME(CheckMouhtPath)
+};
+
+} // namespace mount
+} // namespace common_installer
+
+#endif // COMMON_STEP_MOUNT_STEP_CHECK_MOUNT_PATH_H_
return true;
}
+bool BackupDir(const boost::filesystem::path& src,
+ const boost::filesystem::path& dst, const std::string& entry) {
+ if (!bf::exists(src / entry))
+ return true;
+ if (!MoveDir(src / entry, dst / entry,
+ FS_MERGE_OVERWRITE |
+ FS_COMMIT_COPY_FILE |
+ FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS)) {
+ LOG(ERROR) << "Failed to backup file";
+ return false;
+ }
+
+ return true;
+}
+
int64_t GetUnpackedPackageSize(const bf::path& path) {
int64_t size = 0;
int64_t block_size = GetBlockSizeForPath(path);
bool MoveFile(const boost::filesystem::path& src,
const boost::filesystem::path& dst, bool force = false);
+bool BackupDir(const boost::filesystem::path& src,
+ const boost::filesystem::path& dst, const std::string& entry);
+
bool SetDirPermissions(const boost::filesystem::path& path,
boost::filesystem::perms permissions);