# Target - sources
SET(SRCS
- rds_parser.cc
step/configuration/step_parse.cc
step/configuration/step_parse_recovery.cc
step/encryption/step_encrypt_resources.cc
step/filesystem/step_wgt_patch_storage_directories.cc
step/filesystem/step_wgt_resource_directory.cc
step/pkgmgr/step_generate_xml.cc
- step/rds/step_rds_modify.cc
- step/rds/step_rds_parse.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
+++ /dev/null
-// Copyright (c) 2015 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/rds_parser.h"
-
-#include <fstream>
-
-namespace {
-const char kAdd[] = "#add";
-const char kModify[] = "#modify";
-const char kDelete[] = "#delete";
-}
-
-namespace wgt {
-namespace rds_parser {
-
-RDSParser::RDSParser(const std::string& path_to_delta)
- : path_to_delta_(path_to_delta) {}
-
-bool RDSParser::Parse() {
- std::vector<std::string>* current_container = nullptr;
- std::string line;
-
- std::ifstream file_to_parse(path_to_delta_);
- if (!file_to_parse.is_open())
- return false;
- while (getline(file_to_parse, line)) {
- if (line.compare(kDelete) == 0) {
- current_container = &files_to_delete_;
- continue;
- }
- if (line.compare(kAdd) == 0) {
- current_container = &files_to_add_;
- continue;
- }
- if (line.compare(kModify) == 0) {
- current_container = &files_to_modify_;
- continue;
- }
- if (current_container)
- current_container->push_back(line);
- }
- file_to_parse.close();
- return true;
-}
-
-const std::vector<std::string>& RDSParser::files_to_modify() const {
- return files_to_modify_;
-}
-
-const std::vector<std::string>& RDSParser::files_to_add() const {
- return files_to_add_;
-}
-
-const std::vector<std::string>& RDSParser::files_to_delete() const {
- return files_to_delete_;
-}
-
-} // namespace rds_parser
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2015 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_RDS_PARSER_H_
-#define WGT_RDS_PARSER_H_
-
-#include <string>
-#include <vector>
-namespace wgt {
-namespace rds_parser {
-
-/**
- * \brief Parse RDS config file
- */
-class RDSParser {
- public:
- /**
- * \brief Explicit constructor
- *
- * \param path_to_delta path to directory
- */
- explicit RDSParser(const std::string& path_to_delta);
-
- /**
- * \brief Parse package xml
- *
- * \return true if parsing was successful
- */
- bool Parse();
-
- /**
- * \brief Accessor to vector of files to modify
- *
- * \return files to modify
- */
- const std::vector<std::string>& files_to_modify() const;
-
- /**
- * \brief Accessor to vector of files to add
- *
- * \return files to add
- */
- const std::vector<std::string>& files_to_add() const;
-
- /**
- * \brief Accessor to vector of files to delete
- *
- * \return files to delete
- */
- const std::vector<std::string>& files_to_delete() const;
-
- private:
- std::string path_to_delta_;
- std::vector<std::string> files_to_modify_;
- std::vector<std::string> files_to_add_;
- std::vector<std::string> files_to_delete_;
-};
-
-} // namespace rds_parser
-} // namespace wgt
-
-#endif // WGT_RDS_PARSER_H_
+++ /dev/null
-// Copyright (c) 2015 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_rds_modify.h"
-
-#include <boost/system/error_code.hpp>
-
-#include <manifest_parser/utils/logging.h>
-
-#include <common/utils/file_util.h>
-
-namespace wgt {
-namespace rds {
-
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace cu = common_installer;
-
-StepRDSModify::StepRDSModify(common_installer::InstallerContext* context)
- : Step(context),
- backend_data_(nullptr) {}
-
-common_installer::Step::Status StepRDSModify::precheck() {
- if (context_->unpacked_dir_path.get().empty()) {
- LOG(ERROR) << "unpacked dir path is not set";
- return common_installer::Step::Status::INVALID_VALUE;
- }
- if (!bf::exists(context_->unpacked_dir_path.get())) {
- LOG(ERROR) << "unpacked_dir_path ("
- << context_->unpacked_dir_path.get()
- << ") path does not exist";
- return common_installer::Step::Status::INVALID_VALUE;
- }
- if (context_->pkgid.get().empty()) {
- LOG(ERROR) << "pkgid is not set";
- return common_installer::Step::Status::PACKAGE_NOT_FOUND;
- }
- if (!context_->manifest_data.get()) {
- LOG(ERROR) << "no manifest info available";
- return common_installer::Step::Status::INVALID_VALUE;
- }
- // TODO(w.kosowicz): check if config of installed app was encrypted
- backend_data_ = static_cast<WgtBackendData*>(context_->backend_data.get());
- if (!backend_data_) {
- LOG(ERROR) << "no backend data";
- return common_installer::Step::Status::ERROR;
- }
- return common_installer::Step::Status::OK;
-}
-
-common_installer::Step::Status StepRDSModify::process() {
- LOG(INFO) << "entered process of step modify";
- if (!SetUpTempBackupDir()) {
- LOG(ERROR) << "unable to setup temp directory";
- return common_installer::Step::Status::ERROR;
- }
- context_->pkg_path.set(
- context_->root_application_path.get() /context_->pkgid.get());
- bf::path install_path = context_->pkg_path.get() / "res" / "wgt";
- bf::path unzip_path = context_->unpacked_dir_path.get();
- if (!AddFiles(unzip_path, install_path) ||
- !ModifyFiles(unzip_path, install_path) ||
- !DeleteFiles(install_path)) {
- LOG(ERROR) << "error during file operation";
- return common_installer::Step::Status::ERROR;
- }
- return common_installer::Step::Status::OK;
-}
-
-common_installer::Step::Status StepRDSModify::undo() {
- RestoreFiles();
- return common_installer::Step::Status::OK;
-}
-
-common_installer::Step::Status StepRDSModify::clean() {
- if (bf::exists(backup_temp_dir_))
- bf::remove_all(backup_temp_dir_);
- return common_installer::Step::Status::OK;
-}
-
-bool StepRDSModify::AddFiles(bf::path unzip_path, bf::path install_path) {
- LOG(INFO) << "about to add files";
- bs::error_code error;
- for (const auto& file : backend_data_->files_to_add.get()) {
- if (!PerformBackup(file, Operation::ADD)) {
- LOG(ERROR) << "unable to perform backup of added file";
- return false;
- }
- bf::path temp_install_path(install_path / file);
- if (bf::is_directory(temp_install_path)) {
- if (!bf::exists(temp_install_path) &&
- (!cu::CreateDir(temp_install_path))) {
- LOG(ERROR) << "unable to create dir for temp backup data";
- return false;
- }
- } else {
- if (!bf::exists(temp_install_path.parent_path()) &&
- !cu::CreateDir(temp_install_path.parent_path())) {
- LOG(ERROR) << "unable to create dir for temp backup data";
- return false;
- }
- bf::path temp_unzip_path(unzip_path / file);
- bf::copy_file(temp_unzip_path, temp_install_path, error);
- if (error) {
- LOG(ERROR) << "unable to add file " << error.message();
- return false;
- }
- }
- }
- return true;
-}
-
-bool StepRDSModify::ModifyFiles(bf::path unzip_path, bf::path install_path) {
- LOG(INFO) << "about to modify files";
- bs::error_code error;
- for (const auto& file : backend_data_->files_to_modify.get()) {
- bf::path temp_install_path(install_path / file);
- bf::path temp_unzip_path(unzip_path / file);
- if (!PerformBackup(file, Operation::MODIFY)) {
- LOG(ERROR) << "unable to perform backup of to be modified file";
- return false;
- }
- bf::copy_file(temp_unzip_path, temp_install_path,
- bf::copy_option::overwrite_if_exists, error);
- if (error) {
- LOG(ERROR) << "unable to modify file " << error.message();
- return false;
- }
- }
- return true;
-}
-
-bool StepRDSModify::DeleteFiles(bf::path install_path) {
- LOG(INFO) << "about to delete files";
- bs::error_code error;
- for (const auto& file : backend_data_->files_to_delete.get()) {
- if (!PerformBackup(file, Operation::DELETE)) {
- LOG(ERROR) << "unable to perform backup of to be deleted file";
- return false;
- }
- bf::remove(install_path / file, error);
- if (error) {
- LOG(ERROR) <<"unable to delete files " << error.message();
- return false;
- }
- }
- return true;
-}
-
-bool StepRDSModify::SetUpTempBackupDir() {
- LOG(INFO) << "about to setup tmp backup dir";
- bs::error_code error;
- backup_temp_dir_ = "/tmp/" /
- bf::unique_path("%%%%-%%%%-%%%%-%%%%", error);
- if (error || !cu::CreateDir(backup_temp_dir_)) {
- LOG(ERROR) << "unable to create backup data temp dir";
- return false;
- }
-
- return true;
-}
-
-bool StepRDSModify::PerformBackup(std::string relative_path,
- Operation operation) {
- if (backup_temp_dir_.empty())
- return false;
- if (operation == Operation::DELETE || operation == Operation::MODIFY) {
- bf::path app_path = context_->pkg_path.get() / "res" / "wgt";
- bf::path source_path = app_path / relative_path;
- if (bf::is_directory(source_path)) {
- if (!cu::CreateDir(backup_temp_dir_ / relative_path)) {
- LOG(ERROR) << "unable to create dir for temp backup data";
- return false;
- }
- } else {
- bs::error_code error;
- bf::path tmp_dest_path = backup_temp_dir_ / relative_path;
- if (!bf::exists((tmp_dest_path).parent_path()) &&
- (!cu::CreateDir((tmp_dest_path).parent_path()))) {
- LOG(ERROR) << "unable to create dir for temp backup data";
- return false;
- }
- bf::copy_file(source_path, tmp_dest_path, error);
- if (error) {
- LOG(ERROR) << "unable to backup file: "
- << source_path << " : " << error.message();
- return false;
- }
- }
- }
- success_modifications_.push_back(std::make_pair(relative_path, operation));
- return true;
-}
-
-void StepRDSModify::RestoreFiles() {
- LOG(ERROR) << "error occured about to restore files";
- bf::path app_path(context_->pkg_path.get());
- for (std::pair<std::string, Operation>& modification :
- success_modifications_) {
- bf::path source_path(backup_temp_dir_ / modification.first);
- bf::path destination_path(app_path / modification.first);
- if (modification.second == Operation::ADD) {
- if (bf::is_directory(source_path)) {
- bf::remove_all(destination_path);
- } else {
- bf::remove(destination_path);
- }
- } else if (modification.second == Operation::MODIFY) {
- bf::copy_file(source_path, destination_path,
- bf::copy_option::overwrite_if_exists);
- } else {
- if (bf::is_directory(source_path)) {
- cu::CreateDir(destination_path);
- } else {
- bf::copy_file(source_path, destination_path,
- bf::copy_option::overwrite_if_exists);
- }
- }
- }
- // after files are restore delete temporary location
- bf::remove_all(backup_temp_dir_);
-}
-
-} // namespace rds
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2015 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_RDS_MODIFY_H_
-#define WGT_STEP_RDS_STEP_RDS_MODIFY_H_
-
-#include <boost/filesystem.hpp>
-#include <common/step/step.h>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "wgt/wgt_backend_data.h"
-
-namespace wgt {
-namespace rds {
-
-/**
- * \brief Step that apply RDS modification during reinstallation process
- */
-class StepRDSModify : public common_installer::Step {
- public:
- /**
- * \brief Explicit constructor
- *
- * \param context Installer context
- */
- explicit StepRDSModify(common_installer::InstallerContext* context);
-
- /**
- * \brief
- *
- * \return
- */
- Status process() override;
-
- /**
- * \brief Remove files from temporary location
- *
- * \return Status::OK
- */
- Status clean() override;
-
- /**
- * \brief Restore files to the state from before RDS installation
- *
- * \return Status::OK
- */
- Status undo() override;
-
- /**
- * \brief
- *
- * \return Status::ERROR when manifest is missing, pkgid is missing,
- * or when path to the unpacked directory is missing or not exist,
- * Status::OK otherwise
- */
- Status precheck() override;
-
- private:
- enum class Operation {
- ADD,
- MODIFY,
- DELETE
- };
-
- bool AddFiles(boost::filesystem::path unzip_path,
- boost::filesystem::path install_path);
- bool ModifyFiles(boost::filesystem::path unzip_path,
- boost::filesystem::path install_path);
- bool DeleteFiles(boost::filesystem::path install_path);
- bool SetUpTempBackupDir();
- void DeleteTempBackupDir();
- bool PerformBackup(std::string relative_path, Operation operation);
- void RestoreFiles();
-
- WgtBackendData* backend_data_;
- std::vector<std::pair<std::string, Operation>> success_modifications_;
- boost::filesystem::path backup_temp_dir_;
- std::vector<std::string> files_to_modify_;
- std::vector<std::string> files_to_add_;
- std::vector<std::string> files_to_delete_;
-};
-} // namespace rds
-} // namespace wgt
-
-#endif // WGT_STEP_RDS_STEP_RDS_MODIFY_H_
+++ /dev/null
-// Copyright (c) 2015 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_rds_parse.h"
-
-#include <manifest_parser/utils/logging.h>
-
-#include <memory>
-
-#include "wgt/rds_parser.h"
-#include "wgt/wgt_backend_data.h"
-
-
-namespace wgt {
-namespace rds {
-
-namespace bf = boost::filesystem;
-
-common_installer::Step::Status StepRDSParse::precheck() {
- bf::path rdsPath(context_->unpacked_dir_path.get() / ".rds_delta");
- if (!bf::exists(rdsPath)) {
- LOG(ERROR) << "no rds_delta file";
- return common_installer::Step::Status::INVALID_VALUE;
- }
- rds_file_path_ = rdsPath;
- return common_installer::Step::Status::OK;
-}
-
-common_installer::Step::Status StepRDSParse::process() {
- wgt::rds_parser::RDSParser parser(rds_file_path_.native());
- if (!parser.Parse()) {
- LOG(ERROR) << "parsing of rds delta failed";
- return common_installer::Step::Status::PARSE_ERROR;
- }
-
- WgtBackendData* backend_data =
- static_cast<WgtBackendData*>(context_->backend_data.get());
- if (!backend_data) {
- LOG(ERROR) << "no wgt backend data available";
- return common_installer::Step::Status::PARSE_ERROR;
- }
- backend_data->files_to_modify.set(parser.files_to_modify());
- backend_data->files_to_add.set(parser.files_to_add());
- backend_data->files_to_delete.set(parser.files_to_delete());
- return common_installer::Step::Status::OK;
-}
-
-} // namespace rds
-} // namespace wgt
+++ /dev/null
-// Copyright (c) 2015 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_RDS_PARSE_H_
-#define WGT_STEP_RDS_STEP_RDS_PARSE_H_
-
-#include <common/step/step.h>
-
-#include <boost/filesystem.hpp>
-#include <string>
-#include <vector>
-
-namespace wgt {
-namespace rds {
-
-/**
- * \brief This step parse .rds_delta file
- *
- * This is to prepare RDS installation process
- */
-class StepRDSParse : public common_installer::Step {
- public:
- using Step::Step;
-
- /**
- * \brief Parse .rds_delta file
- *
- * \return Status::ERROR when wgt backend data are missing,
- * Status::OK otherwise
- */
- Status process() override;
-
- /**
- * \brief Empty method
- *
- * \return Status::OK
- */
- Status clean() override { return Status::OK; }
-
- /**
- * \brief Empty method
- *
- * \return Status::OK
- */
- Status undo() override { return Status::OK; }
-
- /**
- * \brief Validate if .rds_delta file exist
- *
- * \return Status::Error if file not exist,
- * Status::OK otherwise
- */
- Status precheck() override;
-
- private:
- boost::filesystem::path rds_file_path_;
-};
-
-} // namespace rds
-} // namespace wgt
-
-#endif // WGT_STEP_RDS_STEP_RDS_PARSE_H_
--- /dev/null
+// 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 <boost/filesystem.hpp>
+#include <pkgmgrinfo_basic.h>
+
+#include <cstdlib>
+#include <cstring>
+#include <memory>
+
+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
--- /dev/null
+// 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 <boost/filesystem.hpp>
+#include <common/step/step.h>
+#include <common/step/rds/step_rds_modify.h>
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#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;
+};
+
+} // rds
+} // wgt
+
+#endif // WGT_STEP_RDS_STEP_WGT_RDS_MODIFY_H_
class WgtBackendData : public common_installer::BackendData {
public:
/**
- * \brief Property of vector of files to add
- */
- Property<std::vector<std::string>> files_to_add;
-
- /**
- * \brief Property of vector of files to modify
- */
- Property<std::vector<std::string>> files_to_modify;
-
- /**
- * \brief Property of vector of files to delete
- */
- Property<std::vector<std::string>> files_to_delete;
-
- /**
* \brief Property of SettingInfo
*/
Property<parse::SettingInfo> settings;
#include <common/step/security/step_update_security.h>
#include <wgt_manifest_handlers/widget_config_parser.h>
+#include <common/step/rds/step_rds_modify.h>
+#include <common/step/rds/step_rds_parse.h>
#include "wgt/step/configuration/step_parse.h"
#include "wgt/step/configuration/step_parse_recovery.h"
#include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
#include "wgt/step/filesystem/step_wgt_resource_directory.h"
#include "wgt/step/pkgmgr/step_generate_xml.h"
-#include "wgt/step/rds/step_rds_modify.h"
-#include "wgt/step/rds/step_rds_parse.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"
ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
ci::configuration::StepParseManifest::StoreLocation::BACKUP);
AddStep<ci::pkgmgr::StepCheckBlacklist>();
- AddStep<wgt::rds::StepRDSParse>();
- AddStep<wgt::rds::StepRDSModify>();
+ AddStep<ci::rds::StepRDSParse>();
+ AddStep<wgt::rds::StepWgtRDSModify>();
AddStep<ci::security::StepUpdateSecurity>();
break;
}