From a93be446c8cb36cff18a0ad5b7337ff512f5f6fd Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 7 Oct 2016 10:56:10 +0200 Subject: [PATCH] Patch reinstall/RDS according to SDK behaviour Commit changes reinstall request argument. Now pkgid is expected instead of path to directory. What is more, if package manifest is not in the directory supplied by reinstall/RDS then it will be copied from install location. Application installer expects that SDK will put files into: - local installation: /home/$USERNAME/apps_rw/tmp/$PKGID/ - global installation: /opt/apps/tmp/$PKGID/ Requires: - https://review.tizen.org/gerrit/91412 Submit together: - https://review.tizen.org/gerrit/91430 - https://review.tizen.org/gerrit/91431 - https://review.tizen.org/gerrit/91432 Verification: - run smoke tests, - run reinstall from SDK, - run RDS from SDK. Change-Id: I7a5008c6a5d9d28f4181a0be92d42dc9c8e57e28 --- src/unit_tests/smoke_test.cc | 19 ++++++--- .../test_samples/smoke/delta_dir/.rds_delta | 6 +-- .../smoke/delta_dir/{ => res/wgt}/ADDED | 0 .../smoke/delta_dir/{ => res/wgt}/MODIFIED | 0 .../smoke/delta_dir/{ => res/wgt}/config.xml | 0 src/wgt/CMakeLists.txt | 2 +- .../step/configuration/step_check_rds_manifest.cc | 49 ++++++++++++++++++++++ .../step/configuration/step_check_rds_manifest.h | 31 ++++++++++++++ src/wgt/step/rds/step_wgt_rds_modify.cc | 23 ---------- src/wgt/step/rds/step_wgt_rds_modify.h | 41 ------------------ src/wgt/wgt_installer.cc | 11 ++--- 11 files changed, 104 insertions(+), 78 deletions(-) rename src/unit_tests/test_samples/smoke/delta_dir/{ => res/wgt}/ADDED (100%) rename src/unit_tests/test_samples/smoke/delta_dir/{ => res/wgt}/MODIFIED (100%) rename src/unit_tests/test_samples/smoke/delta_dir/{ => res/wgt}/config.xml (100%) create mode 100644 src/wgt/step/configuration/step_check_rds_manifest.cc create mode 100644 src/wgt/step/configuration/step_check_rds_manifest.h delete mode 100644 src/wgt/step/rds/step_wgt_rds_modify.cc delete mode 100644 src/wgt/step/rds/step_wgt_rds_modify.h diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 48c6045..ec1ab9d 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -6,13 +6,16 @@ #include #include #include + #include #include #include #include #include #include +#include #include + #include #include #include @@ -334,15 +337,15 @@ ci::AppInstaller::Result Uninstall(const std::string& pkgid, return CallBackend(SIZEOFARRAY(argv), argv, type, mode); } -ci::AppInstaller::Result Reinstall(const bf::path& path, - const bf::path& delta_dir, +ci::AppInstaller::Result RDSUpdate(const bf::path& path, + const std::string& pkgid, PackageType type, RequestResult mode = RequestResult::NORMAL) { if (Install(path, type) != ci::AppInstaller::Result::OK) { LOG(ERROR) << "Failed to install application. Cannot perform RDS"; return ci::AppInstaller::Result::UNKNOWN; } - const char* argv[] = {"", "-r", delta_dir.c_str(), "-u", + const char* argv[] = {"", "-r", pkgid.c_str(), "-u", kTestUserIdStr.c_str()}; return CallBackend(SIZEOFARRAY(argv), argv, type, mode); } @@ -493,10 +496,16 @@ TEST_F(SmokeTest, DeinstallationMode) { TEST_F(SmokeTest, RDSMode) { bf::path path = kSmokePackagesDirectory / "RDSMode.wgt"; - bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/"; std::string pkgid = "smokeapp11"; std::string appid = "smokeapp11.RDSMode"; - ASSERT_EQ(Reinstall(path, delta_directory, PackageType::WGT), + bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/"; + bf::path sdk_expected_directory = + bf::path(ci::GetRootAppPath(false, kTestUserId)) / "tmp" / pkgid; + bs::error_code error; + bf::create_directories(sdk_expected_directory.parent_path(), error); + ASSERT_FALSE(error); + ASSERT_TRUE(CopyDir(delta_directory, sdk_expected_directory)); + ASSERT_EQ(RDSUpdate(path, pkgid, PackageType::WGT), ci::AppInstaller::Result::OK); ValidatePackage(pkgid, {appid}); diff --git a/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta b/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta index fb08dcc..7467bbe 100644 --- a/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta +++ b/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta @@ -1,6 +1,6 @@ #add -ADDED +res/wgt/ADDED #modify -MODIFIED +res/wgt/MODIFIED #delete -DELETED +res/wgt/DELETED diff --git a/src/unit_tests/test_samples/smoke/delta_dir/ADDED b/src/unit_tests/test_samples/smoke/delta_dir/res/wgt/ADDED similarity index 100% rename from src/unit_tests/test_samples/smoke/delta_dir/ADDED rename to src/unit_tests/test_samples/smoke/delta_dir/res/wgt/ADDED diff --git a/src/unit_tests/test_samples/smoke/delta_dir/MODIFIED b/src/unit_tests/test_samples/smoke/delta_dir/res/wgt/MODIFIED similarity index 100% rename from src/unit_tests/test_samples/smoke/delta_dir/MODIFIED rename to src/unit_tests/test_samples/smoke/delta_dir/res/wgt/MODIFIED diff --git a/src/unit_tests/test_samples/smoke/delta_dir/config.xml b/src/unit_tests/test_samples/smoke/delta_dir/res/wgt/config.xml similarity index 100% rename from src/unit_tests/test_samples/smoke/delta_dir/config.xml rename to src/unit_tests/test_samples/smoke/delta_dir/res/wgt/config.xml diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index 3124963..678dc70 100755 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -1,5 +1,6 @@ # Target - sources SET(SRCS + step/configuration/step_check_rds_manifest.cc step/configuration/step_check_start_files.cc step/configuration/step_parse.cc step/encryption/step_encrypt_resources.cc @@ -12,7 +13,6 @@ SET(SRCS step/filesystem/step_wgt_resource_directory.cc step/filesystem/step_wgt_update_package_directory.cc step/pkgmgr/step_generate_xml.cc - step/rds/step_wgt_rds_modify.cc step/security/step_add_default_privileges.cc step/security/step_check_settings_level.cc step/security/step_check_wgt_background_category.cc diff --git a/src/wgt/step/configuration/step_check_rds_manifest.cc b/src/wgt/step/configuration/step_check_rds_manifest.cc new file mode 100644 index 0000000..560f015 --- /dev/null +++ b/src/wgt/step/configuration/step_check_rds_manifest.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache 2.0 license that can be +// found in the LICENSE file. + +#include "wgt/step/configuration/step_check_rds_manifest.h" + +#include +#include +#include + +namespace bf = boost::filesystem; +namespace bs = boost::system; + +namespace { + +const char kConfigInstalled[] = "res/wgt/config.xml"; +const char kConfigDeltaDir[] = "res/wgt/config.xml"; + +} // namespace + +namespace wgt { +namespace configuration { + +common_installer::Step::Status StepCheckRDSManifest::process() { + bf::path target = context_->unpacked_dir_path.get() / kConfigDeltaDir; + if (!bf::exists(target)) { + bf::path source = context_->root_application_path.get() / + context_->pkgid.get() / kConfigInstalled; + if (!bf::exists(source)) { + LOG(ERROR) << "Cannot find old manifest file"; + return Status::APP_DIR_ERROR; + } + bs::error_code error; + bf::create_directories(source.parent_path(), error); + if (error) { + LOG(ERROR) << "Failed to create directories for manifest file"; + return Status::APP_DIR_ERROR; + } + bf::copy_file(source, target, error); + if (error) { + LOG(ERROR) << "Failed to copy old manifest file"; + return Status::APP_DIR_ERROR; + } + } + return Status::OK; +} + +} // namespace configuration +} // namespace wgt diff --git a/src/wgt/step/configuration/step_check_rds_manifest.h b/src/wgt/step/configuration/step_check_rds_manifest.h new file mode 100644 index 0000000..ff5e06f --- /dev/null +++ b/src/wgt/step/configuration/step_check_rds_manifest.h @@ -0,0 +1,31 @@ +// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by an apache 2.0 license that can be +// found in the LICENSE file. + +#ifndef WGT_STEP_CONFIGURATION_STEP_CHECK_RDS_MANIFEST_H_ +#define WGT_STEP_CONFIGURATION_STEP_CHECK_RDS_MANIFEST_H_ + +#include + +#include +#include + +namespace wgt { +namespace configuration { + +class StepCheckRDSManifest : public common_installer::Step { + public: + using Step::Step; + + Status process() override; + Status clean() override { return Status::OK; } + Status undo() override { return Status::OK; } + Status precheck() override { return Status::OK; } + + STEP_NAME(CheckRDSManifest) +}; + +} // namespace configuration +} // namespace wgt + +#endif // WGT_STEP_CONFIGURATION_STEP_CHECK_RDS_MANIFEST_H_ diff --git a/src/wgt/step/rds/step_wgt_rds_modify.cc b/src/wgt/step/rds/step_wgt_rds_modify.cc deleted file mode 100644 index aa293e9..0000000 --- a/src/wgt/step/rds/step_wgt_rds_modify.cc +++ /dev/null @@ -1,23 +0,0 @@ -// 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 "wgt/step/rds/step_wgt_rds_modify.h" - -#include -#include - -#include -#include -#include - -namespace wgt { -namespace rds { - -std::string StepWgtRDSModify::GetAppPath() { - boost::filesystem::path p = context_->pkg_path.get() / "res" / "wgt"; - return p.string(); -} - -} // namespace rds -} // namespace wgt diff --git a/src/wgt/step/rds/step_wgt_rds_modify.h b/src/wgt/step/rds/step_wgt_rds_modify.h deleted file mode 100644 index 2812b5a..0000000 --- a/src/wgt/step/rds/step_wgt_rds_modify.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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 WGT_STEP_RDS_STEP_WGT_RDS_MODIFY_H_ -#define WGT_STEP_RDS_STEP_WGT_RDS_MODIFY_H_ - -#include -#include -#include - -#include -#include -#include - -#include "common/installer_context.h" - -namespace wgt { -namespace rds { - -/** - * \brief Step that apply RDS modification during reinstallation process - */ -class StepWgtRDSModify : public common_installer::rds::StepRDSModify { - public: - using StepRDSModify::StepRDSModify; - - /** - * \brief return app path - * - * \return std::string - */ - std::string GetAppPath() override; - - STEP_NAME(WgtRDSModify) -}; - -} // namespace rds -} // namespace wgt - -#endif // WGT_STEP_RDS_STEP_WGT_RDS_MODIFY_H_ diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 29e1d7e..4905e55 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -59,6 +59,8 @@ #include #include #include +#include +#include #include #include #include @@ -71,9 +73,8 @@ #include #include -#include -#include +#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" #include "wgt/step/encryption/step_encrypt_resources.h" @@ -86,7 +87,6 @@ #include "wgt/step/filesystem/step_wgt_resource_directory.h" #include "wgt/step/filesystem/step_wgt_update_package_directory.h" #include "wgt/step/pkgmgr/step_generate_xml.h" -#include "wgt/step/rds/step_wgt_rds_modify.h" #include "wgt/step/security/step_add_default_privileges.h" #include "wgt/step/security/step_check_settings_level.h" #include "wgt/step/security/step_check_wgt_background_category.h" @@ -214,8 +214,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) } case ci::RequestType::Reinstall: { AddStep(pkgmgr_); + AddStep(); AddStep( - wgt::configuration::StepParse::ConfigLocation::PACKAGE, false); + wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, false); AddStep(); AddStep(); AddStep(); @@ -226,7 +227,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4