From 8f15a2eb5b9209564ecaf86f6dde2f85b1751809 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Fri, 7 Oct 2016 10:04:20 +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: I20bf9195dfa17dc449a9ba790308eef47bc126b5 --- src/tpk/CMakeLists.txt | 2 +- .../configuration/step_check_reinstall_manifest.cc | 43 ++++++++++++++++++++++ .../configuration/step_check_reinstall_manifest.h | 31 ++++++++++++++++ src/tpk/step/rds/step_tpk_rds_modify.cc | 15 -------- src/tpk/step/rds/step_tpk_rds_modify.h | 36 ------------------ src/tpk/tpk_installer.cc | 6 ++- src/unit_tests/smoke_test.cc | 15 ++++++-- 7 files changed, 90 insertions(+), 58 deletions(-) create mode 100644 src/tpk/step/configuration/step_check_reinstall_manifest.cc create mode 100644 src/tpk/step/configuration/step_check_reinstall_manifest.h delete mode 100644 src/tpk/step/rds/step_tpk_rds_modify.cc delete mode 100644 src/tpk/step/rds/step_tpk_rds_modify.h diff --git a/src/tpk/CMakeLists.txt b/src/tpk/CMakeLists.txt index b818d1b..5df1cc4 100644 --- a/src/tpk/CMakeLists.txt +++ b/src/tpk/CMakeLists.txt @@ -1,6 +1,7 @@ SET(SRCS external_dirs.cc step/configuration/step_adjust_install_location.cc + step/configuration/step_check_reinstall_manifest.cc step/filesystem/step_check_pkg_directory_path.cc step/filesystem/step_create_external_storage_directories.cc step/filesystem/step_create_symbolic_link.cc @@ -12,7 +13,6 @@ SET(SRCS step/filesystem/step_update_external_storage_directories.cc step/pkgmgr/step_convert_xml.cc step/pkgmgr/step_manifest_adjustment.cc - step/rds/step_tpk_rds_modify.cc step/security/step_check_tpk_background_category.cc step/security/step_tpk_recover_signature.cc tpk_app_query_interface.cc diff --git a/src/tpk/step/configuration/step_check_reinstall_manifest.cc b/src/tpk/step/configuration/step_check_reinstall_manifest.cc new file mode 100644 index 0000000..22b13c9 --- /dev/null +++ b/src/tpk/step/configuration/step_check_reinstall_manifest.cc @@ -0,0 +1,43 @@ +// 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 "tpk/step/configuration/step_check_reinstall_manifest.h" + +#include +#include +#include + +namespace bf = boost::filesystem; +namespace bs = boost::system; + +namespace { + +const char kManifest[] = "tizen-manifest.xml"; + +} // namespace + +namespace tpk { +namespace configuration { + +common_installer::Step::Status StepCheckReinstallManifest::process() { + bf::path target = context_->unpacked_dir_path.get() / kManifest; + if (!bf::exists(target)) { + bf::path source = context_->root_application_path.get() / + context_->pkgid.get() / kManifest; + if (!bf::exists(source)) { + LOG(ERROR) << "Cannot find old manifest file"; + return Status::APP_DIR_ERROR; + } + bs::error_code 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 tpk diff --git a/src/tpk/step/configuration/step_check_reinstall_manifest.h b/src/tpk/step/configuration/step_check_reinstall_manifest.h new file mode 100644 index 0000000..b5e5647 --- /dev/null +++ b/src/tpk/step/configuration/step_check_reinstall_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 TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_ +#define TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_ + +#include + +#include +#include + +namespace tpk { +namespace configuration { + +class StepCheckReinstallManifest : 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(CheckReinstallManifest) +}; + +} // namespace configuration +} // namespace tpk + +#endif // TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_ diff --git a/src/tpk/step/rds/step_tpk_rds_modify.cc b/src/tpk/step/rds/step_tpk_rds_modify.cc deleted file mode 100644 index 94c5a14..0000000 --- a/src/tpk/step/rds/step_tpk_rds_modify.cc +++ /dev/null @@ -1,15 +0,0 @@ -// 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 "tpk/step/rds/step_tpk_rds_modify.h" - -namespace tpk { -namespace rds { - -std::string StepTpkRDSModify::GetAppPath() { - return context_->pkg_path.get().string(); -} - -} // namespace rds -} // namespace tpk diff --git a/src/tpk/step/rds/step_tpk_rds_modify.h b/src/tpk/step/rds/step_tpk_rds_modify.h deleted file mode 100644 index cc1b404..0000000 --- a/src/tpk/step/rds/step_tpk_rds_modify.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_ -#define TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_ - -#include - -#include -#include -#include - -#include -#include -#include - -namespace tpk { -namespace rds { - -/** - * \brief Step that apply RDS modification during reinstallation process of tpk - */ -class StepTpkRDSModify : public common_installer::rds::StepRDSModify { - using StepRDSModify::StepRDSModify; - - protected: - std::string GetAppPath() override; - - STEP_NAME(TpkRDSModify) -}; - -} // namespace rds -} // namespace tpk - -#endif // TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_ diff --git a/src/tpk/tpk_installer.cc b/src/tpk/tpk_installer.cc index 6297574..0e9f442 100644 --- a/src/tpk/tpk_installer.cc +++ b/src/tpk/tpk_installer.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,7 @@ #include #include "tpk/step/configuration/step_adjust_install_location.h" +#include "tpk/step/configuration/step_check_reinstall_manifest.h" #include "tpk/step/filesystem/step_create_external_storage_directories.h" #include "tpk/step/filesystem/step_create_symbolic_link.h" #include "tpk/step/filesystem/step_check_pkg_directory_path.h" @@ -79,7 +81,6 @@ #include "tpk/step/filesystem/step_update_external_storage_directories.h" #include "tpk/step/pkgmgr/step_convert_xml.h" #include "tpk/step/pkgmgr/step_manifest_adjustment.h" -#include "tpk/step/rds/step_tpk_rds_modify.h" #include "tpk/step/security/step_check_tpk_background_category.h" #include "tpk/step/security/step_tpk_recover_signature.h" @@ -252,6 +253,7 @@ void TpkInstaller::UninstallSteps() { void TpkInstaller::ReinstallSteps() { AddStep(pkgmgr_); + AddStep(); AddStep( ci::configuration::StepParseManifest::ManifestLocation::PACKAGE, ci::configuration::StepParseManifest::StoreLocation::NORMAL); @@ -271,7 +273,7 @@ void TpkInstaller::ReinstallSteps() { AddStep(); AddStep(); AddStep(); - AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index c2ee18f..4713aac 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -337,14 +338,14 @@ ci::AppInstaller::Result DisablePackage(const std::string& path, return CallBackend(SIZEOFARRAY(argv), argv, 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, RequestResult mode = RequestResult::NORMAL) { if (Install(path) != 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, mode); } @@ -453,7 +454,13 @@ TEST_F(SmokeTest, ReinstallMode_Tpk) { bf::path rds_directory = kSmokePackagesDirectory / "delta_dir"; std::string pkgid = "smokeapp25"; std::string appid = "smokeapp25.ReinstallModeTpk"; - ASSERT_EQ(Reinstall(path, rds_directory), ci::AppInstaller::Result::OK); + bf::path sdk_expected_dir = + bf::path(ci::GetRootAppPath(false, kTestUserId)) / "tmp" / pkgid; + bs::error_code error; + bf::create_directories(sdk_expected_dir.parent_path(), error); + ASSERT_FALSE(error); + ASSERT_TRUE(ci::CopyDir(rds_directory, sdk_expected_dir)); + ASSERT_EQ(RDSUpdate(path, pkgid), ci::AppInstaller::Result::OK); ValidatePackage(pkgid, appid); // Check rds modifications -- 2.7.4