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