Patch reinstall/RDS according to SDK behaviour 31/91431/3 accepted/tizen/common/20161013.155648 accepted/tizen/ivi/20161014.074158 accepted/tizen/mobile/20161014.074054 accepted/tizen/tv/20161014.074118 accepted/tizen/wearable/20161014.074137 submit/tizen/20161012.122424
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 7 Oct 2016 08:56:10 +0000 (10:56 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 7 Oct 2016 12:56:26 +0000 (14:56 +0200)
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: I7a5008c6a5d9d28f4181a0be92d42dc9c8e57e28

src/unit_tests/smoke_test.cc
src/unit_tests/test_samples/smoke/delta_dir/.rds_delta
src/unit_tests/test_samples/smoke/delta_dir/res/wgt/ADDED [moved from src/unit_tests/test_samples/smoke/delta_dir/ADDED with 100% similarity]
src/unit_tests/test_samples/smoke/delta_dir/res/wgt/MODIFIED [moved from src/unit_tests/test_samples/smoke/delta_dir/MODIFIED with 100% similarity]
src/unit_tests/test_samples/smoke/delta_dir/res/wgt/config.xml [moved from src/unit_tests/test_samples/smoke/delta_dir/config.xml with 100% similarity]
src/wgt/CMakeLists.txt
src/wgt/step/configuration/step_check_rds_manifest.cc [new file with mode: 0644]
src/wgt/step/configuration/step_check_rds_manifest.h [new file with mode: 0644]
src/wgt/step/rds/step_wgt_rds_modify.cc [deleted file]
src/wgt/step/rds/step_wgt_rds_modify.h [deleted file]
src/wgt/wgt_installer.cc

index 48c6045..ec1ab9d 100644 (file)
@@ -6,13 +6,16 @@
 #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>
@@ -334,15 +337,15 @@ ci::AppInstaller::Result Uninstall(const std::string& pkgid,
   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);
 }
@@ -493,10 +496,16 @@ TEST_F(SmokeTest, DeinstallationMode) {
 
 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});
 
index fb08dcc..7467bbe 100644 (file)
@@ -1,6 +1,6 @@
 #add
-ADDED
+res/wgt/ADDED
 #modify
-MODIFIED
+res/wgt/MODIFIED
 #delete
-DELETED
+res/wgt/DELETED
index 3124963..678dc70 100755 (executable)
@@ -1,5 +1,6 @@
 # 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
@@ -12,7 +13,6 @@ SET(SRCS
   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
diff --git a/src/wgt/step/configuration/step_check_rds_manifest.cc b/src/wgt/step/configuration/step_check_rds_manifest.cc
new file mode 100644 (file)
index 0000000..560f015
--- /dev/null
@@ -0,0 +1,49 @@
+// 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
diff --git a/src/wgt/step/configuration/step_check_rds_manifest.h b/src/wgt/step/configuration/step_check_rds_manifest.h
new file mode 100644 (file)
index 0000000..ff5e06f
--- /dev/null
@@ -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 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_
diff --git a/src/wgt/step/rds/step_wgt_rds_modify.cc b/src/wgt/step/rds/step_wgt_rds_modify.cc
deleted file mode 100644 (file)
index aa293e9..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
diff --git a/src/wgt/step/rds/step_wgt_rds_modify.h b/src/wgt/step/rds/step_wgt_rds_modify.h
deleted file mode 100644 (file)
index 2812b5a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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_
index 29e1d7e..4905e55 100755 (executable)
@@ -59,6 +59,8 @@
 #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>
@@ -71,9 +73,8 @@
 #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"
@@ -86,7 +87,6 @@
 #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"
@@ -214,8 +214,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
     }
     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>();
@@ -226,7 +227,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       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>();