Force uninstall for external storage packages
[platform/core/appfw/wgt-backend.git] / src / hybrid / hybrid_installer.cc
index 6dc43ca..ea2cc76 100644 (file)
@@ -8,18 +8,25 @@
 #include <common/step/backup/step_backup_manifest.h>
 #include <common/step/backup/step_copy_backup.h>
 #include <common/step/configuration/step_block_cross_update.h>
+#include <common/step/configuration/step_check_tizen_version.h>
 #include <common/step/configuration/step_configure.h>
 #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/filesystem/step_acquire_external_storage.h>
+#include <common/step/filesystem/step_optional_acquire_external_storage.h>
 #include <common/step/filesystem/step_clear_data.h>
+#include <common/step/filesystem/step_change_owner.h>
 #include <common/step/filesystem/step_copy.h>
 #include <common/step/filesystem/step_copy_storage_directories.h>
 #include <common/step/filesystem/step_copy_tep.h>
 #include <common/step/filesystem/step_create_icons.h>
+#include <common/step/filesystem/step_create_globalapp_symlinks.h>
 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
 #include <common/step/filesystem/step_create_storage_directories.h>
 #include <common/step/filesystem/step_delta_patch.h>
+#include <common/step/filesystem/step_disable_external_mount.h>
+#include <common/step/filesystem/step_enable_external_mount.h>
 #include <common/step/filesystem/step_recover_files.h>
 #include <common/step/filesystem/step_recover_icons.h>
 #include <common/step/filesystem/step_recover_manifest.h>
 #include <common/step/filesystem/step_recover_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>
 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
 #include <common/step/filesystem/step_remove_temporary_directory.h>
 #include <common/step/filesystem/step_remove_zip_image.h>
+#include <common/step/filesystem/step_remove_tep.h>
 #include <common/step/filesystem/step_unzip.h>
+#include <common/step/filesystem/step_update_tep.h>
 #include <common/step/mount/step_mount_install.h>
 #include <common/step/mount/step_mount_unpacked.h>
 #include <common/step/mount/step_mount_update.h>
 #include <common/step/pkgmgr/step_check_removable.h>
+#include <common/step/pkgmgr/step_check_restriction.h>
 #include <common/step/pkgmgr/step_kill_apps.h>
 #include <common/step/pkgmgr/step_recover_application.h>
 #include <common/step/pkgmgr/step_register_app.h>
@@ -42,7 +53,7 @@
 #include <common/step/pkgmgr/step_run_parser_plugins.h>
 #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/pkgmgr/step_update_pkg_disable_info.h>
 #include <common/step/recovery/step_open_recovery_file.h>
 #include <common/step/security/step_check_signature.h>
 #include <common/step/security/step_privilege_compatibility.h>
@@ -57,6 +68,7 @@
 #include <tpk/step/filesystem/step_tpk_patch_icons.h>
 #include <tpk/step/filesystem/step_tpk_prepare_package_directory.h>
 #include <tpk/step/filesystem/step_tpk_update_package_directory.h>
+#include <tpk/step/security/step_tpk_recover_signature.h>
 
 #include "hybrid/hybrid_backend_data.h"
 #include "hybrid/step/configuration/step_merge_tpk_config.h"
@@ -93,6 +105,9 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::pkgmgr::StepCheckRestriction>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -101,7 +116,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::security::StepCheckWgtImePrivilege>();
       AddStep<hybrid::encryption::StepEncryptResources>();
       AddStep<ci::security::StepRollbackInstallationSecurity>();
-      AddStep<ci::filesystem::StepAcquireExternalStorage>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+      AddStep<ci::filesystem::StepAcquireExternalStorage>(false);
       AddStep<ci::filesystem::StepCopy>();
       AddStep<ci::filesystem::StepCopyTep>();
       AddStep<tpk::filesystem::StepTpkPatchIcons>();
@@ -118,6 +134,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepRegisterApplication>();
       AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::Update:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
@@ -129,6 +147,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -144,10 +164,10 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::backup::StepBackupManifest>();
       AddStep<ci::backup::StepBackupIcons>();
-      AddStep<ci::filesystem::StepAcquireExternalStorage>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+      AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
       AddStep<ci::backup::StepCopyBackup>();
-      AddStep<ci::filesystem::StepCopyTep>();
-      AddStep<ci::pkgmgr::StepUpdateTep>();
+      AddStep<ci::filesystem::StepUpdateTep>();
       AddStep<tpk::filesystem::StepTpkPatchIcons>();
       AddStep<wgt::filesystem::StepWgtPatchIcons>();
       AddStep<ci::filesystem::StepCreateIcons>();
@@ -161,9 +181,12 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepUpdateApplication>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::Uninstall:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::pkgmgr::StepCheckRestriction>();
       AddStep<ci::pkgmgr::StepCheckRemovable>();
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
@@ -171,16 +194,19 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Uninstall);
       AddStep<ci::pkgmgr::StepKillApps>();
-      AddStep<ci::filesystem::StepAcquireExternalStorage>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+      AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
       AddStep<ci::pkgmgr::StepUnregisterApplication>();
       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
+      AddStep<ci::filesystem::StepRemoveTep>();
       AddStep<ci::filesystem::StepRemoveFiles>();
       AddStep<ci::filesystem::StepRemoveZipImage>();
       AddStep<ci::filesystem::StepRemoveIcons>();
       AddStep<wgt::encryption::StepRemoveEncryptionData>();
       AddStep<ci::security::StepRevokeSecurity>();
       AddStep<ci::pkgmgr::StepRemoveManifest>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::Reinstall:
       // RDS is not supported for hybrid apps
@@ -196,10 +222,13 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+      AddStep<ci::filesystem::StepEnableExternalMount>();
       AddStep<ci::filesystem::StepDeltaPatch>();
+      AddStep<ci::filesystem::StepDisableExternalMount>();
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -212,8 +241,10 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::backup::StepBackupManifest>();
       AddStep<ci::backup::StepBackupIcons>();
-      AddStep<ci::filesystem::StepAcquireExternalStorage>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+      AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
       AddStep<ci::backup::StepCopyBackup>();
+      AddStep<ci::filesystem::StepUpdateTep>();
       AddStep<tpk::filesystem::StepTpkPatchIcons>();
       AddStep<wgt::filesystem::StepWgtPatchIcons>();
       AddStep<ci::filesystem::StepCreateIcons>();
@@ -227,6 +258,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepUpdateApplication>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::Recovery:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
@@ -234,13 +267,14 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::configuration::StepParseManifest>(
           ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
-      AddStep<ci::pkgmgr::StepRecoverApplication>();
       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
       AddStep<ci::filesystem::StepRecoverIcons>();
       AddStep<ci::filesystem::StepRecoverManifest>();
       AddStep<ci::filesystem::StepRecoverExternalStorage>();
       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
       AddStep<ci::filesystem::StepRecoverFiles>();
+      AddStep<tpk::security::StepTpkRecoverSignature>();
+      AddStep<ci::pkgmgr::StepRecoverApplication>();
       AddStep<ci::security::StepRecoverSecurity>();
       break;
     case ci::RequestType::Clear:
@@ -260,6 +294,9 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::pkgmgr::StepCheckRestriction>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -268,6 +305,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::security::StepCheckWgtImePrivilege>();
       AddStep<hybrid::encryption::StepEncryptResources>();
       AddStep<ci::security::StepRollbackInstallationSecurity>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<ci::mount::StepMountInstall>();
       AddStep<tpk::filesystem::StepTpkPreparePackageDirectory>();
       AddStep<ci::filesystem::StepCopyTep>();
@@ -285,6 +323,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepRegisterApplication>();
       AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::MountUpdate:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
@@ -296,6 +336,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -311,10 +353,10 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::backup::StepBackupManifest>();
       AddStep<ci::backup::StepBackupIcons>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<ci::mount::StepMountUpdate>();
       AddStep<tpk::filesystem::StepTpkUpdatePackageDirectory>();
-      AddStep<ci::filesystem::StepCopyTep>();
-      AddStep<ci::pkgmgr::StepUpdateTep>();
+      AddStep<ci::filesystem::StepUpdateTep>();
       AddStep<tpk::filesystem::StepTpkPatchIcons>();
       AddStep<wgt::filesystem::StepWgtPatchIcons>();
       AddStep<ci::filesystem::StepCreateIcons>();
@@ -327,6 +369,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<ci::pkgmgr::StepUpdateApplication>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::ManifestDirectInstall:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
@@ -337,17 +381,22 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
       AddStep<ci::security::StepRollbackInstallationSecurity>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Install);
       AddStep<ci::pkgmgr::StepRegisterApplication>();
       AddStep<ci::security::StepRegisterSecurity>();
       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
       break;
     case ci::RequestType::ManifestDirectUpdate:
       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
@@ -359,6 +408,8 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
       AddStep<wgt::configuration::StepParse>(
           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
       AddStep<hybrid::configuration::StepMergeTpkConfig>();
+      AddStep<ci::configuration::StepParsePreload>();
+      AddStep<ci::configuration::StepCheckTizenVersion>();
       AddStep<ci::security::StepCheckSignature>();
       AddStep<ci::security::StepPrivilegeCompatibility>();
       AddStep<wgt::security::StepCheckSettingsLevel>();
@@ -369,10 +420,35 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
       AddStep<ci::pkgmgr::StepKillApps>();
       AddStep<ci::security::StepUpdateSecurity>();
+      AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
       AddStep<wgt::pkgmgr::StepGenerateXml>();
       AddStep<ci::pkgmgr::StepUpdateApplication>();
       AddStep<ci::pkgmgr::StepRunParserPlugin>(
           ci::Plugin::ActionType::Upgrade);
+      AddStep<ci::filesystem::StepChangeOwner>();
+      AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+      break;
+    case ci::RequestType::EnablePkg:
+      AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::configuration::StepParseManifest>(
+          ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+          ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+      AddStep<ci::pkgmgr::StepKillApps>();
+      AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
+        ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Enable);
+      AddStep<ci::pkgmgr::StepRunParserPlugin>(
+        ci::Plugin::ActionType::Uninstall);
+      break;
+    case ci::RequestType::DisablePkg:
+      AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+      AddStep<ci::configuration::StepParseManifest>(
+          ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+          ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+      AddStep<ci::pkgmgr::StepKillApps>();
+      AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
+        ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Disable);
+      AddStep<ci::pkgmgr::StepRunParserPlugin>(
+        ci::Plugin::ActionType::Uninstall);
       break;
     default:
       AddStep<ci::configuration::StepFail>();