add new step for checking pkg directory 70/60470/3 accepted/tizen/common/20160304.194326 accepted/tizen/ivi/20160303.093919 accepted/tizen/mobile/20160303.093804 accepted/tizen/tv/20160303.093828 accepted/tizen/wearable/20160303.093859 submit/tizen/20160303.064856
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 26 Feb 2016 10:06:33 +0000 (19:06 +0900)
committerSemun Lee <sm79.lee@samsung.com>
Wed, 2 Mar 2016 10:44:43 +0000 (02:44 -0800)
Change-Id: Ie05cb3fc5d2191da00b6af957fdbf14027648756
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/tpk/CMakeLists.txt
src/tpk/step/step_check_pkg_directory_path.cc [new file with mode: 0644]
src/tpk/step/step_check_pkg_directory_path.h [new file with mode: 0644]
src/tpk/tpk_installer.cc

index a2b133f..a7c76a5 100644 (file)
@@ -5,6 +5,7 @@ SET(SRCS
     step/step_convert_xml.cc
     step/step_tpk_patch_icons.cc
     step/step_manifest_adjustment.cc
+    step/step_check_pkg_directory_path.cc
     tpk_app_query_interface.cc
     tpk_installer.cc
 )
diff --git a/src/tpk/step/step_check_pkg_directory_path.cc b/src/tpk/step/step_check_pkg_directory_path.cc
new file mode 100644 (file)
index 0000000..b0e70ae
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (c) 2016 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 "tpk/step/step_check_pkg_directory_path.h"
+
+#include <boost/filesystem.hpp>
+#include <string>
+
+namespace tpk {
+namespace filesystem {
+
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+
+common_installer::Step::Status StepCheckPkgDirPath::process() {
+  if (!bf::exists(context_->pkg_path.get())) {
+    LOG(INFO) << "Create pkg_path("
+              << context_->pkg_path.get()
+              << ") for package("
+              << context_->pkgid.get() << ")";
+    bs::error_code error;
+    bf::create_directories(context_->pkg_path.get(), error);
+    if (error) {
+      LOG(ERROR) << "Cannot create directory: "
+                 << context_->pkg_path.get().string();
+      return Step::Status::APP_DIR_ERROR;
+    }
+  }
+
+  return Status::OK;
+}
+
+}  // namespace filesystem
+}  // namespace tpk
diff --git a/src/tpk/step/step_check_pkg_directory_path.h b/src/tpk/step/step_check_pkg_directory_path.h
new file mode 100644 (file)
index 0000000..79d4f40
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (c) 2016 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 TPK_STEP_STEP_CHECK_PKG_DIRECTORY_PATH_H_
+#define TPK_STEP_STEP_CHECK_PKG_DIRECTORY_PATH_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace tpk {
+namespace filesystem {
+
+class StepCheckPkgDirPath : public common_installer::Step {
+ public:
+  using Step::Step;
+
+  Status process() override;
+  Status clean() override { return Status::OK; }
+  Status undo() override { return Status::OK; }
+  Status precheck() override { return Status::OK; }
+
+  SCOPE_LOG_TAG(CheckPkgDirPath)
+};
+
+}  // namespace filesystem
+}  // namespace tpk
+
+#endif  // TPK_STEP_STEP_CHECK_PKG_DIRECTORY_PATH_H_
index 5c8235b..5667699 100644 (file)
@@ -51,6 +51,7 @@
 #include "tpk/step/step_parse_preload.h"
 #include "tpk/step/step_convert_xml.h"
 #include "tpk/step/step_tpk_patch_icons.h"
+#include "tpk/step/step_check_pkg_directory_path.h"
 
 namespace ci = common_installer;
 
@@ -235,6 +236,7 @@ void TpkInstaller::RecoverySteps() {
 
 void TpkInstaller::ManifestDirectInstallSteps() {
   AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+  AddStep<tpk::filesystem::StepCheckPkgDirPath>();
   AddStep<ci::parse::StepParseManifest>(
       ci::parse::StepParseManifest::ManifestLocation::INSTALLED,
       ci::parse::StepParseManifest::StoreLocation::NORMAL);