From cc95a56f9b634aec29c42b7924cbe4c887b9a53e Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Mon, 5 Sep 2016 15:29:49 +0200 Subject: [PATCH] Fix double parsing of config.xml in delta wgt mode Fixed by add a optional delay in checking existence of start files and adding new step Requires: - https://review.tizen.org/gerrit/#/c/86941/ Change-Id: I9efed825d5f04af28493a6bd0003e3b9d6efb3c8 --- src/wgt/CMakeLists.txt | 1 + .../step/configuration/step_check_start_files.cc | 48 ++++++++++++++++++++++ .../step/configuration/step_check_start_files.h | 48 ++++++++++++++++++++++ src/wgt/step/configuration/step_parse.cc | 24 ++++++++--- src/wgt/wgt_backend_data.h | 4 ++ src/wgt/wgt_installer.cc | 6 +-- 6 files changed, 121 insertions(+), 10 deletions(-) create mode 100644 src/wgt/step/configuration/step_check_start_files.cc create mode 100644 src/wgt/step/configuration/step_check_start_files.h diff --git a/src/wgt/CMakeLists.txt b/src/wgt/CMakeLists.txt index fece9b1..3124963 100755 --- a/src/wgt/CMakeLists.txt +++ b/src/wgt/CMakeLists.txt @@ -1,5 +1,6 @@ # Target - sources SET(SRCS + step/configuration/step_check_start_files.cc step/configuration/step_parse.cc step/encryption/step_encrypt_resources.cc step/encryption/step_remove_encryption_data.cc diff --git a/src/wgt/step/configuration/step_check_start_files.cc b/src/wgt/step/configuration/step_check_start_files.cc new file mode 100644 index 0000000..7bf3ad6 --- /dev/null +++ b/src/wgt/step/configuration/step_check_start_files.cc @@ -0,0 +1,48 @@ +// 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/configuration/step_check_start_files.h" + +#include + +#include +#include +#include + +#include + +#include +#include + +namespace bf = boost::filesystem; + +namespace wgt { +namespace configuration { + +common_installer::Step::Status StepCheckStartFiles::process() { + bool flag = false; // it's not important in this step to use this flag + std::string error; + bool result_check = CheckStartFile(static_cast + (context_->backend_data.get())->content.get(), + context_->unpacked_dir_path.get(), + &flag); + if (!result_check) { + LOG(ERROR) << "Could not find valid start file"; + return common_installer::Step::Status::PARSE_ERROR; + } + + result_check = CheckServicesStartFiles(static_cast( + context_->backend_data.get())->service_list.get(), + context_->unpacked_dir_path.get(), + &error); + if (!result_check) { + LOG(ERROR) << error; + return common_installer::Step::Status::PARSE_ERROR; + } + + return common_installer::Step::Status::OK; +} + +} // namespace configuration +} // namespace wgt diff --git a/src/wgt/step/configuration/step_check_start_files.h b/src/wgt/step/configuration/step_check_start_files.h new file mode 100644 index 0000000..7fc7025 --- /dev/null +++ b/src/wgt/step/configuration/step_check_start_files.h @@ -0,0 +1,48 @@ +// 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_CHECK_START_FILES_H_ +#define WGT_STEP_CONFIGURATION_STEP_CHECK_START_FILES_H_ + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + +namespace wgt { +namespace configuration { + +/** + * \brief The StepCheckStartFiles class + * Checks if valid start files exists. + * It needs content info from wgt_backend_data. + * + * Step is used in delta mode. + */ +class StepCheckStartFiles : 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(CheckStartFiles) +}; + +} // namespace configuration +} // namespace wgt + +#endif // WGT_STEP_CONFIGURATION_STEP_CHECK_START_FILES_H_ diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index b2a12bf..0218240 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -650,15 +650,31 @@ common_installer::Step::Status StepParse::process() { LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage(); return common_installer::Step::Status::PARSE_ERROR; } + + WgtBackendData* backend_data = + static_cast(context_->backend_data.get()); + if (check_start_file_) { - if (!parser_->HasValidStartFile()) { + if (!parser_->CheckValidStartFile()) { LOG(ERROR) << parser_->GetErrorMessage(); return common_installer::Step::Status::PARSE_ERROR; } - if (!parser_->HasValidServicesStartFiles()) { + if (!parser_->CheckValidServicesStartFiles()) { LOG(ERROR) << parser_->GetErrorMessage(); return common_installer::Step::Status::PARSE_ERROR; } + } else { + // making backup of content data and services content data + auto content_info = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenContentKey); + auto service_list = + GetManifestDataForKey( + wgt::application_widget_keys::kTizenServiceKey); + if (content_info) + backend_data->content.set(*content_info); + if (service_list) + backend_data->service_list.set(*service_list); } manifest_x* manifest = @@ -711,9 +727,6 @@ common_installer::Step::Status StepParse::process() { if (perm_info) permissions = perm_info->GetAPIPermissions(); - WgtBackendData* backend_data = - static_cast(context_->backend_data.get()); - auto settings_info = GetManifestDataForKey( wgt::application_widget_keys::kTizenSettingKey); @@ -736,7 +749,6 @@ common_installer::Step::Status StepParse::process() { LOG(DEBUG) << " ]-"; LOG(DEBUG) << "]-"; - // TODO(t.iwanek): In delta mode this step is running two times if (context_->manifest_data.get()) pkgmgr_parser_free_manifest_xml(context_->manifest_data.get()); diff --git a/src/wgt/wgt_backend_data.h b/src/wgt/wgt_backend_data.h index 3d2791d..c36cbad 100644 --- a/src/wgt/wgt_backend_data.h +++ b/src/wgt/wgt_backend_data.h @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include @@ -28,6 +30,8 @@ class WgtBackendData : public common_installer::BackendData { Property settings; Property appwidgets; + Property content; + Property service_list; }; } // namespace wgt diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index b728742..282b3c0 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -72,6 +72,7 @@ #include #include +#include "wgt/step/configuration/step_check_start_files.h" #include "wgt/step/configuration/step_parse.h" #include "wgt/step/encryption/step_encrypt_resources.h" #include "wgt/step/encryption/step_remove_encryption_data.h" @@ -233,10 +234,8 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) case ci::RequestType::Delta: { AddStep(pkgmgr_); AddStep(); - // TODO(t.iwanek): manifest is parsed twice... AddStep( wgt::configuration::StepParse::ConfigLocation::PACKAGE, false); - // start file may not have changed AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::BACKUP); @@ -244,8 +243,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep("res/wgt/"); AddStep(); - AddStep( - wgt::configuration::StepParse::ConfigLocation::PACKAGE, true); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4