From 849e240e587c6aaf2ba9e3fc5cf510273093960b Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 22 Dec 2015 11:57:35 +0900 Subject: [PATCH] fix codes to manifest direct install works properly for preload apps [app-installers][tpk-backend] Signed-off-by: Junghyun Yeon Change-Id: I08ea4f838e00a9e7a0a261a9eb619133b54deca8 --- src/tpk/step/step_parse.cc | 84 ++++++++++++++++++++++++++++++++++++++++------ src/tpk/step/step_parse.h | 1 + src/tpk/tpk_installer.cc | 2 -- 3 files changed, 74 insertions(+), 13 deletions(-) diff --git a/src/tpk/step/step_parse.cc b/src/tpk/step/step_parse.cc index 24109b7..dc1ec2f 100644 --- a/src/tpk/step/step_parse.cc +++ b/src/tpk/step/step_parse.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -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(calloc(1, sizeof(label_x))); @@ -250,9 +302,6 @@ bool StepParse::FillWidgetApplication(manifest_x* manifest) { application_x* widget_app = static_cast(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(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); diff --git a/src/tpk/step/step_parse.h b/src/tpk/step/step_parse.h index e60b6ca..6ec52a1 100644 --- a/src/tpk/step/step_parse.h +++ b/src/tpk/step/step_parse.h @@ -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); diff --git a/src/tpk/tpk_installer.cc b/src/tpk/tpk_installer.cc index 7fe8e28..89a95fc 100644 --- a/src/tpk/tpk_installer.cc +++ b/src/tpk/tpk_installer.cc @@ -192,7 +192,6 @@ void TpkInstaller::RecoverySteps() { void TpkInstaller::ManifestDirectInstallSteps() { AddStep(pkgmgr_); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(); @@ -203,7 +202,6 @@ void TpkInstaller::ManifestDirectInstallSteps() { void TpkInstaller::ManifestDirectUpdateSteps() { AddStep(pkgmgr_); AddStep(); - AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4