Add new steps for readonly update 32/101832/6
authorSangyoon Jang <s89.jang@samsung.com>
Tue, 15 Nov 2016 05:30:45 +0000 (14:30 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 7 Dec 2016 06:36:26 +0000 (22:36 -0800)
Change-Id: Iff1ffcd4cecea510b4a91ab3d0730e9f09c30db5
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
src/wgt/CMakeLists.txt
src/wgt/step/configuration/step_parse.cc
src/wgt/step/configuration/step_set_old_signature_files_location.cc [new file with mode: 0644]
src/wgt/step/configuration/step_set_old_signature_files_location.h [new file with mode: 0644]
src/wgt/wgt_app_query_interface.h
src/wgt/wgt_installer.cc

index 678dc70..8b21686 100755 (executable)
@@ -3,6 +3,7 @@ SET(SRCS
   step/configuration/step_check_rds_manifest.cc
   step/configuration/step_check_start_files.cc
   step/configuration/step_parse.cc
+  step/configuration/step_set_old_signature_files_location.cc
   step/encryption/step_encrypt_resources.cc
   step/encryption/step_remove_encryption_data.cc
   step/filesystem/step_copy_preview_icons.cc
index 8fcbcec..d2908fa 100644 (file)
@@ -10,6 +10,7 @@
 #include <common/app_installer.h>
 #include <common/paths.h>
 #include <common/installer_context.h>
+#include <common/pkgmgr_query.h>
 #include <common/privileges.h>
 #include <common/step/step.h>
 #include <common/utils/glist_range.h>
@@ -45,6 +46,7 @@
 #include "wgt/wgt_backend_data.h"
 
 namespace bf = boost::filesystem;
+namespace ci = common_installer;
 
 namespace {
 
@@ -271,6 +273,18 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) {
     manifest->installlocation = strdup("auto");
   }
 
+  // set update true if package is updated preload package
+  ci::RequestType req_type = context_->request_type.get();
+  if (req_type == ci::RequestType::ReadonlyUpdateInstall)
+    manifest->update = strdup("true");
+  else if (req_type == ci::RequestType::ReadonlyUpdateUninstall)
+    manifest->update = strdup("false");
+  else if (ci::QueryIsUpdatedReadonlyPackage(context_->pkgid.get(),
+      context_->uid.get()))
+    manifest->update = strdup("true");
+  else
+    manifest->update = strdup("false");
+
   return true;
 }
 
diff --git a/src/wgt/step/configuration/step_set_old_signature_files_location.cc b/src/wgt/step/configuration/step_set_old_signature_files_location.cc
new file mode 100644 (file)
index 0000000..11ec209
--- /dev/null
@@ -0,0 +1,35 @@
+// 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/configuration/step_set_old_signature_files_location.h>
+
+#include <boost/filesystem/path.hpp>
+
+#include <common/installer_context.h>
+
+namespace bf = boost::filesystem;
+namespace ci = common_installer;
+
+namespace {
+
+const char kWgtPath[] = "res/wgt";
+
+}  // namespace
+
+namespace wgt {
+namespace configuration {
+
+ci::Step::Status StepSetOldSignatureFilesLocation::process() {
+  // This step is required for checking signature files at StepCheckSignature.
+  // StepCheckSignature gets path of signature files from unpacked_dir from
+  // unpacked_dir, which is root directory of package, but signature files
+  // are not at root directory.
+  bf::path oldpath = context_->unpacked_dir_path.get();
+  bf::path newpath = oldpath / kWgtPath;
+  context_->unpacked_dir_path.set(newpath);
+  return Status::OK;
+}
+
+}  // namespace configuration
+}  // namespace wgt
diff --git a/src/wgt/step/configuration/step_set_old_signature_files_location.h b/src/wgt/step/configuration/step_set_old_signature_files_location.h
new file mode 100644 (file)
index 0000000..4d8b5e4
--- /dev/null
@@ -0,0 +1,30 @@
+// 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_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_
+#define WGT_STEP_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <common/step/step.h>
+
+namespace wgt {
+namespace configuration {
+
+class StepSetOldSignatureFilesLocation : 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(SetOldSignatureFilesLocation)
+};
+
+}  // namespace configuration
+}  // namespace wgt
+
+#endif  // WGT_STEP_CONFIGURATION_STEP_SET_OLD_SIGNATURE_FILES_LOCATION_H_
index c7ca0ea..b8ed790 100644 (file)
@@ -36,6 +36,11 @@ class WgtAppQueryInterface : public common_installer::AppQueryInterface {
    */
   bool IsHybridApplication(const std::string& arg, uid_t uid);
 
+  /**
+   * \brief method for getting package id from package file
+   *
+   * \return package id
+   */
   std::string GetPkgId(const std::string& arg) override;
 };
 
index dcb6910..63d8906 100755 (executable)
@@ -16,6 +16,7 @@
 #include <common/step/configuration/step_fail.h>
 #include <common/step/configuration/step_parse_manifest.h>
 #include <common/step/configuration/step_parse_preload.h>
+#include <common/step/configuration/step_switch_readonly_mode.h>
 #include <common/step/filesystem/step_acquire_external_storage.h>
 #include <common/step/filesystem/step_optional_acquire_external_storage.h>
 #include <common/step/filesystem/step_change_owner.h>
@@ -79,6 +80,7 @@
 #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/configuration/step_set_old_signature_files_location.h"
 #include "wgt/step/encryption/step_encrypt_resources.h"
 #include "wgt/step/encryption/step_remove_encryption_data.h"
 #include "wgt/step/filesystem/step_copy_preview_icons.h"
@@ -449,6 +451,72 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     }
+    case ci::RequestType::ReadonlyUpdateInstall: {
+      AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::filesystem::StepUnzip>();
+      AddStep<wgt::configuration::StepParse>(
+          wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
+      AddStep<ci::security::StepCheckSignature>();
+      AddStep<ci::security::StepPrivilegeCompatibility>(
+          ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
+      AddStep<wgt::security::StepCheckSettingsLevel>();
+      AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
+      AddStep<wgt::security::StepCheckWgtNotificationCategory>();
+      AddStep<wgt::security::StepCheckWgtImePrivilege>();
+      AddStep<ci::security::StepCheckOldCertificate>();
+      AddStep<wgt::encryption::StepEncryptResources>();
+      AddStep<wgt::filesystem::StepWgtResourceDirectory>();
+      AddStep<ci::security::StepRollbackInstallationSecurity>();
+      AddStep<ci::configuration::StepSwitchReadonlyMode>();
+      AddStep<ci::configuration::StepParseManifest>(
+          ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+          ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+      AddStep<ci::configuration::StepSwitchReadonlyMode>();
+      AddStep<ci::configuration::StepBlockCrossUpdate>();
+      AddStep<ci::pkgmgr::StepKillApps>();
+      AddStep<ci::filesystem::StepCopy>();
+      AddStep<ci::filesystem::StepCopyTep>();
+      AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
+      AddStep<ci::filesystem::StepCreateStorageDirectories>();
+      AddStep<wgt::filesystem::StepCreateSymbolicLink>();
+      AddStep<wgt::filesystem::StepWgtPatchIcons>();
+      AddStep<wgt::filesystem::StepCopyPreviewIcons>();
+      AddStep<wgt::security::StepCheckExtensionPrivileges>();
+      AddStep<wgt::pkgmgr::StepGenerateXml>();
+      AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+      break;
+    }
+    case ci::RequestType::ReadonlyUpdateUninstall: {
+      AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::pkgmgr::StepCheckRestriction>();
+      AddStep<ci::pkgmgr::StepCheckRemovable>();
+      AddStep<ci::configuration::StepParseManifest>(
+          ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+          ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+      AddStep<ci::configuration::StepSwitchReadonlyMode>();
+      AddStep<ci::configuration::StepParseManifest>(
+          ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+          ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+      AddStep<wgt::configuration::StepSetOldSignatureFilesLocation>();
+      AddStep<ci::security::StepCheckSignature>();
+      AddStep<ci::configuration::StepSwitchReadonlyMode>();
+      AddStep<ci::pkgmgr::StepKillApps>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+      AddStep<ci::filesystem::StepRemoveTep>();
+      AddStep<ci::filesystem::StepRemoveFiles>();
+      AddStep<ci::filesystem::StepRemoveZipImage>();
+      AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::pkgmgr::StepRemoveManifest>();
+      AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+      break;
+    }
     case ci::RequestType::Move: {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::configuration::StepParseManifest>(