fix codes to manifest direct install works properly for preload apps 07/55107/2 accepted/tizen/mobile/20151224.063317 accepted/tizen/tv/20151224.063350 accepted/tizen/wearable/20151224.063430 submit/tizen/20151224.015514 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 22 Dec 2015 02:57:35 +0000 (11:57 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 23 Dec 2015 02:13:24 +0000 (11:13 +0900)
[app-installers][tpk-backend]

Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
Change-Id: I08ea4f838e00a9e7a0a261a9eb619133b54deca8

src/tpk/step/step_parse.cc
src/tpk/step/step_parse.h
src/tpk/tpk_installer.cc

index 24109b7b862b243a3d89e980231c276a93a6ea0d..dc1ec2f8a5fbdb66f2b90da8b0bb04bcc67a5473 100644 (file)
@@ -23,6 +23,7 @@
 #include <manifest_parser/manifest_constants.h>
 
 #include <pkgmgr/pkgmgr_parser.h>
+#include <pkgmgr-info.h>
 
 #include <chrono>
 #include <cstdio>
@@ -75,6 +76,54 @@ common_installer::Step::Status StepParse::precheck() {
   return common_installer::Step::Status::OK;
 }
 
+// TODO(jungh.yeon) : this function should be re-considered
+bf::path StepParse::FindIcon(const std::string& filename) {
+
+  bf::path icon_path;
+  bf::path app_path;
+
+  if (filename.length() == 0)
+    return icon_path;
+
+  // icon path of tpk app will be modified later
+  if (context_->pkg_type.get().compare("rpm") != 0)
+    return filename;
+
+  if (index(filename.c_str(), '/'))
+    return filename;
+
+  icon_path = bf::path(getIconPath(context_->uid.get())) / filename;
+  if (access(icon_path.c_str(), F_OK) == 0)
+    return icon_path;
+
+  icon_path = bf::path(getIconPath(context_->uid.get()) / bf::path("default/small") / filename);
+  if (access(icon_path.c_str(), F_OK) == 0)
+    return icon_path;
+
+  if (context_->uid.get() == GLOBAL_USER)
+    app_path = tzplatform_getenv(TZ_SYS_RW_APP);
+  else {
+    tzplatform_set_user(context_->uid.get());
+    app_path = tzplatform_getenv(TZ_USER_APP);
+    tzplatform_reset_user();
+  }
+
+  icon_path = app_path / context_->pkgid.get() / filename;
+  if (access(icon_path.c_str(), F_OK) == 0)
+    return icon_path;
+
+  icon_path = app_path / context_->pkgid.get() / bf::path("res/icons") / filename;
+  if (access(icon_path.c_str(), F_OK) == 0)
+    return icon_path;
+
+  icon_path = app_path / context_->pkgid.get() / bf::path("shared/res") / filename;
+  if (access(icon_path.c_str(), F_OK) == 0)
+    return icon_path;
+
+  icon_path = "";
+  return icon_path;
+}
+
 bool StepParse::LocateConfigFile() {
   boost::filesystem::path manifest;
   if (!context_->xml_path.get().empty()) {
@@ -143,12 +192,15 @@ bool StepParse::FillPackageInfo(manifest_x* manifest) {
   manifest->ns = strdup(pkg_info->xmlns().c_str());
   manifest->package = strdup(pkg_info->package().c_str());
   manifest->nodisplay_setting = strdup(pkg_info->nodisplay_setting().c_str());
-  manifest->type = strdup("tpk");
   manifest->appsetting = strdup("false");
   manifest->support_disable = strdup("false");
   manifest->version = strdup(pkg_info->version().c_str());
   manifest->installlocation = strdup(pkg_info->install_location().c_str());
   manifest->api_version = strdup(pkg_info->api_version().c_str());
+  if (context_->pkg_type.get().compare("rpm") == 0)
+    manifest->type = strdup("rpm");
+  else
+    manifest->type = strdup("tpk");
 
   for (auto& pair : pkg_info->labels()) {
     label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
@@ -250,9 +302,6 @@ bool StepParse::FillWidgetApplication(manifest_x* manifest) {
     application_x* widget_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     widget_app->appid = strdup(application.widget_info.appid().c_str());
-    widget_app->exec = strdup((context_->root_application_path.get()
-                           / manifest->package / "bin"
-                           / application.widget_info.exec()).c_str());
     widget_app->launch_mode =
         strdup(application.widget_info.launch_mode().c_str());
     widget_app->multiple = strdup(application.widget_info.multiple().c_str());
@@ -275,6 +324,12 @@ bool StepParse::FillWidgetApplication(manifest_x* manifest) {
     widget_app->package = strdup(manifest->package);
     widget_app->support_disable = strdup(manifest->support_disable);
     manifest->application = g_list_append(manifest->application, widget_app);
+    if (strncmp(context_->pkg_type.get().c_str(), "rpm", strlen("rpm")) == 0)
+      widget_app->exec = strdup(application.widget_info.exec().c_str());
+    else
+      widget_app->exec = strdup((context_->root_application_path.get()
+                            / manifest->package / "bin"
+                            / application.widget_info.exec()).c_str());
 
     if (!FillApplicationIconPaths(widget_app, application.app_icons))
       return false;
@@ -304,9 +359,6 @@ bool StepParse::FillServiceApplication(manifest_x* manifest) {
     service_app->appid = strdup(application.sa_info.appid().c_str());
     service_app->autorestart =
         strdup(application.sa_info.auto_restart().c_str());
-    service_app->exec = strdup((context_->root_application_path.get()
-                           / manifest->package / "bin"
-                           / application.sa_info.exec()).c_str());
     service_app->onboot = strdup(application.sa_info.on_boot().c_str());
     service_app->type = strdup(application.sa_info.type().c_str());
     service_app->process_pool =
@@ -328,6 +380,12 @@ bool StepParse::FillServiceApplication(manifest_x* manifest) {
     service_app->package = strdup(manifest->package);
     service_app->support_disable = strdup(manifest->support_disable);
     manifest->application = g_list_append(manifest->application, service_app);
+    if (strncmp(context_->pkg_type.get().c_str(), "rpm", strlen("rpm")) == 0)
+      service_app->exec = strdup(application.sa_info.exec().c_str());
+    else
+      service_app->exec = strdup((context_->root_application_path.get()
+                            / manifest->package / "bin"
+                            / application.sa_info.exec()).c_str());
 
     if (!FillAppControl(service_app,  application.app_control))
       return false;
@@ -360,9 +418,6 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
     application_x* ui_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     ui_app->appid = strdup(application.ui_info.appid().c_str());
-    ui_app->exec = strdup((context_->root_application_path.get()
-                           / manifest->package / "bin"
-                           / application.ui_info.exec()).c_str());
     ui_app->launch_mode = strdup(application.ui_info.launch_mode().c_str());
     ui_app->multiple = strdup(application.ui_info.multiple().c_str());
     ui_app->nodisplay = strdup(application.ui_info.nodisplay().c_str());
@@ -398,6 +453,13 @@ bool StepParse::FillUIApplication(manifest_x* manifest) {
     ui_app->package = strdup(manifest->package);
     ui_app->support_disable = strdup(manifest->support_disable);
     manifest->application = g_list_append(manifest->application, ui_app);
+    if (strncmp(context_->pkg_type.get().c_str(), "rpm", strlen("rpm")) == 0)
+      ui_app->exec = strdup(application.ui_info.exec().c_str());
+    else
+      ui_app->exec = strdup((context_->root_application_path.get()
+                            / manifest->package / "bin"
+                            / application.ui_info.exec()).c_str());
+
 
     if (!FillAppControl(ui_app, application.app_control))
       return false;
@@ -460,7 +522,7 @@ bool StepParse::FillApplicationIconPaths(application_x* app,
     // NOTE: name is an attribute, but the xml writer uses it as text.
     // This must be fixed in whole app-installer modules, including wgt.
     // Current implementation is just for compatibility.
-    icon->text = strdup(application_icon.path().c_str());
+    icon->text = strdup(FindIcon(application_icon.path()).c_str());
     icon->name = strdup(application_icon.path().c_str());
     icon->lang = strdup(DEFAULT_LOCALE);
     app->icon = g_list_append(app->icon, icon);
index e60b6ca50623b8482a99a0cabccb8d74cf2587c1..6ec52a14a5ae71ed0daae9d0587de8ace80a0266 100644 (file)
@@ -42,6 +42,7 @@ class StepParse : public common_installer::Step {
   boost::filesystem::path path_;
 
  private:
+  boost::filesystem::path FindIcon(const std::string& filename);
   bool FillInstallationInfo(manifest_x* manifest);
   bool FillPackageInfo(manifest_x* manifest);
   bool FillAuthorInfo(manifest_x* manifest);
index 7fe8e28a12246ef0eeaf103c22bfa5f827e27741..89a95fc36baa00b05da8a4aacf3dbf121f30b85c 100644 (file)
@@ -192,7 +192,6 @@ void TpkInstaller::RecoverySteps() {
 void TpkInstaller::ManifestDirectInstallSteps() {
   AddStep<ci::configuration::StepConfigure>(pkgmgr_);
   AddStep<tpk::parse::StepParse>();
-  AddStep<ci::security::StepCheckSignature>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepRollbackInstallationSecurity>();
@@ -203,7 +202,6 @@ void TpkInstaller::ManifestDirectInstallSteps() {
 void TpkInstaller::ManifestDirectUpdateSteps() {
   AddStep<ci::configuration::StepConfigure>(pkgmgr_);
   AddStep<tpk::parse::StepParse>();
-  AddStep<ci::security::StepCheckSignature>();
   AddStep<ci::security::StepPrivilegeCompatibility>();
   AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
   AddStep<ci::security::StepCheckOldCertificate>();