Add codes to enable ManifestDirectInstall for mount installed pkg
[platform/core/appfw/app-installers.git] / src / common / step / mount / step_check_mount_path.cc
1 // Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "step/mount/step_check_mount_path.h"
6
7 #include <boost/filesystem/operations.hpp>
8 #include <boost/filesystem/path.hpp>
9
10 #include <string>
11
12 #include "common/paths.h"
13
14 namespace bf = boost::filesystem;
15 namespace bs = boost::system;
16
17 namespace common_installer {
18 namespace mount {
19
20 Step::Status StepCheckMountPath::process() {
21   bf::path zip_destination_path =
22       GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
23   if (!bf::exists(zip_destination_path))
24     return Status::OK;
25
26   context_->manifest_data.get()->zip_mount_file =
27       strdup(zip_destination_path.c_str());
28
29   return Status::OK;
30 }
31
32 Step::Status StepCheckMountPath::precheck() {
33   if (context_->root_application_path.get().empty()) {
34     LOG(ERROR) << "root_application_path attribute is empty";
35     return Step::Status::INVALID_VALUE;
36   }
37
38   if (context_->pkgid.get().empty()) {
39     LOG(ERROR) << "pkgid attribute is empty";
40     return Step::Status::PACKAGE_NOT_FOUND;
41   }
42
43   return Step::Status::OK;
44 }
45
46 }  // namespace mount
47 }  // namespace common_installer