add symlink for ui-gadget application 89/58789/6
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 3 Feb 2016 11:10:21 +0000 (20:10 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Thu, 4 Feb 2016 00:05:38 +0000 (09:05 +0900)
Change-Id: I85486ac70ac4d2ed78077b76b52035349228000a
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/tpk/step/step_create_symbolic_link.cc
src/tpk/step/step_manifest_adjustment.cc
src/tpk/step/step_parse_preload.h
src/tpk/tpk_installer.cc

index f4e3353..649df19 100644 (file)
@@ -18,11 +18,11 @@ namespace tpk {
 namespace filesystem {
 
 namespace bf = boost::filesystem;
+namespace ci = common_installer;
+
 using common_installer::InstallerContext;
 typedef common_installer::Step::Status Status;
 
-namespace {
-
 bool CreateSymLink(application_x* app, InstallerContext* context) {
   boost::system::error_code boost_error;
   bf::path bindir = context->pkg_path.get() /
@@ -33,15 +33,38 @@ bool CreateSymLink(application_x* app, InstallerContext* context) {
     return false;
   }
 
-  // Exec path
-  // Make a symlink with the name of appid, pointing exec file
-  bf::path symlink_path = bindir / bf::path(app->appid);
-  LOG(DEBUG) << "Creating symlink " << symlink_path << " pointing " <<
-      app->exec;
-  bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
-  if (boost_error) {
-    LOG(ERROR) << "Symlink creation failure: " << symlink_path;
-    return false;
+  if (strcmp(app->ui_gadget, "true") == 0) {
+    // Ug-client path
+    // Make a symlink with the name of appid, pointing /usr/bin/ug-client
+    bf::path app_exec_path(app->exec);
+    if (!bf::exists(app_exec_path)) {
+      bf::path ug_client_path(tzplatform_mkpath(TZ_SYS_BIN, "ug-client"));
+      LOG(INFO) << "Createing symlink " << app_exec_path << " pointing " <<
+        ug_client_path;
+      bf::create_symlink(ug_client_path, app_exec_path, boost_error);
+      if (boost_error) {
+        LOG(ERROR) << "Symlink creation failure: " << app_exec_path;
+        return false;
+      }
+    }
+  } else {
+    if (context->request_type.get() == ci::RequestType::ManifestDirectInstall ||
+        context->request_type.get() == ci::RequestType::ManifestDirectUpdate) {
+      return true;
+    }
+
+    // Exec path
+    // Make a symlink with the name of appid, pointing exec file
+    bf::path symlink_path = bindir / bf::path(app->appid);
+    if (!bf::exists(symlink_path)) {
+      LOG(DEBUG) << "Creating symlink " << symlink_path << " pointing " <<
+          app->exec;
+      bf::create_symlink(bf::path(app->exec), symlink_path, boost_error);
+      if (boost_error) {
+        LOG(ERROR) << "Symlink creation failure: " << symlink_path;
+        return false;
+      }
+    }
   }
 
   return true;
@@ -62,8 +85,6 @@ bool SetExecPermission(application_x* app) {
   return true;
 }
 
-}  // namespace
-
 Status StepCreateSymbolicLink::precheck() {
   manifest_x *m = context_->manifest_data.get();
   if (!m) {
index 7777e68..ded3b93 100644 (file)
@@ -10,6 +10,7 @@
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
+#include <string>
 
 namespace bs = boost::system;
 namespace bf = boost::filesystem;
index 8bbaebd..3eb7606 100644 (file)
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a apache 2.0 license that can be
 // found in the LICENSE file.
 
-#ifndef COMMON_STEP_STEP_PARSE_PRELOAD_H_
-#define COMMON_STEP_STEP_PARSE_PRELOAD_H_
+#ifndef TPK_STEP_STEP_PARSE_PRELOAD_H_
+#define TPK_STEP_STEP_PARSE_PRELOAD_H_
 
 #include <manifest_parser/utils/logging.h>
 
@@ -28,4 +28,4 @@ class StepParsePreload : public common_installer::Step {
 }  // namespace tpk
 }  // namespace common_installer
 
-#endif  // COMMON_STEP_STEP_PARSE_PRELOAD_H_
+#endif  // TPK_STEP_STEP_PARSE_PRELOAD_H_
index aaac56c..bff2a59 100644 (file)
@@ -225,6 +225,7 @@ void TpkInstaller::ManifestDirectInstallSteps() {
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
+  AddStep<tpk::filesystem::StepCreateSymbolicLink>();
   AddStep<tpk::filesystem::StepTpkPatchIcons>();
   AddStep<ci::security::StepRollbackInstallationSecurity>();
   AddStep<ci::security::StepRegisterSecurity>();
@@ -240,6 +241,7 @@ void TpkInstaller::ManifestDirectUpdateSteps() {
   AddStep<tpk::pkgmgr::StepManifestAdjustment>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
+  AddStep<tpk::filesystem::StepCreateSymbolicLink>();
   AddStep<tpk::filesystem::StepTpkPatchIcons>();
   AddStep<ci::pkgmgr::StepKillApps>();
   AddStep<ci::security::StepRollbackInstallationSecurity>();