05d8dad8da3e8f1a8133564ca0f77da4034b3b9a
[platform/core/appfw/wgt-backend.git] / src / wgt / wgt_installer.cc
1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
4
5 #include "wgt/wgt_installer.h"
6
7 #include <common/pkgmgr_interface.h>
8
9 #include <common/privileges.h>
10 #include <common/step/backup/step_backup_icons.h>
11 #include <common/step/backup/step_backup_manifest.h>
12 #include <common/step/backup/step_copy_backup.h>
13 #include <common/step/configuration/step_block_cross_update.h>
14 #include <common/step/configuration/step_check_install_location.h>
15 #include <common/step/configuration/step_check_tizen_version.h>
16 #include <common/step/configuration/step_configure.h>
17 #include <common/step/configuration/step_fail.h>
18 #include <common/step/configuration/step_parse_manifest.h>
19 #include <common/step/configuration/step_parse_preload.h>
20 #include <common/step/configuration/step_switch_readonly_mode.h>
21 #include <common/step/filesystem/step_acquire_external_storage.h>
22 #include <common/step/filesystem/step_optional_acquire_external_storage.h>
23 #include <common/step/filesystem/step_change_ownership_and_permission.h>
24 #include <common/step/filesystem/step_copy.h>
25 #include <common/step/filesystem/step_copy_storage_directories.h>
26 #include <common/step/filesystem/step_copy_tep.h>
27 #include <common/step/filesystem/step_create_icons.h>
28 #include <common/step/filesystem/step_create_globalapp_symlinks.h>
29 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
30 #include <common/step/filesystem/step_create_storage_directories.h>
31 #include <common/step/filesystem/step_delta_patch.h>
32 #include <common/step/filesystem/step_disable_external_mount.h>
33 #include <common/step/filesystem/step_enable_external_mount.h>
34 #include <common/step/filesystem/step_migrate_legacy_external_image.h>
35 #include <common/step/filesystem/step_move_installed_storage.h>
36 #include <common/step/filesystem/step_recover_change_owner.h>
37 #include <common/step/filesystem/step_recover_files.h>
38 #include <common/step/filesystem/step_recover_icons.h>
39 #include <common/step/filesystem/step_recover_manifest.h>
40 #include <common/step/filesystem/step_recover_external_storage.h>
41 #include <common/step/filesystem/step_recover_storage_directories.h>
42 #include <common/step/filesystem/step_recover_per_user_storage_directories.h>
43 #include <common/step/filesystem/step_remove_files.h>
44 #include <common/step/filesystem/step_remove_icons.h>
45 #include <common/step/filesystem/step_remove_globalapp_symlinks.h>
46 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
47 #include <common/step/filesystem/step_remove_temporary_directory.h>
48 #include <common/step/filesystem/step_remove_tep.h>
49 #include <common/step/filesystem/step_remove_zip_image.h>
50 #include <common/step/filesystem/step_unzip.h>
51 #include <common/step/filesystem/step_update_per_user_storage_directories.h>
52 #include <common/step/filesystem/step_update_storage_directories.h>
53 #include <common/step/filesystem/step_update_tep.h>
54 #include <common/step/mount/step_mount_install.h>
55 #include <common/step/mount/step_mount_recover.h>
56 #include <common/step/mount/step_mount_unpacked.h>
57 #include <common/step/mount/step_mount_update.h>
58 #include <common/step/pkgmgr/step_check_force_clean.h>
59 #include <common/step/pkgmgr/step_check_installable.h>
60 #include <common/step/pkgmgr/step_check_removable.h>
61 #include <common/step/pkgmgr/step_check_restriction.h>
62 #include <common/step/pkgmgr/step_kill_apps.h>
63 #include <common/step/pkgmgr/step_recover_application.h>
64 #include <common/step/pkgmgr/step_register_app.h>
65 #include <common/step/pkgmgr/step_remove_manifest.h>
66 #include <common/step/pkgmgr/step_run_parser_plugins.h>
67 #include <common/step/pkgmgr/step_unregister_app.h>
68 #include <common/step/pkgmgr/step_update_app.h>
69 #include <common/step/pkgmgr/step_update_pkg_disable_info.h>
70 #include <common/step/rds/step_rds_modify.h>
71 #include <common/step/rds/step_rds_parse.h>
72 #include <common/step/recovery/step_open_recovery_file.h>
73 #include <common/step/security/step_check_old_certificate.h>
74 #include <common/step/security/step_check_signature.h>
75 #include <common/step/security/step_privacy_privilege.h>
76 #include <common/step/security/step_privilege_compatibility.h>
77 #include <common/step/security/step_recover_security.h>
78 #include <common/step/security/step_register_security.h>
79 #include <common/step/security/step_revoke_security.h>
80 #include <common/step/security/step_rollback_deinstallation_security.h>
81 #include <common/step/security/step_rollback_installation_security.h>
82 #include <common/step/security/step_update_security.h>
83 #include <common/step/security/step_register_trust_anchor.h>
84 #include <common/step/security/step_unregister_trust_anchor.h>
85
86 #include <wgt_manifest_handlers/widget_config_parser.h>
87
88 #include "wgt/shared_dirs.h"
89 #include "wgt/step/configuration/step_check_rds_manifest.h"
90 #include "wgt/step/configuration/step_check_start_files.h"
91 #include "wgt/step/configuration/step_parse.h"
92 #include "wgt/step/configuration/step_set_old_signature_files_location.h"
93 #include "wgt/step/encryption/step_encrypt_resources.h"
94 #include "wgt/step/encryption/step_remove_encryption_data.h"
95 #include "wgt/step/filesystem/step_copy_preview_icons.h"
96 #include "wgt/step/filesystem/step_create_symbolic_link.h"
97 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
98 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
99 #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h"
100 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
101 #include "wgt/step/filesystem/step_wgt_undo_patch_storage_directories.h"
102 #include "wgt/step/filesystem/step_wgt_update_package_directory.h"
103 #include "wgt/step/pkgmgr/step_generate_xml.h"
104 #include "wgt/step/security/step_add_default_privileges.h"
105 #include "wgt/step/security/step_check_settings_level.h"
106 #include "wgt/step/security/step_check_wgt_background_category.h"
107 #include "wgt/step/security/step_check_wgt_notification_category.h"
108 #include "wgt/step/security/step_check_wgt_ime_privilege.h"
109 #include "wgt/step/security/step_direct_manifest_check_signature.h"
110 #include "wgt/step/security/step_check_extension_privileges.h"
111 #include "wgt/step/security/step_wgt_recover_signature.h"
112
113 namespace ci = common_installer;
114
115 namespace wgt {
116
117 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
118     : AppInstaller("wgt", pkgrmgr) {
119   context_->backend_data.set(new WgtBackendData());
120
121   /* treat the request */
122   switch (pkgmgr_->GetRequestType()) {
123     case ci::RequestType::Install : {
124       InstallSteps();
125       break;
126     }
127     case ci::RequestType::Update: {
128       UpdateSteps();
129       break;
130     }
131     case ci::RequestType::Uninstall: {
132       UninstallSteps();
133       break;
134     }
135     case ci::RequestType::Reinstall: {
136       ReinstallSteps();
137       break;
138     }
139     case ci::RequestType::Delta: {
140       DeltaSteps();
141       break;
142     }
143     case ci::RequestType::Recovery: {
144       RecoverySteps();
145       break;
146     }
147     case ci::RequestType::MountInstall: {
148       MountInstallSteps();
149       break;
150     }
151     case ci::RequestType::MountUpdate: {
152       MountUpdateSteps();
153       break;
154     }
155     case ci::RequestType::ManifestDirectInstall: {
156       ManifestDirectInstallSteps();
157       break;
158     }
159     case ci::RequestType::ManifestDirectUpdate: {
160       ManifestDirectUpdateSteps();
161       break;
162     }
163     case ci::RequestType::ReadonlyUpdateInstall: {
164       ReadonlyUpdateInstallSteps();
165       break;
166     }
167     case ci::RequestType::ReadonlyUpdateUninstall: {
168       ReadonlyUpdateUninstallSteps();
169       break;
170     }
171     case ci::RequestType::ManifestPartialInstall: {
172       ManifestPartialInstallSteps();
173       break;
174     }
175     case ci::RequestType::ManifestPartialUpdate: {
176       ManifestPartialUpdateSteps();
177       break;
178     }
179     case ci::RequestType::PartialUninstall: {
180       ManifestPartialUninstallSteps();
181       break;
182     }
183     case ci::RequestType::Move: {
184       MoveSteps();
185       break;
186     }
187     case ci::RequestType::EnablePkg: {
188       EnablePkgSteps();
189       break;
190     }
191     case ci::RequestType::DisablePkg: {
192       DisablePkgSteps();
193       break;
194     }
195     case ci::RequestType::MigrateExtImg: {
196       MigrateExtImgSteps();
197       break;
198     }
199     default: {
200       DefaultSteps();
201     }
202   }
203 }
204   void WgtInstaller::InstallSteps() {
205       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
206       AddStep<ci::filesystem::StepUnzip>();
207       AddStep<wgt::configuration::StepParse>(
208         wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
209       AddStep<ci::configuration::StepCheckInstallLocation>();
210       AddStep<ci::pkgmgr::StepCheckInstallable>();
211       AddStep<ci::configuration::StepParsePreload>();
212       AddStep<ci::pkgmgr::StepCheckRestriction>();
213       AddStep<ci::configuration::StepCheckTizenVersion>();
214       AddStep<ci::security::StepCheckSignature>();
215       AddStep<ci::security::StepPrivilegeCompatibility>(
216           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
217       AddStep<wgt::security::StepCheckSettingsLevel>();
218       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
219       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
220       AddStep<wgt::security::StepCheckWgtImePrivilege>();
221       AddStep<wgt::encryption::StepEncryptResources>();
222       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
223       AddStep<ci::security::StepRollbackInstallationSecurity>();
224       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
225       AddStep<ci::filesystem::StepAcquireExternalStorage>(false);
226       AddStep<ci::filesystem::StepCopy>();
227       AddStep<ci::filesystem::StepCopyTep>();
228       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
229       AddStep<ci::filesystem::StepCreateStorageDirectories>();
230       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
231       AddStep<wgt::filesystem::StepWgtPatchIcons>();
232       AddStep<ci::filesystem::StepCreateIcons>();
233       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
234       AddStep<wgt::security::StepCheckExtensionPrivileges>();
235       AddStep<wgt::pkgmgr::StepGenerateXml>();
236       AddStep<ci::pkgmgr::StepRegisterApplication>();
237       AddStep<ci::security::StepRegisterTrustAnchor>(
238           ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
239       AddStep<ci::security::StepPrivacyPrivilege>(
240           ci::security::StepPrivacyPrivilege::ActionType::Install);
241       AddStep<ci::security::StepRegisterSecurity>();
242       AddStep<ci::pkgmgr::StepRunParserPlugin>(
243           ci::Plugin::ActionType::Install);
244       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
245           wgt::filesystem::WgtAdditionalSharedDirs);
246       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
247       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
248   }
249
250   void WgtInstaller::UpdateSteps() {
251       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
252       AddStep<ci::filesystem::StepUnzip>();
253       AddStep<wgt::configuration::StepParse>(
254           wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
255       AddStep<ci::configuration::StepCheckInstallLocation>();
256       AddStep<ci::configuration::StepParsePreload>();
257       AddStep<ci::configuration::StepCheckTizenVersion>();
258       AddStep<ci::security::StepCheckSignature>();
259       AddStep<ci::security::StepPrivilegeCompatibility>(
260           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
261       AddStep<wgt::security::StepCheckSettingsLevel>();
262       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
263       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
264       AddStep<wgt::security::StepCheckWgtImePrivilege>();
265       AddStep<ci::security::StepCheckOldCertificate>();
266       AddStep<wgt::encryption::StepEncryptResources>();
267       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
268       AddStep<ci::configuration::StepParseManifest>(
269           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
270           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
271       AddStep<ci::configuration::StepBlockCrossUpdate>();
272       AddStep<ci::pkgmgr::StepKillApps>();
273       AddStep<ci::backup::StepBackupManifest>();
274       AddStep<ci::backup::StepBackupIcons>();
275       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
276       AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
277       AddStep<ci::backup::StepCopyBackup>();
278       AddStep<ci::filesystem::StepUpdateTep>();
279       AddStep<ci::filesystem::StepUpdateStorageDirectories>();
280       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
281       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
282       AddStep<wgt::filesystem::StepWgtPatchIcons>();
283       AddStep<ci::filesystem::StepCreateIcons>();
284       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
285       AddStep<ci::filesystem::StepCopyStorageDirectories>();
286       AddStep<wgt::security::StepCheckExtensionPrivileges>();
287       AddStep<wgt::pkgmgr::StepGenerateXml>();
288       AddStep<ci::pkgmgr::StepUpdateApplication>();
289       AddStep<ci::security::StepRegisterTrustAnchor>(
290           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
291       AddStep<ci::security::StepPrivacyPrivilege>(
292           ci::security::StepPrivacyPrivilege::ActionType::Update);
293       AddStep<ci::security::StepUpdateSecurity>();
294       AddStep<ci::pkgmgr::StepRunParserPlugin>(
295           ci::Plugin::ActionType::Upgrade);
296       AddStep<ci::filesystem::StepUpdatePerUserStorageDirectories>();
297       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
298       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
299   }
300
301   void WgtInstaller::UninstallSteps() {
302       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
303       AddStep<ci::pkgmgr::StepCheckRestriction>();
304       AddStep<ci::pkgmgr::StepCheckRemovable>();
305       AddStep<ci::pkgmgr::StepCheckForceClean>();
306       AddStep<ci::configuration::StepParseManifest>(
307           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
308           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
309       AddStep<ci::configuration::StepCheckInstallLocation>();
310       AddStep<ci::pkgmgr::StepKillApps>();
311       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
312       AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
313       AddStep<ci::pkgmgr::StepRunParserPlugin>(
314           ci::Plugin::ActionType::Uninstall);
315       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
316       AddStep<ci::pkgmgr::StepUnregisterApplication>();
317       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
318       AddStep<ci::filesystem::StepRemoveTep>();
319       AddStep<ci::filesystem::StepRemoveFiles>();
320       AddStep<ci::filesystem::StepRemoveZipImage>();
321       AddStep<ci::filesystem::StepRemoveIcons>();
322       AddStep<wgt::encryption::StepRemoveEncryptionData>();
323       AddStep<ci::security::StepUnregisterTrustAnchor>();
324       AddStep<ci::security::StepPrivacyPrivilege>(
325           ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
326       AddStep<ci::security::StepRevokeSecurity>();
327       AddStep<ci::pkgmgr::StepRemoveManifest>();
328       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
329   }
330
331   void WgtInstaller::ReinstallSteps() {
332       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
333       AddStep<wgt::configuration::StepCheckRDSManifest>();
334       AddStep<wgt::configuration::StepParse>(
335           wgt::configuration::StepParse::ConfigLocation::RESOURCE_WGT, false);
336       AddStep<ci::configuration::StepCheckInstallLocation>();
337       AddStep<ci::configuration::StepParsePreload>();
338       AddStep<ci::pkgmgr::StepCheckRestriction>();
339       AddStep<ci::configuration::StepCheckTizenVersion>();
340       AddStep<ci::pkgmgr::StepKillApps>();
341       AddStep<ci::configuration::StepParseManifest>(
342           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
343           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
344       AddStep<ci::configuration::StepBlockCrossUpdate>();
345       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
346       AddStep<ci::rds::StepRDSParse>();
347       AddStep<ci::filesystem::StepUpdateTep>();
348       AddStep<ci::rds::StepRDSModify>();
349       AddStep<wgt::security::StepCheckExtensionPrivileges>();
350       AddStep<ci::security::StepRegisterTrustAnchor>(
351           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
352       AddStep<ci::security::StepPrivacyPrivilege>(
353           ci::security::StepPrivacyPrivilege::ActionType::Update);
354       AddStep<ci::security::StepUpdateSecurity>();
355       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
356       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
357   }
358
359   void WgtInstaller::DeltaSteps() {
360       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
361       AddStep<ci::filesystem::StepUnzip>();
362       AddStep<wgt::configuration::StepParse>(
363             wgt::configuration::StepParse::ConfigLocation::PACKAGE, false);
364       AddStep<ci::configuration::StepCheckInstallLocation>();
365       AddStep<ci::configuration::StepParseManifest>(
366           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
367           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
368       AddStep<ci::configuration::StepParsePreload>();
369       AddStep<ci::configuration::StepCheckTizenVersion>();
370       AddStep<ci::filesystem::StepEnableExternalMount>();
371       AddStep<wgt::filesystem::StepWgtUndoPatchStorageDirectories>();
372       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
373       AddStep<ci::filesystem::StepDisableExternalMount>();
374       AddStep<wgt::configuration::StepCheckStartFiles>();
375       AddStep<ci::security::StepCheckSignature>();
376       AddStep<ci::security::StepPrivilegeCompatibility>(
377           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
378       AddStep<wgt::security::StepCheckSettingsLevel>();
379       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
380       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
381       AddStep<wgt::security::StepCheckWgtImePrivilege>();
382       AddStep<ci::security::StepCheckOldCertificate>();
383       AddStep<wgt::encryption::StepEncryptResources>();
384       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
385       AddStep<ci::configuration::StepBlockCrossUpdate>();
386       AddStep<ci::pkgmgr::StepKillApps>();
387       AddStep<ci::backup::StepBackupManifest>();
388       AddStep<ci::backup::StepBackupIcons>();
389       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
390       AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
391       AddStep<ci::backup::StepCopyBackup>();
392       AddStep<ci::filesystem::StepUpdateTep>();
393       AddStep<ci::filesystem::StepUpdateStorageDirectories>();
394       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
395       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
396       AddStep<wgt::filesystem::StepWgtPatchIcons>();
397       AddStep<ci::filesystem::StepCreateIcons>();
398       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
399       AddStep<ci::filesystem::StepCopyStorageDirectories>();
400       AddStep<wgt::security::StepCheckExtensionPrivileges>();
401       AddStep<wgt::pkgmgr::StepGenerateXml>();
402       AddStep<ci::pkgmgr::StepUpdateApplication>();
403       AddStep<ci::security::StepRegisterTrustAnchor>(
404           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
405       AddStep<ci::security::StepPrivacyPrivilege>(
406           ci::security::StepPrivacyPrivilege::ActionType::Update);
407       AddStep<ci::security::StepUpdateSecurity>();
408       AddStep<ci::pkgmgr::StepRunParserPlugin>(
409           ci::Plugin::ActionType::Upgrade);
410       AddStep<ci::filesystem::StepUpdatePerUserStorageDirectories>();
411       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
412       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
413   }
414
415   void WgtInstaller::RecoverySteps() {
416       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
417       AddStep<ci::recovery::StepOpenRecoveryFile>();
418       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
419       AddStep<ci::configuration::StepParseManifest>(
420           ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
421           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
422       AddStep<ci::filesystem::StepRecoverIcons>();
423       AddStep<ci::filesystem::StepRecoverManifest>();
424       AddStep<ci::filesystem::StepRecoverExternalStorage>();
425       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
426       AddStep<ci::filesystem::StepRecoverPerUserStorageDirectories>();
427       AddStep<ci::filesystem::StepRecoverFiles>();
428       AddStep<ci::mount::StepMountRecover>();
429       AddStep<wgt::security::StepWgtRecoverSignature>();
430       AddStep<ci::filesystem::StepRecoverChangeOwner>();
431       AddStep<ci::security::StepRecoverSecurity>();
432       AddStep<ci::pkgmgr::StepRecoverApplication>();
433   }
434
435   void WgtInstaller::MountInstallSteps() {
436       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
437       AddStep<ci::mount::StepMountUnpacked>();
438       AddStep<wgt::configuration::StepParse>(
439           wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
440       AddStep<ci::configuration::StepCheckInstallLocation>();
441       AddStep<ci::pkgmgr::StepCheckInstallable>();
442       AddStep<ci::configuration::StepParsePreload>();
443       AddStep<ci::pkgmgr::StepCheckRestriction>();
444       AddStep<ci::configuration::StepCheckTizenVersion>();
445       AddStep<ci::security::StepCheckSignature>();
446       AddStep<ci::security::StepPrivilegeCompatibility>(
447           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
448       AddStep<wgt::security::StepCheckSettingsLevel>();
449       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
450       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
451       AddStep<wgt::security::StepCheckWgtImePrivilege>();
452       AddStep<wgt::encryption::StepEncryptResources>();
453       AddStep<ci::security::StepRollbackInstallationSecurity>();
454       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
455       AddStep<ci::mount::StepMountInstall>();
456       AddStep<wgt::filesystem::StepWgtPreparePackageDirectory>();
457       AddStep<ci::filesystem::StepCopyTep>();
458       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
459       AddStep<ci::filesystem::StepCreateStorageDirectories>();
460       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
461       AddStep<wgt::filesystem::StepWgtPatchIcons>();
462       AddStep<ci::filesystem::StepCreateIcons>();
463       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
464       AddStep<wgt::pkgmgr::StepGenerateXml>();
465       AddStep<wgt::security::StepCheckExtensionPrivileges>();
466       AddStep<ci::pkgmgr::StepRegisterApplication>();
467       AddStep<ci::security::StepRegisterTrustAnchor>(
468           ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
469       AddStep<ci::security::StepPrivacyPrivilege>(
470           ci::security::StepPrivacyPrivilege::ActionType::Install);
471       AddStep<ci::security::StepRegisterSecurity>();
472       AddStep<ci::pkgmgr::StepRunParserPlugin>(
473           ci::Plugin::ActionType::Install);
474       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
475           wgt::filesystem::WgtAdditionalSharedDirs);
476       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
477       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
478   }
479
480   void WgtInstaller::MountUpdateSteps() {
481       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
482       AddStep<ci::mount::StepMountUnpacked>();
483       AddStep<wgt::configuration::StepParse>(
484           wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
485       AddStep<ci::configuration::StepCheckInstallLocation>();
486       AddStep<ci::configuration::StepParsePreload>();
487       AddStep<ci::configuration::StepCheckTizenVersion>();
488       AddStep<ci::security::StepCheckSignature>();
489       AddStep<ci::security::StepPrivilegeCompatibility>(
490           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
491       AddStep<wgt::security::StepCheckSettingsLevel>();
492       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
493       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
494       AddStep<wgt::security::StepCheckWgtImePrivilege>();
495       AddStep<ci::security::StepCheckOldCertificate>();
496       AddStep<ci::configuration::StepParseManifest>(
497           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
498           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
499       AddStep<ci::configuration::StepBlockCrossUpdate>();
500       AddStep<ci::pkgmgr::StepKillApps>();
501       AddStep<ci::backup::StepBackupManifest>();
502       AddStep<ci::backup::StepBackupIcons>();
503       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
504       AddStep<ci::mount::StepMountUpdate>();
505       AddStep<wgt::filesystem::StepWgtUpdatePackageDirectory>();
506       AddStep<ci::filesystem::StepUpdateTep>();
507       AddStep<ci::filesystem::StepUpdateStorageDirectories>();
508       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
509       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
510       AddStep<wgt::filesystem::StepWgtPatchIcons>();
511       AddStep<ci::filesystem::StepCreateIcons>();
512       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
513       AddStep<wgt::security::StepCheckExtensionPrivileges>();
514       AddStep<wgt::pkgmgr::StepGenerateXml>();
515       AddStep<ci::pkgmgr::StepUpdateApplication>();
516       AddStep<ci::security::StepRegisterTrustAnchor>(
517           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
518       AddStep<ci::security::StepPrivacyPrivilege>(
519           ci::security::StepPrivacyPrivilege::ActionType::Update);
520       AddStep<ci::security::StepUpdateSecurity>();
521       AddStep<ci::pkgmgr::StepRunParserPlugin>(
522           ci::Plugin::ActionType::Upgrade);
523       AddStep<ci::filesystem::StepUpdatePerUserStorageDirectories>();
524       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
525       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
526   }
527
528   void WgtInstaller::ManifestDirectInstallSteps() {
529       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
530       AddStep<wgt::configuration::StepParse>(
531           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
532       AddStep<ci::pkgmgr::StepCheckInstallable>();
533       AddStep<ci::configuration::StepParsePreload>();
534       AddStep<ci::configuration::StepCheckTizenVersion>();
535       AddStep<wgt::security::StepDirectManifestCheckSignature>();
536       AddStep<ci::security::StepPrivilegeCompatibility>(
537           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
538       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
539       AddStep<wgt::security::StepCheckWgtImePrivilege>();
540       AddStep<wgt::security::StepCheckSettingsLevel>();
541       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
542       AddStep<ci::security::StepRollbackInstallationSecurity>();
543       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
544       AddStep<wgt::filesystem::StepWgtPatchIcons>();
545       AddStep<wgt::pkgmgr::StepGenerateXml>();
546       AddStep<ci::pkgmgr::StepRegisterApplication>();
547       AddStep<ci::security::StepRegisterTrustAnchor>(
548           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
549       AddStep<ci::security::StepPrivacyPrivilege>(
550           ci::security::StepPrivacyPrivilege::ActionType::Install);
551       AddStep<ci::security::StepRegisterSecurity>();
552       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
553       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
554           wgt::filesystem::WgtAdditionalSharedDirs);
555       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
556       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
557   }
558
559   void WgtInstaller::ManifestDirectUpdateSteps() {
560       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
561       AddStep<wgt::configuration::StepParse>(
562           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
563       AddStep<ci::configuration::StepParsePreload>();
564       AddStep<ci::configuration::StepCheckTizenVersion>();
565       AddStep<wgt::security::StepDirectManifestCheckSignature>();
566       AddStep<ci::security::StepPrivilegeCompatibility>(
567           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
568       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
569       AddStep<wgt::security::StepCheckWgtImePrivilege>();
570       AddStep<wgt::security::StepCheckSettingsLevel>();
571       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
572       AddStep<ci::configuration::StepParseManifest>(
573           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
574           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
575       AddStep<ci::pkgmgr::StepKillApps>();
576       AddStep<ci::filesystem::StepCopyTep>();
577       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
578       AddStep<wgt::filesystem::StepWgtPatchIcons>();
579       AddStep<wgt::pkgmgr::StepGenerateXml>();
580       AddStep<ci::pkgmgr::StepUpdateApplication>();
581       AddStep<ci::security::StepRegisterTrustAnchor>(
582           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
583       AddStep<ci::security::StepPrivacyPrivilege>(
584           ci::security::StepPrivacyPrivilege::ActionType::Update);
585       AddStep<ci::security::StepUpdateSecurity>();
586       AddStep<ci::pkgmgr::StepRunParserPlugin>(
587           ci::Plugin::ActionType::Upgrade);
588       AddStep<ci::filesystem::StepUpdatePerUserStorageDirectories>();
589       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
590       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
591   }
592
593   void WgtInstaller::ReadonlyUpdateInstallSteps() {
594       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
595       AddStep<ci::filesystem::StepUnzip>();
596       AddStep<wgt::configuration::StepParse>(
597           wgt::configuration::StepParse::ConfigLocation::PACKAGE, true);
598       AddStep<ci::configuration::StepParsePreload>();
599       AddStep<ci::configuration::StepCheckTizenVersion>();
600       AddStep<ci::security::StepCheckSignature>();
601       AddStep<ci::security::StepPrivilegeCompatibility>(
602           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
603       AddStep<wgt::security::StepCheckSettingsLevel>();
604       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
605       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
606       AddStep<wgt::security::StepCheckWgtImePrivilege>();
607       AddStep<ci::security::StepCheckOldCertificate>();
608       AddStep<wgt::encryption::StepEncryptResources>();
609       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
610       AddStep<ci::security::StepRollbackInstallationSecurity>();
611       AddStep<ci::configuration::StepSwitchReadonlyMode>();
612       AddStep<ci::configuration::StepParseManifest>(
613           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
614           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
615       AddStep<ci::configuration::StepSwitchReadonlyMode>();
616       AddStep<ci::configuration::StepBlockCrossUpdate>();
617       AddStep<ci::pkgmgr::StepKillApps>();
618       AddStep<ci::filesystem::StepCopy>();
619       AddStep<ci::filesystem::StepCopyTep>();
620       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
621       AddStep<ci::filesystem::StepCreateStorageDirectories>();
622       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
623       AddStep<wgt::filesystem::StepWgtPatchIcons>();
624       AddStep<wgt::filesystem::StepCopyPreviewIcons>();
625       AddStep<wgt::security::StepCheckExtensionPrivileges>();
626       AddStep<wgt::pkgmgr::StepGenerateXml>();
627       AddStep<ci::pkgmgr::StepUpdateApplication>();
628       AddStep<ci::security::StepRegisterTrustAnchor>(
629           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
630       AddStep<ci::security::StepPrivacyPrivilege>(
631           ci::security::StepPrivacyPrivilege::ActionType::Update);
632       AddStep<ci::security::StepUpdateSecurity>();
633       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
634       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
635       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
636   }
637
638   void WgtInstaller::ReadonlyUpdateUninstallSteps() {
639       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
640       AddStep<ci::pkgmgr::StepCheckRestriction>();
641       AddStep<ci::pkgmgr::StepCheckRemovable>();
642       AddStep<ci::configuration::StepParseManifest>(
643           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
644           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
645       AddStep<ci::configuration::StepSwitchReadonlyMode>();
646       AddStep<ci::configuration::StepParseManifest>(
647           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
648           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
649       AddStep<ci::configuration::StepParsePreload>();
650       AddStep<wgt::configuration::StepSetOldSignatureFilesLocation>();
651       AddStep<ci::security::StepCheckSignature>();
652       AddStep<ci::configuration::StepSwitchReadonlyMode>();
653       AddStep<ci::pkgmgr::StepKillApps>();
654       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
655       AddStep<ci::filesystem::StepRemoveTep>();
656       AddStep<ci::filesystem::StepRemoveFiles>();
657       AddStep<ci::filesystem::StepRemoveZipImage>();
658       AddStep<ci::pkgmgr::StepUpdateApplication>();
659       AddStep<ci::configuration::StepSwitchReadonlyMode>();
660       AddStep<ci::security::StepRegisterTrustAnchor>(
661           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
662       AddStep<ci::security::StepPrivacyPrivilege>(
663           ci::security::StepPrivacyPrivilege::ActionType::Update);
664       AddStep<ci::security::StepUpdateSecurity>();
665       AddStep<ci::pkgmgr::StepRemoveManifest>();
666       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
667   }
668
669   void WgtInstaller::ManifestPartialInstallSteps() {
670       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
671       AddStep<wgt::configuration::StepParse>(
672           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
673       AddStep<ci::configuration::StepParsePreload>();
674       AddStep<ci::security::StepCheckSignature>();
675       AddStep<ci::security::StepPrivilegeCompatibility>(
676           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
677       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
678       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
679       AddStep<ci::pkgmgr::StepRegisterApplication>();
680       AddStep<ci::security::StepRegisterTrustAnchor>(
681           ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
682       AddStep<ci::security::StepPrivacyPrivilege>(
683           ci::security::StepPrivacyPrivilege::ActionType::Install);
684       AddStep<ci::security::StepRegisterSecurity>();
685       AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
686       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>(
687           wgt::filesystem::WgtAdditionalSharedDirs);
688       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
689   }
690
691   void WgtInstaller::ManifestPartialUpdateSteps() {
692       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
693       AddStep<wgt::configuration::StepParse>(
694           wgt::configuration::StepParse::ConfigLocation::INSTALLED, true);
695       AddStep<ci::configuration::StepParsePreload>();
696       AddStep<ci::configuration::StepParseManifest>(
697           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
698           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
699       AddStep<ci::security::StepCheckSignature>();
700       AddStep<ci::security::StepPrivilegeCompatibility>(
701           ci::security::StepPrivilegeCompatibility::InternalPrivType::WGT);
702       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
703       AddStep<ci::pkgmgr::StepKillApps>();
704       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
705       AddStep<ci::pkgmgr::StepUpdateApplication>();
706       AddStep<ci::security::StepRegisterTrustAnchor>(
707           ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
708       AddStep<ci::security::StepPrivacyPrivilege>(
709           ci::security::StepPrivacyPrivilege::ActionType::Update);
710       AddStep<ci::security::StepUpdateSecurity>();
711       AddStep<ci::pkgmgr::StepRunParserPlugin>(
712           ci::Plugin::ActionType::Upgrade);
713       AddStep<ci::filesystem::StepUpdatePerUserStorageDirectories>();
714       AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
715   }
716
717   void WgtInstaller::ManifestPartialUninstallSteps() {
718       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
719       AddStep<ci::pkgmgr::StepCheckRestriction>();
720       AddStep<ci::pkgmgr::StepCheckRemovable>();
721       AddStep<ci::pkgmgr::StepCheckForceClean>();
722       AddStep<ci::configuration::StepParseManifest>(
723           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
724           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
725       AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
726       AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
727       AddStep<ci::pkgmgr::StepRunParserPlugin>(
728           ci::Plugin::ActionType::Uninstall);
729       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
730       AddStep<ci::pkgmgr::StepUnregisterApplication>();
731       AddStep<wgt::encryption::StepRemoveEncryptionData>();
732       AddStep<ci::security::StepUnregisterTrustAnchor>();
733       AddStep<ci::security::StepPrivacyPrivilege>(
734           ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
735       AddStep<ci::security::StepRevokeSecurity>();
736   }
737
738   void WgtInstaller::MoveSteps() {
739       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
740       AddStep<ci::configuration::StepParseManifest>(
741           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
742           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
743       AddStep<ci::configuration::StepCheckInstallLocation>();
744       AddStep<ci::pkgmgr::StepKillApps>();
745       AddStep<ci::filesystem::StepMoveInstalledStorage>();
746       AddStep<ci::security::StepRegisterSecurity>();
747   }
748
749   void WgtInstaller::EnablePkgSteps() {
750       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
751       AddStep<ci::configuration::StepParseManifest>(
752           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
753           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
754       AddStep<ci::pkgmgr::StepKillApps>();
755       AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
756         ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Enable);
757       AddStep<ci::pkgmgr::StepRunParserPlugin>(
758         ci::Plugin::ActionType::Uninstall);
759   }
760
761   void WgtInstaller::DisablePkgSteps() {
762       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
763       AddStep<ci::configuration::StepParseManifest>(
764           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
765           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
766       AddStep<ci::pkgmgr::StepKillApps>();
767       AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
768         ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Disable);
769       AddStep<ci::pkgmgr::StepRunParserPlugin>(
770         ci::Plugin::ActionType::Uninstall);
771   }
772
773   void WgtInstaller::MigrateExtImgSteps() {
774       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
775       AddStep<ci::security::StepMigrateLegacyExtImage>();
776       AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
777   }
778
779   void WgtInstaller::DefaultSteps() {
780       AddStep<ci::configuration::StepFail>();
781   }
782
783 }  // namespace wgt