1 /* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
2 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 // Use of this source code is governed by a apache 2.0 license that can be
4 // found in the LICENSE file.
6 #ifndef COMMON_INSTALLER_CONTEXT_H_
7 #define COMMON_INSTALLER_CONTEXT_H_
9 #include <pkgmgr_parser.h>
12 #include <sys/types.h>
13 #include <vcore/Certificate.h>
21 #include "common/external_mount.h"
22 #include "common/external_storage.h"
23 #include "common/pkgmgr_interface.h"
24 #include "common/recovery_file.h"
25 #include "common/utils/property.h"
26 #include "common/utils/request.h"
28 #include "manifest_info/account.h"
29 #include "manifest_info/ime_info.h"
31 namespace common_installer {
35 std::string extra_data;
36 std::string extra_key;
38 std::vector<std::pair<std::string, std::string>> labels;
41 using ShortcutListInfo = std::vector<ShortcutInfo>;
44 * \brief Structure, that holds additional data retrieved from manifest
45 * and used during generation of platform manifest (for data that are not
46 * available within manifest_x structure
48 class ExtraManifestData {
51 ExtraManifestData() {}
53 Property<AccountInfo> account_info;
54 Property<ShortcutListInfo> shortcut_info;
55 Property<ImeInfo> ime_info;
59 * \brief Base class that is used within specific backends to keep additional
60 * information regarding package
64 /** virtual destructor */
65 virtual ~BackendData() { }
69 * \brief Class represents certificate information
71 class CertificateInfo {
73 /** author_id (using public key from author certificate) */
74 Property<std::string> author_id;
75 /** author_certificate */
76 Property<ValidationCore::CertificatePtr> auth_cert;
77 /** author_intermediate_certificate */
78 Property<ValidationCore::CertificatePtr> auth_im_cert;
79 /** author_root_certificate */
80 Property<ValidationCore::CertificatePtr> auth_root_cert;
81 /** distributor_certificate */
82 Property<ValidationCore::CertificatePtr> dist_cert;
83 /** distributor_intermediate_certificate */
84 Property<ValidationCore::CertificatePtr> dist_im_cert;
85 /** distributor_root_certificate */
86 Property<ValidationCore::CertificatePtr> dist_root_cert;
87 /** distributor2_certificate */
88 Property<ValidationCore::CertificatePtr> dist2_cert;
89 /** distributor2_intermediate_certificate */
90 Property<ValidationCore::CertificatePtr>
92 /** distributor2_root_certificate */
93 Property<ValidationCore::CertificatePtr> dist2_root_cert;
97 * \brief Class used for recovery situation.
98 * It holds pointer to RecoveryFile object.
102 /** default constructor */
103 RecoveryInfo() : cleanup(false) { }
108 * \param rf RecoveryFile object (pointer to object)
110 explicit RecoveryInfo(std::unique_ptr<recovery::RecoveryFile> rf)
111 : recovery_file(std::move(rf)), cleanup(false) {
117 * \param path path of recovery file to be created
118 * \param recovery_cleanup path of recovery file to be created
120 explicit RecoveryInfo(const std::filesystem::path& path,
121 bool recovery_cleanup = false)
122 : filepath(path), cleanup(recovery_cleanup) {
125 /** pointer to RecoveryFile */
126 std::unique_ptr<recovery::RecoveryFile> recovery_file;
128 /** path of recovery file to be created */
129 std::filesystem::path filepath;
131 /** cleanup flag delivered by global recovery file */
136 * Enumeration for Privilege levels
138 enum class PrivilegeLevel : int {
146 * Enumeration for Storage types
148 enum class Storage : int {
155 * Enumeration for move types
157 enum class MoveType : int {
165 * \brief Helper function. Checks (and compares) passed levels
167 * \param required_level level to compare
168 * \param allowed_level level to compare
170 * \return true, if required_level <= allowed_level
172 bool SatifiesPrivilegeLevel(PrivilegeLevel required_level,
173 PrivilegeLevel allowed_level);
176 * \brief translates privilege level to string
178 * \param level privilege level to translate
180 * \return translated level (to string)
182 const char* PrivilegeLevelToString(PrivilegeLevel level);
185 * \brief Holds data generated/used by Steps (e.g. pkgid retrieved from
186 * manifest parsing, path to unzipped package).
187 * ContextInstaller is owned by AppInstaller object. Steps holds
188 * “pointers” to ContextInstaller (pointer is initialized in Step
191 class InstallerContext {
200 * \brief Returns package directory path containing app data
202 inline std::filesystem::path GetPkgPath() const {
203 return root_application_path.get() / pkgid.get();
207 * \brief path to final location of installed package in filesystem
209 Property<std::string> pkgid;
212 * \brief package type (string representing name of backend)
214 Property<std::string> pkg_type;
217 * \brief In-memory representation of platform xml manifest file
218 * - contains all information needed by tizen application
219 * framework to handle package management (pkgid, icon,
220 * applications, appcontrol, privileges and more)
222 Property<manifest_x*> manifest_data;
224 /** Pkgmgr-parser plugins data */
225 Property<ExtraManifestData> manifest_plugins_data;
228 * \brief In-memory representation of platform xml manifest file
229 * - contains all already stored information needed by tizen
230 * application framework to handle package management (pkgid,
231 * icon, applications, appcontrol, privileges and more)
232 * - this field is set only for update installation
233 * (we need this information for rollback possibility)
235 Property<manifest_x*> old_manifest_data;
238 * \brief path to xml platform manifest which was generated according
239 * to maniest_data content */
240 Property<std::filesystem::path> xml_path;
243 * \brief path to backup xml platform manifest which was generated
244 * according to old_maniest_data content (needed for rollback
247 Property<std::filesystem::path> backup_xml_path;
250 * \brief file path used for installation or reinstallation process
252 Property<std::filesystem::path> file_path;
255 * \brief tep file path used for TEP installation process
257 Property<std::filesystem::path> tep_path;
260 * \brief boolean property that indicates tep file should be moved or not
262 Property<bool> is_tep_move;
265 * \brief boolean property that indicates request is external move or not
267 Property<bool> is_move_to_external;
270 * \brief property that indicates move type
272 Property<MoveType> move_type;
275 * \brief path to temporary directory when package files are unpacked
276 * before coping them to final destination
278 Property<std::filesystem::path> unpacked_dir_path;
281 * \brief uid of user which installation was triggered for
282 * (any normal or globaltizenapp)
287 * \brief root directory of installation of all packages for user
288 * (${TZ_USER_HOME}/${USER}/apps_rw/) or
289 * tizenglobalapp user (${TZ_SYS_RO_APP} or ${TZ_SYS_RW_APP})
291 Property<std::filesystem::path> root_application_path;
294 * \brief "void*-like" structure to store backend specific
295 * information about installation process
297 Property<BackendData*> backend_data;
300 * \brief privilege/visibility level discovered from signature files
301 * - restricts package privileges
303 Property<PrivilegeLevel> privilege_level;
306 * \brief certificate information
308 Property<CertificateInfo> certificate_info;
311 * \brief information for recovery
313 Property<RecoveryInfo> recovery_info;
316 * \brief user type of request (GLOBAL/USER)
318 Property<RequestMode> request_mode;
321 * \brief request type received from pkgmgr_installer
323 Property<RequestType> request_type;
326 * \brief installation mode (ONLINE / OFFLINE)
328 Property<InstallationMode> installation_mode;
331 * \brief readonly request received from pkgmgr_installer
333 Property<bool> is_readonly_package;
336 * \brief preload-rw request received from pkgmgr_installer
338 Property<bool> is_preload_rw_package;
341 * \brief force-remove flag received from pkgmgr_installer
343 Property<bool> force_remove;
346 * \brief no-remove flag received from pkgmgr_installer
348 Property<bool> no_remove;
351 * \brief keep-rwdata flag received from pkgmgr_installer
353 Property<bool> keep_rwdata;
356 * \brief partial-rw flag received from pkgmgr_installer
358 Property<bool> partial_rw;
361 * \brief Describes force clean behaviour from db data. It set to ture,
362 * the uninstallation will be done to the end of steps.
364 Property<bool> force_clean_from_db;
367 * \brief Describes behaviour for security manager. It set to true, this will
368 * force to generates n-to-n rules for package's apps.
369 * This will be used for hybrid apps.
371 Property<bool> cross_app_rules;
374 * \brief boolean property that indicates the request is for debugging or not.
376 Property<bool> debug_mode;
379 * \brief boolean property that indicates
380 * the request is for skip optimization or not.
382 Property<bool> skip_optimization;
385 * \brief Property of vector of files to add
387 Property<std::vector<std::string>> files_to_add;
390 * \brief Property of vector of files to modify
392 Property<std::vector<std::string>> files_to_modify;
395 * \brief Property of vector of files to delete
397 Property<std::vector<std::string>> files_to_delete;
400 * @brief External Storage object if installing in external
402 std::unique_ptr<ExternalStorage> external_storage;
405 * @brief External package mount object if delta update with external
407 std::unique_ptr<ExternalMount> external_mount;
410 * @brief skip-check-reference flag received from pkgmgr_installer
412 Property<bool> skip_check_reference;
415 * @brief Storage where package to be installed
417 Property<Storage> storage;
420 * @brief Index of current request
425 } // namespace common_installer
427 #endif // COMMON_INSTALLER_CONTEXT_H_