Implement coping TEP in wgt and hybrid backend
[platform/core/appfw/wgt-backend.git] / src / hybrid / hybrid_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 "hybrid/hybrid_installer.h"
6
7 #include <common/step/backup/step_backup_icons.h>
8 #include <common/step/backup/step_backup_manifest.h>
9 #include <common/step/backup/step_copy_backup.h>
10 #include <common/step/configuration/step_configure.h>
11 #include <common/step/configuration/step_fail.h>
12 #include <common/step/configuration/step_parse_manifest.h>
13 #include <common/step/filesystem/step_clear_data.h>
14 #include <common/step/filesystem/step_copy.h>
15 #include <common/step/filesystem/step_copy_storage_directories.h>
16 #include <common/step/filesystem/step_copy_tep.h>
17 #include <common/step/filesystem/step_create_icons.h>
18 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
19 #include <common/step/filesystem/step_create_storage_directories.h>
20 #include <common/step/filesystem/step_delta_patch.h>
21 #include <common/step/filesystem/step_recover_files.h>
22 #include <common/step/filesystem/step_recover_icons.h>
23 #include <common/step/filesystem/step_recover_manifest.h>
24 #include <common/step/filesystem/step_recover_storage_directories.h>
25 #include <common/step/filesystem/step_remove_files.h>
26 #include <common/step/filesystem/step_remove_icons.h>
27 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
28 #include <common/step/filesystem/step_remove_temporary_directory.h>
29 #include <common/step/filesystem/step_unzip.h>
30 #include <common/step/pkgmgr/step_check_removable.h>
31 #include <common/step/pkgmgr/step_kill_apps.h>
32 #include <common/step/pkgmgr/step_recover_application.h>
33 #include <common/step/pkgmgr/step_register_app.h>
34 #include <common/step/pkgmgr/step_remove_manifest.h>
35 #include <common/step/pkgmgr/step_run_parser_plugins.h>
36 #include <common/step/pkgmgr/step_unregister_app.h>
37 #include <common/step/pkgmgr/step_update_app.h>
38 #include <common/step/pkgmgr/step_update_tep.h>
39 #include <common/step/recovery/step_open_recovery_file.h>
40 #include <common/step/security/step_check_signature.h>
41 #include <common/step/security/step_privilege_compatibility.h>
42 #include <common/step/security/step_recover_security.h>
43 #include <common/step/security/step_register_security.h>
44 #include <common/step/security/step_revoke_security.h>
45 #include <common/step/security/step_rollback_deinstallation_security.h>
46 #include <common/step/security/step_rollback_installation_security.h>
47 #include <common/step/security/step_update_security.h>
48
49 #include <tpk/step/filesystem/step_create_symbolic_link.h>
50 #include <tpk/step/filesystem/step_tpk_patch_icons.h>
51
52 #include "hybrid/hybrid_backend_data.h"
53 #include "hybrid/step/configuration/step_merge_tpk_config.h"
54 #include "hybrid/step/configuration/step_parse.h"
55 #include "hybrid/step/configuration/step_stash_tpk_config.h"
56 #include "hybrid/step/encryption/step_encrypt_resources.h"
57 #include "wgt/step/configuration/step_parse_recovery.h"
58 #include "wgt/step/encryption/step_remove_encryption_data.h"
59 #include "wgt/step/filesystem/step_create_symbolic_link.h"
60 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
61 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
62 #include "wgt/step/pkgmgr/step_generate_xml.h"
63 #include "wgt/step/security/step_check_settings_level.h"
64 #include "wgt/step/security/step_check_wgt_background_category.h"
65
66 namespace ci = common_installer;
67
68 namespace hybrid {
69
70 HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr)
71     : AppInstaller("wgt", pkgmgr) {
72   context_->backend_data.set(new HybridBackendData());
73
74   switch (pkgmgr_->GetRequestType()) {
75     case ci::RequestType::Install:
76       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
77       AddStep<ci::filesystem::StepUnzip>();
78       AddStep<ci::configuration::StepParseManifest>(
79           ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
80           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
81       AddStep<hybrid::configuration::StepStashTpkConfig>();
82       AddStep<hybrid::configuration::StepParse>(true);
83       AddStep<hybrid::configuration::StepMergeTpkConfig>();
84       AddStep<ci::security::StepCheckSignature>();
85       AddStep<ci::security::StepPrivilegeCompatibility>();
86       AddStep<wgt::security::StepCheckSettingsLevel>();
87       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
88       AddStep<hybrid::encryption::StepEncryptResources>();
89       AddStep<ci::security::StepRollbackInstallationSecurity>();
90       AddStep<ci::filesystem::StepCopy>();
91       AddStep<ci::filesystem::StepCopyTep>();
92       AddStep<tpk::filesystem::StepTpkPatchIcons>();
93       AddStep<wgt::filesystem::StepWgtPatchIcons>();
94       AddStep<ci::filesystem::StepCreateIcons>();
95       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
96       AddStep<ci::filesystem::StepCreateStorageDirectories>();
97       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
98       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
99       AddStep<wgt::pkgmgr::StepGenerateXml>();
100       AddStep<ci::pkgmgr::StepRunParserPlugin>(
101           ci::Plugin::ActionType::Install);
102       AddStep<ci::pkgmgr::StepRegisterApplication>();
103       AddStep<ci::security::StepRegisterSecurity>();
104       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
105       break;
106     case ci::RequestType::Update:
107       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
108       AddStep<ci::filesystem::StepUnzip>();
109       AddStep<ci::configuration::StepParseManifest>(
110           ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
111           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
112       AddStep<hybrid::configuration::StepStashTpkConfig>();
113       AddStep<hybrid::configuration::StepParse>(true);
114       AddStep<hybrid::configuration::StepMergeTpkConfig>();
115       AddStep<ci::security::StepCheckSignature>();
116       AddStep<ci::security::StepPrivilegeCompatibility>();
117       AddStep<wgt::security::StepCheckSettingsLevel>();
118       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
119       AddStep<hybrid::encryption::StepEncryptResources>();
120       AddStep<ci::security::StepRollbackInstallationSecurity>();
121       AddStep<ci::configuration::StepParseManifest>(
122           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
123           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
124       AddStep<ci::pkgmgr::StepKillApps>();
125       AddStep<ci::backup::StepBackupManifest>();
126       AddStep<ci::backup::StepBackupIcons>();
127       AddStep<ci::backup::StepCopyBackup>();
128       AddStep<ci::filesystem::StepCopyTep>();
129       AddStep<tpk::filesystem::StepTpkPatchIcons>();
130       AddStep<wgt::filesystem::StepWgtPatchIcons>();
131       AddStep<ci::filesystem::StepCreateIcons>();
132       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
133       AddStep<ci::filesystem::StepCopyStorageDirectories>();
134       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
135       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
136       AddStep<ci::security::StepUpdateSecurity>();
137       AddStep<wgt::pkgmgr::StepGenerateXml>();
138       AddStep<ci::pkgmgr::StepUpdateApplication>();
139       AddStep<ci::pkgmgr::StepRunParserPlugin>(
140           ci::Plugin::ActionType::Upgrade);
141       // TODO(t.iwanek): this step is supposed to be removed as it is quickfix
142       AddStep<ci::pkgmgr::StepUpdateTep>();
143       break;
144     case ci::RequestType::Uninstall:
145       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
146       AddStep<ci::pkgmgr::StepCheckRemovable>();
147       AddStep<ci::configuration::StepParseManifest>(
148           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
149           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
150       AddStep<ci::pkgmgr::StepRunParserPlugin>(
151           ci::Plugin::ActionType::Uninstall);
152       AddStep<ci::pkgmgr::StepKillApps>();
153       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
154       AddStep<ci::pkgmgr::StepUnregisterApplication>();
155       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
156       AddStep<ci::filesystem::StepRemoveFiles>();
157       AddStep<ci::filesystem::StepRemoveIcons>();
158       AddStep<wgt::encryption::StepRemoveEncryptionData>();
159       AddStep<ci::security::StepRevokeSecurity>();
160       AddStep<ci::pkgmgr::StepRemoveManifest>();
161       break;
162     case ci::RequestType::Reinstall:
163       // RDS is not supported for hybrid apps
164       AddStep<ci::configuration::StepFail>();
165       break;
166     case ci::RequestType::Delta:
167       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
168       AddStep<ci::filesystem::StepUnzip>();
169       AddStep<ci::configuration::StepParseManifest>(
170           ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
171           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
172       AddStep<ci::filesystem::StepDeltaPatch>();
173       AddStep<hybrid::configuration::StepStashTpkConfig>();
174       AddStep<hybrid::configuration::StepParse>(true);
175       AddStep<hybrid::configuration::StepMergeTpkConfig>();
176       AddStep<ci::security::StepCheckSignature>();
177       AddStep<ci::security::StepPrivilegeCompatibility>();
178       AddStep<wgt::security::StepCheckSettingsLevel>();
179       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
180       AddStep<hybrid::encryption::StepEncryptResources>();
181       AddStep<ci::security::StepRollbackInstallationSecurity>();
182       AddStep<ci::configuration::StepParseManifest>(
183           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
184           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
185       AddStep<ci::pkgmgr::StepKillApps>();
186       AddStep<ci::backup::StepBackupManifest>();
187       AddStep<ci::backup::StepBackupIcons>();
188       AddStep<ci::backup::StepCopyBackup>();
189       AddStep<tpk::filesystem::StepTpkPatchIcons>();
190       AddStep<wgt::filesystem::StepWgtPatchIcons>();
191       AddStep<ci::filesystem::StepCreateIcons>();
192       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
193       AddStep<ci::filesystem::StepCopyStorageDirectories>();
194       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
195       AddStep<tpk::filesystem::StepCreateSymbolicLink>();
196       AddStep<ci::security::StepUpdateSecurity>();
197       AddStep<wgt::pkgmgr::StepGenerateXml>();
198       AddStep<ci::pkgmgr::StepUpdateApplication>();
199       AddStep<ci::pkgmgr::StepRunParserPlugin>(
200           ci::Plugin::ActionType::Upgrade);
201       break;
202     case ci::RequestType::Recovery:
203       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
204       AddStep<ci::recovery::StepOpenRecoveryFile>();
205       AddStep<ci::configuration::StepParseManifest>(
206           ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
207           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
208       AddStep<hybrid::configuration::StepStashTpkConfig>();
209       AddStep<wgt::configuration::StepParseRecovery>();
210       AddStep<hybrid::configuration::StepMergeTpkConfig>();
211       AddStep<ci::pkgmgr::StepRecoverApplication>();
212       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
213       AddStep<ci::filesystem::StepRecoverIcons>();
214       AddStep<ci::filesystem::StepRecoverManifest>();
215       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
216       AddStep<ci::filesystem::StepRecoverFiles>();
217       AddStep<ci::security::StepRecoverSecurity>();
218       break;
219     case ci::RequestType::Clear:
220       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
221       AddStep<ci::filesystem::StepClearData>();
222       break;
223     default:
224       AddStep<ci::configuration::StepFail>();
225       break;
226   }
227 }
228
229 }  // namespace hybrid
230