From 89b66c02fd032842fd8366a2ec0650b9bb8232d0 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Wed, 16 Nov 2016 16:37:34 +0100 Subject: [PATCH 01/16] Fix manifest preload location This patch sets manifest location for preload request to TZ_SYS_RO_PACKAGES. Change-Id: I678e78981fdcb8698d1cda8f1b5eba7bf6173e49 --- src/wgt/step/pkgmgr/step_generate_xml.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index a20a3a3..3e63560 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -340,7 +340,8 @@ common_installer::Step::Status StepGenerateXml::precheck() { common_installer::Step::Status StepGenerateXml::process() { bf::path xml_path = - bf::path(getUserManifestPath(context_->uid.get(), false)) + bf::path(getUserManifestPath(context_->uid.get(), + context_->is_preload_request.get())) / bf::path(context_->pkgid.get()); xml_path += ".xml"; context_->xml_path.set(xml_path.string()); -- 2.7.4 From f0222f78e3f0e056c697b68ea94d9da7e54aa1cb Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 17 Nov 2016 19:36:31 +0900 Subject: [PATCH 02/16] Add StepCheckInstallable Requires: - https://review.tizen.org/gerrit/98476 Change-Id: I13c733301b6b57f92533a7a451ccb920b1c86635 Signed-off-by: Sangyoon Jang --- src/hybrid/hybrid_installer.cc | 4 ++++ src/wgt/wgt_installer.cc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index ee59c63..2b416e3 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( ci::configuration::StepParseManifest::ManifestLocation::PACKAGE, ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true); @@ -299,6 +301,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( ci::configuration::StepParseManifest::ManifestLocation::PACKAGE, ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true); @@ -388,6 +391,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::INSTALLED, true); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index e1140e2..a9b0473 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -316,6 +318,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -394,6 +397,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(pkgmgr_); AddStep( wgt::configuration::StepParse::ConfigLocation::INSTALLED, true); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From 749c566211473c2fa4d6a8c9952147cbb673c330 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Tue, 15 Nov 2016 09:02:01 +0100 Subject: [PATCH 03/16] Fix StepCreateStorageDirectores This patch provides proper handling for following test case: 1. Crash installation before StepGenerateXML 2. Install again 3. The installation should be successful Change-Id: Ic55d86d5164ecb1f596f7ddc7d51cf16a0f6268e --- src/wgt/step/filesystem/step_create_symbolic_link.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.cc b/src/wgt/step/filesystem/step_create_symbolic_link.cc index cbdbb7f..a814f04 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_symbolic_link.cc @@ -42,6 +42,8 @@ bool StepCreateSymbolicLink::CreateSymlinksForApps() { common_installer::CreateDir(exec_path); exec_path /= bf::path(app->appid); + if (bf::exists(exec_path)) + bf::remove_all(exec_path); if (strcmp(app->component_type, "uiapp") == 0) { bf::create_symlink(bf::path(WRT_LAUNCHER), exec_path, error); -- 2.7.4 From 18be8ca9cadfd4fe6f13c69202d7b3eb756336ba Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Tue, 15 Nov 2016 10:35:47 +0100 Subject: [PATCH 04/16] [Coding style] Wgt step reorder as tpk This commit reoders step RegisterApplication with RegisterSecurity as it is done in Tpk installer. It could be done because that steps do not depend of each other. Change-Id: Ia30152f749f0b5a360bdabcfad032142e84cdd5f --- src/wgt/wgt_installer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index a9b0473..43fc80c 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -139,10 +139,10 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From f877886dd2baf5f15fc2c4cca80a7cafe4bae39a Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 17 Nov 2016 19:34:46 +0900 Subject: [PATCH 05/16] Adjust to privilege verification API change Requires: - https://review.tizen.org/gerrit/98384 - https://review.tizen.org/gerrit/98161 Change-Id: Idf6d33b3216466f23efbcb0ad2d1c25ea131936a Signed-off-by: Sangyoon Jang --- src/wgt/step/security/step_check_extension_privileges.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wgt/step/security/step_check_extension_privileges.cc b/src/wgt/step/security/step_check_extension_privileges.cc index 990ba97..2e8d2a2 100755 --- a/src/wgt/step/security/step_check_extension_privileges.cc +++ b/src/wgt/step/security/step_check_extension_privileges.cc @@ -123,6 +123,7 @@ bool StepCheckExtensionPrivileges::CheckPrivilegeLevel( std::string error_message; if (!common_installer::ValidatePrivilegeLevel( context_->privilege_level.get(), + context_->uid.get(), context_->manifest_data.get()->api_version, privileges, &error_message)) { -- 2.7.4 From 6a4cf6791a12ed4a4371fd0cd3e251bdbbf75ca9 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 21 Nov 2016 16:00:25 +0900 Subject: [PATCH 06/16] Implement wgt backend library This backend library is for getting package information from file. The functions are called by dlsym from pkgmgr_client api. (Refer to: https://review.tizen.org/gerrit/73286) Change-Id: I547fae4bf0a431a28826ef8c4f6e83768c4acc18 Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 3 + packaging/wgt-backend.spec | 3 + src/CMakeLists.txt | 1 + src/lib/CMakeLists.txt | 15 ++++ src/lib/wgt_archive_info.cc | 214 ++++++++++++++++++++++++++++++++++++++++++++ src/lib/wgt_archive_info.h | 23 +++++ src/lib/wgt_pkgmgr.cc | 34 +++++++ 7 files changed, 293 insertions(+) create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/wgt_archive_info.cc create mode 100644 src/lib/wgt_archive_info.h create mode 100644 src/lib/wgt_pkgmgr.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index f39937d..77ad385 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}") # Targets SET(TARGET_LIBNAME_WGT "wgt-installer") +SET(TARGET_LIBNAME_WGT_ARCHIVE_INFO "wgt") SET(TARGET_WGT_BACKEND "wgt-backend") SET(TARGET_LIBNAME_HYBRID "hybrid-installer") @@ -46,8 +47,10 @@ PKG_CHECK_MODULES(APP_INSTALLERS_DEPS REQUIRED app-installers) PKG_CHECK_MODULES(WGT_MANIFEST_HANDLERS_DEPS REQUIRED wgt-manifest-handlers) PKG_CHECK_MODULES(MANIFEST_PARSER_DEPS REQUIRED manifest-parser) PKG_CHECK_MODULES(PKGMGR_INSTALLER_DEPS REQUIRED pkgmgr-installer) +PKG_CHECK_MODULES(PKGMGR_TYPES_DEPS REQUIRED pkgmgr-types) PKG_CHECK_MODULES(ENCRYPTION_DEPS REQUIRED libwebappenc) PKG_CHECK_MODULES(TPK_INSTALLER_DEPS REQUIRED tpk-installer) +PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf) FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem regex program_options) FIND_PACKAGE(GTest REQUIRED) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index dbc504c..998fc24 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -16,8 +16,10 @@ BuildRequires: pkgconfig(app-installers) BuildRequires: pkgconfig(manifest-parser) BuildRequires: pkgconfig(wgt-manifest-handlers) BuildRequires: pkgconfig(pkgmgr-installer) +BuildRequires: pkgconfig(pkgmgr-types) BuildRequires: pkgconfig(libwebappenc) BuildRequires: pkgconfig(tpk-installer) +BuildRequires: pkgconfig(vconf) %description This is a package that installs the WGT backend of pkgmgr. @@ -57,6 +59,7 @@ ln -s %{_bindir}/wgt-backend %{buildroot}%{_sysconfdir}/package-manager/backend/ %manifest wgt-backend.manifest %license LICENSE %{_sysconfdir}/package-manager/backend/wgt +%{_sysconfdir}/package-manager/backendlib/libwgt.so %{_bindir}/wgt-backend %{_datadir}/wgt-backend/default.png diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0136fd6..5384753 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,5 @@ ADD_SUBDIRECTORY(hybrid) +ADD_SUBDIRECTORY(lib) ADD_SUBDIRECTORY(wgt) ADD_SUBDIRECTORY(wgt_backend) ADD_SUBDIRECTORY(unit_tests) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 0000000..a14aaae --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,15 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} LIB_SRCS) +ADD_LIBRARY(${TARGET_LIBNAME_WGT_ARCHIVE_INFO} SHARED ${LIB_SRCS}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_WGT_ARCHIVE_INFO} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../") + +APPLY_PKG_CONFIG(${TARGET_LIBNAME_WGT_ARCHIVE_INFO} PUBLIC + APP_INSTALLERS_DEPS + PKGMGR_TYPES_DEPS + MANIFEST_PARSER_DEPS + WGT_MANIFEST_HANDLERS_DEPS + VCONF_DEPS + Boost +) + +INSTALL(TARGETS ${TARGET_LIBNAME_WGT_ARCHIVE_INFO} DESTINATION ${SYSCONF_INSTALL_DIR}/package-manager/backendlib) diff --git a/src/lib/wgt_archive_info.cc b/src/lib/wgt_archive_info.cc new file mode 100644 index 0000000..bcaa43b --- /dev/null +++ b/src/lib/wgt_archive_info.cc @@ -0,0 +1,214 @@ +// 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 "lib/wgt_archive_info.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace bf = boost::filesystem; +namespace ci = common_installer; + +namespace { + +const char kVconfLanguageKey[] = "db/menu_widget/language"; + +bool ExtractPackageArchive(const char* file_path, const bf::path& tmp_dir) { + if (!ci::ExtractToTmpDir(file_path, tmp_dir)) { + LOG(ERROR) << "Failed to extract"; + return false; + } + return true; +} + +bool GetPackageInfo(wgt::parse::WidgetConfigParser& parser, + package_manager_pkg_detail_info_t* info) { + auto widget_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::WidgetInfo::Key())); + auto app_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::TizenApplicationInfo::Key())); + if (!widget_info || !app_info) { + LOG(ERROR) << "WidgetInfo / TizenApplicationInfo not found"; + return false; + } + + snprintf(info->pkg_type, sizeof(info->pkg_type), "wgt"); + snprintf(info->version, sizeof(info->version), "%s", + widget_info->version().c_str()); + snprintf(info->author, sizeof(info->version), "%s", + widget_info->author().c_str()); + + snprintf(info->pkg_name, sizeof(info->pkg_name), "%s", + app_info->package().c_str()); + snprintf(info->pkgid, sizeof(info->pkgid), "%s", app_info->package().c_str()); + snprintf(info->api_version, sizeof(info->api_version), "%s", + app_info->required_version().c_str()); + + return true; +} + +bool GetPrivilegesInfo(wgt::parse::WidgetConfigParser& parser, + package_manager_pkg_detail_info_t* info) { + auto privileges_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::PermissionsInfo::Key())); + if (!privileges_info) + return false; + + const auto& privileges = privileges_info->GetAPIPermissions(); + for (auto& priv : privileges) { + info->privilege_list = g_list_append(info->privilege_list, + strdup(priv.c_str())); + } + + return true; +} + +bool GetLabelInfo(wgt::parse::WidgetConfigParser& parser, const char* locale, + package_manager_pkg_detail_info_t* info) { + auto widget_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::WidgetInfo::Key())); + if (!widget_info) + return false; + + std::string name; + const auto& labels = widget_info->name_set(); + if (labels.find(locale) != labels.end()) { + name = labels.find(locale)->second; + snprintf(info->label, sizeof(info->label), "%s", name.c_str()); + return true; + } else if (labels.find("") != labels.end()) { + name = labels.find("")->second; + snprintf(info->label, sizeof(info->label), "%s", name.c_str()); + return true; + } + + return false; +} + +bool GetDescriptionInfo(wgt::parse::WidgetConfigParser& parser, + const char* locale, package_manager_pkg_detail_info_t* info) { + auto widget_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::WidgetInfo::Key())); + if (!widget_info) + return false; + + std::string desc; + const auto& descriptions = widget_info->description_set(); + if (descriptions.find(locale) != descriptions.end()) { + desc = descriptions.find(locale)->second; + snprintf(info->pkg_description, sizeof(info->pkg_description), "%s", + desc.c_str()); + return true; + } else if (descriptions.find("") != descriptions.end()) { + desc = descriptions.find("")->second; + snprintf(info->pkg_description, sizeof(info->pkg_description), "%s", + desc.c_str()); + return true; + } + + return false; +} + +bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir, + package_manager_pkg_detail_info_t* info) { + bf::path icon_path; + if (icon.is_absolute()) + icon_path = icon; + else + icon_path = tmp_dir / icon; + + LOG(INFO) << "Icon file path: " << icon_path; + + std::ifstream ifs(icon_path.c_str(), + std::ifstream::in | std::ifstream::binary); + ifs.seekg(0, ifs.end); + int len = ifs.tellg(); + ifs.seekg(0, ifs.beg); + + if (len <= 0) + return false; + + char* buf = static_cast(malloc(sizeof(char) * len)); + + LOG(INFO) << "Reading icon file, " << len << " bytes"; + ifs.read(buf, len); + + info->icon_buf = buf; + info->icon_size = len; + + return true; +} + +bool GetIconInfo(wgt::parse::WidgetConfigParser& parser, + bf::path& tmp_dir, package_manager_pkg_detail_info_t* info) { + auto icons_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key())); + if (!icons_info) + return false; + + return ReadIcon(icons_info->icons().front().path(), tmp_dir, info); +} + +} // namespace + +bool WgtArchiveInfo::GetArchiveInfo(const char* file_path, + package_manager_pkg_detail_info_t* info) { + bf::path tmp_dir = ci::GenerateTmpDir("/tmp"); + if (!ci::CreateDir(tmp_dir)) + return false; + LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir; + if (!ExtractPackageArchive(file_path, tmp_dir)) + return false; + + wgt::parse::WidgetConfigParser parser; + bf::path manifest_path = tmp_dir / "config.xml"; + if (!parser.ParseManifest(manifest_path)) { + LOG(ERROR) << "Failed to parse"; + bf::remove_all(tmp_dir); + return false; + } + + if (!GetPackageInfo(parser, info)) { + LOG(ERROR) << "Failed to get package info"; + bf::remove_all(tmp_dir); + return false; + } + if (!GetPrivilegesInfo(parser, info)) + LOG(WARNING) << "Failed to get privileges info"; + if (!GetIconInfo(parser, tmp_dir, info)) + LOG(WARNING) << "Failed to get icon info"; + + char* locale = vconf_get_str(kVconfLanguageKey); + if (!GetLabelInfo(parser, locale, info)) + LOG(WARNING) << "Failed to get label info"; + if (!GetDescriptionInfo(parser, locale, info)) + LOG(WARNING) << "Failed to get description info"; + + free(locale); + bf::remove_all(tmp_dir); + + return true; +} diff --git a/src/lib/wgt_archive_info.h b/src/lib/wgt_archive_info.h new file mode 100644 index 0000000..3882f78 --- /dev/null +++ b/src/lib/wgt_archive_info.h @@ -0,0 +1,23 @@ +// 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 LIB_WGT_ARCHIVE_INFO_H_ +#define LIB_WGT_ARCHIVE_INFO_H_ + +#include + +#include + +#include + +class WgtArchiveInfo : public common_installer::Singleton { + CRTP_DECLARE_DEFAULT_CONSTRUCTOR_CLASS(WgtArchiveInfo) + public: + bool GetArchiveInfo(const char* file_path, + package_manager_pkg_detail_info_t* info); + + SCOPE_LOG_TAG(WgtArchiveInfo) +}; + +#endif // LIB_WGT_ARCHIVE_INFO diff --git a/src/lib/wgt_pkgmgr.cc b/src/lib/wgt_pkgmgr.cc new file mode 100644 index 0000000..129c185 --- /dev/null +++ b/src/lib/wgt_pkgmgr.cc @@ -0,0 +1,34 @@ +// 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 + +#include "lib/wgt_archive_info.h" + +#define EXPORT_API __attribute__((visibility("default"))) + +namespace { + +int GetPackageArchiveInfo(const char* path, + package_manager_pkg_detail_info_t* info) { + if (!WgtArchiveInfo::Instance().GetArchiveInfo(path, info)) + return -1; + return 0; +} + +void PluginOnUnload() { +} + +} // namespace + +extern "C" EXPORT_API int pkg_plugin_on_load(pkg_plugin_set* set) { + if (set == nullptr) + return -1; + set->plugin_on_unload = PluginOnUnload; + set->pkg_is_installed = nullptr; + set->get_installed_pkg_list = nullptr; + set->get_pkg_detail_info = nullptr; + set->get_pkg_detail_info_from_package = GetPackageArchiveInfo; + return 0; +} -- 2.7.4 From da4c4d58e52f8df826f5643fdeed5e07161b5da9 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Tue, 22 Nov 2016 16:43:12 +0900 Subject: [PATCH 07/16] apply extended concept of package's attribute. Requires : https://review.tizen.org/gerrit/#/c/99039/ Change-Id: I3da722ec30cd00554b9fe9e00b001bb6922a8cbf Signed-off-by: jongmyeongko --- src/hybrid/hybrid_installer.cc | 1 + src/wgt/step/configuration/step_parse.cc | 4 ---- src/wgt/step/encryption/step_encrypt_resources.cc | 2 +- src/wgt/step/encryption/step_remove_encryption_data.cc | 2 +- src/wgt/step/pkgmgr/step_generate_xml.cc | 2 +- src/wgt/wgt_installer.cc | 2 ++ 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 2b416e3..324c771 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -236,6 +236,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep( diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index cf349e8..8fcbcec 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -230,10 +230,6 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->type = strdup("wgt"); manifest->appsetting = strdup("false"); manifest->nodisplay_setting = strdup("false"); - if (context_->is_preload_request.get()) - manifest->preload = strdup("true"); - else - manifest->preload = strdup("false"); manifest->installed_storage = strdup("installed_internal"); // For wgt package use the long name diff --git a/src/wgt/step/encryption/step_encrypt_resources.cc b/src/wgt/step/encryption/step_encrypt_resources.cc index d7d2e9a..9c6b9d8 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.cc +++ b/src/wgt/step/encryption/step_encrypt_resources.cc @@ -195,7 +195,7 @@ bool StepEncryptResources::EncryptFile(const bf::path &src) { == common_installer::RequestMode::GLOBAL) { ret = wae_encrypt_global_web_application( context_->pkgid.get().c_str(), - context_->is_preload_request.get() ? + context_->is_readonly_package.get() ? true : false, inChunk.get(), (size_t)bytesRead, diff --git a/src/wgt/step/encryption/step_remove_encryption_data.cc b/src/wgt/step/encryption/step_remove_encryption_data.cc index e398b23..7b3e9ac 100644 --- a/src/wgt/step/encryption/step_remove_encryption_data.cc +++ b/src/wgt/step/encryption/step_remove_encryption_data.cc @@ -18,7 +18,7 @@ common_installer::Step::Status StepRemoveEncryptionData::process() { int ret; if (context_->request_mode.get() == common_installer::RequestMode::GLOBAL) ret = wae_remove_global_app_dek(context_->pkgid.get().c_str(), - context_->is_preload_request.get() ? + context_->is_readonly_package.get() ? true : false); else ret = wae_remove_app_dek(context_->uid.get(), diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 3e63560..d1d1e6f 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -341,7 +341,7 @@ common_installer::Step::Status StepGenerateXml::precheck() { common_installer::Step::Status StepGenerateXml::process() { bf::path xml_path = bf::path(getUserManifestPath(context_->uid.get(), - context_->is_preload_request.get())) + context_->is_readonly_package.get())) / bf::path(context_->pkgid.get()); xml_path += ".xml"; context_->xml_path.set(xml_path.string()); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 43fc80c..e87ec01 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -222,6 +222,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep( wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, false); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -247,6 +248,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::BACKUP); + AddStep(); AddStep(); AddStep(); AddStep("res/wgt/"); -- 2.7.4 From 6d35edbd8c01d948ae06abbe4f2d76cc92adc2ff Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Mon, 17 Oct 2016 12:53:12 +0200 Subject: [PATCH 08/16] Fix smoke tests for hybrid packages Change-Id: I0d475b40ad6251184fcbef992e1cf5008c7fe2b6 --- src/unit_tests/smoke_test.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index ec1ab9d..4dab080 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -750,7 +750,8 @@ TEST_F(SmokeTest, DeinstallationMode_Hybrid) { std::string appid2 = "smokehyb03.Native"; ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK); - ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK); + ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID), + ci::AppInstaller::Result::OK); CheckPackageNonExistance(pkgid, {appid1, appid2}); } @@ -795,10 +796,10 @@ TEST_F(SmokeTest, MountUpdateMode_Hybrid) { std::string pkgid = "smokehyb06"; std::string appid1 = "smokehyb06.web"; std::string appid2 = "smokehyb06.service"; - ASSERT_EQ(MountInstall(path_old, PackageType::WGT), + ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID), ci::AppInstaller::Result::OK); AddDataFiles(pkgid); - ASSERT_EQ(MountInstall(path_new, PackageType::WGT), + ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID), ci::AppInstaller::Result::OK); ScopedTzipInterface interface(pkgid); ValidatePackage(pkgid, {appid1, appid2}); -- 2.7.4 From a729223f7143f2ff31e3f8b6ee508a6e51a242f9 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Thu, 20 Oct 2016 10:34:21 +0200 Subject: [PATCH 09/16] Fix for MountUpdateMode_Rollback Requires: - https://review.tizen.org/gerrit/#/c/97897/ To verify run wgt-backend smoke test Change-Id: I08198a4003acd457f2a8282d143a8272df53feb2 --- src/wgt/step/filesystem/step_wgt_update_package_directory.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc index 17e07d9..c762dc4 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc @@ -77,6 +77,12 @@ StepWgtUpdatePackageDirectory::RecoverBackupOfDirectories() { if (!bf::exists(directory_backup)) continue; LOG(DEBUG) << "Recover directory entry: " << entry; + bs::error_code error; + bf::remove_all(directory, error); + if (error) { + LOG(ERROR) << "Failed to remove fail-update directory: " << directory; + return Status::APP_DIR_ERROR; + } if (!ci::MoveDir(directory_backup, directory)) { LOG(ERROR) << "Failed to restore directory backup " << directory_backup; -- 2.7.4 From 5efd5d210268c584984dc8b1072c37270f16fe11 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Fri, 18 Nov 2016 11:48:41 +0100 Subject: [PATCH 10/16] Fix for UpdateMode_Rollback_Hybrid and MountUpdateMode_Rollback_Hybrid There are unneeded step that remove all smack rules. There should be all smack rules as before an update. Verify: - # su - app_fw - $ /usr/bin/wgt-backend-ut/smoke-test Submit together: - https://review.tizen.org/gerrit/#/c/98725/ Requires: - https://review.tizen.org/gerrit/#/c/97903/ Change-Id: I5a0f4c929c9f90f06f67a68c3a1bcfc4939f9cc8 --- src/hybrid/hybrid_installer.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 324c771..0cd47f6 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -164,7 +164,6 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::BACKUP); @@ -360,7 +359,6 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::BACKUP); -- 2.7.4 From d331e90ba010054f9188371556678b209ccfadba Mon Sep 17 00:00:00 2001 From: Piotr Dabrowski Date: Mon, 28 Nov 2016 17:06:05 +0100 Subject: [PATCH 11/16] Change order of steps in wgt as in tpk StepRegisterSecurity StepRegisterApplication StepRunParserPlugin StepUpdateSecurity StepUpdateApplication StepRunParserPlugin Change-Id: I92c30d65c7af2b50c2ae2f32b8343ef522db2249 --- src/hybrid/hybrid_installer.cc | 6 +++--- src/wgt/wgt_installer.cc | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index 0cd47f6..dbd4244 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -136,8 +136,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); @@ -331,8 +331,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); @@ -405,8 +405,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); - AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Install); AddStep(); diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index e87ec01..dcb6910 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -139,10 +139,10 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep( - ci::Plugin::ActionType::Install); AddStep(); AddStep(); + AddStep( + ci::Plugin::ActionType::Install); AddStep(); AddStep(); AddStep(); @@ -185,9 +185,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); - AddStep(); AddStep(); AddStep(); break; @@ -281,9 +281,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); - AddStep(); AddStep(); AddStep(); break; @@ -344,12 +344,12 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); - AddStep( - ci::Plugin::ActionType::Install); AddStep(); AddStep(); AddStep(); + AddStep(); + AddStep( + ci::Plugin::ActionType::Install); AddStep(); AddStep(); break; @@ -388,9 +388,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); - AddStep(); AddStep(); AddStep(); break; @@ -413,9 +413,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Install); - AddStep(); AddStep(); AddStep(); break; @@ -442,9 +442,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); - AddStep(); AddStep(); AddStep(); break; -- 2.7.4 From a7dbc9bdb0c8b9e6070bd15214d111abdba381c7 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 1 Dec 2016 00:01:47 +0900 Subject: [PATCH 12/16] fix build error - this override function will be used. Change-Id: I7d28e1e8b0dbf98dda4482eb8bbbe62390f50eab Signed-off-by: jongmyeongko --- src/wgt/wgt_app_query_interface.cc | 4 ++++ src/wgt/wgt_app_query_interface.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/wgt_app_query_interface.cc index be08ae1..8c75226 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/wgt_app_query_interface.cc @@ -127,4 +127,8 @@ bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg, return false; } +std::string WgtAppQueryInterface::GetPkgId(const std::string& arg) { + return GetPkgIdFromPath(arg); +} + } // namespace wgt diff --git a/src/wgt/wgt_app_query_interface.h b/src/wgt/wgt_app_query_interface.h index fe075fe..c7ca0ea 100644 --- a/src/wgt/wgt_app_query_interface.h +++ b/src/wgt/wgt_app_query_interface.h @@ -35,6 +35,8 @@ class WgtAppQueryInterface : public common_installer::AppQueryInterface { * \return true if package is hybrid */ bool IsHybridApplication(const std::string& arg, uid_t uid); + + std::string GetPkgId(const std::string& arg) override; }; } // namespace wgt -- 2.7.4 From eeff6059746db645244a60d612d314f2375bbd17 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Thu, 1 Dec 2016 01:53:01 +0900 Subject: [PATCH 13/16] change disable_pkg test Change-Id: Ie821fea7e3697e1f0381b1d76778f7b31fe29c40 Signed-off-by: jongmyeongko --- src/unit_tests/smoke_test.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 4dab080..c696ad8 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -538,9 +538,7 @@ TEST_F(SmokeTest, DisablePkg) { ci::AppInstaller::Result::OK); ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK); - ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, - ci::GetRequestMode(kTestUserId), - kTestUserId)); + ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, kTestUserId)); ValidatePackageFS(pkgid, {appid}); } -- 2.7.4 From e8512c751441b6e15272764aef56e6ff234707eb Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 2 Dec 2016 17:05:01 +0900 Subject: [PATCH 14/16] Set missing manifest attribute: readonly, preload Change-Id: I4a9395a7f646dae6f67723c95b7e1d5cb2496e91 Signed-off-by: Sangyoon Jang --- src/wgt/step/pkgmgr/step_generate_xml.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index d1d1e6f..50a538d 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -420,6 +420,12 @@ void StepGenerateXml::GenerateManifestElementAttributes( BAD_CAST context_->manifest_data.get()->api_version); xmlTextWriterWriteAttribute(writer, BAD_CAST "nodisplay-setting", BAD_CAST context_->manifest_data.get()->nodisplay_setting); + if (context_->is_readonly_package.get()) { + xmlTextWriterWriteAttribute(writer, BAD_CAST "readonly", BAD_CAST "true"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "preload", BAD_CAST "true"); + } else if (context_->is_preload_rw_package.get()) { + xmlTextWriterWriteAttribute(writer, BAD_CAST "preload", BAD_CAST "true"); + } } void StepGenerateXml::GenerateLangLabels(xmlTextWriterPtr writer) { -- 2.7.4 From 09628a8787ce460521356b2fb2164861eb95755e Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 1 Dec 2016 15:44:15 +0900 Subject: [PATCH 15/16] Fix smoke test Now gid of data, shared/data dir is system_share. Change-Id: Id69017b75af1f12cb61d6aa2fd24c1d528a43963 Signed-off-by: Sangyoon Jang --- src/unit_tests/smoke_test.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index c696ad8..7b185d3 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,7 @@ namespace { const uid_t kTestUserId = tzplatform_getuid(TZ_SYS_DEFAULT_USER); const gid_t kTestGroupId = tzplatform_getgid(TZ_SYS_DEFAULT_USER); +const char kTestGroupName[] = "system_share"; const std::string kTestUserIdStr = std::to_string(kTestUserId); @@ -229,7 +231,12 @@ void ValidatePackageFS(const std::string& pkgid, struct stat stats; stat(iter->path().c_str(), &stats); ASSERT_EQ(kTestUserId, stats.st_uid) << "Invalid uid: " << iter->path(); - ASSERT_EQ(kTestGroupId, stats.st_gid) << "Invalid gid: " << iter->path(); + if (iter->path().filename() == "data") { + boost::optional gid = ci::GetGidByGroupName(kTestGroupName); + ASSERT_EQ(*gid, stats.st_gid) << "Invalid gid: " << iter->path(); + } else { + ASSERT_EQ(kTestGroupId, stats.st_gid) << "Invalid gid: " << iter->path(); + } } } -- 2.7.4 From 57df390b05a52494b9090d0fdc49ab7d22c6a4d1 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Wed, 30 Nov 2016 13:48:52 +0100 Subject: [PATCH 16/16] Addition of main attribute for widget-application This commit repairs the issue with generating proper main attribute for widget-application element in manifest. Only one attribute can be set to "true" for list of apps (widget-application). Submit together: - https://review.tizen.org/gerrit/#/c/101269/ - https://review.tizen.org/gerrit/#/c/101267/ - https://review.tizen.org/gerrit/#/c/101266/ Change-Id: Icdc622d05b0d2b5787db8e099f1db978f130af97 --- src/wgt/step/pkgmgr/step_generate_xml.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 50a538d..b34417b 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -94,6 +94,10 @@ bool WriteWidgetApplicationAttributesAndElements( if (app->multiple) xmlTextWriterWriteAttribute(writer, BAD_CAST "multiple", BAD_CAST app->multiple); + if (app->mainapp) + xmlTextWriterWriteAttribute(writer, BAD_CAST "main", + BAD_CAST app->mainapp); + // FIXME: For hotfix, must be removed if (app->support_sizes) { for (auto& ss : GListRange(app->support_sizes)) { @@ -115,8 +119,6 @@ bool WriteWidgetApplicationAttributesAndElements( } // Add extra elements for wgt widget-application - xmlTextWriterWriteAttribute(writer, BAD_CAST "main", - BAD_CAST (appwidget->primary ? "true" : "false")); // NOLINT if (!appwidget->update_period.empty()) { xmlTextWriterWriteAttribute(writer, BAD_CAST "update-period", BAD_CAST std::to_string(static_cast( -- 2.7.4