#include <boost/filesystem/path.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/system/error_code.hpp>
+
#include <common/paths.h>
#include <common/pkgmgr_interface.h>
#include <common/pkgmgr_query.h>
#include <common/request.h>
#include <common/step/configuration/step_fail.h>
#include <common/tzip_interface.h>
+#include <common/utils/file_util.h>
#include <common/utils/subprocess.h>
+
#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
#include <pkgmgr-info.h>
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);
}
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});
#add
-ADDED
+res/wgt/ADDED
#modify
-MODIFIED
+res/wgt/MODIFIED
#delete
-DELETED
+res/wgt/DELETED
# 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
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
--- /dev/null
+// 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 <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/system/error_code.hpp>
+
+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
--- /dev/null
+// 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 <manifest_parser/utils/logging.h>
+
+#include <common/installer_context.h>
+#include <common/step/step.h>
+
+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_
+++ /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;
-
- STEP_NAME(WgtRDSModify)
-};
-
-} // namespace rds
-} // namespace wgt
-
-#endif // WGT_STEP_RDS_STEP_WGT_RDS_MODIFY_H_
#include <common/step/pkgmgr/step_unregister_app.h>
#include <common/step/pkgmgr/step_update_app.h>
#include <common/step/pkgmgr/step_update_pkg_disable_info.h>
+#include <common/step/rds/step_rds_modify.h>
+#include <common/step/rds/step_rds_parse.h>
#include <common/step/recovery/step_open_recovery_file.h>
#include <common/step/security/step_check_old_certificate.h>
#include <common/step/security/step_check_signature.h>
#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_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"
#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"
}
case ci::RequestType::Reinstall: {
AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<wgt::configuration::StepCheckRDSManifest>();
AddStep<wgt::configuration::StepParse>(
- wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
+ wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, false);
AddStep<ci::pkgmgr::StepCheckRestriction>();
AddStep<ci::configuration::StepCheckTizenVersion>();
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
AddStep<ci::rds::StepRDSParse>();
AddStep<ci::filesystem::StepUpdateTep>();
- AddStep<wgt::rds::StepWgtRDSModify>();
+ AddStep<ci::rds::StepRDSModify>();
AddStep<wgt::security::StepCheckExtensionPrivileges>();
AddStep<ci::security::StepUpdateSecurity>();
AddStep<ci::filesystem::StepChangeOwner>();