Change order of some steps
[platform/core/appfw/wgt-backend.git] / src / wgt / wgt_installer.cc
index 337f446..32ba8d6 100755 (executable)
@@ -38,6 +38,7 @@
 #include <common/step/filesystem/step_recover_manifest.h>
 #include <common/step/filesystem/step_recover_external_storage.h>
 #include <common/step/filesystem/step_recover_storage_directories.h>
+#include <common/step/filesystem/step_recover_per_user_storage_directories.h>
 #include <common/step/filesystem/step_remove_files.h>
 #include <common/step/filesystem/step_remove_icons.h>
 #include <common/step/filesystem/step_remove_globalapp_symlinks.h>
@@ -91,6 +92,7 @@
 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
 #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h"
 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
+#include "wgt/step/filesystem/step_wgt_undo_patch_storage_directories.h"
 #include "wgt/step/filesystem/step_wgt_update_package_directory.h"
 #include "wgt/step/pkgmgr/step_generate_xml.h"
 #include "wgt/step/security/step_add_default_privileges.h"
@@ -113,6 +115,87 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
   /* treat the request */
   switch (pkgmgr_->GetRequestType()) {
     case ci::RequestType::Install : {
+      InstallSteps();
+      break;
+    }
+    case ci::RequestType::Update: {
+      UpdateSteps();
+      break;
+    }
+    case ci::RequestType::Uninstall: {
+      UninstallSteps();
+      break;
+    }
+    case ci::RequestType::Reinstall: {
+      ReinstallSteps();
+      break;
+    }
+    case ci::RequestType::Delta: {
+      DeltaSteps();
+      break;
+    }
+    case ci::RequestType::Recovery: {
+      RecoverySteps();
+      break;
+    }
+    case ci::RequestType::MountInstall: {
+      MountInstallSteps();
+      break;
+    }
+    case ci::RequestType::MountUpdate: {
+      MountUpdateSteps();
+      break;
+    }
+    case ci::RequestType::ManifestDirectInstall: {
+      ManifestDirectInstallSteps();
+      break;
+    }
+    case ci::RequestType::ManifestDirectUpdate: {
+      ManifestDirectUpdateSteps();
+      break;
+    }
+    case ci::RequestType::ReadonlyUpdateInstall: {
+      ReadonlyUpdateInstallSteps();
+      break;
+    }
+    case ci::RequestType::ReadonlyUpdateUninstall: {
+      ReadonlyUpdateUninstallSteps();
+      break;
+    }
+    case ci::RequestType::ManifestPartialInstall: {
+      ManifestPartialInstallSteps();
+      break;
+    }
+    case ci::RequestType::ManifestPartialUpdate: {
+      ManifestPartialUpdateSteps();
+      break;
+    }
+    case ci::RequestType::PartialUninstall: {
+      ManifestPartialUninstallSteps();
+      break;
+    }
+    case ci::RequestType::Move: {
+      MoveSteps();
+      break;
+    }
+    case ci::RequestType::EnablePkg: {
+      EnablePkgSteps();
+      break;
+    }
+    case ci::RequestType::DisablePkg: {
+      DisablePkgSteps();
+      break;
+    }
+    case ci::RequestType::MigrateExtImg: {
+      MigrateExtImgSteps();
+      break;
+    }
+    default: {
+      DefaultSteps();
+    }
+  }
+}
+  void WgtInstaller::InstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
       AddStep<wgt::configuration::StepParse>(
@@ -143,17 +226,17 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
       AddStep<wgt::security::StepCheckExtensionPrivileges>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
-      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRegisterApplication>();
+      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Install);
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
           wgt::filesystem::WgtAdditionalSharedDirs);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::Update: {
+  }
+
+  void WgtInstaller::UpdateSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
       AddStep<wgt::configuration::StepParse>(
@@ -188,16 +271,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
       AddStep<ci::filesystem::StepCopyStorageDirectories>();
       AddStep<wgt::security::StepCheckExtensionPrivileges>();
-      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::Uninstall: {
+  }
+
+  void WgtInstaller::UninstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::pkgmgr::StepCheckRemovable>();
@@ -221,9 +304,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::security::StepRevokeSecurity>();
       AddStep<ci::pkgmgr::StepRemoveManifest>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::Reinstall: {
+  }
+
+  void WgtInstaller::ReinstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<wgt::configuration::StepCheckRDSManifest>();
       AddStep<wgt::configuration::StepParse>(
@@ -244,9 +327,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::Delta: {
+  }
+
+  void WgtInstaller::DeltaSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
       AddStep<wgt::configuration::StepParse>(
@@ -257,6 +340,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::configuration::StepParsePreload>();
       AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::filesystem::StepEnableExternalMount>();
+      AddStep<wgt::filesystem::StepWgtUndoPatchStorageDirectories>();
       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
       AddStep<ci::filesystem::StepDisableExternalMount>();
       AddStep<wgt::configuration::StepCheckStartFiles>();
@@ -285,16 +369,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
       AddStep<ci::filesystem::StepCopyStorageDirectories>();
       AddStep<wgt::security::StepCheckExtensionPrivileges>();
-      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::Recovery: {
+  }
+
+  void WgtInstaller::RecoverySteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::recovery::StepOpenRecoveryFile>();
       AddStep<ci::configuration::StepParseManifest>(
@@ -305,15 +389,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::filesystem::StepRecoverManifest>();
       AddStep<ci::filesystem::StepRecoverExternalStorage>();
       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
+      AddStep<ci::filesystem::StepRecoverPerUserStorageDirectories>();
       AddStep<ci::filesystem::StepRecoverFiles>();
       AddStep<ci::mount::StepMountRecover>();
       AddStep<wgt::security::StepWgtRecoverSignature>();
-      AddStep<ci::pkgmgr::StepRecoverApplication>();
       AddStep<ci::filesystem::StepRecoverChangeOwner>();
       AddStep<ci::security::StepRecoverSecurity>();
-      break;
-    }
-    case ci::RequestType::MountInstall: {
+      AddStep<ci::pkgmgr::StepRecoverApplication>();
+  }
+
+  void WgtInstaller::MountInstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::mount::StepMountUnpacked>();
       AddStep<wgt::configuration::StepParse>(
@@ -343,17 +428,17 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<wgt::security::StepCheckExtensionPrivileges>();
-      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRegisterApplication>();
+      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Install);
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
           wgt::filesystem::WgtAdditionalSharedDirs);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::MountUpdate: {
+  }
+
+  void WgtInstaller::MountUpdateSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::mount::StepMountUnpacked>();
       AddStep<wgt::configuration::StepParse>(
@@ -385,16 +470,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::filesystem::StepCreateIcons>();
       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
       AddStep<wgt::security::StepCheckExtensionPrivileges>();
-      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::ManifestDirectInstall: {
+  }
+
+  void WgtInstaller::ManifestDirectInstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
@@ -412,16 +497,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<wgt::filesystem::StepWgtPatchIcons>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
-      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRegisterApplication>();
+      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
           wgt::filesystem::WgtAdditionalSharedDirs);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::ManifestDirectUpdate: {
+  }
+
+  void WgtInstaller::ManifestDirectUpdateSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
@@ -439,18 +524,18 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::filesystem::StepCopyTep>();
-      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<wgt::filesystem::StepWgtPatchIcons>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::ReadonlyUpdateInstall: {
+  }
+
+  void WgtInstaller::ReadonlyUpdateInstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::filesystem::StepUnzip>();
       AddStep<wgt::configuration::StepParse>(
@@ -489,9 +574,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::ReadonlyUpdateUninstall: {
+  }
+
+  void WgtInstaller::ReadonlyUpdateUninstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::pkgmgr::StepCheckRemovable>();
@@ -514,26 +599,27 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRemoveManifest>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
-      break;
-    }
-    case ci::RequestType::ManifestPartialInstall: {
+  }
+
+  void WgtInstaller::ManifestPartialInstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
       AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
-      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRegisterApplication>();
+      AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
           wgt::filesystem::WgtAdditionalSharedDirs);
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::ManifestPartialUpdate: {
+  }
+
+  void WgtInstaller::ManifestPartialUpdateSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
@@ -541,18 +627,20 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+      AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>(
           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
-      AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
+      AddStep<ci::security::StepUpdateSecurity>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-      break;
-    }
-    case ci::RequestType::PartialUninstall: {
+  }
+
+  void WgtInstaller::ManifestPartialUninstallSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::pkgmgr::StepCheckRemovable>();
@@ -568,9 +656,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::pkgmgr::StepUnregisterApplication>();
       AddStep<wgt::encryption::StepRemoveEncryptionData>();
       AddStep<ci::security::StepRevokeSecurity>();
-      break;
-    }
-    case ci::RequestType::Move: {
+  }
+
+  void WgtInstaller::MoveSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
@@ -578,9 +666,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::filesystem::StepMoveInstalledStorage>();
       AddStep<ci::security::StepRegisterSecurity>();
-      break;
-    }
-    case ci::RequestType::EnablePkg: {
+  }
+
+  void WgtInstaller::EnablePkgSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
@@ -590,9 +678,9 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
         ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Enable);
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
         ci::Plugin::ActionType::Uninstall);
-      break;
-    }
-    case ci::RequestType::DisablePkg: {
+  }
+
+  void WgtInstaller::DisablePkgSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
@@ -602,18 +690,16 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
         ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Disable);
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
         ci::Plugin::ActionType::Uninstall);
-      break;
-    }
-    case ci::RequestType::MigrateExtImg: {
+  }
+
+  void WgtInstaller::MigrateExtImgSteps() {
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
       AddStep<ci::security::StepMigrateLegacyExtImage>();
       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
-      break;
-    }
-    default: {
+  }
+
+  void WgtInstaller::DefaultSteps() {
       AddStep<ci::configuration::StepFail>();
-    }
   }
-}
 
 }  // namespace wgt