From 73f795782362c4c651a74eb7759d831eb4fd43a7 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 7 Jan 2020 18:00:03 +0900 Subject: [PATCH 01/16] Release version 0.13.0 Changes: - Fix adding steps using default steps Change-Id: Ia6d51c5d8f084943176f344158a61336361d8ded Signed-off-by: Ilho Kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 81f10bc..b72199f 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.12.15 +Version: 0.13.0 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 809b4fa12b835dfc3aed838ef7601997cb4ab14e Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 4 Dec 2019 13:52:13 +0900 Subject: [PATCH 02/16] Move utility files into newly created directory Move it to reduce module circular dependency. Change-Id: Iffed47db7a38950afe961ea4ebdc9b5fd643e57f Signed-off-by: Junghyun Yeon --- src/hybrid/hybrid_backend_data.h | 2 +- src/unit_tests/manifest_test.cc | 2 +- src/unit_tests/smoke_test_helper.cc | 2 +- src/unit_tests/smoke_utils.h | 2 +- src/wgt/CMakeLists.txt | 4 +++- src/wgt/step/configuration/step_check_start_files.cc | 2 +- src/wgt/step/configuration/step_check_start_files.h | 2 +- src/wgt/step/configuration/step_parse.cc | 2 +- src/wgt/step/encryption/step_encrypt_resources.h | 2 +- src/wgt/step/filesystem/step_copy_preview_icons.cc | 2 +- src/wgt/step/pkgmgr/step_generate_xml.cc | 2 +- src/wgt/step/security/step_check_extension_privileges.cc | 2 +- src/wgt/step/security/step_check_settings_level.cc | 2 +- src/wgt/step/security/step_check_wgt_background_category.cc | 2 +- src/wgt/{ => utils}/extension_config_parser.cc | 2 +- src/wgt/{ => utils}/extension_config_parser.h | 0 src/wgt/{ => utils}/shared_dirs.h | 0 src/wgt/{ => utils}/wgt_app_query_interface.cc | 2 +- src/wgt/{ => utils}/wgt_app_query_interface.h | 0 src/wgt/{ => utils}/wgt_backend_data.h | 0 src/wgt/wgt_installer.cc | 2 +- src/wgt_backend/wgt_backend.cc | 2 +- 22 files changed, 20 insertions(+), 18 deletions(-) rename src/wgt/{ => utils}/extension_config_parser.cc (99%) mode change 100755 => 100644 rename src/wgt/{ => utils}/extension_config_parser.h (100%) mode change 100755 => 100644 rename src/wgt/{ => utils}/shared_dirs.h (100%) rename src/wgt/{ => utils}/wgt_app_query_interface.cc (98%) rename src/wgt/{ => utils}/wgt_app_query_interface.h (100%) rename src/wgt/{ => utils}/wgt_backend_data.h (100%) diff --git a/src/hybrid/hybrid_backend_data.h b/src/hybrid/hybrid_backend_data.h index 9cc98c9..de0e9a0 100644 --- a/src/hybrid/hybrid_backend_data.h +++ b/src/hybrid/hybrid_backend_data.h @@ -13,7 +13,7 @@ #include #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace hybrid { diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 051d2f3..e195ff0 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -19,7 +19,7 @@ #include #include "wgt/step/configuration/step_parse.h" -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" #define ASSERT_CSTR_EQ(STR1, STR2) \ ASSERT_EQ(strcmp(STR1, STR2), 0) \ diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index 3549d84..9d666b2 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -5,7 +5,7 @@ #include #include -#include "wgt/wgt_app_query_interface.h" +#include "wgt/utils/wgt_app_query_interface.h" #include "wgt/wgt_installer.h" namespace ci = common_installer; diff --git a/src/unit_tests/smoke_utils.h b/src/unit_tests/smoke_utils.h index 7b22263..14e0994 100644 --- a/src/unit_tests/smoke_utils.h +++ b/src/unit_tests/smoke_utils.h @@ -16,7 +16,7 @@ #include "hybrid/hybrid_installer.h" #include "wgt/wgt_installer.h" -#include "wgt/wgt_app_query_interface.h" +#include "wgt/utils/wgt_app_query_interface.h" namespace smoke_test { diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index a9baf9b..e2456c7 100755 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -5,6 +5,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/encryption WGT_STEP_ENCRYP AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/filesystem WGT_STEP_FILESYSTEM_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/pkgmgr WGT_STEP_PKGMGR_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/security WGT_STEP_SECURITY_SRCS) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils WGT_UTILS_SRCS) # Target - definition ADD_LIBRARY(${TARGET_LIBNAME_WGT} STATIC @@ -13,7 +14,8 @@ ADD_LIBRARY(${TARGET_LIBNAME_WGT} STATIC ${WGT_STEP_ENCRYPTION_SRCS} ${WGT_STEP_FILESYSTEM_SRCS} ${WGT_STEP_PKGMGR_SRCS} - ${WGT_STEP_SECURITY_SRCS}) + ${WGT_STEP_SECURITY_SRCS} + ${WGT_UTILS_SRCS}) # Target - includes TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_WGT} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../") # Target - deps diff --git a/src/wgt/step/configuration/step_check_start_files.cc b/src/wgt/step/configuration/step_check_start_files.cc index 6db5b8e..c39474b 100644 --- a/src/wgt/step/configuration/step_check_start_files.cc +++ b/src/wgt/step/configuration/step_check_start_files.cc @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/src/wgt/step/configuration/step_check_start_files.h b/src/wgt/step/configuration/step_check_start_files.h index 7fc7025..31f42d5 100644 --- a/src/wgt/step/configuration/step_check_start_files.h +++ b/src/wgt/step/configuration/step_check_start_files.h @@ -12,7 +12,7 @@ #include -#include +#include #include #include diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 9cbf0fb..be1e09c 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -47,7 +47,7 @@ #include #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace bf = boost::filesystem; namespace ci = common_installer; diff --git a/src/wgt/step/encryption/step_encrypt_resources.h b/src/wgt/step/encryption/step_encrypt_resources.h index 6b420fd..b66db68 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.h +++ b/src/wgt/step/encryption/step_encrypt_resources.h @@ -10,7 +10,7 @@ #include #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace wgt { namespace encryption { diff --git a/src/wgt/step/filesystem/step_copy_preview_icons.cc b/src/wgt/step/filesystem/step_copy_preview_icons.cc index 2cdf5cc..b706345 100644 --- a/src/wgt/step/filesystem/step_copy_preview_icons.cc +++ b/src/wgt/step/filesystem/step_copy_preview_icons.cc @@ -10,7 +10,7 @@ #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace bf = boost::filesystem; namespace ci = common_installer; diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index f6537f9..7294e17 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -23,7 +23,7 @@ #include #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace bs = boost::system; namespace bf = boost::filesystem; diff --git a/src/wgt/step/security/step_check_extension_privileges.cc b/src/wgt/step/security/step_check_extension_privileges.cc index b5330bd..affeb47 100755 --- a/src/wgt/step/security/step_check_extension_privileges.cc +++ b/src/wgt/step/security/step_check_extension_privileges.cc @@ -22,7 +22,7 @@ #include #include -#include "wgt/extension_config_parser.h" +#include "wgt/utils/extension_config_parser.h" namespace { diff --git a/src/wgt/step/security/step_check_settings_level.cc b/src/wgt/step/security/step_check_settings_level.cc index b26f7ed..2ea5a85 100644 --- a/src/wgt/step/security/step_check_settings_level.cc +++ b/src/wgt/step/security/step_check_settings_level.cc @@ -12,7 +12,7 @@ #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace wgt { namespace security { diff --git a/src/wgt/step/security/step_check_wgt_background_category.cc b/src/wgt/step/security/step_check_wgt_background_category.cc index b3d6a2c..a245545 100644 --- a/src/wgt/step/security/step_check_wgt_background_category.cc +++ b/src/wgt/step/security/step_check_wgt_background_category.cc @@ -7,7 +7,7 @@ #include #include -#include "wgt/wgt_backend_data.h" +#include "wgt/utils/wgt_backend_data.h" namespace { diff --git a/src/wgt/extension_config_parser.cc b/src/wgt/utils/extension_config_parser.cc old mode 100755 new mode 100644 similarity index 99% rename from src/wgt/extension_config_parser.cc rename to src/wgt/utils/extension_config_parser.cc index 2409389..7a448a4 --- a/src/wgt/extension_config_parser.cc +++ b/src/wgt/utils/extension_config_parser.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a apache 2.0 license that can be // found in the LICENSE file. -#include "wgt/extension_config_parser.h" +#include "wgt/utils/extension_config_parser.h" #include #include diff --git a/src/wgt/extension_config_parser.h b/src/wgt/utils/extension_config_parser.h old mode 100755 new mode 100644 similarity index 100% rename from src/wgt/extension_config_parser.h rename to src/wgt/utils/extension_config_parser.h diff --git a/src/wgt/shared_dirs.h b/src/wgt/utils/shared_dirs.h similarity index 100% rename from src/wgt/shared_dirs.h rename to src/wgt/utils/shared_dirs.h diff --git a/src/wgt/wgt_app_query_interface.cc b/src/wgt/utils/wgt_app_query_interface.cc similarity index 98% rename from src/wgt/wgt_app_query_interface.cc rename to src/wgt/utils/wgt_app_query_interface.cc index 736982c..3c9131e 100644 --- a/src/wgt/wgt_app_query_interface.cc +++ b/src/wgt/utils/wgt_app_query_interface.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by an apache 2.0 license that can be // found in the LICENSE file. -#include "wgt/wgt_app_query_interface.h" +#include "wgt/utils/wgt_app_query_interface.h" #include #include diff --git a/src/wgt/wgt_app_query_interface.h b/src/wgt/utils/wgt_app_query_interface.h similarity index 100% rename from src/wgt/wgt_app_query_interface.h rename to src/wgt/utils/wgt_app_query_interface.h diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/utils/wgt_backend_data.h similarity index 100% rename from src/wgt/wgt_backend_data.h rename to src/wgt/utils/wgt_backend_data.h diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index f74e37a..76d0a00 100644 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -14,7 +14,7 @@ #include -#include "wgt/shared_dirs.h" +#include "wgt/utils/shared_dirs.h" #include "wgt/step/configuration/step_check_rds_manifest.h" #include "wgt/step/configuration/step_check_start_files.h" #include "wgt/step/configuration/step_parse.h" diff --git a/src/wgt_backend/wgt_backend.cc b/src/wgt_backend/wgt_backend.cc index f0633b4..9f003e3 100644 --- a/src/wgt_backend/wgt_backend.cc +++ b/src/wgt_backend/wgt_backend.cc @@ -7,7 +7,7 @@ #include #include "hybrid/hybrid_installer.h" -#include "wgt/wgt_app_query_interface.h" +#include "wgt/utils/wgt_app_query_interface.h" #include "wgt/wgt_installer.h" namespace ci = common_installer; -- 2.7.4 From 7d5895abb99e19a2b9a5482489c034a58d73b413 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Fri, 17 Jan 2020 10:33:50 +0900 Subject: [PATCH 03/16] Resolve static analysis issue Change-Id: I97616611b142e81b8457e653a0a8218b7419a442 Signed-off-by: Junghyun Yeon --- src/hybrid/step/pkgmgr/step_merge_xml.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hybrid/step/pkgmgr/step_merge_xml.cc b/src/hybrid/step/pkgmgr/step_merge_xml.cc index e36e542..529545c 100644 --- a/src/hybrid/step/pkgmgr/step_merge_xml.cc +++ b/src/hybrid/step/pkgmgr/step_merge_xml.cc @@ -90,6 +90,8 @@ xmlNodePtr StepMergeXml::GetXmlNode(const xmlDocPtr doc, xmlXPathObjectPtr obj = xmlXPathEvalExpression((const xmlChar*)expr.c_str(), ctxt); if (!obj || !obj->nodesetval || !obj->nodesetval->nodeNr) { + if (obj) + xmlXPathFreeObject(obj); xmlXPathFreeContext(ctxt); return nullptr; } @@ -140,7 +142,7 @@ bool StepMergeXml::SetTpkPrivilegeType() { xmlSetProp(node, kPrivilegeTypeAttributeKey, (const xmlChar*)"tpk"); } } - + xmlXPathFreeObject(xpath_obj); xmlXPathFreeContext(xpath_ctx); return true; -- 2.7.4 From e1cdfec8f7057b50e6a0a9a13b308cffbe951e6c Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 17 Jan 2020 17:43:08 +0900 Subject: [PATCH 04/16] Release version 0.13.1 Changes: - Move utility files into newly created directory - Resolve static analysis issue Change-Id: I27ce0fac37328ea066bf1fffb2bb9f65d89b3e50 Signed-off-by: Ilho Kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index b72199f..7553347 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.13.0 +Version: 0.13.1 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 0b9dfe6e0c68cac273a3d844702734480daf4480 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 10 Feb 2020 16:33:29 +0900 Subject: [PATCH 05/16] Add return value checking routine Change-Id: Ibc4b9ed32dd5c908e3ec5976a1e364ba11fed87e Signed-off-by: Junghyun Yeon --- src/wgt/step/filesystem/step_create_wgt_symbolic_link.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wgt/step/filesystem/step_create_wgt_symbolic_link.cc b/src/wgt/step/filesystem/step_create_wgt_symbolic_link.cc index d234494..8581504 100644 --- a/src/wgt/step/filesystem/step_create_wgt_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_wgt_symbolic_link.cc @@ -40,7 +40,8 @@ bool StepCreateWgtSymbolicLink::CreateSymlinksForApps() { continue; // binary is a symbolic link named and is located in / bf::path exec_path = context_->GetPkgPath() / bf::path("bin"); - common_installer::CreateDir(exec_path); + if (!common_installer::CreateDir(exec_path)) + return false; exec_path /= bf::path(app->appid); common_installer::RemoveAll(exec_path); -- 2.7.4 From 3a8f13bcfd4131ede02e2826b06e08a8021ca731 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 23 Jan 2020 10:41:39 +0900 Subject: [PATCH 06/16] Change clean operations not to return failure Change-Id: Ica687fe9393e7adff0bed3107b597df9472a2fab Signed-off-by: Ilho Kim --- src/wgt/step/filesystem/step_wgt_update_package_directory.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 76396db..efe6be8 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc @@ -108,14 +108,8 @@ ci::Step::Status StepWgtUpdatePackageDirectory::process() { ci::Step::Status StepWgtUpdatePackageDirectory::clean() { bf::path backup_path = ci::GetBackupPathForPackagePath(context_->GetPkgPath()); - if (bf::exists(backup_path)) { - bs::error_code error; - bf::remove_all(backup_path, error); - if (error) { - LOG(ERROR) << "Failed to remove backup directories"; - return Status::APP_DIR_ERROR; - } - } + if (bf::exists(backup_path)) + ci::RemoveAll(backup_path); return Status::OK; } -- 2.7.4 From 9d752830b7a5b0d71c14ee115f1bc6465aa507a7 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 14 Feb 2020 16:54:47 +0900 Subject: [PATCH 07/16] Release version 0.13.2 Changes: - Add return value checking routine - Change clean operations not to return failure Change-Id: Ib2903107521b3e7d71b79de34ab08af0a71fdb63 Signed-off-by: Ilho Kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 7553347..6f44f5f 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.13.1 +Version: 0.13.2 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From f54fe6ed3c2c7ab91b154ef60387d06ac09b0ce8 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 14 Oct 2019 10:59:07 +0900 Subject: [PATCH 08/16] Split rpm packaging into library part and backend part Change-Id: Icdf2ae772b047ae521a5cfbceb7586c1df946ed5 Signed-off-by: Sangyoon Jang --- packaging/wgt-backend-tests.manifest | 10 ------ packaging/wgt-backend.spec | 59 ++++++++++++++++++++++++++-------- packaging/wgt-installer-tests.manifest | 10 ++++++ packaging/wgt-installer.manifest | 5 +++ src/hybrid/CMakeLists.txt | 6 +++- src/unit_tests/CMakeLists.txt | 2 +- src/unit_tests/manifest_test.cc | 2 +- src/unit_tests/smoke_test.cc | 12 +++---- src/unit_tests/smoke_utils.cc | 2 +- src/wgt/CMakeLists.txt | 10 +++++- src/wgt/wgt-installer.pc.in | 11 +++++++ 11 files changed, 94 insertions(+), 35 deletions(-) delete mode 100644 packaging/wgt-backend-tests.manifest create mode 100644 packaging/wgt-installer-tests.manifest create mode 100644 packaging/wgt-installer.manifest create mode 100644 src/wgt/wgt-installer.pc.in diff --git a/packaging/wgt-backend-tests.manifest b/packaging/wgt-backend-tests.manifest deleted file mode 100644 index 8ea34c3..0000000 --- a/packaging/wgt-backend-tests.manifest +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 6f44f5f..7c933b4 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -7,8 +7,10 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1000: wgt-backend.manifest -Source1001: wgt-backend-tests.manifest +Source1001: wgt-installer.manifest +Source1002: wgt-installer-tests.manifest +Requires: wgt-installer = %{version} BuildRequires: boost-devel BuildRequires: cmake BuildRequires: gtest-devel @@ -26,18 +28,34 @@ BuildRequires: pkgconfig(libgum) %description This is a package that installs the WGT backend of pkgmgr. -%package tests -Summary: Unit tests for wgt-backend -Requires: %{name} = %{version} +%package -n wgt-installer +Summary: Wgt-installer library +Group: Application Framework/Package Management -%description tests -Unit tests for wgt-backend +%description -n wgt-installer +This package contains wgt-installer library + +%package -n wgt-installer-devel +Summary: Wgt-installer development files +Group: Application Framework/Package Management +Requires: wgt-installer = %{version} + +%description -n wgt-installer-devel +This package contains header files of wgt-installer library + +%package -n wgt-installer-tests +Summary: Unit tests for wgt-installer +Requires: wgt-installer = %{version} + +%description -n wgt-installer-tests +Unit tests for wgt-installer %prep %setup -q cp %{SOURCE1000} . cp %{SOURCE1001} . +cp %{SOURCE1002} . %build %cmake . -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} @@ -48,22 +66,35 @@ make %{?_smp_mflags} mkdir -p %{buildroot}/etc/package-manager/backend ln -s %{_bindir}/wgt-backend %{buildroot}%{_sysconfdir}/package-manager/backend/wgt -%post tests -/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=eip %{_bindir}/wgt-backend-ut/smoke-test -/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=eip %{_bindir}/wgt-backend-ut/smoke-test-helper +%post -n wgt-installer-tests +/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=eip %{_bindir}/wgt-installer-ut/smoke-test +/usr/sbin/setcap cap_chown,cap_dac_override,cap_fowner=eip %{_bindir}/wgt-installer-ut/smoke-test-helper %files %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 -%files tests -%manifest wgt-backend-tests.manifest -%{_bindir}/wgt-backend-ut/* -%{_datadir}/wgt-backend-ut/* +%files -n wgt-installer +%manifest wgt-installer.manifest +%{_sysconfdir}/package-manager/backendlib/libwgt.so +%{_libdir}/libwgt-installer.so* +%{_libdir}/libhybrid-installer.so* + +%files -n wgt-installer-devel +%{_includedir}/app-installers/wgt/*.h +%{_includedir}/app-installers/wgt/*/*.h +%{_includedir}/app-installers/wgt/*/*/*.h +%{_includedir}/app-installers/hybrid/*.h +%{_includedir}/app-installers/hybrid/*/*/*.h +%{_libdir}/pkgconfig/wgt-installer.pc + +%files -n wgt-installer-tests +%manifest wgt-installer-tests.manifest +%{_bindir}/wgt-installer-ut/* +%{_datadir}/wgt-installer-ut/* %changelog * Thu Dec 18 2015 Pawel Sikorski 0.1-1 diff --git a/packaging/wgt-installer-tests.manifest b/packaging/wgt-installer-tests.manifest new file mode 100644 index 0000000..f5159f3 --- /dev/null +++ b/packaging/wgt-installer-tests.manifest @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packaging/wgt-installer.manifest b/packaging/wgt-installer.manifest new file mode 100644 index 0000000..c00c25b --- /dev/null +++ b/packaging/wgt-installer.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/src/hybrid/CMakeLists.txt b/src/hybrid/CMakeLists.txt index 016c783..9d11bd9 100644 --- a/src/hybrid/CMakeLists.txt +++ b/src/hybrid/CMakeLists.txt @@ -2,7 +2,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} HYBRID_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/configuration HYBRID_STEP_CONFIGURATION_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/encryption HYBRID_STEP_ENCRYPTION_SRCS) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/pkgmgr HYBRID_STEP_PKGMGR_SRCS) -ADD_LIBRARY(${TARGET_LIBNAME_HYBRID} STATIC +ADD_LIBRARY(${TARGET_LIBNAME_HYBRID} SHARED ${HYBRID_SRCS} ${HYBRID_STEP_CONFIGURATION_SRCS} ${HYBRID_STEP_ENCRYPTION_SRCS} @@ -19,3 +19,7 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_HYBRID} PUBLIC # Target - in-package deps TARGET_LINK_LIBRARIES(${TARGET_LIBNAME_HYBRID} PRIVATE ${TARGET_LIBNAME_WGT}) SET_TARGET_PROPERTIES(${TARGET_LIBNAME_HYBRID} PROPERTIES COMPILE_FLAGS "-fPIC") + +INSTALL(TARGETS ${TARGET_LIBNAME_HYBRID} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(DIRECTORY ./ DESTINATION ${INCLUDEDIR}/app-installers/hybrid/ + FILES_MATCHING PATTERN "*.h") diff --git a/src/unit_tests/CMakeLists.txt b/src/unit_tests/CMakeLists.txt index 5e98bc3..380ad2d 100644 --- a/src/unit_tests/CMakeLists.txt +++ b/src/unit_tests/CMakeLists.txt @@ -1,4 +1,4 @@ -SET(DESTINATION_DIR wgt-backend-ut) +SET(DESTINATION_DIR wgt-installer-ut) SET(TARGET_SMOKE_UTILS smoke-utils) # Executables diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index e195ff0..ca90c26 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -30,7 +30,7 @@ namespace ci = common_installer; namespace { const char kManifestTestcaseData[] = - "/usr/share/wgt-backend-ut/test_samples/manifest/"; + "/usr/share/wgt-installer-ut/test_samples/manifest/"; template gint Size(GListRange* range) { diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 4ceba21..581908a 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -235,7 +235,7 @@ TEST_F(SmokeTest, DeltaMode) { TEST_F(SmokeTest, RecoveryMode_ForInstallation) { bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt"; - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str()); ASSERT_NE(backend_crash.Wait(), 0); @@ -256,7 +256,7 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { std::string pkgid = "smokewgt10"; std::string appid = "smokewgt10.RecoveryModeForUpdate"; AddDataFiles(pkgid, params.test_user.uid); - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str()); ASSERT_NE(backend_crash.Wait(), 0); @@ -277,7 +277,7 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK); - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str()); ASSERT_NE(backend_crash.Wait(), 0); @@ -297,7 +297,7 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { TEST_F(SmokeTest, RecoveryMode_ForMountInstall) { bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-w", path.string(), "-u", test_uid_str.c_str()); ASSERT_NE(backend_crash.Wait(), 0); @@ -321,7 +321,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { ASSERT_EQ(backend.MountInstallSuccess(path_old), ci::AppInstaller::Result::OK); AddDataFiles(pkgid, params.test_user.uid); - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-w", path_new.string(), "-u", test_uid_str.c_str()); ASSERT_NE(backend_crash.Wait(), 0); @@ -867,7 +867,7 @@ TEST_F(SmokeTest, InstallExtendedMode) { TEST_F(SmokeTest, RecoveryMode_CrashAfterUnzip) { bf::path path = kSmokePackagesDirectory / "RecoveryMode_CrashAfterUnzip.wgt"; RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid); - ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper"); + ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper"); std::string test_uid_str = std::to_string(params.test_user.uid); backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str(), "-step_name", "Unzip"); diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index 14965f9..44c8158 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -19,7 +19,7 @@ namespace st = smoke_test; namespace smoke_test { const bf::path kSmokePackagesDirectory = - "/usr/share/wgt-backend-ut/test_samples/smoke/"; + "/usr/share/wgt-installer-ut/test_samples/smoke/"; bool ValidatePackage(const std::string& pkgid, const std::vector& appids, diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index e2456c7..9aa1b7b 100755 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -8,7 +8,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/step/security WGT_STEP_SECURITY AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils WGT_UTILS_SRCS) # Target - definition -ADD_LIBRARY(${TARGET_LIBNAME_WGT} STATIC +ADD_LIBRARY(${TARGET_LIBNAME_WGT} SHARED ${WGT_SRCS} ${WGT_STEP_CONFIGURATION_SRCS} ${WGT_STEP_ENCRYPTION_SRCS} @@ -28,3 +28,11 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_WGT} PUBLIC Boost ) SET_TARGET_PROPERTIES(${TARGET_LIBNAME_WGT} PROPERTIES COMPILE_FLAGS "-fPIC") + +INSTALL(TARGETS ${TARGET_LIBNAME_WGT} DESTINATION ${LIB_INSTALL_DIR}) + +# Export devel package +CONFIGURE_FILE(wgt-installer.pc.in wgt-installer.pc @ONLY) +INSTALL(FILES wgt-installer.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ./ DESTINATION ${INCLUDEDIR}/app-installers/wgt/ + FILES_MATCHING PATTERN "*.h") diff --git a/src/wgt/wgt-installer.pc.in b/src/wgt/wgt-installer.pc.in new file mode 100644 index 0000000..ec397c2 --- /dev/null +++ b/src/wgt/wgt-installer.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +exec_prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: wgt-installer +Description: Wgt-installer library +Version: @FULLVER@ +Requires: app-installers pkgmgr wgt-manifest-handlers manifest-parser +Libs: -L${libdir} -lwgt-installer -lhybrid-installer +Cflags: -I${includedir}/app-installers/ -- 2.7.4 From a9deda311ddc7ed79ab18c4ac107c1c01bcd6277 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 18 Feb 2020 09:16:38 +0900 Subject: [PATCH 09/16] Fix smoke test Recovery check routine changed after the recovery file is created Change-Id: Ic2aa91853301c704d78cbc1a928b3a725c21f578 Signed-off-by: Ilho Kim --- src/unit_tests/extensive_smoke_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/unit_tests/extensive_smoke_test.cc b/src/unit_tests/extensive_smoke_test.cc index 1f0a8ab..92abb49 100644 --- a/src/unit_tests/extensive_smoke_test.cc +++ b/src/unit_tests/extensive_smoke_test.cc @@ -93,7 +93,7 @@ TEST_F(SmokeTest, RecoveryMode_ForInstallation) { std::vector args = {"", "-i", path.string(), "-u", test_user_str.c_str()}; backend.CrashAfterEachStep(&args, [&](int step) -> bool { - if (step >= 1) { + if (step >= 2) { bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); EXTENDED_ASSERT_FALSE(recovery_file.empty()); @@ -118,7 +118,7 @@ TEST_F(SmokeTest, RecoveryMode_ForUpdate) { std::vector args = {"", "-i", path_new.string(), "-u", test_user_str.c_str()}; backend.CrashAfterEachStep(&args, [&](int step) -> bool { - if (step >= 1) { + if (step >= 2) { bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); EXTENDED_ASSERT_FALSE(recovery_file.empty()); @@ -146,7 +146,7 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { std::vector args = {"", "-i", path_new.string(), "-u", test_user_str.c_str()}; backend.CrashAfterEachStep(&args, [&](int step) -> bool { - if (step >= 1) { + if (step >= 2) { bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); EXTENDED_ASSERT_FALSE(recovery_file.empty()); @@ -171,7 +171,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) { std::vector args = {"", "-w", path.string(), "-u", test_user_str.c_str()}; backend.CrashAfterEachStep(&args, [&](int step) -> bool { - if (step >= 1) { + if (step >= 2) { bf::path recovery_file = FindRecoveryFile("/wgt-recovery", params.test_user.uid); EXTENDED_ASSERT_FALSE(recovery_file.empty()); @@ -197,7 +197,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) { std::vector args = {"", "-w", path_new.string(), "-u", test_user_str.c_str()}; backend.CrashAfterEachStep(&args, [&](int step) -> bool { - if (step >= 1) { + if (step >= 2) { // Filesystem may be mounted after crash ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid); -- 2.7.4 From dc3d02324f7d161c92d86f459544c72561c71ade Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 26 Feb 2020 15:36:01 +0900 Subject: [PATCH 10/16] Fix StepEncryptResources Revert if statement expression. Change-Id: Ie147d0952ce8f3dec67fe00760baf9194e22c216 Signed-off-by: Junghyun Yeon --- src/wgt/step/encryption/step_encrypt_resources.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wgt/step/encryption/step_encrypt_resources.cc b/src/wgt/step/encryption/step_encrypt_resources.cc index dffaa89..c5bbb9b 100644 --- a/src/wgt/step/encryption/step_encrypt_resources.cc +++ b/src/wgt/step/encryption/step_encrypt_resources.cc @@ -165,7 +165,7 @@ bool StepEncryptResources::EncryptFile(const bf::path &src) { return false; } const std::size_t fileSize = info.st_size; - if (!fileSize) { + if (0 == fileSize) { LOG(ERROR) << src << " size is 0, so encryption will be skipped"; return true; } @@ -192,7 +192,7 @@ bool StepEncryptResources::EncryptFile(const bf::path &src) { do { bytesRead = ReadBytes(inChunk.get(), chunkSize, input); - if (!bytesRead) { + if (0 != bytesRead) { unsigned char* encrypted_data = nullptr; size_t encrypted_size = 0; // TODO(p.sikorski) check if it is Preloaded @@ -266,11 +266,11 @@ bool StepEncryptResources::EncryptFile(const bf::path &src) { fclose(input); LOG(DEBUG) << "File encrypted successfully"; - if (!unlink(src.c_str())) + if (0 != unlink(src.c_str())) return false; LOG(DEBUG) << "Rename encrypted file"; - if (!std::rename(encFile.c_str(), src.c_str())) + if (0 != std::rename(encFile.c_str(), src.c_str())) return false; return true; -- 2.7.4 From 74d7eb833c58dfef070170f000a8ea37cd0d19f7 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Thu, 27 Feb 2020 12:32:05 +0900 Subject: [PATCH 11/16] Release version 0.14.0 Changes: - Split rpm packaging into library part and backend part - Fix smoke test - Fix StepEncryptResources Change-Id: Ic0313967106bdf0d8069afe7235fadfbeb17721a Signed-off-by: Sangyoon Jang --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 7c933b4..8b9514b 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.13.2 +Version: 0.14.0 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 832271df62d44a92ebb4cd06927799a34e3b4d46 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 27 Feb 2020 10:50:03 +0900 Subject: [PATCH 12/16] Add StepCrash's clean operation This patch can be used to test the installation termination in a clean operation Change-Id: I9b5cc0e991d84196d4738d360d106b55c8e352ff Signed-off-by: Ilho Kim --- src/unit_tests/smoke_test_helper.cc | 54 +++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index 9d666b2..6e8643c 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -12,37 +12,54 @@ namespace ci = common_installer; namespace { +enum class CrashStepType { + PROCESS, + CLEAN +}; + class StepCrash : public ci::Step { public: using Step::Step; + explicit StepCrash(ci::InstallerContext* context, CrashStepType type) : + ci::Step::Step(context), type_(type) {} + ci::Step::Status process() override { - raise(SIGSEGV); + if (type_ == CrashStepType::PROCESS) + raise(SIGSEGV); + return Status::OK; + } + ci::Step::Status clean() override { + if (type_ == CrashStepType::CLEAN) + raise(SIGSEGV); return Status::OK; } - ci::Step::Status clean() override { return ci::Step::Status::OK; } ci::Step::Status undo() override { return ci::Step::Status::OK; } ci::Step::Status precheck() override { return ci::Step::Status::OK; } STEP_NAME(Crash) + + private: + CrashStepType type_; }; #define OVERRIDE_STEPS_BLOCK(STEPS) \ void STEPS() override { \ wgt::WgtInstaller::STEPS(); \ if (crash_at_ > -1) \ - AddStepAtIndex(crash_at_); \ + AddStepAtIndex(crash_at_, type_); \ else if (step_name_.size()) \ - AddStepAfter(step_name_); \ + AddStepAfter(step_name_, type_); \ else \ - AddStep(); \ + AddStep(type_); \ } \ class CrashWgtInstaller : public wgt::WgtInstaller { public: explicit CrashWgtInstaller(ci::PkgMgrPtr pkgmgr, int crash_at, - std::string step_name) : wgt::WgtInstaller(pkgmgr), crash_at_(crash_at), - step_name_(step_name) { } + std::string step_name, CrashStepType type) : + wgt::WgtInstaller(pkgmgr), crash_at_(crash_at), + step_name_(step_name), type_(type) { } private: OVERRIDE_STEPS_BLOCK(InstallSteps) @@ -68,6 +85,7 @@ class CrashWgtInstaller : public wgt::WgtInstaller { int crash_at_; std::string step_name_; + CrashStepType type_; }; } // namespace @@ -77,18 +95,26 @@ int main(int argc, char** argv) { int index = -1; int backend_argc = argc; std::string step_name; - if (!strcmp(argv[argc-2], "-idx")) { - index = atoi(argv[argc-1]); - backend_argc = argc - 2; + CrashStepType type = CrashStepType::PROCESS; + + if (!strcmp(argv[backend_argc - 2], "-idx")) { + index = atoi(argv[argc - 1]); + backend_argc -= 2; LOG(DEBUG) << "Step crash after " << index << " step."; } - if (!strcmp(argv[argc-2], "-step_name")) { - step_name = argv[argc-1]; - backend_argc = argc-2; + if (!strcmp(argv[backend_argc - 2], "-step_name")) { + step_name = argv[backend_argc - 1]; + backend_argc -= 2; LOG(DEBUG) << "Step crash after " << step_name << " step."; } + if (!strcmp(argv[backend_argc - 1], "-type_clean")) { + backend_argc--; + type = CrashStepType::CLEAN; + LOG(DEBUG) << "step will be crashed in clean operation"; + } + ci::PkgmgrInstaller pkgmgr_installer; wgt::WgtAppQueryInterface query_interface; auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, @@ -98,7 +124,7 @@ int main(int argc, char** argv) { return EINVAL; } - ::CrashWgtInstaller installer(pkgmgr, index, step_name); + ::CrashWgtInstaller installer(pkgmgr, index, step_name, type); return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; } -- 2.7.4 From 000e9d5f457f786900808b4e5cd42e7a319f3cd1 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 6 Mar 2020 16:43:43 +0900 Subject: [PATCH 13/16] Release version 0.14.1 Changes: - Add StepCrash's clean operation Change-Id: Ied6df2a64c86403393e442e7aaede065d0704106 Signed-off-by: Ilho Kim --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 8b9514b..2d9d7de 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.14.0 +Version: 0.14.1 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 6b8ec2ffe8a484f932a664ed9dab71ad1b03479b Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 4 Mar 2020 14:29:28 +0900 Subject: [PATCH 14/16] Fix WgtArchiveInfo There is a new base class for WgtArchiveInfo. Requires: - https://review.tizen.org/gerrit/c/platform/core/appfw/app-installers/+/226596 Change-Id: I3f0a5524b2267e979da6231e7bf589d086f37d3a Signed-off-by: Sangyoon Jang --- src/lib/wgt_archive_info.cc | 176 +++++++++++++++++++++----------------------- src/lib/wgt_archive_info.h | 26 +++++-- src/lib/wgt_pkgmgr.cc | 5 +- 3 files changed, 109 insertions(+), 98 deletions(-) diff --git a/src/lib/wgt_archive_info.cc b/src/lib/wgt_archive_info.cc index 095b60d..4f5a18b 100644 --- a/src/lib/wgt_archive_info.cc +++ b/src/lib/wgt_archive_info.cc @@ -4,10 +4,10 @@ #include "lib/wgt_archive_info.h" -#include -#include #include +#include + #include #include #include @@ -17,7 +17,6 @@ #include -#include #include #include #include @@ -32,17 +31,19 @@ const char kVconfLanguageKey[] = VCONFKEY_LANGSET; const char kConfigFileName[] = "config.xml"; const char kHybridConfigFileName[] = "res/wgt/config.xml"; -bool ExtractPackageArchive(const char* file_path, const char* file, - const bf::path& tmp_dir) { - if (!ci::ExtractToTmpDir(file_path, tmp_dir, file)) { +bool ExtractPackageArchive(const std::string& file_path, + const std::string& file, const bf::path& tmp_dir) { + if (!ci::ExtractToTmpDir(file_path.c_str(), tmp_dir, file.c_str())) { LOG(ERROR) << "Failed to extract"; return false; } return true; } -bool GetPackageInfo(const wgt::parse::WidgetConfigParser& parser, - package_manager_pkg_detail_info_t* info) { +} // namespace + +bool WgtArchiveInfo::GetPackageInfo( + const wgt::parse::WidgetConfigParser& parser) { auto widget_info = std::static_pointer_cast( parser.GetManifestData(wgt::parse::WidgetInfo::Key())); @@ -54,23 +55,18 @@ bool GetPackageInfo(const wgt::parse::WidgetConfigParser& parser, 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()); + type_ = "wgt"; + name_ = app_info->package().c_str(); + pkgid_ = app_info->package().c_str(); + version_ = widget_info->version().c_str(); + api_version_ = app_info->required_version().c_str(); + author_ = widget_info->author().c_str(); return true; } -bool GetPrivilegesInfo(const wgt::parse::WidgetConfigParser& parser, - package_manager_pkg_detail_info_t* info) { +bool WgtArchiveInfo::GetPrivilegesInfo( + const wgt::parse::WidgetConfigParser& parser) { auto privileges_info = std::static_pointer_cast( parser.GetManifestData(wgt::parse::PermissionsInfo::Key())); @@ -78,16 +74,59 @@ bool GetPrivilegesInfo(const wgt::parse::WidgetConfigParser& parser, 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())); + for (auto& priv : privileges) + privileges_.emplace_back("wgt", priv); + + return true; +} + +bool WgtArchiveInfo::GetIconInfo( + const wgt::parse::WidgetConfigParser& parser) { + auto icons_info = + std::static_pointer_cast( + parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key())); + if (!icons_info || icons_info->icons().empty()) + return false; + + icon_ = icons_info->icons().front().path(); + + return true; +} + +bool WgtArchiveInfo::ReadIcon(const bf::path& icon, const bf::path& tmp_dir) { + bf::path icon_path = tmp_dir / icon; + + LOG(INFO) << "Icon file path: " << icon_path; + + if (!bf::exists(icon_path)) { + LOG(WARNING) << "Icon file doesn't actually exist, skip reading icon"; + return true; } + std::ifstream ifs(icon_path.c_str(), + std::ifstream::in | std::ifstream::binary); + ifs.seekg(0, ifs.end); + std::streamoff len = ifs.tellg(); + ifs.seekg(0, ifs.beg); + + if (len <= 0) + return false; + + icon_buf_.resize(len / sizeof(unsigned char)); + ifs.read(reinterpret_cast(icon_buf_.data()), len); + if (len != icon_buf_.size()) { + LOG(ERROR) << "Reading icon failed, icon size is: " << len + << ", but read size is: " << icon_buf_.size(); + return false; + } + + LOG(INFO) << "Reading icon file, " << icon_buf_.size() << " bytes"; + return true; } -bool GetLabelInfo(const wgt::parse::WidgetConfigParser& parser, - const char* locale, package_manager_pkg_detail_info_t* info) { +bool WgtArchiveInfo::GetLabelInfo(const wgt::parse::WidgetConfigParser& parser, + const char* locale) { auto widget_info = std::static_pointer_cast( parser.GetManifestData(wgt::parse::WidgetInfo::Key())); @@ -98,19 +137,19 @@ bool GetLabelInfo(const wgt::parse::WidgetConfigParser& parser, 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()); + label_ = name; return true; } else if (labels.find("") != labels.end()) { name = labels.find("")->second; - snprintf(info->label, sizeof(info->label), "%s", name.c_str()); + label_ = name; return true; } return false; } -bool GetDescriptionInfo(const wgt::parse::WidgetConfigParser& parser, - const char* locale, package_manager_pkg_detail_info_t* info) { +bool WgtArchiveInfo::GetDescriptionInfo( + const wgt::parse::WidgetConfigParser& parser, const char* locale) { auto widget_info = std::static_pointer_cast( parser.GetManifestData(wgt::parse::WidgetInfo::Key())); @@ -121,75 +160,29 @@ bool GetDescriptionInfo(const wgt::parse::WidgetConfigParser& parser, 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()); + description_ = desc; return true; } else if (descriptions.find("") != descriptions.end()) { desc = descriptions.find("")->second; - snprintf(info->pkg_description, sizeof(info->pkg_description), "%s", - desc.c_str()); + description_ = desc; 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 = tmp_dir / icon; - - LOG(INFO) << "Icon file path: " << icon_path; - - if (!bf::exists(icon_path)) { - LOG(WARNING) << "Icon file doesn't actually exist, skip reading icon"; - return true; - } - - 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; -} - -std::string GetIconInfo(const wgt::parse::WidgetConfigParser& parser) { - auto icons_info = - std::static_pointer_cast( - parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key())); - if (!icons_info || icons_info->icons().empty()) - return {}; - - return std::string(icons_info->icons().front().path()); -} - -} // namespace - -bool WgtArchiveInfo::GetArchiveInfo(const char* file_path, - package_manager_pkg_detail_info_t* info) { +bool WgtArchiveInfo::LoadArchiveInfo() { bf::path tmp_dir = ci::GenerateTmpDir("/tmp"); if (!ci::CreateDir(tmp_dir)) return false; LOG(DEBUG) << "Unpack at temporary dir: " << tmp_dir; bool is_hybrid = false; - if (!ExtractPackageArchive(file_path, kHybridConfigFileName, tmp_dir)) + if (!ExtractPackageArchive(path_, kHybridConfigFileName, tmp_dir)) return false; if (bf::exists(tmp_dir / kHybridConfigFileName)) { is_hybrid = true; } else { - if (!ExtractPackageArchive(file_path, kConfigFileName, tmp_dir)) + if (!ExtractPackageArchive(path_, kConfigFileName, tmp_dir)) return false; } @@ -205,25 +198,26 @@ bool WgtArchiveInfo::GetArchiveInfo(const char* file_path, return false; } - if (!GetPackageInfo(parser, info)) { + if (!GetPackageInfo(parser)) { LOG(ERROR) << "Failed to get package info"; bf::remove_all(tmp_dir); return false; } - if (!GetPrivilegesInfo(parser, info)) + if (!GetPrivilegesInfo(parser)) LOG(WARNING) << "Failed to get privileges info"; - std::string icon = GetIconInfo(parser); - if (!icon.empty()) { + if (!GetIconInfo(parser)) + LOG(WARNING) << "Failed to get icon info"; + if (!icon_.empty()) { std::string icon_path; if (is_hybrid) - icon_path = "res/wgt/" + icon; + icon_path = "res/wgt/" + icon_; else - icon_path = icon; - if (!ExtractPackageArchive(file_path, icon_path.c_str(), tmp_dir)) { + icon_path = icon_; + if (!ExtractPackageArchive(path_, icon_path, tmp_dir)) { bf::remove_all(tmp_dir); return false; } - if (!ReadIcon(icon_path, tmp_dir, info)) { + if (!ReadIcon(icon_path, tmp_dir)) { LOG(WARNING) << "Failed to get icon info"; bf::remove_all(tmp_dir); return false; @@ -233,9 +227,9 @@ bool WgtArchiveInfo::GetArchiveInfo(const char* file_path, char* locale = vconf_get_str(kVconfLanguageKey); if (!locale) locale = strdup(""); - if (!GetLabelInfo(parser, locale, info)) + if (!GetLabelInfo(parser, locale)) LOG(WARNING) << "Failed to get label info"; - if (!GetDescriptionInfo(parser, locale, info)) + if (!GetDescriptionInfo(parser, locale)) LOG(WARNING) << "Failed to get description info"; free(locale); diff --git a/src/lib/wgt_archive_info.h b/src/lib/wgt_archive_info.h index e2bf8d1..085bb47 100644 --- a/src/lib/wgt_archive_info.h +++ b/src/lib/wgt_archive_info.h @@ -5,17 +5,31 @@ #ifndef LIB_WGT_ARCHIVE_INFO_H_ #define LIB_WGT_ARCHIVE_INFO_H_ -#include +#include +#include #include +#include -#include +#include -class WgtArchiveInfo : public common_installer::Singleton { - CRTP_DECLARE_DEFAULT_CONSTRUCTOR_CLASS(WgtArchiveInfo) +namespace bf = boost::filesystem; + +class WgtArchiveInfo : public common_installer::ArchiveInfo { public: - bool GetArchiveInfo(const char* file_path, - package_manager_pkg_detail_info_t* info); + explicit WgtArchiveInfo(std::string path) + : common_installer::ArchiveInfo(path) { } + bool LoadArchiveInfo() override; + + private: + bool GetPackageInfo(const wgt::parse::WidgetConfigParser& parser); + bool GetPrivilegesInfo(const wgt::parse::WidgetConfigParser& parser); + bool GetIconInfo(const wgt::parse::WidgetConfigParser& parser); + bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir); + bool GetLabelInfo(const wgt::parse::WidgetConfigParser& parser, + const char* locale); + bool GetDescriptionInfo(const wgt::parse::WidgetConfigParser& parser, + const char* locale); SCOPE_LOG_TAG(WgtArchiveInfo) }; diff --git a/src/lib/wgt_pkgmgr.cc b/src/lib/wgt_pkgmgr.cc index 129c185..62dbad1 100644 --- a/src/lib/wgt_pkgmgr.cc +++ b/src/lib/wgt_pkgmgr.cc @@ -12,7 +12,10 @@ namespace { int GetPackageArchiveInfo(const char* path, package_manager_pkg_detail_info_t* info) { - if (!WgtArchiveInfo::Instance().GetArchiveInfo(path, info)) + WgtArchiveInfo archive_info(path); + if (!archive_info.LoadArchiveInfo()) + return -1; + if (!archive_info.GetPkgDetailInfo(info)) return -1; return 0; } -- 2.7.4 From 751e705a5b6a5e6674fc430e9b8f0c898811ab2b Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 24 Mar 2020 20:15:52 +0900 Subject: [PATCH 15/16] Fix some header guards Change-Id: If66b17887cfce128342ad77a8cace34b5b2c13d0 Signed-off-by: Sangyoon Jang --- src/wgt/utils/extension_config_parser.h | 6 +++--- src/wgt/utils/shared_dirs.h | 6 +++--- src/wgt/utils/wgt_app_query_interface.h | 6 +++--- src/wgt/utils/wgt_backend_data.h | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/wgt/utils/extension_config_parser.h b/src/wgt/utils/extension_config_parser.h index 915497e..2e45b7b 100644 --- a/src/wgt/utils/extension_config_parser.h +++ b/src/wgt/utils/extension_config_parser.h @@ -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 WGT_EXTENSION_CONFIG_PARSER_H_ -#define WGT_EXTENSION_CONFIG_PARSER_H_ +#ifndef WGT_UTILS_EXTENSION_CONFIG_PARSER_H_ +#define WGT_UTILS_EXTENSION_CONFIG_PARSER_H_ #include #include @@ -35,4 +35,4 @@ class ExtensionConfigParser { } // namespace wgt -#endif // WGT_EXTENSION_CONFIG_PARSER_H_ +#endif // WGT_UTILS_EXTENSION_CONFIG_PARSER_H_ diff --git a/src/wgt/utils/shared_dirs.h b/src/wgt/utils/shared_dirs.h index 61bb319..07468d4 100644 --- a/src/wgt/utils/shared_dirs.h +++ b/src/wgt/utils/shared_dirs.h @@ -2,8 +2,8 @@ // Use of this source code is governed by an apache-2.0 license that can be // found in the LICENSE file. -#ifndef WGT_SHARED_DIRS_H_ -#define WGT_SHARED_DIRS_H_ +#ifndef WGT_UTILS_SHARED_DIRS_H_ +#define WGT_UTILS_SHARED_DIRS_H_ #include @@ -17,4 +17,4 @@ const std::vector WgtAdditionalSharedDirs = { } // namespace filesystem } // namespace wgt -#endif // WGT_SHARED_DIRS_H_ +#endif // WGT_UTILS_SHARED_DIRS_H_ diff --git a/src/wgt/utils/wgt_app_query_interface.h b/src/wgt/utils/wgt_app_query_interface.h index c19d46a..bf1b2ae 100644 --- a/src/wgt/utils/wgt_app_query_interface.h +++ b/src/wgt/utils/wgt_app_query_interface.h @@ -2,8 +2,8 @@ // Use of this source code is governed by an apache 2.0 license that can be // found in the LICENSE file. -#ifndef WGT_WGT_APP_QUERY_INTERFACE_H_ -#define WGT_WGT_APP_QUERY_INTERFACE_H_ +#ifndef WGT_UTILS_WGT_APP_QUERY_INTERFACE_H_ +#define WGT_UTILS_WGT_APP_QUERY_INTERFACE_H_ #include @@ -35,4 +35,4 @@ class WgtAppQueryInterface : public common_installer::AppQueryInterface { } // namespace wgt -#endif // WGT_WGT_APP_QUERY_INTERFACE_H_ +#endif // WGT_UTILS_WGT_APP_QUERY_INTERFACE_H_ diff --git a/src/wgt/utils/wgt_backend_data.h b/src/wgt/utils/wgt_backend_data.h index cd7651a..5ba139e 100644 --- a/src/wgt/utils/wgt_backend_data.h +++ b/src/wgt/utils/wgt_backend_data.h @@ -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 WGT_WGT_BACKEND_DATA_H_ -#define WGT_WGT_BACKEND_DATA_H_ +#ifndef WGT_UTILS_WGT_BACKEND_DATA_H_ +#define WGT_UTILS_WGT_BACKEND_DATA_H_ #include #include @@ -38,4 +38,4 @@ class WgtBackendData : public common_installer::BackendData { } // namespace wgt -#endif // WGT_WGT_BACKEND_DATA_H_ +#endif // WGT_UTILS_WGT_BACKEND_DATA_H_ -- 2.7.4 From 75fe1c6a3878f398eeb908b3a479cba6ef3041b0 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Thu, 5 Mar 2020 17:07:46 +0900 Subject: [PATCH 16/16] Allow Id of UI App to be empty if all Service Apps type global The wgt service app should have a dummy ui app even if it is not needed This patch allows the UI app's ID to be empty if all service app types are global -Before -> Allow -> Disallow -After -> Allow -> Conditionally Allow(If all service app's types global) Requires: [wgt-manifest-handlers]https://review.tizen.org/gerrit/#/c/platform/core/appfw/wgt-manifest-handlers/+/226780/ Change-Id: I2ed942fd7fb16b71a98cdac253bf71ca18cdf067 Signed-off-by: Ilho Kim --- src/wgt/step/configuration/step_parse.cc | 41 ++++++++++++++++++++++++++++++++ src/wgt/step/configuration/step_parse.h | 1 + 2 files changed, 42 insertions(+) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index be1e09c..b544181 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -336,12 +336,51 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { return true; } +bool StepParse::AllServiceAppGlobal() { + auto service_list = + GetManifestDataForKey( + app_keys::kTizenServiceKey); + if (!service_list) { + LOG(ERROR) << "service app list empty"; + return false; + } + bool all_service_app_global = true; + for (const auto& service_info : service_list->services) { + if (service_info.type() != "global") { + all_service_app_global = false; + break; + } + } + + if (!all_service_app_global) { + LOG(ERROR) << "All service app types are not global"; + return false; + } + + return true; +} + bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { auto app_info = GetManifestDataForKey( app_keys::kTizenApplicationKey); if (!app_info.get()) return true; + + if (app_info.get()->id().empty()) { + if (!AllServiceAppGlobal()) { + LOG(ERROR) << "Empty of ui app's id is possible" + << " when service app types are all global"; + return false; + } + if (app_info->package().empty()) { + LOG(ERROR) << "app_info's package is empty"; + return false; + } + manifest->package = strdup(app_info->package().c_str()); + return true; + } + bool has_watch_category = false; bool has_ime = false; bool has_downloadable_font = false; @@ -513,6 +552,8 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { application->metadata = g_list_append(application->metadata, item); } + if (!manifest->mainapp_id) + manifest->mainapp_id = strdup(application->appid); manifest->application = g_list_append(manifest->application, application); } return true; diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index 5c8593c..c4afe3a 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -55,6 +55,7 @@ class StepParse : public common_installer::Step { std::string GetPackageVersion(const std::string& manifest_version); + bool AllServiceAppGlobal(); bool FillInstallationInfo(manifest_x* manifest); bool FillIconPaths(manifest_x* manifest); bool FillWidgetInfo(manifest_x* manifest); -- 2.7.4