Mount install steps
[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/step/backup/step_backup_icons.h>
10 #include <common/step/backup/step_backup_manifest.h>
11 #include <common/step/backup/step_copy_backup.h>
12 #include <common/step/configuration/step_block_cross_update.h>
13 #include <common/step/configuration/step_configure.h>
14 #include <common/step/configuration/step_fail.h>
15 #include <common/step/configuration/step_parse_manifest.h>
16 #include <common/step/filesystem/step_clear_data.h>
17 #include <common/step/filesystem/step_copy.h>
18 #include <common/step/filesystem/step_copy_storage_directories.h>
19 #include <common/step/filesystem/step_copy_tep.h>
20 #include <common/step/filesystem/step_create_icons.h>
21 #include <common/step/filesystem/step_create_per_user_storage_directories.h>
22 #include <common/step/filesystem/step_create_storage_directories.h>
23 #include <common/step/filesystem/step_delta_patch.h>
24 #include <common/step/filesystem/step_recover_files.h>
25 #include <common/step/filesystem/step_recover_icons.h>
26 #include <common/step/filesystem/step_recover_manifest.h>
27 #include <common/step/filesystem/step_recover_storage_directories.h>
28 #include <common/step/filesystem/step_remove_files.h>
29 #include <common/step/filesystem/step_remove_icons.h>
30 #include <common/step/filesystem/step_remove_per_user_storage_directories.h>
31 #include <common/step/filesystem/step_remove_temporary_directory.h>
32 #include <common/step/filesystem/step_remove_zip_image.h>
33 #include <common/step/filesystem/step_unzip.h>
34 #include <common/step/mount/step_mount_install.h>
35 #include <common/step/mount/step_mount_unpacked.h>
36 #include <common/step/mount/step_mount_update.h>
37 #include <common/step/pkgmgr/step_check_blacklist.h>
38 #include <common/step/pkgmgr/step_check_removable.h>
39 #include <common/step/pkgmgr/step_kill_apps.h>
40 #include <common/step/pkgmgr/step_recover_application.h>
41 #include <common/step/pkgmgr/step_register_app.h>
42 #include <common/step/pkgmgr/step_remove_manifest.h>
43 #include <common/step/pkgmgr/step_run_parser_plugins.h>
44 #include <common/step/pkgmgr/step_unregister_app.h>
45 #include <common/step/pkgmgr/step_update_app.h>
46 #include <common/step/pkgmgr/step_update_tep.h>
47 #include <common/step/recovery/step_open_recovery_file.h>
48 #include <common/step/security/step_check_old_certificate.h>
49 #include <common/step/security/step_check_signature.h>
50 #include <common/step/security/step_privilege_compatibility.h>
51 #include <common/step/security/step_recover_security.h>
52 #include <common/step/security/step_register_security.h>
53 #include <common/step/security/step_revoke_security.h>
54 #include <common/step/security/step_rollback_deinstallation_security.h>
55 #include <common/step/security/step_rollback_installation_security.h>
56 #include <common/step/security/step_update_security.h>
57
58 #include <wgt_manifest_handlers/widget_config_parser.h>
59 #include <common/step/rds/step_rds_modify.h>
60 #include <common/step/rds/step_rds_parse.h>
61
62 #include "wgt/step/configuration/step_parse.h"
63 #include "wgt/step/configuration/step_parse_recovery.h"
64 #include "wgt/step/encryption/step_encrypt_resources.h"
65 #include "wgt/step/encryption/step_remove_encryption_data.h"
66 #include "wgt/step/filesystem/step_create_symbolic_link.h"
67 #include "wgt/step/filesystem/step_wgt_patch_icons.h"
68 #include "wgt/step/filesystem/step_wgt_patch_storage_directories.h"
69 #include "wgt/step/filesystem/step_wgt_prepare_package_directory.h"
70 #include "wgt/step/filesystem/step_wgt_resource_directory.h"
71 #include "wgt/step/filesystem/step_wgt_update_package_directory.h"
72 #include "wgt/step/pkgmgr/step_generate_xml.h"
73 #include "wgt/step/rds/step_wgt_rds_modify.h"
74 #include "wgt/step/security/step_add_default_privileges.h"
75 #include "wgt/step/security/step_check_settings_level.h"
76 #include "wgt/step/security/step_check_wgt_background_category.h"
77 #include "wgt/step/security/step_check_wgt_notification_category.h"
78
79 namespace ci = common_installer;
80
81 namespace wgt {
82
83 WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr)
84     : AppInstaller("wgt", pkgrmgr) {
85   context_->backend_data.set(new WgtBackendData());
86
87   /* treat the request */
88   switch (pkgmgr_->GetRequestType()) {
89     case ci::RequestType::Install : {
90       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
91       AddStep<ci::filesystem::StepUnzip>();
92       AddStep<wgt::configuration::StepParse>(true);
93       AddStep<ci::pkgmgr::StepCheckBlacklist>();
94       AddStep<ci::security::StepCheckSignature>();
95       AddStep<ci::security::StepPrivilegeCompatibility>();
96       AddStep<wgt::security::StepCheckSettingsLevel>();
97       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
98       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
99       AddStep<wgt::encryption::StepEncryptResources>();
100       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
101       AddStep<ci::security::StepRollbackInstallationSecurity>();
102       AddStep<ci::filesystem::StepCopy>();
103       AddStep<ci::filesystem::StepCopyTep>();
104       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
105       AddStep<ci::filesystem::StepCreateStorageDirectories>();
106       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
107       AddStep<wgt::filesystem::StepWgtPatchIcons>();
108       AddStep<ci::filesystem::StepCreateIcons>();
109       AddStep<wgt::pkgmgr::StepGenerateXml>();
110       AddStep<ci::pkgmgr::StepRegisterApplication>();
111       AddStep<ci::pkgmgr::StepRunParserPlugin>(
112           ci::Plugin::ActionType::Install);
113       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
114       AddStep<ci::security::StepRegisterSecurity>();
115       break;
116     }
117     case ci::RequestType::Update: {
118       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
119       AddStep<ci::filesystem::StepUnzip>();
120       AddStep<wgt::configuration::StepParse>(true);
121       AddStep<ci::pkgmgr::StepCheckBlacklist>();
122       AddStep<ci::security::StepCheckSignature>();
123       AddStep<ci::security::StepPrivilegeCompatibility>();
124       AddStep<wgt::security::StepCheckSettingsLevel>();
125       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
126       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
127       AddStep<ci::security::StepCheckOldCertificate>();
128       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
129       AddStep<ci::configuration::StepParseManifest>(
130           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
131           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
132       AddStep<ci::configuration::StepBlockCrossUpdate>();
133       AddStep<ci::pkgmgr::StepKillApps>();
134       AddStep<ci::backup::StepBackupManifest>();
135       AddStep<ci::backup::StepBackupIcons>();
136       AddStep<ci::backup::StepCopyBackup>();
137       AddStep<ci::filesystem::StepCopyTep>();
138       AddStep<ci::pkgmgr::StepUpdateTep>();
139       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
140       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
141       AddStep<wgt::filesystem::StepWgtPatchIcons>();
142       AddStep<ci::filesystem::StepCreateIcons>();
143       AddStep<ci::filesystem::StepCopyStorageDirectories>();
144       AddStep<ci::security::StepUpdateSecurity>();
145       AddStep<wgt::pkgmgr::StepGenerateXml>();
146       AddStep<ci::pkgmgr::StepRunParserPlugin>(
147           ci::Plugin::ActionType::Upgrade);
148       AddStep<ci::pkgmgr::StepUpdateApplication>();
149       break;
150     }
151     case ci::RequestType::Uninstall: {
152       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
153       AddStep<ci::pkgmgr::StepCheckRemovable>();
154       AddStep<ci::configuration::StepParseManifest>(
155           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
156           ci::configuration::StepParseManifest::StoreLocation::NORMAL);
157       AddStep<ci::pkgmgr::StepKillApps>();
158       AddStep<ci::pkgmgr::StepRunParserPlugin>(
159           ci::Plugin::ActionType::Uninstall);
160       AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
161       AddStep<ci::pkgmgr::StepUnregisterApplication>();
162       AddStep<ci::security::StepRollbackDeinstallationSecurity>();
163       AddStep<ci::filesystem::StepRemoveFiles>();
164       AddStep<ci::filesystem::StepRemoveZipImage>();
165       AddStep<ci::filesystem::StepRemoveIcons>();
166       AddStep<wgt::encryption::StepRemoveEncryptionData>();
167       AddStep<ci::security::StepRevokeSecurity>();
168       AddStep<ci::pkgmgr::StepRemoveManifest>();
169       break;
170     }
171     case ci::RequestType::Reinstall: {
172       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
173       AddStep<wgt::configuration::StepParse>(false);
174       AddStep<ci::pkgmgr::StepKillApps>();
175       AddStep<ci::configuration::StepParseManifest>(
176           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
177           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
178       AddStep<ci::configuration::StepBlockCrossUpdate>();
179       AddStep<ci::pkgmgr::StepCheckBlacklist>();
180       AddStep<ci::rds::StepRDSParse>();
181       AddStep<wgt::rds::StepWgtRDSModify>();
182       AddStep<ci::security::StepUpdateSecurity>();
183       break;
184     }
185     case ci::RequestType::Delta: {
186       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
187       AddStep<ci::filesystem::StepUnzip>();
188       // TODO(t.iwanek): manifest is parsed twice...
189       AddStep<wgt::configuration::StepParse>(false);
190       // start file may not have changed
191       AddStep<ci::filesystem::StepDeltaPatch>("res/wgt/");
192       AddStep<wgt::configuration::StepParse>(true);
193       AddStep<ci::pkgmgr::StepCheckBlacklist>();
194       AddStep<ci::security::StepCheckSignature>();
195       AddStep<ci::security::StepPrivilegeCompatibility>();
196       AddStep<wgt::security::StepCheckSettingsLevel>();
197       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
198       AddStep<wgt::security::StepCheckWgtNotificationCategory>();
199       AddStep<ci::security::StepCheckOldCertificate>();
200       AddStep<wgt::filesystem::StepWgtResourceDirectory>();
201       AddStep<ci::configuration::StepParseManifest>(
202           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
203           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
204       AddStep<ci::configuration::StepBlockCrossUpdate>();
205       AddStep<ci::pkgmgr::StepKillApps>();
206       AddStep<ci::backup::StepBackupManifest>();
207       AddStep<ci::backup::StepBackupIcons>();
208       AddStep<ci::backup::StepCopyBackup>();
209       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
210       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
211       AddStep<wgt::filesystem::StepWgtPatchIcons>();
212       AddStep<ci::filesystem::StepCreateIcons>();
213       AddStep<ci::filesystem::StepCopyStorageDirectories>();
214       AddStep<ci::security::StepUpdateSecurity>();
215       AddStep<wgt::pkgmgr::StepGenerateXml>();
216       AddStep<ci::pkgmgr::StepRunParserPlugin>(
217           ci::Plugin::ActionType::Upgrade);
218       AddStep<ci::pkgmgr::StepUpdateApplication>();
219       break;
220     }
221     case ci::RequestType::Recovery: {
222       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
223       AddStep<ci::recovery::StepOpenRecoveryFile>();
224       AddStep<wgt::configuration::StepParseRecovery>();
225       AddStep<ci::pkgmgr::StepRecoverApplication>();
226       AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
227       AddStep<ci::filesystem::StepRecoverIcons>();
228       AddStep<ci::filesystem::StepRecoverManifest>();
229       AddStep<ci::filesystem::StepRecoverStorageDirectories>();
230       AddStep<ci::filesystem::StepRecoverFiles>();
231       AddStep<ci::security::StepRecoverSecurity>();
232       break;
233     }
234     case ci::RequestType::Clear: {
235       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
236       AddStep<ci::filesystem::StepClearData>();
237       break;
238     }
239     case ci::RequestType::MountInstall: {
240       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
241       AddStep<ci::mount::StepMountUnpacked>();
242       AddStep<wgt::configuration::StepParse>(true);
243       AddStep<ci::pkgmgr::StepCheckBlacklist>();
244       AddStep<ci::security::StepCheckSignature>();
245       AddStep<ci::security::StepPrivilegeCompatibility>();
246       AddStep<wgt::security::StepCheckSettingsLevel>();
247       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
248       AddStep<wgt::encryption::StepEncryptResources>();
249       AddStep<ci::security::StepRollbackInstallationSecurity>();
250       AddStep<ci::mount::StepMountInstall>();
251       AddStep<wgt::filesystem::StepWgtPreparePackageDirectory>();
252       AddStep<ci::filesystem::StepCopyTep>();
253       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
254       AddStep<ci::filesystem::StepCreateStorageDirectories>();
255       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
256       AddStep<wgt::filesystem::StepWgtPatchIcons>();
257       AddStep<ci::filesystem::StepCreateIcons>();
258       AddStep<wgt::pkgmgr::StepGenerateXml>();
259       AddStep<ci::pkgmgr::StepRegisterApplication>();
260       AddStep<ci::pkgmgr::StepRunParserPlugin>(
261           ci::Plugin::ActionType::Install);
262       AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
263       AddStep<ci::security::StepRegisterSecurity>();
264       break;
265     }
266     case ci::RequestType::MountUpdate: {
267       AddStep<ci::configuration::StepConfigure>(pkgmgr_);
268       AddStep<ci::mount::StepMountUnpacked>();
269       AddStep<wgt::configuration::StepParse>(true);
270       AddStep<ci::pkgmgr::StepCheckBlacklist>();
271       AddStep<ci::security::StepCheckSignature>();
272       AddStep<ci::security::StepPrivilegeCompatibility>();
273       AddStep<wgt::security::StepCheckSettingsLevel>();
274       AddStep<wgt::security::StepCheckWgtBackgroundCategory>();
275       AddStep<ci::security::StepCheckOldCertificate>();
276       AddStep<ci::configuration::StepParseManifest>(
277           ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
278           ci::configuration::StepParseManifest::StoreLocation::BACKUP);
279       AddStep<ci::configuration::StepBlockCrossUpdate>();
280       AddStep<ci::pkgmgr::StepKillApps>();
281       AddStep<ci::backup::StepBackupManifest>();
282       AddStep<ci::backup::StepBackupIcons>();
283       AddStep<ci::mount::StepMountUpdate>();
284       AddStep<wgt::filesystem::StepWgtUpdatePackageDirectory>();
285       AddStep<ci::filesystem::StepCopyTep>();
286       AddStep<ci::pkgmgr::StepUpdateTep>();
287       AddStep<wgt::filesystem::StepWgtPatchStorageDirectories>();
288       AddStep<wgt::filesystem::StepCreateSymbolicLink>();
289       AddStep<wgt::filesystem::StepWgtPatchIcons>();
290       AddStep<ci::filesystem::StepCreateIcons>();
291       AddStep<ci::security::StepUpdateSecurity>();
292       AddStep<wgt::pkgmgr::StepGenerateXml>();
293       AddStep<ci::pkgmgr::StepRunParserPlugin>(
294           ci::Plugin::ActionType::Upgrade);
295       AddStep<ci::pkgmgr::StepUpdateApplication>();
296       break;
297     }
298     default: {
299       AddStep<ci::configuration::StepFail>();
300     }
301   }
302 }
303
304 }  // namespace wgt