Implement reinstall request handling 55/64655/7
authorTomasz Iwanek <t.iwanek@samsung.com>
Mon, 4 Apr 2016 12:10:22 +0000 (14:10 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Thu, 7 Apr 2016 09:21:49 +0000 (02:21 -0700)
Requires:
 - https://review.tizen.org/gerrit/#/c/64662/

To verify, run new smoke test:
 /usr/bin/tpk-backend-ut/smoke-test --gtest_filter="*Reinstall*"

Change-Id: I59112f8a290674548f45a63988d5cceb1954d5ea

src/tpk/CMakeLists.txt
src/tpk/step/rds/step_tpk_rds_modify.cc [new file with mode: 0644]
src/tpk/step/rds/step_tpk_rds_modify.h [new file with mode: 0644]
src/tpk/tpk_installer.cc
src/unit_tests/smoke_test.cc
src/unit_tests/test_samples/smoke/ReinstallMode_Tpk.tpk [new file with mode: 0644]
src/unit_tests/test_samples/smoke/delta_dir/.rds_delta [new file with mode: 0644]
src/unit_tests/test_samples/smoke/delta_dir/ADDED [new file with mode: 0644]
src/unit_tests/test_samples/smoke/delta_dir/MODIFIED [new file with mode: 0644]
src/unit_tests/test_samples/smoke/delta_dir/tizen-manifest.xml [new file with mode: 0644]

index ffc4627..e562860 100644 (file)
@@ -5,6 +5,7 @@ SET(SRCS
   step/filesystem/step_tpk_patch_icons.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
   tpk_app_query_interface.cc
   tpk_installer.cc
diff --git a/src/tpk/step/rds/step_tpk_rds_modify.cc b/src/tpk/step/rds/step_tpk_rds_modify.cc
new file mode 100644 (file)
index 0000000..94c5a14
--- /dev/null
@@ -0,0 +1,15 @@
+// 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
new file mode 100644 (file)
index 0000000..387779c
--- /dev/null
@@ -0,0 +1,34 @@
+// 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;
+};
+
+}  // namespace rds
+}  // namespace tpk
+
+#endif // TPK_STEP_RDS_STEP_TPK_RDS_MODIFY_H_
index 371a65d..00b2587 100644 (file)
@@ -35,6 +35,7 @@
 #include <common/step/pkgmgr/step_unregister_app.h>
 #include <common/step/pkgmgr/step_update_app.h>
 #include <common/step/pkgmgr/step_update_tep.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>
@@ -52,6 +53,7 @@
 #include "tpk/step/filesystem/step_check_pkg_directory_path.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"
 
 namespace ci = common_installer;
@@ -187,7 +189,34 @@ void TpkInstaller::UninstallSteps() {
 }
 
 void TpkInstaller::ReinstallSteps() {
-  AddStep<ci::configuration::StepFail>();
+  AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+  AddStep<ci::configuration::StepParseManifest>(
+     ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+     ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+  AddStep<tpk::configuration::StepParsePreload>();
+  AddStep<ci::pkgmgr::StepCheckBlacklist>();
+  // TODO(t.iwanek): add StepCheckSignature which is missing
+  // this step is temporary removed because of validation problems as files
+  // not exising in signature but existing is fs will cause error (data files)
+  AddStep<ci::security::StepPrivilegeCompatibility>();
+  AddStep<tpk::security::StepCheckTpkBackgroundCategory>();
+  // TODO(t.iwanek): add StepCheckOldCertificate which is missing
+  AddStep<ci::configuration::StepParseManifest>(
+     ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+     ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+  AddStep<ci::pkgmgr::StepKillApps>();
+  AddStep<ci::backup::StepBackupManifest>();
+  AddStep<ci::backup::StepBackupIcons>();
+  AddStep<ci::rds::StepRDSParse>();
+  AddStep<tpk::rds::StepTpkRDSModify>();
+  AddStep<tpk::filesystem::StepCreateSymbolicLink>();
+  AddStep<tpk::filesystem::StepTpkPatchIcons>();
+  AddStep<ci::filesystem::StepCreateIcons>();
+  AddStep<ci::security::StepUpdateSecurity>();
+  AddStep<tpk::pkgmgr::StepConvertXml>();
+  AddStep<tpk::pkgmgr::StepManifestAdjustment>();
+  AddStep<ci::pkgmgr::StepUpdateApplication>();
+  AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
 }
 
 void TpkInstaller::DeltaSteps() {
index 79098d2..ede698e 100644 (file)
@@ -382,6 +382,23 @@ TEST_F(SmokeTest, DeltaMode_Tpk) {
   ValidateFileContentInPackage(pkgid, "MODIFIED", "version 2\n");
 }
 
+TEST_F(SmokeTest, ReinstallMode_Tpk) {
+  bf::path path = kSmokePackagesDirectory / "ReinstallMode_Tpk.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);
+  ValidatePackage(pkgid, appid);
+
+  // Check rds modifications
+  bf::path root_path = ci::GetRootAppPath(false);
+  ASSERT_FALSE(bf::exists(root_path / pkgid / "DELETED"));
+  ASSERT_TRUE(bf::exists(root_path / pkgid / "ADDED"));
+  ASSERT_TRUE(bf::exists(root_path / pkgid / "bin" / "native"));
+  ASSERT_TRUE(bf::exists(root_path / pkgid / "shared" / "res" / "native.png"));
+  ValidateFileContentInPackage(pkgid, "MODIFIED", "version 2\n");
+}
+
 TEST_F(SmokeTest, InstallationMode_Tpk) {
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Tpk.tpk";
   std::string pkgid = "smokeapp12";
diff --git a/src/unit_tests/test_samples/smoke/ReinstallMode_Tpk.tpk b/src/unit_tests/test_samples/smoke/ReinstallMode_Tpk.tpk
new file mode 100644 (file)
index 0000000..e57cdcc
Binary files /dev/null and b/src/unit_tests/test_samples/smoke/ReinstallMode_Tpk.tpk differ
diff --git a/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta b/src/unit_tests/test_samples/smoke/delta_dir/.rds_delta
new file mode 100644 (file)
index 0000000..fb08dcc
--- /dev/null
@@ -0,0 +1,6 @@
+#add
+ADDED
+#modify
+MODIFIED
+#delete
+DELETED
diff --git a/src/unit_tests/test_samples/smoke/delta_dir/ADDED b/src/unit_tests/test_samples/smoke/delta_dir/ADDED
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/unit_tests/test_samples/smoke/delta_dir/MODIFIED b/src/unit_tests/test_samples/smoke/delta_dir/MODIFIED
new file mode 100644 (file)
index 0000000..1f7a7a4
--- /dev/null
@@ -0,0 +1 @@
+version 2
diff --git a/src/unit_tests/test_samples/smoke/delta_dir/tizen-manifest.xml b/src/unit_tests/test_samples/smoke/delta_dir/tizen-manifest.xml
new file mode 100644 (file)
index 0000000..4777c0c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3" package="smokeapp25" version="1.0.0">
+    <profile name="mobile"/>
+    <ui-application appid="smokeapp25.ReinstallModeTpk" exec="native" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+        <label>native</label>
+        <icon>native.png</icon>
+    </ui-application>
+</manifest>