Patch reinstall/RDS according to SDK behaviour 30/91430/3 accepted/tizen/3.0/ivi/20161028.123107 accepted/tizen/3.0/mobile/20161028.122418 accepted/tizen/3.0/tv/20161028.122639 accepted/tizen/3.0/wearable/20161028.122904 accepted/tizen/common/20161013.155647 accepted/tizen/ivi/20161014.074156 accepted/tizen/mobile/20161014.074052 accepted/tizen/tv/20161014.074117 accepted/tizen/wearable/20161014.074135 submit/tizen/20161012.122424 submit/tizen_3.0/20161028.062323 submit/tizen_3.0/20161028.082323 submit/tizen_3.0_common/20161104.104000
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 7 Oct 2016 08:04:20 +0000 (10:04 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Fri, 7 Oct 2016 12:57:05 +0000 (14:57 +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: I20bf9195dfa17dc449a9ba790308eef47bc126b5

src/tpk/CMakeLists.txt
src/tpk/step/configuration/step_check_reinstall_manifest.cc [new file with mode: 0644]
src/tpk/step/configuration/step_check_reinstall_manifest.h [new file with mode: 0644]
src/tpk/step/rds/step_tpk_rds_modify.cc [deleted file]
src/tpk/step/rds/step_tpk_rds_modify.h [deleted file]
src/tpk/tpk_installer.cc
src/unit_tests/smoke_test.cc

index b818d1b..5df1cc4 100644 (file)
@@ -1,6 +1,7 @@
 SET(SRCS
   external_dirs.cc
   step/configuration/step_adjust_install_location.cc
+  step/configuration/step_check_reinstall_manifest.cc
   step/filesystem/step_check_pkg_directory_path.cc
   step/filesystem/step_create_external_storage_directories.cc
   step/filesystem/step_create_symbolic_link.cc
@@ -12,7 +13,6 @@ SET(SRCS
   step/filesystem/step_update_external_storage_directories.cc
   step/pkgmgr/step_convert_xml.cc
   step/pkgmgr/step_manifest_adjustment.cc
-  step/rds/step_tpk_rds_modify.cc
   step/security/step_check_tpk_background_category.cc
   step/security/step_tpk_recover_signature.cc
   tpk_app_query_interface.cc
diff --git a/src/tpk/step/configuration/step_check_reinstall_manifest.cc b/src/tpk/step/configuration/step_check_reinstall_manifest.cc
new file mode 100644 (file)
index 0000000..22b13c9
--- /dev/null
@@ -0,0 +1,43 @@
+// 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 "tpk/step/configuration/step_check_reinstall_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 kManifest[] = "tizen-manifest.xml";
+
+}  // namespace
+
+namespace tpk {
+namespace configuration {
+
+common_installer::Step::Status StepCheckReinstallManifest::process() {
+  bf::path target = context_->unpacked_dir_path.get() / kManifest;
+  if (!bf::exists(target)) {
+    bf::path source = context_->root_application_path.get() /
+        context_->pkgid.get() / kManifest;
+    if (!bf::exists(source)) {
+      LOG(ERROR) << "Cannot find old manifest file";
+      return Status::APP_DIR_ERROR;
+    }
+    bs::error_code 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 tpk
diff --git a/src/tpk/step/configuration/step_check_reinstall_manifest.h b/src/tpk/step/configuration/step_check_reinstall_manifest.h
new file mode 100644 (file)
index 0000000..b5e5647
--- /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 TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_
+#define TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <common/installer_context.h>
+#include <common/step/step.h>
+
+namespace tpk {
+namespace configuration {
+
+class StepCheckReinstallManifest : 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(CheckReinstallManifest)
+};
+
+}  // namespace configuration
+}  // namespace tpk
+
+#endif  // TPK_STEP_CONFIGURATION_STEP_CHECK_REINSTALL_MANIFEST_H_
diff --git a/src/tpk/step/rds/step_tpk_rds_modify.cc b/src/tpk/step/rds/step_tpk_rds_modify.cc
deleted file mode 100644 (file)
index 94c5a14..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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 "tpk/step/rds/step_tpk_rds_modify.h"
-
-namespace tpk {
-namespace rds {
-
-std::string StepTpkRDSModify::GetAppPath() {
-  return context_->pkg_path.get().string();
-}
-
-}  // namespace rds
-}  // namespace tpk
diff --git a/src/tpk/step/rds/step_tpk_rds_modify.h b/src/tpk/step/rds/step_tpk_rds_modify.h
deleted file mode 100644 (file)
index cc1b404..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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 TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
-#define TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
-
-#include <boost/filesystem.hpp>
-
-#include <common/step/step.h>
-#include <common/installer_context.h>
-#include <common/step/rds/step_rds_modify.h>
-
-#include <string>
-#include <utility>
-#include <vector>
-
-namespace tpk {
-namespace rds {
-
-/**
- * \brief Step that apply RDS modification during reinstallation process of tpk
- */
-class StepTpkRDSModify : public common_installer::rds::StepRDSModify {
-  using StepRDSModify::StepRDSModify;
-
- protected:
-  std::string GetAppPath() override;
-
-  STEP_NAME(TpkRDSModify)
-};
-
-}  // namespace rds
-}  // namespace tpk
-
-#endif  // TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
index 6297574..0e9f442 100644 (file)
@@ -55,6 +55,7 @@
 #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>
@@ -68,6 +69,7 @@
 #include <common/step/security/step_update_security.h>
 
 #include "tpk/step/configuration/step_adjust_install_location.h"
+#include "tpk/step/configuration/step_check_reinstall_manifest.h"
 #include "tpk/step/filesystem/step_create_external_storage_directories.h"
 #include "tpk/step/filesystem/step_create_symbolic_link.h"
 #include "tpk/step/filesystem/step_check_pkg_directory_path.h"
@@ -79,7 +81,6 @@
 #include "tpk/step/filesystem/step_update_external_storage_directories.h"
 #include "tpk/step/pkgmgr/step_convert_xml.h"
 #include "tpk/step/pkgmgr/step_manifest_adjustment.h"
-#include "tpk/step/rds/step_tpk_rds_modify.h"
 #include "tpk/step/security/step_check_tpk_background_category.h"
 #include "tpk/step/security/step_tpk_recover_signature.h"
 
@@ -252,6 +253,7 @@ void TpkInstaller::UninstallSteps() {
 
 void TpkInstaller::ReinstallSteps() {
   AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+  AddStep<tpk::configuration::StepCheckReinstallManifest>();
   AddStep<ci::configuration::StepParseManifest>(
      ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
      ci::configuration::StepParseManifest::StoreLocation::NORMAL);
@@ -271,7 +273,7 @@ void TpkInstaller::ReinstallSteps() {
   AddStep<ci::backup::StepBackupIcons>();
   AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
   AddStep<ci::rds::StepRDSParse>();
-  AddStep<tpk::rds::StepTpkRDSModify>();
+  AddStep<ci::rds::StepRDSModify>();
   AddStep<ci::filesystem::StepUpdateTep>();
   AddStep<tpk::filesystem::StepCreateSymbolicLink>();
   AddStep<tpk::filesystem::StepTpkPatchIcons>();
index c2ee18f..4713aac 100644 (file)
@@ -13,6 +13,7 @@
 #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>
@@ -337,14 +338,14 @@ ci::AppInstaller::Result DisablePackage(const std::string& path,
   return CallBackend(SIZEOFARRAY(argv), argv, 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,
                                    RequestResult mode = RequestResult::NORMAL) {
   if (Install(path) != 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, mode);
 }
@@ -453,7 +454,13 @@ TEST_F(SmokeTest, ReinstallMode_Tpk) {
   bf::path rds_directory = kSmokePackagesDirectory / "delta_dir";
   std::string pkgid = "smokeapp25";
   std::string appid = "smokeapp25.ReinstallModeTpk";
-  ASSERT_EQ(Reinstall(path, rds_directory), ci::AppInstaller::Result::OK);
+  bf::path sdk_expected_dir =
+      bf::path(ci::GetRootAppPath(false, kTestUserId)) / "tmp" / pkgid;
+  bs::error_code error;
+  bf::create_directories(sdk_expected_dir.parent_path(), error);
+  ASSERT_FALSE(error);
+  ASSERT_TRUE(ci::CopyDir(rds_directory, sdk_expected_dir));
+  ASSERT_EQ(RDSUpdate(path, pkgid), ci::AppInstaller::Result::OK);
   ValidatePackage(pkgid, appid);
 
   // Check rds modifications