From 1629a3589d9f0545115d72c67fceb412936c5a76 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 15 Nov 2016 14:30:45 +0900 Subject: [PATCH] Add new steps for readonly update Change-Id: Iff1ffcd4cecea510b4a91ab3d0730e9f09c30db5 Signed-off-by: Sangyoon Jang --- src/wgt/CMakeLists.txt | 1 + src/wgt/step/configuration/step_parse.cc | 14 +++++ .../step_set_old_signature_files_location.cc | 35 +++++++++++ .../step_set_old_signature_files_location.h | 30 ++++++++++ src/wgt/wgt_app_query_interface.h | 5 ++ src/wgt/wgt_installer.cc | 68 ++++++++++++++++++++++ 6 files changed, 153 insertions(+) create mode 100644 src/wgt/step/configuration/step_set_old_signature_files_location.cc create mode 100644 src/wgt/step/configuration/step_set_old_signature_files_location.h diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index 678dc70..8b21686 100755 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -3,6 +3,7 @@ SET(SRCS step/configuration/step_check_rds_manifest.cc step/configuration/step_check_start_files.cc step/configuration/step_parse.cc + step/configuration/step_set_old_signature_files_location.cc step/encryption/step_encrypt_resources.cc step/encryption/step_remove_encryption_data.cc step/filesystem/step_copy_preview_icons.cc diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 8fcbcec..d2908fa 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ #include "wgt/wgt_backend_data.h" namespace bf = boost::filesystem; +namespace ci = common_installer; namespace { @@ -271,6 +273,18 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->installlocation = strdup("auto"); } + // set update true if package is updated preload package + ci::RequestType req_type = context_->request_type.get(); + if (req_type == ci::RequestType::ReadonlyUpdateInstall) + manifest->update = strdup("true"); + else if (req_type == ci::RequestType::ReadonlyUpdateUninstall) + manifest->update = strdup("false"); + else if (ci::QueryIsUpdatedReadonlyPackage(context_->pkgid.get(), + context_->uid.get())) + manifest->update = strdup("true"); + else + manifest->update = strdup("false"); + return true; } diff --git a/src/wgt/step/configuration/step_set_old_signature_files_location.cc b/src/wgt/step/configuration/step_set_old_signature_files_location.cc new file mode 100644 index 0000000..11ec209 --- /dev/null +++ b/src/wgt/step/configuration/step_set_old_signature_files_location.cc @@ -0,0 +1,35 @@ +// 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 + +#include + +namespace bf = boost::filesystem; +namespace ci = common_installer; + +namespace { + +const char kWgtPath[] = "res/wgt"; + +} // namespace + +namespace wgt { +namespace configuration { + +ci::Step::Status StepSetOldSignatureFilesLocation::process() { + // This step is required for checking signature files at StepCheckSignature. + // StepCheckSignature gets path of signature files from unpacked_dir from + // unpacked_dir, which is root directory of package, but signature files + // are not at root directory. + bf::path oldpath = context_->unpacked_dir_path.get(); + bf::path newpath = oldpath / kWgtPath; + context_->unpacked_dir_path.set(newpath); + return Status::OK; +} + +} // namespace configuration +} // namespace wgt diff --git a/src/wgt/step/configuration/step_set_old_signature_files_location.h b/src/wgt/step/configuration/step_set_old_signature_files_location.h new file mode 100644 index 0000000..4d8b5e4 --- /dev/null +++ b/src/wgt/step/configuration/step_set_old_signature_files_location.h @@ -0,0 +1,30 @@ +// 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_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_ +#define WGT_STEP_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_ + +#include + +#include + +namespace wgt { +namespace configuration { + +class StepSetOldSignatureFilesLocation : 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(SetOldSignatureFilesLocation) +}; + +} // namespace configuration +} // namespace wgt + +#endif // WGT_STEP_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_ diff --git a/src/wgt/wgt_app_query_interface.h b/src/wgt/wgt_app_query_interface.h index c7ca0ea..b8ed790 100644 --- a/src/wgt/wgt_app_query_interface.h +++ b/src/wgt/wgt_app_query_interface.h @@ -36,6 +36,11 @@ class WgtAppQueryInterface : public common_installer::AppQueryInterface { */ bool IsHybridApplication(const std::string& arg, uid_t uid); + /** + * \brief method for getting package id from package file + * + * \return package id + */ std::string GetPkgId(const std::string& arg) override; }; diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index dcb6910..63d8906 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ #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/configuration/step_set_old_signature_files_location.h" #include "wgt/step/encryption/step_encrypt_resources.h" #include "wgt/step/encryption/step_remove_encryption_data.h" #include "wgt/step/filesystem/step_copy_preview_icons.h" @@ -449,6 +451,72 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); break; } + case ci::RequestType::ReadonlyUpdateInstall: { + AddStep(pkgmgr_); + AddStep(); + AddStep( + wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); + AddStep(); + AddStep(); + AddStep( + ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep( + ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, + ci::configuration::StepParseManifest::StoreLocation::BACKUP); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(ci::Plugin::ActionType::Upgrade); + AddStep(); + AddStep(); + break; + } + case ci::RequestType::ReadonlyUpdateUninstall: { + AddStep(pkgmgr_); + AddStep(); + AddStep(); + AddStep( + ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, + ci::configuration::StepParseManifest::StoreLocation::BACKUP); + AddStep(); + AddStep( + ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, + ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(); + AddStep(ci::Plugin::ActionType::Upgrade); + break; + } case ci::RequestType::Move: { AddStep(pkgmgr_); AddStep( -- 2.7.4