Relocating some files to reduce modular circular dependency ratio.
Change-Id: I3aeaef2af1b341a0b09b94282d37adc1b8d8e77c
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/plugins COMMON_PLUGINS_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/plugins/types COMMON_PLUGINS_TYPES_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils COMMON_UTILS_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/installer COMMON_INSTALLER_SRCS)
# Target - definition
ADD_LIBRARY(${TARGET_LIBNAME_COMMON} SHARED
${COMMON_SRCS}
${COMMON_STEP_SECURITY_SRCS}
${COMMON_PLUGINS_SRCS}
${COMMON_PLUGINS_TYPES_SRCS}
- ${COMMON_UTILS_SRCS})
+ ${COMMON_UTILS_SRCS}
+ ${COMMON_INSTALLER_SRCS})
# Target - includes
TARGET_INCLUDE_DIRECTORIES(${TARGET_LIBNAME_COMMON} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../")
# Target - deps
INSTALL(FILES app-installers.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(DIRECTORY ./ DESTINATION ${INCLUDEDIR}/app-installers/common/
FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ./installer/ DESTINATION ${INCLUDEDIR}/app-installers/common/
+ FILES_MATCHING PATTERN "*.h")
+
+++ /dev/null
-/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#include <unistd.h>
-
-#include <cstdio>
-#include <fstream>
-#include <TTraceWrapper.h>
-
-#include "common/app_installer.h"
-#include "common/installer_context.h"
-#include "common/pkgmgr_interface.h"
-#include "common/pkgmgr_signal.h"
-#include "common/step/configuration/step_fail.h"
-#include "common/utils/file_logbackend.h"
-
-#include "common/step/backup/step_backup_icons.h"
-#include "common/step/backup/step_backup_manifest.h"
-#include "common/step/backup/step_copy_backup.h"
-#include "common/step/configuration/step_block_cross_update.h"
-#include "common/step/configuration/step_check_install_location.h"
-#include "common/step/configuration/step_check_tizen_version.h"
-#include "common/step/configuration/step_configure.h"
-#include "common/step/configuration/step_parse_manifest.h"
-#include "common/step/configuration/step_parse_preload.h"
-#include "common/step/configuration/step_switch_readonly_mode.h"
-#include "common/step/filesystem/step_acquire_external_storage.h"
-#include "common/step/filesystem/step_change_ownership_and_permission.h"
-#include "common/step/filesystem/step_copy.h"
-#include "common/step/filesystem/step_copy_storage_directories.h"
-#include "common/step/filesystem/step_copy_tep.h"
-#include "common/step/filesystem/step_create_globalapp_symlinks.h"
-#include "common/step/filesystem/step_create_icons.h"
-#include "common/step/filesystem/step_create_storage_directories.h"
-#include "common/step/filesystem/step_delta_patch.h"
-#include "common/step/filesystem/step_disable_external_mount.h"
-#include "common/step/filesystem/step_enable_external_mount.h"
-#include "common/step/filesystem/step_migrate_legacy_external_image.h"
-#include "common/step/filesystem/step_move_installed_storage.h"
-#include "common/step/filesystem/step_optional_acquire_external_storage.h"
-#include "common/step/filesystem/step_recover_change_owner.h"
-#include "common/step/filesystem/step_recover_external_storage.h"
-#include "common/step/filesystem/step_recover_files.h"
-#include "common/step/filesystem/step_recover_globalapp_symlinks.h"
-#include "common/step/filesystem/step_recover_icons.h"
-#include "common/step/filesystem/step_recover_manifest.h"
-#include "common/step/filesystem/step_recover_storage_directories.h"
-#include "common/step/filesystem/step_remove_files.h"
-#include "common/step/filesystem/step_remove_icons.h"
-#include "common/step/filesystem/step_remove_globalapp_symlinks.h"
-#include "common/step/filesystem/step_remove_per_user_storage_directories.h"
-#include "common/step/filesystem/step_remove_temporary_directory.h"
-#include "common/step/filesystem/step_remove_tep.h"
-#include "common/step/filesystem/step_remove_user_data.h"
-#include "common/step/filesystem/step_remove_zip_image.h"
-#include "common/step/filesystem/step_unzip.h"
-#include "common/step/filesystem/step_update_storage_directories.h"
-#include "common/step/filesystem/step_update_tep.h"
-#include "common/step/mount/step_check_mount_path.h"
-#include "common/step/mount/step_mount_install.h"
-#include "common/step/mount/step_mount_recover.h"
-#include "common/step/mount/step_mount_unpacked.h"
-#include "common/step/mount/step_mount_update.h"
-#include "common/step/mount/step_unmount.h"
-#include "common/step/pkgmgr/step_check_force_clean.h"
-#include "common/step/pkgmgr/step_check_installable.h"
-#include "common/step/pkgmgr/step_check_removable.h"
-#include "common/step/pkgmgr/step_check_restriction.h"
-#include "common/step/pkgmgr/step_check_upgradable.h"
-#include "common/step/pkgmgr/step_kill_apps.h"
-#include "common/step/pkgmgr/step_recover_application.h"
-#include "common/step/pkgmgr/step_recover_parser_plugins.h"
-#include "common/step/pkgmgr/step_register_app.h"
-#include "common/step/pkgmgr/step_remove_manifest.h"
-#include "common/step/pkgmgr/step_run_parser_plugins.h"
-#include "common/step/pkgmgr/step_unregister_app.h"
-#include "common/step/pkgmgr/step_update_app.h"
-#include "common/step/pkgmgr/step_update_pkg_disable_info.h"
-#include "common/step/rds/step_rds_modify.h"
-#include "common/step/rds/step_rds_parse.h"
-#include "common/step/recovery/step_create_recovery_file.h"
-#include "common/step/recovery/step_open_recovery_file.h"
-#include "common/step/security/step_check_old_certificate.h"
-#include "common/step/security/step_get_privilege_level.h"
-#include "common/step/security/step_privacy_privilege.h"
-#include "common/step/security/step_recover_security.h"
-#include "common/step/security/step_recover_trust_anchor.h"
-#include "common/step/security/step_register_security.h"
-#include "common/step/security/step_register_trust_anchor.h"
-#include "common/step/security/step_revoke_security.h"
-#include "common/step/security/step_revoke_trust_anchor.h"
-#include "common/step/security/step_rollback_installation_security.h"
-#include "common/step/security/step_signature.h"
-#include "common/step/security/step_unregister_trust_anchor.h"
-#include "common/step/security/step_update_security.h"
-
-namespace ci = common_installer;
-
-namespace {
-
-const unsigned kProgressRange = 100;
-const char kLogFileName[] = LOGDIR"/app-installers.log";
-const char kHistoryFileName[] = LOGDIR"/installation-history.log";
-const int kLogRotationSize = 1024 * 256; // 256KB
-const int kLogMaximumRotation = 3;
-
-}
-
-namespace common_installer {
-
-AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
- : pkgmgr_(pkgmgr), context_(new InstallerContext()),
- status_(Step::Status::OK), result_(Result::OK), index_(0) {
- context_->pkg_type.set(package_type);
- context_->installation_mode.set(pkgmgr->GetInstallationMode());
-
- // pkgmgr signal should work only for online mode
- // there is no one to receive it in offline mode
- if (context_->installation_mode.get() == InstallationMode::ONLINE) {
- pi_ = pkgmgr->CreatePkgmgrSignal();
- }
-}
-
-AppInstaller::~AppInstaller() {
-}
-
-void AppInstaller::Init() {
- // for multi installer
- context_->index.set(index_);
- pkgmgr_->SetAppQueryInterface(index_);
-
- switch (pkgmgr_->GetRequestType(index_)) {
- case RequestType::Install:
- InstallSteps();
- break;
- case RequestType::Update:
- UpdateSteps();
- break;
- case RequestType::Uninstall:
- UninstallSteps();
- break;
- case RequestType::Reinstall:
- ReinstallSteps();
- break;
- case RequestType::Delta:
- DeltaSteps();
- break;
- case RequestType::Move:
- MoveSteps();
- break;
- case RequestType::Recovery:
- RecoverySteps();
- break;
- case RequestType::MountInstall:
- MountInstallSteps();
- break;
- case RequestType::MountUpdate:
- MountUpdateSteps();
- break;
- case RequestType::ManifestDirectInstall:
- ManifestDirectInstallSteps();
- break;
- case RequestType::ManifestDirectUpdate:
- ManifestDirectUpdateSteps();
- break;
- case RequestType::ManifestPartialInstall:
- ManifestPartialInstallSteps();
- break;
- case RequestType::ManifestPartialUpdate:
- ManifestPartialUpdateSteps();
- break;
- case RequestType::PartialUninstall:
- PartialUninstallSteps();
- break;
- case RequestType::ReadonlyUpdateInstall:
- ReadonlyUpdateInstallSteps();
- break;
- case RequestType::ReadonlyUpdateUninstall:
- ReadonlyUpdateUninstallSteps();
- break;
- case RequestType::EnablePkg:
- EnablePkgSteps();
- break;
- case RequestType::DisablePkg:
- DisablePkgSteps();
- break;
- case RequestType::MigrateExtImg:
- MigrateExtImgSteps();
- break;
- case RequestType::RecoverDB:
- RecoverDBSteps();
- break;
- default:
- UnknownSteps();
- break;
- }
-}
-
-AppInstaller::Result AppInstaller::Run() {
- Process();
- if (it_ != steps_.end() && result_ == Result::ERROR) {
- LOG(ERROR) << "Failure occurs in step: " << (*it_)->name();
- Undo();
- } else {
- Clean();
- }
- sync();
-
- if ((context_->installation_mode.get() == InstallationMode::OFFLINE) &&
- (result_ == Result::ERROR)) {
- std::fstream info_file("/tmp/.preload_install_error",
- std::ios::out | std::ios::app);
- info_file << context_->pkgid.get() << std::endl;
- info_file.close();
- }
-
- return result_;
-}
-
-void AppInstaller::LogHistory(bool success) {
- std::shared_ptr<utils::FileLogBackend> history_logger =
- std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
- kHistoryFileName, kLogRotationSize, kLogMaximumRotation));
- std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" +
- GetRequestTypeString(context_->request_type.get());
- if (success)
- history += "|SUCCESS";
- else
- history += "|FAIL";
- history_logger->WriteLog(::utils::LogLevel::LOG_INFO, "", history);
- history_logger->WriteLogToFile();
-}
-
-AppInstaller::Result AppInstaller::Process() {
- Init();
-
- failure_logger_ =
- std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
- kLogFileName, kLogRotationSize, kLogMaximumRotation));
- ::utils::LogCore::GetCore().AddLogBackend(failure_logger_);
-
- unsigned total_steps = steps_.size();
- unsigned current_step = 1;
-
- for (it_ = steps_.begin(); it_ != steps_.end(); ++it_, ++current_step) {
- status_ = SafeExecute(*it_, &Step::precheck, "precheck");
- if (status_ == Step::Status::OK)
- status_ = SafeExecute(*it_, &Step::process, "process");
-
- if (status_ != Step::Status::OK) {
- if (status_ != Step::Status::RECOVERY_DONE) {
- LOG(ERROR) << "Error during processing";
- result_ = Result::ERROR;
- }
- break;
- }
- SendProgress(current_step * kProgressRange / total_steps);
- }
-
- return result_;
-}
-
-AppInstaller::Result AppInstaller::Undo() {
- do {
- if (it_ == steps_.end())
- --it_;
- if (SafeExecute(*it_, &Step::undo, "undo") != Step::Status::OK) {
- LOG(ERROR) << "Error during undo operation(" << (*it_)->name()
- << "), but continuing...";
- result_ = Result::UNDO_ERROR;
- }
- } while (it_-- != steps_.begin());
- sync();
- failure_logger_->WriteLogToFile();
-
- // Undo will be invoked when other installer fails when multi-install, but the
- // status of current installer can be ok. We need to change this to proper
- // error code to notify that entire installation was failed to listener.
- // TODO(jeremy.jang): Need some other error for multi-install failure?
- if (status_ == Step::Status::OK)
- status_ = Step::Status::ERROR;
- SendFinished(status_);
-
- LogHistory(false);
-
- return result_;
-}
-
-AppInstaller::Result AppInstaller::Clean() {
- const auto& recovery_file =
- context_->recovery_info.get().recovery_file;
- if (recovery_file) {
- recovery_file->set_cleanup(true);
- recovery_file->WriteAndCommitFileContent();
- }
- SendFinished(status_);
-
- do {
- if (it_ == steps_.end())
- --it_;
- if (SafeExecute(*it_, &Step::clean, "clean") != Step::Status::OK) {
- LOG(ERROR) << "Error during clean operation(" << (*it_)->name() << ")";
- result_ = Result::CLEANUP_ERROR;
- break;
- }
- } while (it_-- != steps_.begin());
- sync();
-
- LogHistory(true);
-
- return result_;
-}
-
-void AppInstaller::InstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::filesystem::StepUnzip>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckInstallable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::pkgmgr::StepCheckRestriction>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepRollbackInstallationSecurity>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepAcquireExternalStorage>(false);
- AddStep<ci::filesystem::StepCopy>();
- AddStep<ci::filesystem::StepCopyTep>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepRegisterApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Install);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
- AddStep<ci::filesystem::StepCreateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::UpdateSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::filesystem::StepUnzip>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::configuration::StepBlockCrossUpdate>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::backup::StepBackupManifest>();
- AddStep<ci::backup::StepBackupIcons>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::backup::StepCopyBackup>();
- AddStep<ci::filesystem::StepUpdateTep>();
- AddStep<ci::filesystem::StepCopyStorageDirectories>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::UninstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::pkgmgr::StepCheckRestriction>();
- AddStep<ci::pkgmgr::StepCheckRemovable>();
- AddStep<ci::pkgmgr::StepCheckForceClean>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Uninstall);
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
- AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
- AddStep<ci::pkgmgr::StepUnregisterApplication>();
- AddStep<ci::security::StepUnregisterTrustAnchor>();
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
- AddStep<ci::filesystem::StepRemoveFiles>();
- AddStep<ci::filesystem::StepRemoveZipImage>();
- AddStep<ci::filesystem::StepRemoveIcons>();
- AddStep<ci::filesystem::StepRemoveTep>();
- AddStep<ci::security::StepRevokeSecurity>();
- AddStep<ci::pkgmgr::StepRemoveManifest>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ReinstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::configuration::StepBlockCrossUpdate>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::backup::StepBackupManifest>();
- AddStep<ci::backup::StepBackupIcons>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::rds::StepRDSParse>();
- AddStep<ci::rds::StepRDSModify>();
- AddStep<ci::filesystem::StepUpdateTep>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::DeltaSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::filesystem::StepUnzip>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::filesystem::StepEnableExternalMount>();
- AddStep<ci::filesystem::StepDeltaPatch>();
- AddStep<ci::filesystem::StepDisableExternalMount>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::configuration::StepBlockCrossUpdate>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::backup::StepBackupManifest>();
- AddStep<ci::backup::StepBackupIcons>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::backup::StepCopyBackup>();
- AddStep<ci::filesystem::StepUpdateTep>();
- AddStep<ci::filesystem::StepCopyStorageDirectories>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::MoveSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::pkgmgr::StepCheckRestriction>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::filesystem::StepMoveInstalledStorage>();
- AddStep<ci::security::StepRegisterSecurity>();
-}
-
-void AppInstaller::RecoverySteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepOpenRecoveryFile>();
- AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::filesystem::StepRecoverIcons>();
- AddStep<ci::pkgmgr::StepRecoverParserPlugin>();
- AddStep<ci::filesystem::StepRecoverManifest>();
- AddStep<ci::filesystem::StepRecoverExternalStorage>();
- AddStep<ci::filesystem::StepRecoverStorageDirectories>();
- AddStep<ci::filesystem::StepRecoverGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepRecoverFiles>();
- AddStep<ci::mount::StepMountRecover>();
- AddStep<ci::filesystem::StepRecoverChangeOwner>();
- AddStep<ci::pkgmgr::StepRecoverApplication>();
- AddStep<ci::security::StepRecoverTrustAnchor>();
- AddStep<ci::security::StepRecoverSecurity>();
-}
-
-void AppInstaller::MountInstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::mount::StepMountUnpacked>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckInstallable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::pkgmgr::StepCheckRestriction>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepRollbackInstallationSecurity>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::mount::StepMountInstall>();
- AddStep<ci::filesystem::StepCopyTep>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepRegisterApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Install);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
- AddStep<ci::mount::StepUnmount>();
- AddStep<ci::filesystem::StepCreateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::MountUpdateSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::mount::StepMountUnpacked>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::configuration::StepBlockCrossUpdate>();
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::backup::StepBackupManifest>();
- AddStep<ci::backup::StepBackupIcons>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::mount::StepMountUpdate>();
- AddStep<ci::filesystem::StepUpdateTep>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::mount::StepUnmount>();
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ManifestDirectInstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepCheckInstallable>();
- AddStep<ci::mount::StepCheckMountPath>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepRollbackInstallationSecurity>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::pkgmgr::StepRegisterApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Install);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
- AddStep<ci::filesystem::StepCreateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ManifestDirectUpdateSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::mount::StepCheckMountPath>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ManifestPartialInstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::security::StepSignature>(false);
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::pkgmgr::StepRegisterApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Install);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
- AddStep<ci::filesystem::StepCreateStorageDirectories>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ManifestPartialUpdateSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::security::StepSignature>(false);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepRegisterSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::PartialUninstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::pkgmgr::StepCheckRemovable>();
- AddStep<ci::pkgmgr::StepCheckForceClean>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
- AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
- AddStep<ci::pkgmgr::StepUnregisterApplication>();
- AddStep<ci::security::StepUnregisterTrustAnchor>();
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
- AddStep<ci::security::StepRevokeSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(
- ci::Plugin::ActionType::Uninstall);
-}
-
-void AppInstaller::ReadonlyUpdateInstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::recovery::StepCreateRecoveryFile>();
- AddStep<ci::filesystem::StepUnzip>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::configuration::StepSwitchReadonlyMode>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepSwitchReadonlyMode>();
- AddStep<ci::configuration::StepCheckInstallLocation>();
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::configuration::StepCheckTizenVersion>();
- AddStep<ci::security::StepSignature>(true);
- AddStep<ci::security::StepCheckOldCertificate>();
- AddStep<ci::configuration::StepBlockCrossUpdate>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::filesystem::StepCopy>();
- AddStep<ci::filesystem::StepCopyTep>();
- AddStep<ci::filesystem::StepCreateIcons>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
- AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
-}
-
-void AppInstaller::ReadonlyUpdateUninstallSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::BACKUP);
- AddStep<ci::configuration::StepSwitchReadonlyMode>();
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepCheckUpgradable>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::security::StepSignature>(false);
- AddStep<ci::configuration::StepSwitchReadonlyMode>();
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
- AddStep<ci::security::StepRevokeTrustAnchor>();
- AddStep<ci::pkgmgr::StepUpdateApplication>();
- AddStep<ci::security::StepRegisterTrustAnchor>(
- ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
- AddStep<ci::security::StepPrivacyPrivilege>(
- ci::security::StepPrivacyPrivilege::ActionType::Update);
- AddStep<ci::filesystem::StepRemoveFiles>();
- AddStep<ci::filesystem::StepRemoveZipImage>();
- AddStep<ci::filesystem::StepRemoveIcons>();
- AddStep<ci::filesystem::StepRemoveTep>();
- AddStep<ci::filesystem::StepRemoveUserData>();
- AddStep<ci::configuration::StepSwitchReadonlyMode>();
- AddStep<ci::security::StepUpdateSecurity>();
- AddStep<ci::pkgmgr::StepRemoveManifest>();
- AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
- AddStep<ci::filesystem::StepUpdateStorageDirectories>();
-}
-
-void AppInstaller::DisablePkgSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepKillApps>();
- AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
- ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Disable);
- AddStep<ci::pkgmgr::StepRunParserPlugin>(
- ci::Plugin::ActionType::Uninstall);
-}
-
-void AppInstaller::EnablePkgSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
- ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Enable);
- AddStep<ci::pkgmgr::StepRunParserPlugin>(
- ci::Plugin::ActionType::Install);
-}
-
-void AppInstaller::MigrateExtImgSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::security::StepMigrateLegacyExtImage>();
- AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
-}
-
-void AppInstaller::RecoverDBSteps() {
- AddStep<ci::configuration::StepConfigure>(pkgmgr_);
- AddStep<ci::configuration::StepParseManifest>(
- ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
- ci::configuration::StepParseManifest::StoreLocation::NORMAL);
- AddStep<ci::pkgmgr::StepCheckInstallable>();
- AddStep<ci::mount::StepCheckMountPath>();
- AddStep<ci::configuration::StepParsePreload>();
- AddStep<ci::security::StepGetPrivilegeLevel>();
- AddStep<ci::pkgmgr::StepRegisterApplication>();
-}
-
-void AppInstaller::UnknownSteps() {
- AddStep<configuration::StepFail>();
-}
-
-void AppInstaller::HandleStepError(Step::Status result,
- const std::string& error) {
- if (pi_)
- pi_->SendError(result, error, context_->pkg_type.get(),
- context_->pkgid.get());
-}
-
-void AppInstaller::SendProgress(int progress) {
- if (pi_) {
- // send START signal as soon as possible if not sent
- if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
- if (!context_->pkgid.get().empty()) {
- // set request type before sending start signal
- pi_->SetRequestType(context_->request_type.get());
- pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
- }
- }
-
- // send installation progress
- pi_->SendProgress(progress,
- context_->pkg_type.get(), context_->pkgid.get());
- }
-}
-
-void AppInstaller::SendFinished(Step::Status process_status) {
- if (pi_) {
- // send START if pkgid was not parsed
- if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
- // set request type before sending start signal
- pi_->SetRequestType(context_->request_type.get());
- pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
- }
- pi_->SendFinished(process_status,
- context_->pkg_type.get(),
- context_->pkgid.get());
- }
-}
-
-Step::Status AppInstaller::SafeExecute(std::unique_ptr<Step> const& step_ptr,
- Step::Status (Step::*method)(),
- std::string name) {
- Step::Status process_status = Step::Status::OK;
- try {
- TTRACE(TTRACE_TAG_APP, "%s_%s", step_ptr->name(), name.c_str());
- process_status = ((*step_ptr).*method)();
- } catch (const std::exception& err) {
- LOG(ERROR) << "Exception occurred in " << name.c_str() << "(): "
- << err.what() << " in step: " << step_ptr->name();
- process_status = Step::Status::ERROR;
- }
- return process_status;
-}
-
-} // namespace common_installer
+++ /dev/null
-/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a apache 2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_APP_INSTALLER_H_
-#define COMMON_APP_INSTALLER_H_
-
-#include <manifest_parser/utils/logging.h>
-
-#include <boost/bind.hpp>
-
-#include <list>
-#include <memory>
-#include <string>
-#include <utility>
-
-#include "common/archive_info.h"
-#include "common/pkgmgr_interface.h"
-#include "common/pkgmgr_signal.h"
-#include "common/step/step.h"
-#include "common/utils/file_logbackend.h"
-#include "common/utils/macros.h"
-
-namespace common_installer {
-
-/**
- * \brief Includes the main “steps” processing mechanisms. It holds
- * the lists of steps and runs each of the step in the configured
- * order.
- */
-class AppInstaller {
- public:
- /** Enumeration of possible returned Results */
- enum class Result {
- OK,
- ERROR,
- CLEANUP_ERROR,
- UNDO_ERROR,
- UNKNOWN
- };
-
- /**
- * \brief explicit Constructor
- *
- * \param package_type package type
- * \param pkgmgr pointer to PkgMgrInterface object
- */
- explicit AppInstaller(const char* package_type, PkgMgrPtr pkgmgr);
-
- /** virtual desctructor */
- virtual ~AppInstaller();
-
- /**
- * \brief Adds new step to installer by specified type
- * Type of template parameter is used to create requested step
- * class instance.
- * Context of installer is passed to step in this method
- * and is not being exposed outside installer.
- * Step arguments are deduced and forwarded to constructor.
- *
- * \tparam StepT Step object to be added to the step list
- * \tparam Args constructor arguments for StepT object
- * \param args argument list
- */
- template<class StepT, class... Args>
- void AddStep(Args&&... args) {
- std::unique_ptr<Step> step(
- new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
- steps_.emplace_back(std::move(step));
- }
-
- /**
- * \brief Removes specific step in steps list.
- * \param step_name step name to be removed
- */
- void RemoveStep(std::string step_name) {
- auto it = std::find_if(steps_.begin(), steps_.end(),
- [&](const std::unique_ptr<Step>& s) {
- return step_name == s->name();
- });
- if (steps_.end() == it) {
- LOG(ERROR) << "Can't find the step : " << step_name;
- return;
- }
- steps_.erase(it);
- }
-
- /**
- * \brief Adds new step to installer by specified type on specyfic place
- * in steps list.
- * Type of template parameter is used to create requested step
- * class instance.
- * Context of installer is passed to step in this method
- * and is not being exposed outside installer.
- * Step arguments are deduced and forwarded to constructor.
- *
- * \tparam StepT Step object to be added to the step list
- * \tparam index index at which the new step is added
- * \tparam Args constructor arguments for StepT object
- * \param args argument list
- */
- template<class StepT, class... Args>
- void AddStepAtIndex(unsigned int index, Args&&... args) {
- std::unique_ptr<Step> step(
- new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
- std::list<std::unique_ptr<Step>> tmpList;
- tmpList.emplace_back(std::move(step));
- auto it = steps_.begin();
- std::advance(it, index);
- steps_.splice(it, tmpList);
- }
-
- /**
- * \brief Replaces new step to installer by specified type
- * Type of template parameter is used to create requested step
- * class instance.
- * Context of installer is passed to step in this method
- * and is not being exposed outside installer.
- * Step arguments are deduced and forwarded to constructor.
- * \tparam StepT Step object to be added to the step list
- * \tparam Args constructor arguments for StepT object
- * \param step_name step name to replace
- * \param args argument list
- */
- template<class StepT, class... Args>
- void ReplaceStep(std::string step_name, Args&&... args) {
- auto it = std::find_if(std::begin(steps_), std::end(steps_),
- [&](const std::unique_ptr<Step>& s) {
- return step_name == s->name();
- });
-
- if (steps_.end() == it) {
- LOG(ERROR) << "Can't find the step : " << step_name;
- return;
- }
-
- std::unique_ptr<Step> step(
- new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
- *it = std::move(step);
- }
-
- /**
- * \brief Adds new step before specified step
- * Type of template parameter is used to create requested step
- * class instance.
- * Context of installer is passed to step in this method
- * and is not being exposed outside installer.
- * Step arguments are deduced and forwarded to constructor.
- * \tparam StepT Step object to be added to the step list
- * \tparam Args constructor arguments for StepT object
- * \param step_name step name to find and add
- * \param args argument list
- */
- template<class StepT, class... Args>
- void AddStepBefore(std::string step_name, Args&&... args) {
- auto it = std::find_if(std::begin(steps_), std::end(steps_),
- [&](const std::unique_ptr<Step>& s) {
- return step_name == s->name();
- });
-
- if (steps_.end() == it) {
- LOG(ERROR) << "Can't find the step : " << step_name;
- return;
- }
-
- std::unique_ptr<Step> step(
- new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
- steps_.insert(it, std::move(step));
- }
-
- /**
- * \brief Adds new step after specified step
- * Type of template parameter is used to create requested step
- * class instance.
- * Context of installer is passed to step in this method
- * and is not being exposed outside installer.
- * Step arguments are deduced and forwarded to constructor.
- * \tparam StepT Step object to be added to the step list
- * \tparam Args constructor arguments for StepT object
- * \param step_name step name to find and add
- * \param args argument list
- */
- template<class StepT, class... Args>
- void AddStepAfter(std::string step_name, Args&&... args) {
- auto it = std::find_if(std::begin(steps_), std::end(steps_),
- [&](const std::unique_ptr<Step>& s) {
- return step_name == s->name();
- });
-
- if (steps_.end() == it) {
- LOG(ERROR) << "Can't find the step : " << step_name;
- return;
- }
-
- std::unique_ptr<Step> step(
- new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
- steps_.insert(++it, std::move(step));
- }
-
- /**
- * \brief runs the steps in the specific sequence
- *
- * \return Result of the run (eg Result:OK)
- */
- Result Run();
-
- /**
- * \brief runs the process operations of steps
- *
- * \return Result of the run (eg Result:OK)
- */
- Result Process();
-
- /**
- * \brief runs the undo operations of steps
- *
- * \return Result of the run (eg Result:OK)
- */
- Result Undo();
-
- /**
- * \brief runs the clean operations of steps
- *
- * \return Result of the run (eg Result:OK)
- */
- Result Clean();
-
- /**
- * \brief This method can be used to check
- * the number of the registered steps.
- *
- * \return number of steps registered in app-installer
- */
- unsigned int StepCount() {
- return steps_.size();
- }
-
- void SetIndex(int index) {
- index_ = index;
- }
-
- int GetIndex() {
- return index_;
- }
-
- virtual std::unique_ptr<ArchiveInfo> GetArchiveInfo() = 0;
-
- protected:
- PkgMgrPtr pkgmgr_;
- std::unique_ptr<InstallerContext> context_;
-
- virtual void InstallSteps();
- virtual void UpdateSteps();
- virtual void UninstallSteps();
- virtual void ReinstallSteps();
- virtual void DeltaSteps();
- virtual void MoveSteps();
- virtual void RecoverySteps();
- virtual void MountInstallSteps();
- virtual void MountUpdateSteps();
- virtual void ManifestDirectInstallSteps();
- virtual void ManifestDirectUpdateSteps();
- virtual void ManifestPartialInstallSteps();
- virtual void ManifestPartialUpdateSteps();
- virtual void PartialUninstallSteps();
- virtual void ReadonlyUpdateInstallSteps();
- virtual void ReadonlyUpdateUninstallSteps();
- virtual void DisablePkgSteps();
- virtual void EnablePkgSteps();
- virtual void MigrateExtImgSteps();
- virtual void RecoverDBSteps();
- virtual void UnknownSteps();
-
- private:
- void Init();
-
- std::list<std::unique_ptr<Step>> steps_;
- std::list<std::unique_ptr<Step>>::iterator it_;
-
- // data used to send signal
- std::unique_ptr<PkgmgrSignal> pi_;
-
- void SendProgress(int progress);
- void SendFinished(Step::Status status);
- Step::Status SafeExecute(std::unique_ptr<Step> const& step_ptr,
- Step::Status (Step::*method)(),
- std::string name);
- void HandleStepError(Step::Status result, const std::string& error);
-
- std::shared_ptr<utils::FileLogBackend> failure_logger_;
- Step::Status status_;
- Result result_;
- void LogHistory(bool success);
-
- int index_;
-
- friend class InstallerRunner;
-
- SCOPE_LOG_TAG(AppInstaller)
-
- DISALLOW_COPY_AND_ASSIGN(AppInstaller);
-};
-
-} // namespace common_installer
-
-#endif // COMMON_APP_INSTALLER_H_
// found in the LICENSE file.
#include "common/app_query_interface.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
#include <utility>
#include "common/archive_info.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
using Dependency = std::tuple<std::string, std::string, std::string>;
#include <tuple>
#include <vector>
-#include "common/app_installer.h"
+#include "common/installer/app_installer.h"
#include "common/pkgmgr_interface.h"
namespace common_installer {
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
-#include "common/paths.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
+#include "common/utils/paths.h"
namespace bf = boost::filesystem;
#include <manifest_parser/utils/logging.h>
-#include "common/request.h"
#include "common/utils/byte_size_literals.h"
#include "common/utils/file_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
#include <string>
#include <vector>
-#include "common/request.h"
#include "common/app2ext_dynamic_service.h"
+#include "common/utils/request.h"
namespace common_installer {
--- /dev/null
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include <unistd.h>
+
+#include <cstdio>
+#include <fstream>
+#include <TTraceWrapper.h>
+
+#include "common/installer/app_installer.h"
+#include "common/installer_context.h"
+#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_signal.h"
+#include "common/step/configuration/step_fail.h"
+#include "common/utils/file_logbackend.h"
+
+#include "common/step/backup/step_backup_icons.h"
+#include "common/step/backup/step_backup_manifest.h"
+#include "common/step/backup/step_copy_backup.h"
+#include "common/step/configuration/step_block_cross_update.h"
+#include "common/step/configuration/step_check_install_location.h"
+#include "common/step/configuration/step_check_tizen_version.h"
+#include "common/step/configuration/step_configure.h"
+#include "common/step/configuration/step_parse_manifest.h"
+#include "common/step/configuration/step_parse_preload.h"
+#include "common/step/configuration/step_switch_readonly_mode.h"
+#include "common/step/filesystem/step_acquire_external_storage.h"
+#include "common/step/filesystem/step_change_ownership_and_permission.h"
+#include "common/step/filesystem/step_copy.h"
+#include "common/step/filesystem/step_copy_storage_directories.h"
+#include "common/step/filesystem/step_copy_tep.h"
+#include "common/step/filesystem/step_create_globalapp_symlinks.h"
+#include "common/step/filesystem/step_create_icons.h"
+#include "common/step/filesystem/step_create_storage_directories.h"
+#include "common/step/filesystem/step_delta_patch.h"
+#include "common/step/filesystem/step_disable_external_mount.h"
+#include "common/step/filesystem/step_enable_external_mount.h"
+#include "common/step/filesystem/step_migrate_legacy_external_image.h"
+#include "common/step/filesystem/step_move_installed_storage.h"
+#include "common/step/filesystem/step_optional_acquire_external_storage.h"
+#include "common/step/filesystem/step_recover_change_owner.h"
+#include "common/step/filesystem/step_recover_external_storage.h"
+#include "common/step/filesystem/step_recover_files.h"
+#include "common/step/filesystem/step_recover_globalapp_symlinks.h"
+#include "common/step/filesystem/step_recover_icons.h"
+#include "common/step/filesystem/step_recover_manifest.h"
+#include "common/step/filesystem/step_recover_storage_directories.h"
+#include "common/step/filesystem/step_remove_files.h"
+#include "common/step/filesystem/step_remove_icons.h"
+#include "common/step/filesystem/step_remove_globalapp_symlinks.h"
+#include "common/step/filesystem/step_remove_per_user_storage_directories.h"
+#include "common/step/filesystem/step_remove_temporary_directory.h"
+#include "common/step/filesystem/step_remove_tep.h"
+#include "common/step/filesystem/step_remove_user_data.h"
+#include "common/step/filesystem/step_remove_zip_image.h"
+#include "common/step/filesystem/step_unzip.h"
+#include "common/step/filesystem/step_update_storage_directories.h"
+#include "common/step/filesystem/step_update_tep.h"
+#include "common/step/mount/step_check_mount_path.h"
+#include "common/step/mount/step_mount_install.h"
+#include "common/step/mount/step_mount_recover.h"
+#include "common/step/mount/step_mount_unpacked.h"
+#include "common/step/mount/step_mount_update.h"
+#include "common/step/mount/step_unmount.h"
+#include "common/step/pkgmgr/step_check_force_clean.h"
+#include "common/step/pkgmgr/step_check_installable.h"
+#include "common/step/pkgmgr/step_check_removable.h"
+#include "common/step/pkgmgr/step_check_restriction.h"
+#include "common/step/pkgmgr/step_check_upgradable.h"
+#include "common/step/pkgmgr/step_kill_apps.h"
+#include "common/step/pkgmgr/step_recover_application.h"
+#include "common/step/pkgmgr/step_recover_parser_plugins.h"
+#include "common/step/pkgmgr/step_register_app.h"
+#include "common/step/pkgmgr/step_remove_manifest.h"
+#include "common/step/pkgmgr/step_run_parser_plugins.h"
+#include "common/step/pkgmgr/step_unregister_app.h"
+#include "common/step/pkgmgr/step_update_app.h"
+#include "common/step/pkgmgr/step_update_pkg_disable_info.h"
+#include "common/step/rds/step_rds_modify.h"
+#include "common/step/rds/step_rds_parse.h"
+#include "common/step/recovery/step_create_recovery_file.h"
+#include "common/step/recovery/step_open_recovery_file.h"
+#include "common/step/security/step_check_old_certificate.h"
+#include "common/step/security/step_get_privilege_level.h"
+#include "common/step/security/step_privacy_privilege.h"
+#include "common/step/security/step_recover_security.h"
+#include "common/step/security/step_recover_trust_anchor.h"
+#include "common/step/security/step_register_security.h"
+#include "common/step/security/step_register_trust_anchor.h"
+#include "common/step/security/step_revoke_security.h"
+#include "common/step/security/step_revoke_trust_anchor.h"
+#include "common/step/security/step_rollback_installation_security.h"
+#include "common/step/security/step_signature.h"
+#include "common/step/security/step_unregister_trust_anchor.h"
+#include "common/step/security/step_update_security.h"
+
+namespace ci = common_installer;
+
+namespace {
+
+const unsigned kProgressRange = 100;
+const char kLogFileName[] = LOGDIR"/app-installers.log";
+const char kHistoryFileName[] = LOGDIR"/installation-history.log";
+const int kLogRotationSize = 1024 * 256; // 256KB
+const int kLogMaximumRotation = 3;
+
+}
+
+namespace common_installer {
+
+AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
+ : pkgmgr_(pkgmgr), context_(new InstallerContext()),
+ status_(Step::Status::OK), result_(Result::OK), index_(0) {
+ context_->pkg_type.set(package_type);
+ context_->installation_mode.set(pkgmgr->GetInstallationMode());
+
+ // pkgmgr signal should work only for online mode
+ // there is no one to receive it in offline mode
+ if (context_->installation_mode.get() == InstallationMode::ONLINE) {
+ pi_ = pkgmgr->CreatePkgmgrSignal();
+ }
+}
+
+AppInstaller::~AppInstaller() {
+}
+
+void AppInstaller::Init() {
+ // for multi installer
+ context_->index.set(index_);
+ pkgmgr_->SetAppQueryInterface(index_);
+
+ switch (pkgmgr_->GetRequestType(index_)) {
+ case RequestType::Install:
+ InstallSteps();
+ break;
+ case RequestType::Update:
+ UpdateSteps();
+ break;
+ case RequestType::Uninstall:
+ UninstallSteps();
+ break;
+ case RequestType::Reinstall:
+ ReinstallSteps();
+ break;
+ case RequestType::Delta:
+ DeltaSteps();
+ break;
+ case RequestType::Move:
+ MoveSteps();
+ break;
+ case RequestType::Recovery:
+ RecoverySteps();
+ break;
+ case RequestType::MountInstall:
+ MountInstallSteps();
+ break;
+ case RequestType::MountUpdate:
+ MountUpdateSteps();
+ break;
+ case RequestType::ManifestDirectInstall:
+ ManifestDirectInstallSteps();
+ break;
+ case RequestType::ManifestDirectUpdate:
+ ManifestDirectUpdateSteps();
+ break;
+ case RequestType::ManifestPartialInstall:
+ ManifestPartialInstallSteps();
+ break;
+ case RequestType::ManifestPartialUpdate:
+ ManifestPartialUpdateSteps();
+ break;
+ case RequestType::PartialUninstall:
+ PartialUninstallSteps();
+ break;
+ case RequestType::ReadonlyUpdateInstall:
+ ReadonlyUpdateInstallSteps();
+ break;
+ case RequestType::ReadonlyUpdateUninstall:
+ ReadonlyUpdateUninstallSteps();
+ break;
+ case RequestType::EnablePkg:
+ EnablePkgSteps();
+ break;
+ case RequestType::DisablePkg:
+ DisablePkgSteps();
+ break;
+ case RequestType::MigrateExtImg:
+ MigrateExtImgSteps();
+ break;
+ case RequestType::RecoverDB:
+ RecoverDBSteps();
+ break;
+ default:
+ UnknownSteps();
+ break;
+ }
+}
+
+AppInstaller::Result AppInstaller::Run() {
+ Process();
+ if (it_ != steps_.end() && result_ == Result::ERROR) {
+ LOG(ERROR) << "Failure occurs in step: " << (*it_)->name();
+ Undo();
+ } else {
+ Clean();
+ }
+ sync();
+
+ if ((context_->installation_mode.get() == InstallationMode::OFFLINE) &&
+ (result_ == Result::ERROR)) {
+ std::fstream info_file("/tmp/.preload_install_error",
+ std::ios::out | std::ios::app);
+ info_file << context_->pkgid.get() << std::endl;
+ info_file.close();
+ }
+
+ return result_;
+}
+
+void AppInstaller::LogHistory(bool success) {
+ std::shared_ptr<utils::FileLogBackend> history_logger =
+ std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
+ kHistoryFileName, kLogRotationSize, kLogMaximumRotation));
+ std::string history = "pkgid:" + context_->pkgid.get() + "|mode:" +
+ GetRequestTypeString(context_->request_type.get());
+ if (success)
+ history += "|SUCCESS";
+ else
+ history += "|FAIL";
+ history_logger->WriteLog(::utils::LogLevel::LOG_INFO, "", history);
+ history_logger->WriteLogToFile();
+}
+
+AppInstaller::Result AppInstaller::Process() {
+ Init();
+
+ failure_logger_ =
+ std::shared_ptr<utils::FileLogBackend>(new utils::FileLogBackend(
+ kLogFileName, kLogRotationSize, kLogMaximumRotation));
+ ::utils::LogCore::GetCore().AddLogBackend(failure_logger_);
+
+ unsigned total_steps = steps_.size();
+ unsigned current_step = 1;
+
+ for (it_ = steps_.begin(); it_ != steps_.end(); ++it_, ++current_step) {
+ status_ = SafeExecute(*it_, &Step::precheck, "precheck");
+ if (status_ == Step::Status::OK)
+ status_ = SafeExecute(*it_, &Step::process, "process");
+
+ if (status_ != Step::Status::OK) {
+ if (status_ != Step::Status::RECOVERY_DONE) {
+ LOG(ERROR) << "Error during processing";
+ result_ = Result::ERROR;
+ }
+ break;
+ }
+ SendProgress(current_step * kProgressRange / total_steps);
+ }
+
+ return result_;
+}
+
+AppInstaller::Result AppInstaller::Undo() {
+ do {
+ if (it_ == steps_.end())
+ --it_;
+ if (SafeExecute(*it_, &Step::undo, "undo") != Step::Status::OK) {
+ LOG(ERROR) << "Error during undo operation(" << (*it_)->name()
+ << "), but continuing...";
+ result_ = Result::UNDO_ERROR;
+ }
+ } while (it_-- != steps_.begin());
+ sync();
+ failure_logger_->WriteLogToFile();
+
+ // Undo will be invoked when other installer fails when multi-install, but the
+ // status of current installer can be ok. We need to change this to proper
+ // error code to notify that entire installation was failed to listener.
+ // TODO(jeremy.jang): Need some other error for multi-install failure?
+ if (status_ == Step::Status::OK)
+ status_ = Step::Status::ERROR;
+ SendFinished(status_);
+
+ LogHistory(false);
+
+ return result_;
+}
+
+AppInstaller::Result AppInstaller::Clean() {
+ const auto& recovery_file =
+ context_->recovery_info.get().recovery_file;
+ if (recovery_file) {
+ recovery_file->set_cleanup(true);
+ recovery_file->WriteAndCommitFileContent();
+ }
+ SendFinished(status_);
+
+ do {
+ if (it_ == steps_.end())
+ --it_;
+ if (SafeExecute(*it_, &Step::clean, "clean") != Step::Status::OK) {
+ LOG(ERROR) << "Error during clean operation(" << (*it_)->name() << ")";
+ result_ = Result::CLEANUP_ERROR;
+ break;
+ }
+ } while (it_-- != steps_.begin());
+ sync();
+
+ LogHistory(true);
+
+ return result_;
+}
+
+void AppInstaller::InstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckInstallable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::pkgmgr::StepCheckRestriction>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepRollbackInstallationSecurity>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepAcquireExternalStorage>(false);
+ AddStep<ci::filesystem::StepCopy>();
+ AddStep<ci::filesystem::StepCopyTep>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Install);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::UpdateSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::configuration::StepBlockCrossUpdate>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::backup::StepBackupIcons>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::backup::StepCopyBackup>();
+ AddStep<ci::filesystem::StepUpdateTep>();
+ AddStep<ci::filesystem::StepCopyStorageDirectories>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::UninstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::pkgmgr::StepCheckRestriction>();
+ AddStep<ci::pkgmgr::StepCheckRemovable>();
+ AddStep<ci::pkgmgr::StepCheckForceClean>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Uninstall);
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
+ AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
+ AddStep<ci::pkgmgr::StepUnregisterApplication>();
+ AddStep<ci::security::StepUnregisterTrustAnchor>();
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
+ AddStep<ci::filesystem::StepRemoveFiles>();
+ AddStep<ci::filesystem::StepRemoveZipImage>();
+ AddStep<ci::filesystem::StepRemoveIcons>();
+ AddStep<ci::filesystem::StepRemoveTep>();
+ AddStep<ci::security::StepRevokeSecurity>();
+ AddStep<ci::pkgmgr::StepRemoveManifest>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ReinstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::configuration::StepBlockCrossUpdate>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::backup::StepBackupIcons>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::rds::StepRDSParse>();
+ AddStep<ci::rds::StepRDSModify>();
+ AddStep<ci::filesystem::StepUpdateTep>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::DeltaSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::filesystem::StepEnableExternalMount>();
+ AddStep<ci::filesystem::StepDeltaPatch>();
+ AddStep<ci::filesystem::StepDisableExternalMount>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::configuration::StepBlockCrossUpdate>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::backup::StepBackupIcons>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepAcquireExternalStorage>(true);
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::backup::StepCopyBackup>();
+ AddStep<ci::filesystem::StepUpdateTep>();
+ AddStep<ci::filesystem::StepCopyStorageDirectories>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::MoveSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::pkgmgr::StepCheckRestriction>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::filesystem::StepMoveInstalledStorage>();
+ AddStep<ci::security::StepRegisterSecurity>();
+}
+
+void AppInstaller::RecoverySteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepOpenRecoveryFile>();
+ AddStep<ci::filesystem::StepRemoveTemporaryDirectory>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::RECOVERY,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::filesystem::StepRecoverIcons>();
+ AddStep<ci::pkgmgr::StepRecoverParserPlugin>();
+ AddStep<ci::filesystem::StepRecoverManifest>();
+ AddStep<ci::filesystem::StepRecoverExternalStorage>();
+ AddStep<ci::filesystem::StepRecoverStorageDirectories>();
+ AddStep<ci::filesystem::StepRecoverGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepRecoverFiles>();
+ AddStep<ci::mount::StepMountRecover>();
+ AddStep<ci::filesystem::StepRecoverChangeOwner>();
+ AddStep<ci::pkgmgr::StepRecoverApplication>();
+ AddStep<ci::security::StepRecoverTrustAnchor>();
+ AddStep<ci::security::StepRecoverSecurity>();
+}
+
+void AppInstaller::MountInstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::mount::StepMountUnpacked>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckInstallable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::pkgmgr::StepCheckRestriction>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepRollbackInstallationSecurity>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::mount::StepMountInstall>();
+ AddStep<ci::filesystem::StepCopyTep>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::INSTALL);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Install);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
+ AddStep<ci::mount::StepUnmount>();
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::MountUpdateSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::mount::StepMountUnpacked>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::configuration::StepBlockCrossUpdate>();
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::backup::StepBackupManifest>();
+ AddStep<ci::backup::StepBackupIcons>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::mount::StepMountUpdate>();
+ AddStep<ci::filesystem::StepUpdateTep>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::mount::StepUnmount>();
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>(true);
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ManifestDirectInstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepCheckInstallable>();
+ AddStep<ci::mount::StepCheckMountPath>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepRollbackInstallationSecurity>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Install);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ManifestDirectUpdateSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::mount::StepCheckMountPath>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ManifestPartialInstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::security::StepSignature>(false);
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Install);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
+ AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ManifestPartialUpdateSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::security::StepSignature>(false);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepRegisterSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::PartialUninstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::pkgmgr::StepCheckRemovable>();
+ AddStep<ci::pkgmgr::StepCheckForceClean>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::filesystem::StepOptionalAcquireExternalStorage>();
+ AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
+ AddStep<ci::pkgmgr::StepUnregisterApplication>();
+ AddStep<ci::security::StepUnregisterTrustAnchor>();
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Uninstall);
+ AddStep<ci::security::StepRevokeSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(
+ ci::Plugin::ActionType::Uninstall);
+}
+
+void AppInstaller::ReadonlyUpdateInstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::recovery::StepCreateRecoveryFile>();
+ AddStep<ci::filesystem::StepUnzip>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::PACKAGE,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::configuration::StepSwitchReadonlyMode>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepSwitchReadonlyMode>();
+ AddStep<ci::configuration::StepCheckInstallLocation>();
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::configuration::StepCheckTizenVersion>();
+ AddStep<ci::security::StepSignature>(true);
+ AddStep<ci::security::StepCheckOldCertificate>();
+ AddStep<ci::configuration::StepBlockCrossUpdate>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::filesystem::StepCopy>();
+ AddStep<ci::filesystem::StepCopyTep>();
+ AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+ AddStep<ci::filesystem::StepCreateGlobalAppSymlinks>();
+}
+
+void AppInstaller::ReadonlyUpdateUninstallSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::BACKUP);
+ AddStep<ci::configuration::StepSwitchReadonlyMode>();
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepCheckUpgradable>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::security::StepSignature>(false);
+ AddStep<ci::configuration::StepSwitchReadonlyMode>();
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::filesystem::StepRemoveGlobalAppSymlinks>();
+ AddStep<ci::security::StepRevokeTrustAnchor>();
+ AddStep<ci::pkgmgr::StepUpdateApplication>();
+ AddStep<ci::security::StepRegisterTrustAnchor>(
+ ci::security::StepRegisterTrustAnchor::RegisterType::UPDATE);
+ AddStep<ci::security::StepPrivacyPrivilege>(
+ ci::security::StepPrivacyPrivilege::ActionType::Update);
+ AddStep<ci::filesystem::StepRemoveFiles>();
+ AddStep<ci::filesystem::StepRemoveZipImage>();
+ AddStep<ci::filesystem::StepRemoveIcons>();
+ AddStep<ci::filesystem::StepRemoveTep>();
+ AddStep<ci::filesystem::StepRemoveUserData>();
+ AddStep<ci::configuration::StepSwitchReadonlyMode>();
+ AddStep<ci::security::StepUpdateSecurity>();
+ AddStep<ci::pkgmgr::StepRemoveManifest>();
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepUpdateStorageDirectories>();
+}
+
+void AppInstaller::DisablePkgSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepKillApps>();
+ AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
+ ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Disable);
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(
+ ci::Plugin::ActionType::Uninstall);
+}
+
+void AppInstaller::EnablePkgSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepUpdatePkgDisableInfo>(
+ ci::pkgmgr::StepUpdatePkgDisableInfo::ActionType::Enable);
+ AddStep<ci::pkgmgr::StepRunParserPlugin>(
+ ci::Plugin::ActionType::Install);
+}
+
+void AppInstaller::MigrateExtImgSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::security::StepMigrateLegacyExtImage>();
+ AddStep<ci::filesystem::StepChangeOwnershipAndPermission>();
+}
+
+void AppInstaller::RecoverDBSteps() {
+ AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+ AddStep<ci::configuration::StepParseManifest>(
+ ci::configuration::StepParseManifest::ManifestLocation::INSTALLED,
+ ci::configuration::StepParseManifest::StoreLocation::NORMAL);
+ AddStep<ci::pkgmgr::StepCheckInstallable>();
+ AddStep<ci::mount::StepCheckMountPath>();
+ AddStep<ci::configuration::StepParsePreload>();
+ AddStep<ci::security::StepGetPrivilegeLevel>();
+ AddStep<ci::pkgmgr::StepRegisterApplication>();
+}
+
+void AppInstaller::UnknownSteps() {
+ AddStep<configuration::StepFail>();
+}
+
+void AppInstaller::HandleStepError(Step::Status result,
+ const std::string& error) {
+ if (pi_)
+ pi_->SendError(result, error, context_->pkg_type.get(),
+ context_->pkgid.get());
+}
+
+void AppInstaller::SendProgress(int progress) {
+ if (pi_) {
+ // send START signal as soon as possible if not sent
+ if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
+ if (!context_->pkgid.get().empty()) {
+ // set request type before sending start signal
+ pi_->SetRequestType(context_->request_type.get());
+ pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
+ }
+ }
+
+ // send installation progress
+ pi_->SendProgress(progress,
+ context_->pkg_type.get(), context_->pkgid.get());
+ }
+}
+
+void AppInstaller::SendFinished(Step::Status process_status) {
+ if (pi_) {
+ // send START if pkgid was not parsed
+ if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
+ // set request type before sending start signal
+ pi_->SetRequestType(context_->request_type.get());
+ pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
+ }
+ pi_->SendFinished(process_status,
+ context_->pkg_type.get(),
+ context_->pkgid.get());
+ }
+}
+
+Step::Status AppInstaller::SafeExecute(std::unique_ptr<Step> const& step_ptr,
+ Step::Status (Step::*method)(),
+ std::string name) {
+ Step::Status process_status = Step::Status::OK;
+ try {
+ TTRACE(TTRACE_TAG_APP, "%s_%s", step_ptr->name(), name.c_str());
+ process_status = ((*step_ptr).*method)();
+ } catch (const std::exception& err) {
+ LOG(ERROR) << "Exception occurred in " << name.c_str() << "(): "
+ << err.what() << " in step: " << step_ptr->name();
+ process_status = Step::Status::ERROR;
+ }
+ return process_status;
+}
+
+} // namespace common_installer
--- /dev/null
+/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by a apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_INSTALLER_APP_INSTALLER_H_
+#define COMMON_INSTALLER_APP_INSTALLER_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <boost/bind.hpp>
+
+#include <list>
+#include <memory>
+#include <string>
+#include <utility>
+
+#include "common/archive_info.h"
+#include "common/pkgmgr_interface.h"
+#include "common/pkgmgr_signal.h"
+#include "common/step/step.h"
+#include "common/utils/file_logbackend.h"
+#include "common/utils/macros.h"
+
+namespace common_installer {
+
+/**
+ * \brief Includes the main “steps” processing mechanisms. It holds
+ * the lists of steps and runs each of the step in the configured
+ * order.
+ */
+class AppInstaller {
+ public:
+ /** Enumeration of possible returned Results */
+ enum class Result {
+ OK,
+ ERROR,
+ CLEANUP_ERROR,
+ UNDO_ERROR,
+ UNKNOWN
+ };
+
+ /**
+ * \brief explicit Constructor
+ *
+ * \param package_type package type
+ * \param pkgmgr pointer to PkgMgrInterface object
+ */
+ explicit AppInstaller(const char* package_type, PkgMgrPtr pkgmgr);
+
+ /** virtual desctructor */
+ virtual ~AppInstaller();
+
+ /**
+ * \brief Adds new step to installer by specified type
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ *
+ * \tparam StepT Step object to be added to the step list
+ * \tparam Args constructor arguments for StepT object
+ * \param args argument list
+ */
+ template<class StepT, class... Args>
+ void AddStep(Args&&... args) {
+ std::unique_ptr<Step> step(
+ new StepT(context_.get(), std::forward<Args>(args)...));
+ step->on_error.connect(
+ boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+ steps_.emplace_back(std::move(step));
+ }
+
+ /**
+ * \brief Removes specific step in steps list.
+ * \param step_name step name to be removed
+ */
+ void RemoveStep(std::string step_name) {
+ auto it = std::find_if(steps_.begin(), steps_.end(),
+ [&](const std::unique_ptr<Step>& s) {
+ return step_name == s->name();
+ });
+ if (steps_.end() == it) {
+ LOG(ERROR) << "Can't find the step : " << step_name;
+ return;
+ }
+ steps_.erase(it);
+ }
+
+ /**
+ * \brief Adds new step to installer by specified type on specyfic place
+ * in steps list.
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ *
+ * \tparam StepT Step object to be added to the step list
+ * \tparam index index at which the new step is added
+ * \tparam Args constructor arguments for StepT object
+ * \param args argument list
+ */
+ template<class StepT, class... Args>
+ void AddStepAtIndex(unsigned int index, Args&&... args) {
+ std::unique_ptr<Step> step(
+ new StepT(context_.get(), std::forward<Args>(args)...));
+ step->on_error.connect(
+ boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+ std::list<std::unique_ptr<Step>> tmpList;
+ tmpList.emplace_back(std::move(step));
+ auto it = steps_.begin();
+ std::advance(it, index);
+ steps_.splice(it, tmpList);
+ }
+
+ /**
+ * \brief Replaces new step to installer by specified type
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ * \tparam StepT Step object to be added to the step list
+ * \tparam Args constructor arguments for StepT object
+ * \param step_name step name to replace
+ * \param args argument list
+ */
+ template<class StepT, class... Args>
+ void ReplaceStep(std::string step_name, Args&&... args) {
+ auto it = std::find_if(std::begin(steps_), std::end(steps_),
+ [&](const std::unique_ptr<Step>& s) {
+ return step_name == s->name();
+ });
+
+ if (steps_.end() == it) {
+ LOG(ERROR) << "Can't find the step : " << step_name;
+ return;
+ }
+
+ std::unique_ptr<Step> step(
+ new StepT(context_.get(), std::forward<Args>(args)...));
+ step->on_error.connect(
+ boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+ *it = std::move(step);
+ }
+
+ /**
+ * \brief Adds new step before specified step
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ * \tparam StepT Step object to be added to the step list
+ * \tparam Args constructor arguments for StepT object
+ * \param step_name step name to find and add
+ * \param args argument list
+ */
+ template<class StepT, class... Args>
+ void AddStepBefore(std::string step_name, Args&&... args) {
+ auto it = std::find_if(std::begin(steps_), std::end(steps_),
+ [&](const std::unique_ptr<Step>& s) {
+ return step_name == s->name();
+ });
+
+ if (steps_.end() == it) {
+ LOG(ERROR) << "Can't find the step : " << step_name;
+ return;
+ }
+
+ std::unique_ptr<Step> step(
+ new StepT(context_.get(), std::forward<Args>(args)...));
+ step->on_error.connect(
+ boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+ steps_.insert(it, std::move(step));
+ }
+
+ /**
+ * \brief Adds new step after specified step
+ * Type of template parameter is used to create requested step
+ * class instance.
+ * Context of installer is passed to step in this method
+ * and is not being exposed outside installer.
+ * Step arguments are deduced and forwarded to constructor.
+ * \tparam StepT Step object to be added to the step list
+ * \tparam Args constructor arguments for StepT object
+ * \param step_name step name to find and add
+ * \param args argument list
+ */
+ template<class StepT, class... Args>
+ void AddStepAfter(std::string step_name, Args&&... args) {
+ auto it = std::find_if(std::begin(steps_), std::end(steps_),
+ [&](const std::unique_ptr<Step>& s) {
+ return step_name == s->name();
+ });
+
+ if (steps_.end() == it) {
+ LOG(ERROR) << "Can't find the step : " << step_name;
+ return;
+ }
+
+ std::unique_ptr<Step> step(
+ new StepT(context_.get(), std::forward<Args>(args)...));
+ step->on_error.connect(
+ boost::bind(&AppInstaller::HandleStepError, this, _1, _2));
+ steps_.insert(++it, std::move(step));
+ }
+
+ /**
+ * \brief runs the steps in the specific sequence
+ *
+ * \return Result of the run (eg Result:OK)
+ */
+ Result Run();
+
+ /**
+ * \brief runs the process operations of steps
+ *
+ * \return Result of the run (eg Result:OK)
+ */
+ Result Process();
+
+ /**
+ * \brief runs the undo operations of steps
+ *
+ * \return Result of the run (eg Result:OK)
+ */
+ Result Undo();
+
+ /**
+ * \brief runs the clean operations of steps
+ *
+ * \return Result of the run (eg Result:OK)
+ */
+ Result Clean();
+
+ /**
+ * \brief This method can be used to check
+ * the number of the registered steps.
+ *
+ * \return number of steps registered in app-installer
+ */
+ unsigned int StepCount() {
+ return steps_.size();
+ }
+
+ void SetIndex(int index) {
+ index_ = index;
+ }
+
+ int GetIndex() {
+ return index_;
+ }
+
+ virtual std::unique_ptr<ArchiveInfo> GetArchiveInfo() = 0;
+
+ protected:
+ PkgMgrPtr pkgmgr_;
+ std::unique_ptr<InstallerContext> context_;
+
+ virtual void InstallSteps();
+ virtual void UpdateSteps();
+ virtual void UninstallSteps();
+ virtual void ReinstallSteps();
+ virtual void DeltaSteps();
+ virtual void MoveSteps();
+ virtual void RecoverySteps();
+ virtual void MountInstallSteps();
+ virtual void MountUpdateSteps();
+ virtual void ManifestDirectInstallSteps();
+ virtual void ManifestDirectUpdateSteps();
+ virtual void ManifestPartialInstallSteps();
+ virtual void ManifestPartialUpdateSteps();
+ virtual void PartialUninstallSteps();
+ virtual void ReadonlyUpdateInstallSteps();
+ virtual void ReadonlyUpdateUninstallSteps();
+ virtual void DisablePkgSteps();
+ virtual void EnablePkgSteps();
+ virtual void MigrateExtImgSteps();
+ virtual void RecoverDBSteps();
+ virtual void UnknownSteps();
+
+ private:
+ void Init();
+
+ std::list<std::unique_ptr<Step>> steps_;
+ std::list<std::unique_ptr<Step>>::iterator it_;
+
+ // data used to send signal
+ std::unique_ptr<PkgmgrSignal> pi_;
+
+ void SendProgress(int progress);
+ void SendFinished(Step::Status status);
+ Step::Status SafeExecute(std::unique_ptr<Step> const& step_ptr,
+ Step::Status (Step::*method)(),
+ std::string name);
+ void HandleStepError(Step::Status result, const std::string& error);
+
+ std::shared_ptr<utils::FileLogBackend> failure_logger_;
+ Step::Status status_;
+ Result result_;
+ void LogHistory(bool success);
+
+ int index_;
+
+ friend class InstallerRunner;
+
+ SCOPE_LOG_TAG(AppInstaller)
+
+ DISALLOW_COPY_AND_ASSIGN(AppInstaller);
+};
+
+} // namespace common_installer
+
+#endif // COMMON_INSTALLER_APP_INSTALLER_H_
#include "common/external_storage.h"
#include "common/pkgmgr_interface.h"
#include "common/recovery_file.h"
-#include "common/request.h"
#include "common/utils/property.h"
+#include "common/utils/request.h"
#include "manifest_info/account.h"
#include "manifest_info/ime_info.h"
#include <string>
#include <utility>
-#include "common/app_installer.h"
+#include "common/installer/app_installer.h"
#include "common/installer_context.h"
#include "common/installer_factory.h"
#include "common/pkgmgr_interface.h"
#include <list>
#include <memory>
-#include "common/app_installer.h"
+#include "common/installer/app_installer.h"
#include "common/dependency_checker.h"
#include "common/global_recovery_file.h"
#include "common/pkgmgr_interface.h"
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/paths.h"
-
-#include <manifest_parser/utils/logging.h>
-
-#include <boost/filesystem/operations.hpp>
-
-#include <pwd.h>
-#include <tzplatform_config.h>
-#include <storage-internal.h>
-
-#include <vector>
-
-#include "common/utils/user_util.h"
-
-namespace bf = boost::filesystem;
-namespace ci = common_installer;
-
-namespace {
-
-const char kImageDir[] = ".image";
-const char kBckExtension[] = ".bck";
-
-boost::filesystem::path GetBackupPath(const boost::filesystem::path& pkg_path) {
- bf::path backup_path = pkg_path;
- backup_path += kBckExtension;
- return backup_path;
-}
-
-} // namespace
-
-namespace common_installer {
-
-boost::filesystem::path GetBackupPathForPackagePath(
- const boost::filesystem::path& pkg_path) {
- return GetBackupPath(pkg_path);
-}
-
-boost::filesystem::path GetBackupPathForManifestFile(
- const boost::filesystem::path& manifest_path) {
- return GetBackupPath(manifest_path);
-}
-
-boost::filesystem::path GetBackupPathForIconFile(
- const boost::filesystem::path& icon_path) {
- return GetBackupPath(icon_path);
-}
-
-std::string GetIconFileBackupExtension() {
- return kBckExtension;
-}
-
-boost::filesystem::path GetBackupPathForZipFile(const bf::path& zip_path) {
- return GetBackupPath(zip_path);
-}
-
-boost::filesystem::path GetMountLocation(const bf::path& pkg_path) {
- return pkg_path / ".pkg";
-}
-
-boost::filesystem::path GetZipPackageLocation(
- const boost::filesystem::path& pkg_path,
- const std::string& pkgid) {
- return pkg_path / kImageDir / pkgid;
-}
-
-boost::filesystem::path GetExternalCardPath() {
- char* sdpath = nullptr;
- int storage_id = 0;
- int ret;
-
- ret = storage_get_primary_sdcard(&storage_id, &sdpath);
- if (ret != STORAGE_ERROR_NONE) {
- free(sdpath);
- return bf::path();
- }
-
- if (sdpath) {
- std::string mount_path(sdpath);
- free(sdpath);
- return bf::path(mount_path);
- }
-
- return bf::path();
-}
-
-boost::filesystem::path GetExternalTepPath(RequestMode request_mode,
- uid_t uid) {
- bf::path result;
- bf::path ext_mount_path = GetExternalCardPath();
- if (bf::is_empty(ext_mount_path))
- return result;
- result = ext_mount_path / "tep";
- if (request_mode == RequestMode::USER)
- result /= ci::GetUsernameByUid(uid);
- return result;
-}
-
-boost::filesystem::path GetInternalTepPath(
- const boost::filesystem::path& pkg_path) {
- return pkg_path / "tep";
-}
-
-boost::filesystem::path GetIconPath(const bf::path& base_path,
- const std::string& pkgid,
- const bf::path& icon_filename,
- const bf::path& root_path) {
- std::vector<bf::path> paths;
- bf::path system_path = base_path / icon_filename;
- bf::path small_system_path = base_path / "default" / "small" / icon_filename;
- bf::path res_path = root_path / pkgid / "res" / "icons" / icon_filename;
-
- paths.push_back(system_path);
- paths.push_back(small_system_path);
- paths.push_back(res_path);
-
- for (auto& path : paths) {
- if (bf::exists(path))
- return path;
- }
-
- return {};
-}
-
-bool IsExtendedStorageAvailable() {
- bool is_available = false;
- int ret = storage_foreach_device_supported(
- [](int, storage_type_e type, storage_state_e state,
- const char* path, void* user_data) -> bool {
- if (type != STORAGE_TYPE_EXTENDED_INTERNAL)
- return true;
- if (state != STORAGE_STATE_MOUNTED)
- return true;
- bool* is_available = static_cast<bool*>(user_data);
- if (bf::exists(path))
- *is_available = true;
- // Stop iteration
- return false;
- },
- &is_available);
- if (ret != STORAGE_ERROR_NONE) {
- LOG(ERROR) << "Failed to call storage_foreach_device_supported()";
- return false;
- }
- return is_available;
-}
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_PATHS_H_
-#define COMMON_PATHS_H_
-
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <unistd.h>
-
-#include <string>
-
-#include "common/request.h"
-
-namespace common_installer {
-
-/**
- * \brief Helper function for getting backup path (used for recovery)
- * based on package path
- *
- * \param pkg_path package path
- *
- * \return backup path
- */
-boost::filesystem::path GetBackupPathForPackagePath(
- const boost::filesystem::path& pkg_path);
-
-/**
- * \brief Helper function for getting backup path (used for recovery)
- * based on manifest file path
- *
- * \param manifest_path path to manifest file
- *
- * \return backup path
- */
-boost::filesystem::path GetBackupPathForManifestFile(
- const boost::filesystem::path& manifest_path);
-
-/**
- * \brief Helper function for getting backup path (used for recovery)
- * based on icon path
- *
- * \param icon_path path to icon file
- *
- * \return backup path
- */
-boost::filesystem::path GetBackupPathForIconFile(
- const boost::filesystem::path& icon_path);
-
-/**
- * @brief GetIconFileBackupExtension
- * @return extension for backup icon files
- */
-std::string GetIconFileBackupExtension();
-
-/**
- * \brief Helper function for getting backup path of zip (used for recovery)
- * based on zip path
- *
- * \param zip_path path to zip file
- *
- * \return backup path of zip
- */
-boost::filesystem::path GetBackupPathForZipFile(
- const boost::filesystem::path& zip_path);
-
-/**
- * @brief GetZipPackageLocation
- * Returns location where zip package file must be copied during package
- * installation.
- *
- * @param pkg_path package path
- * @param pkgid package id
- *
- * @return full path of zip package location
- */
-boost::filesystem::path GetZipPackageLocation(
- const boost::filesystem::path& pkg_path,
- const std::string& pkgid);
-
-/**
- * @brief GetMountLocation
- * Returns the mount point of zip package. This location is used to
- * mount package.
- *
- * @param pkg_path package path for which zip mount location is being obtained
- *
- * @return full path of package mount point
- */
-boost::filesystem::path GetMountLocation(
- const boost::filesystem::path& pkg_path);
-
-/**
- * @brief GetExternalCardPath
- * Returns full path to mounted filesystem of sd card
- *
- * @return path
- */
-boost::filesystem::path GetExternalCardPath();
-
-/**
- * @brief GetExternalTepPath
- * Returns external installation location for tep package
- * @param request_mode request type
- * @param uid user id of request
- *
- * @return full directory path
- */
-boost::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
-
-/**
- * @brief GetInternalTepPath
- * Returns internal installation location for tep package
- * @param pkg_path path of installation request
- *
- * @return full directory path
- */
-boost::filesystem::path GetInternalTepPath(
- const boost::filesystem::path& pkg_path);
-
-/**
- * @brief GetIconPath
- * Returns internal location for preinstalled global app icon
- * @param base_path path of icon in application
- * @param pkgid package id
- * @param icon_filename filename of icon
- * @param root_path root path of application
- *
- * @return full icon path
- */
-boost::filesystem::path GetIconPath(const boost::filesystem::path& base_path,
- const std::string& pkgid,
- const boost::filesystem::path& icon_filename,
- const boost::filesystem::path& root_path);
-
-/**
- * @brief IsExtendedStorageAvailable
- * Returns true if the extended storage is available
- *
- * @return true is the extended storage is available, otherwise false
- */
-bool IsExtendedStorageAvailable();
-
-} // namespace common_installer
-
-#endif // COMMON_PATHS_H_
#include <manifest_parser/utils/version_number.h>
-#include "common/request.h"
#include "common/utils/glist_range.h"
+#include "common/utils/request.h"
namespace {
#include <vector>
#include "common/installer_context.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace common_installer {
#include <fstream>
#include "common/app_query_interface.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/pkgmgr_signal.h"
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
#include <string>
#include "common/app_query_interface.h"
-#include "common/request.h"
#include "common/utils/macros.h"
+#include "common/utils/request.h"
namespace common_installer {
+++ /dev/null
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/pkgmgr_query.h"
-
-#include <sys/types.h>
-#include <manifest_parser/utils/logging.h>
-#include <pkgmgr_installer.h>
-#include <pkgmgr_parser.h>
-#include <tzplatform_config.h>
-
-#include <cstring>
-#include <utility>
-
-namespace ci = common_installer;
-
-namespace {
-
-const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
-
-int PkgmgrForeachPluginCallback(const char* pkgid, const char* appid,
- const char* plugin_type, const char* plugin_name, void* user_data) {
- auto* data_list =
- static_cast<std::vector<ci::PkgQueryInterface::PluginInfo>*>(user_data);
- data_list->emplace_back(pkgid, appid ? appid : "", plugin_type, plugin_name);
- return PMINFO_R_OK;
-}
-
-} // namespace
-
-namespace common_installer {
-
-std::shared_ptr<PkgHandle> PkgQueryInterface::PkgQuery::GetResult(
- const std::string& pkgid, uid_t uid, bool refresh) {
- const auto& it = query_results_.find(std::make_pair(pkgid, uid));
- if (it != query_results_.end()) {
- if (refresh)
- query_results_.erase(it);
- else
- return it->second;
- }
-
- pkgmgrinfo_pkginfo_h handle;
- int error_ = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid.c_str(), uid,
- &handle);
- if (error_ != PMINFO_R_OK) {
- if (error_ != PMINFO_R_ENOENT)
- LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
- return nullptr;
- }
- auto res = query_results_.emplace(std::make_pair(pkgid, uid),
- std::make_shared<PkgHandle>(handle));
- return res.first->second;
-}
-
-PkgQueryInterface::PkgQueryInterface(const std::string& pkgid, uid_t uid,
- bool refresh)
- : error_(0), pkgid_(pkgid), uid_(uid) {
- handle_ = PkgQuery::Instance().GetResult(pkgid_, uid, refresh);
-}
-
-PkgQueryInterface::~PkgQueryInterface() {
-}
-
-bool PkgQueryInterface::IsValid() {
- return handle_ != nullptr;
-}
-
-int PkgQueryInterface::GetLastOperationError() {
- return error_;
-}
-
-std::string PkgQueryInterface::Version() {
- if (!IsValid())
- return {};
- char* version = nullptr;
- error_ = pkgmgrinfo_pkginfo_get_version(handle_->handle, &version);
- if (error_ != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_version failed with error: "
- << error_;
- return {};
- }
- std::string version_value;
- if (version)
- version_value = version;
- return version_value;
-}
-
-std::string PkgQueryInterface::TepPath() {
- if (!IsValid())
- return {};
- char* tep_name = nullptr;
- error_ = pkgmgrinfo_pkginfo_get_tep_name(handle_->handle, &tep_name);
- if (error_ != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_tep_name failed with error: "
- << error_;
- return {};
- }
- std::string tep_name_value;
- if (tep_name)
- tep_name_value = tep_name;
- return tep_name_value;
-}
-
-std::string PkgQueryInterface::ZipMountFile() {
- if (!IsValid())
- return {};
- char* zip_mount_file = nullptr;
- error_ = pkgmgrinfo_pkginfo_get_zip_mount_file(handle_->handle,
- &zip_mount_file);
- if (error_ != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_zip_mount_file failed with error: "
- << error_;
- return {};
- }
- std::string zip_mount_file_value;
- if (zip_mount_file)
- zip_mount_file_value = zip_mount_file;
- return zip_mount_file_value;
-}
-
-std::string PkgQueryInterface::StorageForPkgId() {
- if (!IsValid())
- return {};
- // initial & default : internal
- std::string installed_location = "installed_internal";
-
- pkgmgrinfo_installed_storage storage;
- error_ = pkgmgrinfo_pkginfo_get_installed_storage(handle_->handle, &storage);
-
- if (error_ != PMINFO_R_OK)
- return "";
-
- if (storage == PMINFO_EXTERNAL_STORAGE)
- installed_location = "installed_external";
- else if (storage == PMINFO_EXTENDED_STORAGE)
- installed_location = "installed_extended";
-
- return installed_location;
-}
-
-std::string PkgQueryInterface::Type() {
- if (!IsValid())
- return {};
- char* type = nullptr;
- error_ = pkgmgrinfo_pkginfo_get_type(handle_->handle, &type);
- if (error_ != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_type failed with error: "
- << error_;
- return {};
- }
- std::string type_value;
- if (type)
- type_value = type;
- return type_value;
-}
-
-bool PkgQueryInterface::IsPackageInstalled() {
- if (!IsValid())
- return false;
- bool is_global = false;
- if (pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global) !=
- PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
- return false;
- }
-
- if (uid_ == kGlobalUserUid && is_global)
- return true;
- if (uid_ != kGlobalUserUid && is_global)
- return false;
- return true;
-}
-
-bool PkgQueryInterface::IsPackageInstalled(RequestMode mode) {
- if (!IsValid())
- return false;
- bool is_global = false;
- error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
- return false;
- }
-
- if (mode == RequestMode::GLOBAL && !is_global)
- return false;
- if (mode == RequestMode::USER && is_global)
- return false;
-
- return true;
-}
-
-bool PkgQueryInterface::IsGlobalPackage() {
- if (!IsValid())
- return false;
- bool is_global = false;
- error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
- return false;
- }
- return is_global;
-}
-
-bool PkgQueryInterface::IsReadonlyPackage() {
- if (!IsValid())
- return false;
- bool is_readonly = false;
- error_ = pkgmgrinfo_pkginfo_is_readonly(handle_->handle, &is_readonly);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_readonly failed";
- return false;
- }
- return is_readonly;
-}
-
-bool PkgQueryInterface::IsUpdatedPackage() {
- if (!IsValid())
- return false;
- bool is_update = false;
- error_ = pkgmgrinfo_pkginfo_is_update(handle_->handle, &is_update);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_update failed";
- return false;
- }
- return is_update;
-}
-
-bool PkgQueryInterface::IsPreloadPackage() {
- if (!IsValid())
- return false;
- bool is_preload = false;
- error_ = pkgmgrinfo_pkginfo_is_preload(handle_->handle, &is_preload);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_preload failed";
- return false;
- }
- return is_preload;
-}
-
-bool PkgQueryInterface::IsSystemPackage() {
- if (!IsValid())
- return false;
- bool is_system = false;
- error_ = pkgmgrinfo_pkginfo_is_system(handle_->handle, &is_system);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_system failed";
- return false;
- }
- return is_system;
-}
-
-bool PkgQueryInterface::IsRemovablePackage() {
- if (!IsValid())
- return false;
- bool is_removable = false;
- error_ = pkgmgrinfo_pkginfo_is_removable(handle_->handle, &is_removable);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "pkgmgrinfo_pkginfo_is_removable failed";
- return false;
- }
- return is_removable;
-}
-
-bool PkgQueryInterface::AppidsForPkgId(std::vector<std::string>* result) {
- if (!IsValid())
- return false;
- error_ = pkgmgrinfo_appinfo_get_usr_list(handle_->handle, PMINFO_ALL_APP,
- [](const pkgmgrinfo_appinfo_h handle, void* user_data) -> int {
- auto* data = static_cast<std::vector<std::string>*>(user_data);
- char* app_id = nullptr;
- if (pkgmgrinfo_appinfo_get_appid(handle, &app_id) != PMINFO_R_OK)
- return PMINFO_R_ERROR;
- data->emplace_back(app_id);
- return PMINFO_R_OK;
- },
- result, uid_);
- return error_ == PMINFO_R_OK;
-}
-
-bool PkgQueryInterface::PrivilegesForPkgId(std::vector<std::string>* result) {
- if (!IsValid())
- return false;
- error_ = pkgmgrinfo_pkginfo_foreach_privilege(handle_->handle,
- [](const char* privilege_name, void* user_data) -> int {
- auto* data = static_cast<std::vector<std::string>*>(user_data);
- data->emplace_back(privilege_name);
- return PMINFO_R_OK;
- },
- result);
- return error_ == PMINFO_R_OK;
-}
-
-bool PkgQueryInterface::PackagesDependsOn(
- std::vector<DependencyInfo>* result) {
- if (!IsValid())
- return false;
- error_ = pkgmgrinfo_pkginfo_foreach_depends_on(handle_->handle,
- [](const char* from, const char* to, const char* type,
- const char* version, void* user_data) -> int {
- auto* data =
- static_cast<std::vector<ci::PkgQueryInterface::DependencyInfo>*>(
- user_data);
- data->emplace_back(from, to, type, version ? version : "");
- return PMINFO_R_OK;
- },
- result);
- return error_ == PMINFO_R_OK;
-}
-
-bool PkgQueryInterface::IsPluginExecuted(const std::string& plugin_type,
- const std::string& plugin_name) {
- if (!IsValid())
- return false;
- std::vector<PluginInfo> plugin_list;
- error_ = pkgmgrinfo_pkginfo_foreach_plugin(handle_->handle,
- &PkgmgrForeachPluginCallback, &plugin_list);
- if (error_ != PMINFO_R_OK) {
- LOG(ERROR) << "Failed to get plugin info";
- return false;
- }
-
- for (const auto& plugin : plugin_list) {
- if (plugin_type.compare(std::get<2>(plugin)) == 0 &&
- plugin_name.compare(std::get<3>(plugin)) == 0) {
- return true;
- }
- }
- return false;
-}
-
-bool PkgQueryInterface::PluginExecutionInfo(
- std::vector<PluginInfo>* plugin_list) {
- if (!IsValid())
- return false;
-
- error_ = pkgmgrinfo_pkginfo_foreach_plugin(handle_->handle,
- &PkgmgrForeachPluginCallback, plugin_list);
- return error_ == PMINFO_R_OK;
-}
-
-std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
- uid_t uid) {
- pkgmgrinfo_certinfo_h handle;
- int ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
- if (ret != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_create_certinfo failed with error: "
- << ret;
- return {};
- }
- ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid.c_str(), handle, uid);
- if (ret != PMINFO_R_OK) {
- if (ret != PMINFO_R_ENOENT)
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_load_certinfo failed with error: "
- << ret;
- pkgmgrinfo_pkginfo_destroy_certinfo(handle);
- return {};
- }
- const char* author_cert = nullptr;
- ret = pkgmgrinfo_pkginfo_get_cert_value(handle, PMINFO_AUTHOR_SIGNER_CERT,
- &author_cert);
- if (ret != PMINFO_R_OK) {
- LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_cert_value failed with error: "
- << ret;
- pkgmgrinfo_pkginfo_destroy_certinfo(handle);
- return {};
- }
- std::string old_author_certificate;
- if (author_cert)
- old_author_certificate = author_cert;
- pkgmgrinfo_pkginfo_destroy_certinfo(handle);
- return old_author_certificate;
-}
-
-bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid) {
- pkgmgrinfo_pkginfo_h handle;
- int ret = pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkg_id.c_str(),
- uid, &handle);
- if (ret != PMINFO_R_OK) {
- if (ret != PMINFO_R_ENOENT)
- LOG(ERROR) <<
- "Failed to call pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo";
- return false;
- }
-
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return true;
-}
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_PKGMGR_QUERY_H_
-#define COMMON_PKGMGR_QUERY_H_
-
-#include <unistd.h>
-#include <pkgmgr-info.h>
-#include <sys/types.h>
-
-#include <map>
-#include <memory>
-#include <string>
-#include <tuple>
-#include <utility>
-#include <vector>
-
-#include "common/request.h"
-#include "common/utils/singleton.h"
-
-namespace common_installer {
-
-struct PkgHandle {
- pkgmgrinfo_pkginfo_h handle;
- explicit PkgHandle(pkgmgrinfo_pkginfo_h pkginfo_handle) {
- handle = pkginfo_handle;
- }
- ~PkgHandle() {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- }
-};
-
-/**
- * \brief Adapter interface for external PkgMgr module.
- */
-class PkgQueryInterface {
- public:
- using PluginInfo =
- std::tuple<std::string, std::string, std::string, std::string>;
- using DependencyInfo =
- std::tuple<std::string, std::string, std::string, std::string>;
- PkgQueryInterface(const std::string& pkgid, uid_t uid, bool refresh = false);
- ~PkgQueryInterface();
-
- bool IsValid();
- int GetLastOperationError();
-
- /**
- * \brief Returns package version for given package.
- *
- * @return version or empty
- */
- std::string Version();
-
- /**
- * \brief Returns tizen extension package path for given package.
- *
- * @return path or empty
- */
- std::string TepPath();
-
- /**
- * \brief Returns zip mount path for given package.
- *
- * @return path or empty
- */
- std::string ZipMountFile();
-
- /**
- * \brief Returns storage for given package.
- *
- * @return path or empty
- */
- std::string StorageForPkgId();
-
- /**
- * \brief Returns type for given package.
- *
- * @return type or empty
- */
- std::string Type();
-
- /**
- * \brief Checks if given package is installed/registered.
- *
- * \return true if package is installed
- */
- bool IsPackageInstalled();
-
- /**
- * \brief Checks if given package is installed/registered as request mode.
- *
- * \param mode request mode
- *
- * \return true if package is installed
- */
- bool IsPackageInstalled(RequestMode mode);
-
- /**
- * \brief Checks if given package is global package.
- *
- * \return true if package is global package
- */
- bool IsGlobalPackage();
-
- /**
- * \brief Checks if given package is readonly package.
- *
- * \return true if package is readonly
- */
- bool IsReadonlyPackage();
-
- /**
- * \brief Checks if given package is updated package.
- *
- * \return true if package is updated
- */
- bool IsUpdatedPackage();
-
- /**
- * \brief Checks if given package is preloaded package.
- *
- * \return true if package is preloaded
- */
- bool IsPreloadPackage();
-
- /**
- * \brief Checks if given package is system package.
- *
- * \return true if package is system package
- */
- bool IsSystemPackage();
-
- /**
- * \brief Checks if given package is removable package.
- *
- * \return true if package is removable package
- */
- bool IsRemovablePackage();
-
- /**
- * \brief Returns list of appids for given package.
- *
- * \param result[out] Output
- *
- * \return true if success
- */
- bool AppidsForPkgId(std::vector<std::string>* result);
- /**
- * \brief Returns list of privileges for given package
- *
- * \param result result - privileges
- *
- * \return true if success
- */
- bool PrivilegesForPkgId(std::vector<std::string>* result);
-
- /**
- * \brief Returns whether plugin has executed for given package
- *
- * \param plugin_type plugin type
- * \param plugin_name plugin name
- *
- * \return true if success
- */
- bool IsPluginExecuted(const std::string& plugin_type,
- const std::string& plugin_name);
-
- /**
- * \brief Returns list of plugins executed with given package
- *
- * \param plugin_list[out] plugin list
- *
- * \return true if success
- */
- bool PluginExecutionInfo(std::vector<PluginInfo>* plugin_list);
-
-
- /**
- * \brief Returns list of packages depends on given package
- *
- * \param result[out] Output
- *
- * \return true if success
- */
- bool PackagesDependsOn(std::vector<DependencyInfo>* result);
-
- private:
- class PkgQuery : public Singleton<PkgQuery> {
- CRTP_DECLARE_DEFAULT_CONSTRUCTOR_CLASS(PkgQuery)
- public:
- std::shared_ptr<PkgHandle> GetResult(const std::string& pkgid, uid_t uid,
- bool refresh);
-
- private:
- std::map<std::pair<std::string, uid_t>, std::shared_ptr<PkgHandle>>
- query_results_;
- };
-
- int error_;
- std::string pkgid_;
- uid_t uid_;
- std::shared_ptr<PkgHandle> handle_;
-};
-
-/**
- * \brief Adapter interface for external PkgMgr module used for getting
- * certificate information for given package
- *
- * \param pkgid package pkgid
- * \param uid user id
- *
- * \return returns certificate information
- */
-std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
- uid_t uid);
-
-/**
- * \brief Adapter interface for external PkgMgr module used for checking
- * if given package is disabled package
- *
- * \param pkg_id package id
- * \param uid user id
- *
- * \return true if package is disable.
- */
-bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid);
-
-} // namespace common_installer
-
-#endif // COMMON_PKGMGR_QUERY_H_
#include <map>
#include <vector>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace {
#include <utility>
#include <vector>
-#include "common/request.h"
#include "common/step/step.h"
#include "common/utils/macros.h"
+#include "common/utils/request.h"
namespace common_installer {
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/plugins/category_plugin.h"
+
+#include <pkgmgr-info.h>
+#include <pkgmgr_parser.h>
+
+#include <algorithm>
+#include <map>
+#include <vector>
+
+#include "common/utils/glist_range.h"
+
+namespace {
+
+std::string GetCategoryName(const std::string& url) {
+ return url.substr(url.find_last_of('/') + 1);
+}
+
+void ClearCategoryDetail(gpointer data) {
+ __category_t* category = reinterpret_cast<__category_t*>(data);
+ free(const_cast<char*>(category->name));
+ free(category);
+}
+
+} // namespace
+
+namespace common_installer {
+
+const char CategoryPlugin::kType[] = "category";
+
+std::unique_ptr<CategoryPlugin> CategoryPlugin::Create(
+ const PluginInfo& plugin_info) {
+ std::unique_ptr<CategoryPlugin> plugin(new CategoryPlugin(plugin_info));
+ if (!plugin->Load())
+ return nullptr;
+ return plugin;
+}
+
+bool CategoryPlugin::AddPluginInfo(manifest_x* manifest, const char* appid) {
+ plugin_x* plugin = static_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
+ if (!plugin) {
+ LOG(ERROR) << "out of memory";
+ return false;
+ }
+ plugin->pkgid = strdup(manifest->package);
+ plugin->appid = strdup(appid);
+ plugin->plugin_type = strdup(plugin_info_.type().c_str());
+ plugin->plugin_name = strdup(plugin_info_.name().c_str());
+ manifest->plugin = g_list_append(manifest->plugin, plugin);
+ return true;
+}
+
+std::string CategoryPlugin::GetFunctionName(ActionType action) const {
+ static std::map<ActionType, std::string> names {
+ {ActionType::Install, "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL"},
+ {ActionType::Upgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE"},
+ {ActionType::Uninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL"},
+ {ActionType::RecoverInstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
+ {ActionType::RecoverUpgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
+ {ActionType::RecoverUninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
+ {ActionType::Clean, "PKGMGR_CATEGORY_PARSER_PLUGIN_CLEAN"},
+ {ActionType::Undo, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNDO"},
+ {ActionType::Removed, "PKGMGR_CATEGORY_PARSER_PLUGIN_REMOVED"},
+ };
+
+ auto pos = names.find(action);
+ if (pos == names.end()) {
+ LOG(INFO) << "Function name not defined";
+ return "";
+ }
+ return pos->second;
+}
+
+bool CategoryPlugin::Run(xmlDocPtr /*doc_ptr*/, manifest_x* manifest,
+ ActionType action_type) {
+ std::string name;
+ std::string tag = GetCategoryName(plugin_info_.name());
+ if (tag.empty())
+ return false;
+
+ std::vector<std::string> appid_list;
+ if (action_type == ActionType::Upgrade) {
+ if (pkgmgrinfo_plugininfo_foreach_plugininfo(manifest->package,
+ CategoryPlugin::kType,
+ plugin_info_.name().c_str(),
+ [](const char*, const char* appid, const char*,
+ const char*, void* user_data) -> int {
+ auto* appid_list =
+ static_cast<std::vector<std::string>*>(user_data);
+ appid_list->emplace_back(std::string(appid));
+ return PMINFO_R_OK;
+ },
+ &appid_list) != PMINFO_R_OK) {
+ LOG(ERROR) << "Failed to get previous execution info";
+ return false;
+ }
+ std::sort(appid_list.begin(), appid_list.end());
+ }
+
+ for (application_x* app : GListRange<application_x*>(manifest->application)) {
+ // pack all categories starting with key to list that will
+ // be sent to the plugin.
+ // e.g. all http://tizen.org/category/antivirus/*
+ // will be packed for http://tizen.org/category/antivirus
+ GList* category_list = nullptr;
+ for (const char* category : GListRange<char*>(app->category)) {
+ const std::string& sub_key_prefix = plugin_info_.name();
+ if (std::string(category).find(sub_key_prefix) == 0) {
+ __category_t* c = reinterpret_cast<__category_t*>(
+ calloc(1, sizeof(__category_t)));
+ if (!c) {
+ LOG(ERROR) << "Out of memory";
+ g_list_free_full(category_list, &ClearCategoryDetail);
+ return false;
+ }
+ c->name = strdup(category);
+ if (!c->name) {
+ LOG(ERROR) << "Out of memory";
+ free(c);
+ g_list_free_full(category_list, &ClearCategoryDetail);
+ return false;
+ }
+ category_list = g_list_append(category_list, c);
+ }
+ }
+
+ // skip application if it has no given category
+ if (!category_list) {
+ if (action_type != ActionType::Upgrade)
+ continue;
+ auto iter = std::lower_bound(appid_list.begin(), appid_list.end(),
+ app->appid);
+ if (iter != appid_list.end() && *iter == app->appid) {
+ name = GetFunctionName(ActionType::Removed);
+ iter = appid_list.erase(iter);
+ category_list = nullptr;
+ } else {
+ continue;
+ }
+ } else {
+ name = GetFunctionName(action_type);
+ if (!AddPluginInfo(manifest, app->appid)) {
+ g_list_free_full(category_list, &ClearCategoryDetail);
+ return false;
+ }
+ auto iter = std::lower_bound(appid_list.begin(), appid_list.end(),
+ app->appid);
+ if (iter != appid_list.end() && *iter == app->appid)
+ appid_list.erase(iter);
+ }
+ int result = 0;
+ Exec(name, &result, manifest->package, app->appid, category_list);
+ if (result) {
+ LOG(ERROR) << "Function: " << name << " of plugin "
+ << plugin_info_.path() << " failed";
+ g_list_free_full(category_list, &ClearCategoryDetail);
+ return false;
+ }
+ g_list_free_full(category_list, &ClearCategoryDetail);
+ }
+
+ if (action_type != ActionType::Upgrade)
+ return true;
+
+ name = GetFunctionName(ActionType::Removed);
+ for (auto appid : appid_list) {
+ int result = 0;
+ Exec(name, &result, manifest->package, appid, nullptr);
+ if (result) {
+ LOG(ERROR) << "Function: " << name << " of plugin "
+ << plugin_info_.path() << " failed";
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_PLUGINS_CATEGORY_PLUGIN_H_
+#define COMMON_PLUGINS_CATEGORY_PLUGIN_H_
+
+#include <memory>
+#include <string>
+
+#include "common/plugins/plugin.h"
+
+namespace common_installer {
+
+class CategoryPlugin : public Plugin {
+ public:
+ static const char kType[];
+
+ static std::unique_ptr<CategoryPlugin> Create(const PluginInfo& plugin_info);
+ bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
+ ActionType action_type) override;
+
+ private:
+ bool AddPluginInfo(manifest_x* manifest, const char* appid);
+ std::string GetFunctionName(ActionType action) const;
+
+ using Plugin::Plugin;
+
+ SCOPE_LOG_TAG(CategoryPlugin)
+};
+
+} // namespace common_installer
+
+#endif // COMMON_PLUGINS_CATEGORY_PLUGIN_H_
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/plugins/metadata_plugin.h"
+
+#include <pkgmgr-info.h>
+#include <pkgmgr_parser.h>
+
+#include <algorithm>
+#include <map>
+#include <vector>
+
+#include "common/utils/glist_range.h"
+
+namespace {
+
+std::string GetMetadataTag(const std::string& url) {
+ return url.substr(url.find_last_of('/') + 1);
+}
+
+void ClearMetadataDetail(gpointer data) {
+ __metadata_t* meta = reinterpret_cast<__metadata_t*>(data);
+ if (meta->key)
+ free(const_cast<char*>(meta->key));
+ if (meta->value)
+ free(const_cast<char*>(meta->value));
+ free(meta);
+}
+
+} // namespace
+
+namespace common_installer {
+
+const char MetadataPlugin::kType[] = "metadata";
+
+std::unique_ptr<MetadataPlugin> MetadataPlugin::Create(
+ const PluginInfo& plugin_info) {
+ std::unique_ptr<MetadataPlugin> plugin(new MetadataPlugin(plugin_info));
+ if (!plugin->Load())
+ return nullptr;
+ return plugin;
+}
+
+bool MetadataPlugin::AddPluginInfo(manifest_x* manifest, const char* appid) {
+ plugin_x* plugin = static_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
+ if (!plugin) {
+ LOG(ERROR) << "out of memory";
+ return false;
+ }
+ plugin->pkgid = strdup(manifest->package);
+ plugin->appid = strdup(appid);
+ plugin->plugin_type = strdup(plugin_info_.type().c_str());
+ plugin->plugin_name = strdup(plugin_info_.name().c_str());
+ if (!plugin->pkgid || !plugin->appid |
+ !plugin->plugin_type || !plugin->plugin_name) {
+ LOG(ERROR) << "out of memory";
+ free(plugin->pkgid);
+ free(plugin->appid);
+ free(plugin->plugin_type);
+ free(plugin->plugin_name);
+ free(plugin);
+ return false;
+ }
+ manifest->plugin = g_list_append(manifest->plugin, plugin);
+ return true;
+}
+
+std::string MetadataPlugin::GetFunctionName(ActionType action) const {
+ static std::map<ActionType, std::string> names {
+ {ActionType::Install, "PKGMGR_MDPARSER_PLUGIN_INSTALL"},
+ {ActionType::Upgrade, "PKGMGR_MDPARSER_PLUGIN_UPGRADE"},
+ {ActionType::Uninstall, "PKGMGR_MDPARSER_PLUGIN_UNINSTALL"},
+ {ActionType::RecoverInstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERINSTALL"},
+ {ActionType::RecoverUpgrade, "PKGMGR_MDPARSER_PLUGIN_RECOVERUPGRADE"},
+ {ActionType::RecoverUninstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERUNINSTALL"},
+ {ActionType::Clean, "PKGMGR_MDPARSER_PLUGIN_CLEAN"},
+ {ActionType::Undo, "PKGMGR_MDPARSER_PLUGIN_UNDO"},
+ {ActionType::Removed, "PKGMGR_MDPARSER_PLUGIN_REMOVED"},
+ };
+
+ auto pos = names.find(action);
+ if (pos == names.end()) {
+ LOG(INFO) << "Function name not defined";
+ return "";
+ }
+ return pos->second;
+}
+
+bool MetadataPlugin::Run(xmlDocPtr /*doc_ptr*/, manifest_x* manifest,
+ ActionType action_type) {
+ std::string name;
+ std::string tag = GetMetadataTag(plugin_info_.name());
+ if (tag.empty())
+ return false;
+
+ if (action_type == ActionType::Upgrade) {
+ if (pkgmgrinfo_plugininfo_foreach_plugininfo(manifest->package,
+ MetadataPlugin::kType,
+ plugin_info_.name().c_str(),
+ [](const char*, const char* appid, const char*,
+ const char*, void* user_data) -> int {
+ auto* appid_list =
+ static_cast<std::vector<std::string>*>(user_data);
+ appid_list->emplace_back(std::string(appid));
+ return PMINFO_R_OK;
+ },
+ &appid_list_) != PMINFO_R_OK) {
+ LOG(ERROR) << "Failed to get previous execution info";
+ return false;
+ }
+ std::sort(appid_list_.begin(), appid_list_.end());
+ }
+
+ for (application_x* app : GListRange<application_x*>(manifest->application)) {
+ // pack all metadata starting with key to list that will
+ // be sent to the plugin.
+ // e.g. all http://developer.samsung.com/tizen/metadata/profile/*
+ // will be packed for http://developer.samsung.com/tizen/metadata/profile
+ GList* md_list = nullptr;
+ for (metadata_x* meta : GListRange<metadata_x*>(app->metadata)) {
+ const std::string& sub_key_prefix = plugin_info_.name();
+ if (meta->key && meta->value &&
+ std::string(meta->key).find(sub_key_prefix) == 0) {
+ __metadata_t* md = reinterpret_cast<__metadata_t*>(
+ calloc(1, sizeof(__metadata_t)));
+ if (!md) {
+ LOG(ERROR) << "Out of memory";
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ return false;
+ }
+ md->key = strdup(meta->key);
+ if (!md->key) {
+ LOG(ERROR) << "Out of memory";
+ free(md);
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ return false;
+ }
+ md->value = strdup(meta->value);
+ if (!md->value) {
+ LOG(ERROR) << "Out of memory";
+ ClearMetadataDetail(md);
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ return false;
+ }
+ md_list = g_list_append(md_list, md);
+ }
+ }
+
+ // skip application if it has no given metadata
+ if (!md_list) {
+ continue;
+ } else {
+ name = GetFunctionName(action_type);
+ if (!AddPluginInfo(manifest, app->appid)) {
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ return false;
+ }
+ auto iter = std::lower_bound(appid_list_.begin(), appid_list_.end(),
+ app->appid);
+ if (iter != appid_list_.end() && *iter == app->appid)
+ appid_list_.erase(iter);
+ }
+ int result = 0;
+ Exec(name, &result, manifest->package, app->appid, md_list);
+ if (result) {
+ LOG(ERROR) << "Function: " << name << " of plugin "
+ << plugin_info_.path() << " failed";
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ return false;
+ }
+ g_list_free_full(md_list, &ClearMetadataDetail);
+ }
+
+ if (action_type == ActionType::Clean ||
+ action_type == ActionType::Undo)
+ name = GetFunctionName(action_type);
+ else
+ name = GetFunctionName(ActionType::Removed);
+ for (auto appid : appid_list_) {
+ int result = 0;
+ Exec(name, &result, manifest->package, appid.c_str(), nullptr);
+ if (result) {
+ LOG(ERROR) << "Function: " << name << " of plugin "
+ << plugin_info_.path() << " failed";
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_PLUGINS_METADATA_PLUGIN_H_
+#define COMMON_PLUGINS_METADATA_PLUGIN_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "common/plugins/plugin.h"
+
+namespace common_installer {
+
+class MetadataPlugin : public Plugin {
+ public:
+ static const char kType[];
+
+ static std::unique_ptr<MetadataPlugin> Create(const PluginInfo& plugin_info);
+ bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
+ ActionType action_type) override;
+
+ private:
+ bool AddPluginInfo(manifest_x* manifest, const char* appid);
+ std::string GetFunctionName(ActionType action) const;
+
+ using Plugin::Plugin;
+
+ std::vector<std::string> appid_list_;
+ SCOPE_LOG_TAG(MetadataPlugin)
+};
+
+} // namespace common_installer
+
+#endif // COMMON_PLUGINS_METADATA_PLUGIN_H_
#include <manifest_parser/utils/logging.h>
-#include "common/plugins/types/category_plugin.h"
-#include "common/plugins/types/metadata_plugin.h"
-#include "common/plugins/types/tag_plugin.h"
+#include "common/plugins/category_plugin.h"
+#include "common/plugins/metadata_plugin.h"
+#include "common/plugins/tag_plugin.h"
namespace common_installer {
#include "common/plugins/plugin_factory.h"
#include "common/plugins/plugin_list_parser.h"
#include "common/plugins/plugin_xml_parser.h"
-#include "common/plugins/types/category_plugin.h"
-#include "common/plugins/types/metadata_plugin.h"
-#include "common/plugins/types/tag_plugin.h"
+#include "common/plugins/category_plugin.h"
+#include "common/plugins/metadata_plugin.h"
+#include "common/plugins/tag_plugin.h"
#include "common/utils/glist_range.h"
namespace {
#include <string>
#include <vector>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/plugins/plugin.h"
#include "common/plugins/plugin_list_parser.h"
#include "common/plugins/plugin_xml_parser.h"
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/plugins/tag_plugin.h"
+
+#include <map>
+#include <utility>
+
+namespace common_installer {
+
+const char TagPlugin::kType[] = "tag";
+
+std::unique_ptr<TagPlugin> TagPlugin::Create(
+ const PluginInfo& plugin_info, Plugin::ActionType action_type) {
+ std::unique_ptr<TagPlugin> plugin(new TagPlugin(plugin_info, action_type));
+ if (!plugin->Load())
+ return nullptr;
+ return plugin;
+}
+
+std::string TagPlugin::GetFunctionName(ProcessType process,
+ ActionType action) const {
+ static std::map<std::pair<ActionType, ProcessType>, std::string> names {
+ {{ActionType::Install, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_INSTALL"}, // NOLINT
+ {{ActionType::Upgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE"}, // NOLINT
+ {{ActionType::Uninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUNINSTALL"}, // NOLINT
+ {{ActionType::Install, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_INSTALL"}, // NOLINT
+ {{ActionType::Upgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UPGRADE"}, // NOLINT
+ {{ActionType::Uninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNINSTALL"}, // NOLINT
+ {{ActionType::Removed, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_REMOVED"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
+ {{ActionType::Clean, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_CLEAN"}, // NOLINT
+ {{ActionType::Undo, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNDO"}, // NOLINT
+ {{ActionType::Install, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_INSTALL"}, // NOLINT
+ {{ActionType::Upgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UPGRADE"}, // NOLINT
+ {{ActionType::Uninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL"}, // NOLINT
+ {{ActionType::RecoverInstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERINSTALL"}, // NOLINT
+ {{ActionType::RecoverUpgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUPGRADE"}, // NOLINT
+ {{ActionType::RecoverUninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUNINSTALL"}, // NOLINT
+ };
+
+ auto pos = names.find(std::make_pair(action, process));
+ if (pos == names.end()) {
+ LOG(INFO) << "Function name not defined";
+ return "";
+ }
+ return pos->second;
+}
+
+xmlNodePtr MakePluginNode(xmlNodePtr node, const std::string& tag_name) {
+ xmlNodePtr ret_node = nullptr;
+ if (tag_name == reinterpret_cast<const char*>(node->name)) {
+ ret_node = xmlCopyNode(node, 1);
+ return ret_node;
+ }
+
+ for (xmlNodePtr child = xmlFirstElementChild(node);
+ child != nullptr; child = xmlNextElementSibling(child)) {
+ xmlNodePtr child_node = MakePluginNode(child, tag_name);
+ if (!child_node)
+ continue;
+ if (!ret_node)
+ ret_node = xmlCopyNode(node, 0);
+ xmlAddChild(ret_node, child_node);
+ }
+ return ret_node;
+}
+
+xmlDocPtr TagPlugin::CreateDocPtrForPlugin(xmlDocPtr doc_ptr,
+ const std::string& tag_name) const {
+ // Make copy of document and root node
+ xmlNodePtr root_node = xmlDocGetRootElement(doc_ptr);
+ if (!root_node) {
+ LOG(ERROR) << "Original document is empty. Cannot create copy for plugin";
+ return nullptr;
+ }
+ xmlDocPtr plugin_doc_ptr = xmlCopyDoc(doc_ptr, 0);
+ xmlNodePtr plugin_root_node = MakePluginNode(root_node, tag_name);
+ if (!plugin_root_node) {
+ LOG(ERROR) << "make plugin node fail";
+ return nullptr;
+ }
+ xmlDocSetRootElement(plugin_doc_ptr, plugin_root_node);
+ xmlSetTreeDoc(plugin_root_node, plugin_doc_ptr);
+ return plugin_doc_ptr;
+}
+
+bool TagPlugin::Run(xmlDocPtr doc_ptr, manifest_x* manifest,
+ ActionType action_type) {
+ xmlDocPtr plugin_doc_ptr = CreateDocPtrForPlugin(doc_ptr,
+ plugin_info_.name());
+ if (!plugin_doc_ptr)
+ return false;
+
+ int result = 0;
+ ActionType type =
+ (action_type_ != ActionType::Unknown &&
+ action_type != ActionType::Undo &&
+ action_type != ActionType::Clean) ? action_type_ : action_type;
+ std::string pre_function = GetFunctionName(ProcessType::Pre, type);
+ Exec(pre_function, &result, manifest->package);
+ if (result) {
+ LOG(ERROR) << "Function: " << pre_function << " of plugin "
+ << plugin_info_.path() << " failed";
+ xmlFreeDoc(plugin_doc_ptr);
+ return false;
+ }
+
+ std::string main_function = GetFunctionName(ProcessType::Main, type);
+ Exec(main_function, &result, plugin_doc_ptr, manifest->package);
+ if (result) {
+ LOG(ERROR) << "Function: " << main_function << " of plugin "
+ << plugin_info_.path() << " failed";
+ xmlFreeDoc(plugin_doc_ptr);
+ return false;
+ }
+
+ std::string post_function = GetFunctionName(ProcessType::Post, type);
+ Exec(post_function, &result, manifest->package);
+ if (result) {
+ LOG(ERROR) << "Function: " << post_function << " of plugin "
+ << plugin_info_.path() << " failed";
+ xmlFreeDoc(plugin_doc_ptr);
+ return false;
+ }
+
+ xmlFreeDoc(plugin_doc_ptr);
+ return true;
+}
+
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_PLUGINS_TAG_PLUGIN_H_
+#define COMMON_PLUGINS_TAG_PLUGIN_H_
+
+#include <manifest_parser/utils/logging.h>
+
+#include <memory>
+#include <string>
+
+#include "common/plugins/plugin.h"
+#include "common/plugins/plugin_list_parser.h"
+
+namespace common_installer {
+
+class TagPlugin : public Plugin {
+ public:
+ static const char kType[];
+
+ static std::unique_ptr<TagPlugin> Create(const PluginInfo& plugin_info,
+ Plugin::ActionType action_type = Plugin::ActionType::Unknown);
+
+ bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
+ ActionType action_type) override;
+
+ private:
+ using Plugin::Plugin;
+
+ TagPlugin(const PluginInfo& plugin_info, Plugin::ActionType action_type)
+ : Plugin(plugin_info), action_type_(action_type) {}
+
+ std::string GetFunctionName(ProcessType process, ActionType action) const;
+
+ /**
+ * @brief CreateDocPtrForPlugin
+ * Create copy of xml document with nodes only matching requested
+ * tag_name
+ * @param doc_ptr original doc ptr of document
+ * @param tag_name name of required node/nodes
+ * @return requested copy
+ */
+ xmlDocPtr CreateDocPtrForPlugin(xmlDocPtr doc_ptr,
+ const std::string& tag_name) const;
+
+ Plugin::ActionType action_type_;
+ SCOPE_LOG_TAG(TagPlugin)
+};
+
+} // namespace common_installer
+
+#endif // COMMON_PLUGINS_TAG_PLUGIN_H_
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/plugins/types/category_plugin.h"
-
-#include <pkgmgr-info.h>
-#include <pkgmgr_parser.h>
-
-#include <algorithm>
-#include <map>
-#include <vector>
-
-#include "common/utils/glist_range.h"
-
-namespace {
-
-std::string GetCategoryName(const std::string& url) {
- return url.substr(url.find_last_of('/') + 1);
-}
-
-void ClearCategoryDetail(gpointer data) {
- __category_t* category = reinterpret_cast<__category_t*>(data);
- free(const_cast<char*>(category->name));
- free(category);
-}
-
-} // namespace
-
-namespace common_installer {
-
-const char CategoryPlugin::kType[] = "category";
-
-std::unique_ptr<CategoryPlugin> CategoryPlugin::Create(
- const PluginInfo& plugin_info) {
- std::unique_ptr<CategoryPlugin> plugin(new CategoryPlugin(plugin_info));
- if (!plugin->Load())
- return nullptr;
- return plugin;
-}
-
-bool CategoryPlugin::AddPluginInfo(manifest_x* manifest, const char* appid) {
- plugin_x* plugin = static_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
- if (!plugin) {
- LOG(ERROR) << "out of memory";
- return false;
- }
- plugin->pkgid = strdup(manifest->package);
- plugin->appid = strdup(appid);
- plugin->plugin_type = strdup(plugin_info_.type().c_str());
- plugin->plugin_name = strdup(plugin_info_.name().c_str());
- manifest->plugin = g_list_append(manifest->plugin, plugin);
- return true;
-}
-
-std::string CategoryPlugin::GetFunctionName(ActionType action) const {
- static std::map<ActionType, std::string> names {
- {ActionType::Install, "PKGMGR_CATEGORY_PARSER_PLUGIN_INSTALL"},
- {ActionType::Upgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_UPGRADE"},
- {ActionType::Uninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNINSTALL"},
- {ActionType::RecoverInstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
- {ActionType::RecoverUpgrade, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
- {ActionType::RecoverUninstall, "PKGMGR_CATEGORY_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
- {ActionType::Clean, "PKGMGR_CATEGORY_PARSER_PLUGIN_CLEAN"},
- {ActionType::Undo, "PKGMGR_CATEGORY_PARSER_PLUGIN_UNDO"},
- {ActionType::Removed, "PKGMGR_CATEGORY_PARSER_PLUGIN_REMOVED"},
- };
-
- auto pos = names.find(action);
- if (pos == names.end()) {
- LOG(INFO) << "Function name not defined";
- return "";
- }
- return pos->second;
-}
-
-bool CategoryPlugin::Run(xmlDocPtr /*doc_ptr*/, manifest_x* manifest,
- ActionType action_type) {
- std::string name;
- std::string tag = GetCategoryName(plugin_info_.name());
- if (tag.empty())
- return false;
-
- std::vector<std::string> appid_list;
- if (action_type == ActionType::Upgrade) {
- if (pkgmgrinfo_plugininfo_foreach_plugininfo(manifest->package,
- CategoryPlugin::kType,
- plugin_info_.name().c_str(),
- [](const char*, const char* appid, const char*,
- const char*, void* user_data) -> int {
- auto* appid_list =
- static_cast<std::vector<std::string>*>(user_data);
- appid_list->emplace_back(std::string(appid));
- return PMINFO_R_OK;
- },
- &appid_list) != PMINFO_R_OK) {
- LOG(ERROR) << "Failed to get previous execution info";
- return false;
- }
- std::sort(appid_list.begin(), appid_list.end());
- }
-
- for (application_x* app : GListRange<application_x*>(manifest->application)) {
- // pack all categories starting with key to list that will
- // be sent to the plugin.
- // e.g. all http://tizen.org/category/antivirus/*
- // will be packed for http://tizen.org/category/antivirus
- GList* category_list = nullptr;
- for (const char* category : GListRange<char*>(app->category)) {
- const std::string& sub_key_prefix = plugin_info_.name();
- if (std::string(category).find(sub_key_prefix) == 0) {
- __category_t* c = reinterpret_cast<__category_t*>(
- calloc(1, sizeof(__category_t)));
- if (!c) {
- LOG(ERROR) << "Out of memory";
- g_list_free_full(category_list, &ClearCategoryDetail);
- return false;
- }
- c->name = strdup(category);
- if (!c->name) {
- LOG(ERROR) << "Out of memory";
- free(c);
- g_list_free_full(category_list, &ClearCategoryDetail);
- return false;
- }
- category_list = g_list_append(category_list, c);
- }
- }
-
- // skip application if it has no given category
- if (!category_list) {
- if (action_type != ActionType::Upgrade)
- continue;
- auto iter = std::lower_bound(appid_list.begin(), appid_list.end(),
- app->appid);
- if (iter != appid_list.end() && *iter == app->appid) {
- name = GetFunctionName(ActionType::Removed);
- iter = appid_list.erase(iter);
- category_list = nullptr;
- } else {
- continue;
- }
- } else {
- name = GetFunctionName(action_type);
- if (!AddPluginInfo(manifest, app->appid)) {
- g_list_free_full(category_list, &ClearCategoryDetail);
- return false;
- }
- auto iter = std::lower_bound(appid_list.begin(), appid_list.end(),
- app->appid);
- if (iter != appid_list.end() && *iter == app->appid)
- appid_list.erase(iter);
- }
- int result = 0;
- Exec(name, &result, manifest->package, app->appid, category_list);
- if (result) {
- LOG(ERROR) << "Function: " << name << " of plugin "
- << plugin_info_.path() << " failed";
- g_list_free_full(category_list, &ClearCategoryDetail);
- return false;
- }
- g_list_free_full(category_list, &ClearCategoryDetail);
- }
-
- if (action_type != ActionType::Upgrade)
- return true;
-
- name = GetFunctionName(ActionType::Removed);
- for (auto appid : appid_list) {
- int result = 0;
- Exec(name, &result, manifest->package, appid, nullptr);
- if (result) {
- LOG(ERROR) << "Function: " << name << " of plugin "
- << plugin_info_.path() << " failed";
- return false;
- }
- }
- return true;
-}
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_PLUGINS_TYPES_CATEGORY_PLUGIN_H_
-#define COMMON_PLUGINS_TYPES_CATEGORY_PLUGIN_H_
-
-#include <memory>
-#include <string>
-
-#include "common/plugins/plugin.h"
-
-namespace common_installer {
-
-class CategoryPlugin : public Plugin {
- public:
- static const char kType[];
-
- static std::unique_ptr<CategoryPlugin> Create(const PluginInfo& plugin_info);
- bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
- ActionType action_type) override;
-
- private:
- bool AddPluginInfo(manifest_x* manifest, const char* appid);
- std::string GetFunctionName(ActionType action) const;
-
- using Plugin::Plugin;
-
- SCOPE_LOG_TAG(CategoryPlugin)
-};
-
-} // namespace common_installer
-
-#endif // COMMON_PLUGINS_TYPES_CATEGORY_PLUGIN_H_
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/plugins/types/metadata_plugin.h"
-
-#include <pkgmgr-info.h>
-#include <pkgmgr_parser.h>
-
-#include <algorithm>
-#include <map>
-#include <vector>
-
-#include "common/utils/glist_range.h"
-
-namespace {
-
-std::string GetMetadataTag(const std::string& url) {
- return url.substr(url.find_last_of('/') + 1);
-}
-
-void ClearMetadataDetail(gpointer data) {
- __metadata_t* meta = reinterpret_cast<__metadata_t*>(data);
- if (meta->key)
- free(const_cast<char*>(meta->key));
- if (meta->value)
- free(const_cast<char*>(meta->value));
- free(meta);
-}
-
-} // namespace
-
-namespace common_installer {
-
-const char MetadataPlugin::kType[] = "metadata";
-
-std::unique_ptr<MetadataPlugin> MetadataPlugin::Create(
- const PluginInfo& plugin_info) {
- std::unique_ptr<MetadataPlugin> plugin(new MetadataPlugin(plugin_info));
- if (!plugin->Load())
- return nullptr;
- return plugin;
-}
-
-bool MetadataPlugin::AddPluginInfo(manifest_x* manifest, const char* appid) {
- plugin_x* plugin = static_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
- if (!plugin) {
- LOG(ERROR) << "out of memory";
- return false;
- }
- plugin->pkgid = strdup(manifest->package);
- plugin->appid = strdup(appid);
- plugin->plugin_type = strdup(plugin_info_.type().c_str());
- plugin->plugin_name = strdup(plugin_info_.name().c_str());
- if (!plugin->pkgid || !plugin->appid |
- !plugin->plugin_type || !plugin->plugin_name) {
- LOG(ERROR) << "out of memory";
- free(plugin->pkgid);
- free(plugin->appid);
- free(plugin->plugin_type);
- free(plugin->plugin_name);
- free(plugin);
- return false;
- }
- manifest->plugin = g_list_append(manifest->plugin, plugin);
- return true;
-}
-
-std::string MetadataPlugin::GetFunctionName(ActionType action) const {
- static std::map<ActionType, std::string> names {
- {ActionType::Install, "PKGMGR_MDPARSER_PLUGIN_INSTALL"},
- {ActionType::Upgrade, "PKGMGR_MDPARSER_PLUGIN_UPGRADE"},
- {ActionType::Uninstall, "PKGMGR_MDPARSER_PLUGIN_UNINSTALL"},
- {ActionType::RecoverInstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERINSTALL"},
- {ActionType::RecoverUpgrade, "PKGMGR_MDPARSER_PLUGIN_RECOVERUPGRADE"},
- {ActionType::RecoverUninstall, "PKGMGR_MDPARSER_PLUGIN_RECOVERUNINSTALL"},
- {ActionType::Clean, "PKGMGR_MDPARSER_PLUGIN_CLEAN"},
- {ActionType::Undo, "PKGMGR_MDPARSER_PLUGIN_UNDO"},
- {ActionType::Removed, "PKGMGR_MDPARSER_PLUGIN_REMOVED"},
- };
-
- auto pos = names.find(action);
- if (pos == names.end()) {
- LOG(INFO) << "Function name not defined";
- return "";
- }
- return pos->second;
-}
-
-bool MetadataPlugin::Run(xmlDocPtr /*doc_ptr*/, manifest_x* manifest,
- ActionType action_type) {
- std::string name;
- std::string tag = GetMetadataTag(plugin_info_.name());
- if (tag.empty())
- return false;
-
- if (action_type == ActionType::Upgrade) {
- if (pkgmgrinfo_plugininfo_foreach_plugininfo(manifest->package,
- MetadataPlugin::kType,
- plugin_info_.name().c_str(),
- [](const char*, const char* appid, const char*,
- const char*, void* user_data) -> int {
- auto* appid_list =
- static_cast<std::vector<std::string>*>(user_data);
- appid_list->emplace_back(std::string(appid));
- return PMINFO_R_OK;
- },
- &appid_list_) != PMINFO_R_OK) {
- LOG(ERROR) << "Failed to get previous execution info";
- return false;
- }
- std::sort(appid_list_.begin(), appid_list_.end());
- }
-
- for (application_x* app : GListRange<application_x*>(manifest->application)) {
- // pack all metadata starting with key to list that will
- // be sent to the plugin.
- // e.g. all http://developer.samsung.com/tizen/metadata/profile/*
- // will be packed for http://developer.samsung.com/tizen/metadata/profile
- GList* md_list = nullptr;
- for (metadata_x* meta : GListRange<metadata_x*>(app->metadata)) {
- const std::string& sub_key_prefix = plugin_info_.name();
- if (meta->key && meta->value &&
- std::string(meta->key).find(sub_key_prefix) == 0) {
- __metadata_t* md = reinterpret_cast<__metadata_t*>(
- calloc(1, sizeof(__metadata_t)));
- if (!md) {
- LOG(ERROR) << "Out of memory";
- g_list_free_full(md_list, &ClearMetadataDetail);
- return false;
- }
- md->key = strdup(meta->key);
- if (!md->key) {
- LOG(ERROR) << "Out of memory";
- free(md);
- g_list_free_full(md_list, &ClearMetadataDetail);
- return false;
- }
- md->value = strdup(meta->value);
- if (!md->value) {
- LOG(ERROR) << "Out of memory";
- ClearMetadataDetail(md);
- g_list_free_full(md_list, &ClearMetadataDetail);
- return false;
- }
- md_list = g_list_append(md_list, md);
- }
- }
-
- // skip application if it has no given metadata
- if (!md_list) {
- continue;
- } else {
- name = GetFunctionName(action_type);
- if (!AddPluginInfo(manifest, app->appid)) {
- g_list_free_full(md_list, &ClearMetadataDetail);
- return false;
- }
- auto iter = std::lower_bound(appid_list_.begin(), appid_list_.end(),
- app->appid);
- if (iter != appid_list_.end() && *iter == app->appid)
- appid_list_.erase(iter);
- }
- int result = 0;
- Exec(name, &result, manifest->package, app->appid, md_list);
- if (result) {
- LOG(ERROR) << "Function: " << name << " of plugin "
- << plugin_info_.path() << " failed";
- g_list_free_full(md_list, &ClearMetadataDetail);
- return false;
- }
- g_list_free_full(md_list, &ClearMetadataDetail);
- }
-
- if (action_type == ActionType::Clean ||
- action_type == ActionType::Undo)
- name = GetFunctionName(action_type);
- else
- name = GetFunctionName(ActionType::Removed);
- for (auto appid : appid_list_) {
- int result = 0;
- Exec(name, &result, manifest->package, appid.c_str(), nullptr);
- if (result) {
- LOG(ERROR) << "Function: " << name << " of plugin "
- << plugin_info_.path() << " failed";
- return false;
- }
- }
- return true;
-}
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_PLUGINS_TYPES_METADATA_PLUGIN_H_
-#define COMMON_PLUGINS_TYPES_METADATA_PLUGIN_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "common/plugins/plugin.h"
-
-namespace common_installer {
-
-class MetadataPlugin : public Plugin {
- public:
- static const char kType[];
-
- static std::unique_ptr<MetadataPlugin> Create(const PluginInfo& plugin_info);
- bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
- ActionType action_type) override;
-
- private:
- bool AddPluginInfo(manifest_x* manifest, const char* appid);
- std::string GetFunctionName(ActionType action) const;
-
- using Plugin::Plugin;
-
- std::vector<std::string> appid_list_;
- SCOPE_LOG_TAG(MetadataPlugin)
-};
-
-} // namespace common_installer
-
-#endif // COMMON_PLUGINS_TYPES_METADATA_PLUGIN_H_
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/plugins/types/tag_plugin.h"
-
-#include <map>
-#include <utility>
-
-namespace common_installer {
-
-const char TagPlugin::kType[] = "tag";
-
-std::unique_ptr<TagPlugin> TagPlugin::Create(
- const PluginInfo& plugin_info, Plugin::ActionType action_type) {
- std::unique_ptr<TagPlugin> plugin(new TagPlugin(plugin_info, action_type));
- if (!plugin->Load())
- return nullptr;
- return plugin;
-}
-
-std::string TagPlugin::GetFunctionName(ProcessType process,
- ActionType action) const {
- static std::map<std::pair<ActionType, ProcessType>, std::string> names {
- {{ActionType::Install, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_INSTALL"}, // NOLINT
- {{ActionType::Upgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UPGRADE"}, // NOLINT
- {{ActionType::Uninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL"}, // NOLINT
- {{ActionType::RecoverInstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERINSTALL"}, // NOLINT
- {{ActionType::RecoverUpgrade, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUPGRADE"}, // NOLINT
- {{ActionType::RecoverUninstall, ProcessType::Pre}, "PKGMGR_PARSER_PLUGIN_PRE_RECOVERUNINSTALL"}, // NOLINT
- {{ActionType::Install, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_INSTALL"}, // NOLINT
- {{ActionType::Upgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UPGRADE"}, // NOLINT
- {{ActionType::Uninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNINSTALL"}, // NOLINT
- {{ActionType::Removed, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_REMOVED"}, // NOLINT
- {{ActionType::RecoverInstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERINSTALL"}, // NOLINT
- {{ActionType::RecoverUpgrade, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUPGRADE"}, // NOLINT
- {{ActionType::RecoverUninstall, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_RECOVERUNINSTALL"}, // NOLINT
- {{ActionType::Clean, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_CLEAN"}, // NOLINT
- {{ActionType::Undo, ProcessType::Main}, "PKGMGR_PARSER_PLUGIN_UNDO"}, // NOLINT
- {{ActionType::Install, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_INSTALL"}, // NOLINT
- {{ActionType::Upgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UPGRADE"}, // NOLINT
- {{ActionType::Uninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_UNINSTALL"}, // NOLINT
- {{ActionType::RecoverInstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERINSTALL"}, // NOLINT
- {{ActionType::RecoverUpgrade, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUPGRADE"}, // NOLINT
- {{ActionType::RecoverUninstall, ProcessType::Post}, "PKGMGR_PARSER_PLUGIN_POST_RECOVERUNINSTALL"}, // NOLINT
- };
-
- auto pos = names.find(std::make_pair(action, process));
- if (pos == names.end()) {
- LOG(INFO) << "Function name not defined";
- return "";
- }
- return pos->second;
-}
-
-xmlNodePtr MakePluginNode(xmlNodePtr node, const std::string& tag_name) {
- xmlNodePtr ret_node = nullptr;
- if (tag_name == reinterpret_cast<const char*>(node->name)) {
- ret_node = xmlCopyNode(node, 1);
- return ret_node;
- }
-
- for (xmlNodePtr child = xmlFirstElementChild(node);
- child != nullptr; child = xmlNextElementSibling(child)) {
- xmlNodePtr child_node = MakePluginNode(child, tag_name);
- if (!child_node)
- continue;
- if (!ret_node)
- ret_node = xmlCopyNode(node, 0);
- xmlAddChild(ret_node, child_node);
- }
- return ret_node;
-}
-
-xmlDocPtr TagPlugin::CreateDocPtrForPlugin(xmlDocPtr doc_ptr,
- const std::string& tag_name) const {
- // Make copy of document and root node
- xmlNodePtr root_node = xmlDocGetRootElement(doc_ptr);
- if (!root_node) {
- LOG(ERROR) << "Original document is empty. Cannot create copy for plugin";
- return nullptr;
- }
- xmlDocPtr plugin_doc_ptr = xmlCopyDoc(doc_ptr, 0);
- xmlNodePtr plugin_root_node = MakePluginNode(root_node, tag_name);
- if (!plugin_root_node) {
- LOG(ERROR) << "make plugin node fail";
- return nullptr;
- }
- xmlDocSetRootElement(plugin_doc_ptr, plugin_root_node);
- xmlSetTreeDoc(plugin_root_node, plugin_doc_ptr);
- return plugin_doc_ptr;
-}
-
-bool TagPlugin::Run(xmlDocPtr doc_ptr, manifest_x* manifest,
- ActionType action_type) {
- xmlDocPtr plugin_doc_ptr = CreateDocPtrForPlugin(doc_ptr,
- plugin_info_.name());
- if (!plugin_doc_ptr)
- return false;
-
- int result = 0;
- ActionType type =
- (action_type_ != ActionType::Unknown &&
- action_type != ActionType::Undo &&
- action_type != ActionType::Clean) ? action_type_ : action_type;
- std::string pre_function = GetFunctionName(ProcessType::Pre, type);
- Exec(pre_function, &result, manifest->package);
- if (result) {
- LOG(ERROR) << "Function: " << pre_function << " of plugin "
- << plugin_info_.path() << " failed";
- xmlFreeDoc(plugin_doc_ptr);
- return false;
- }
-
- std::string main_function = GetFunctionName(ProcessType::Main, type);
- Exec(main_function, &result, plugin_doc_ptr, manifest->package);
- if (result) {
- LOG(ERROR) << "Function: " << main_function << " of plugin "
- << plugin_info_.path() << " failed";
- xmlFreeDoc(plugin_doc_ptr);
- return false;
- }
-
- std::string post_function = GetFunctionName(ProcessType::Post, type);
- Exec(post_function, &result, manifest->package);
- if (result) {
- LOG(ERROR) << "Function: " << post_function << " of plugin "
- << plugin_info_.path() << " failed";
- xmlFreeDoc(plugin_doc_ptr);
- return false;
- }
-
- xmlFreeDoc(plugin_doc_ptr);
- return true;
-}
-
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_PLUGINS_TYPES_TAG_PLUGIN_H_
-#define COMMON_PLUGINS_TYPES_TAG_PLUGIN_H_
-
-#include <manifest_parser/utils/logging.h>
-
-#include <memory>
-#include <string>
-
-#include "common/plugins/plugin.h"
-#include "common/plugins/plugin_list_parser.h"
-
-namespace common_installer {
-
-class TagPlugin : public Plugin {
- public:
- static const char kType[];
-
- static std::unique_ptr<TagPlugin> Create(const PluginInfo& plugin_info,
- Plugin::ActionType action_type = Plugin::ActionType::Unknown);
-
- bool Run(xmlDocPtr doc_ptr, manifest_x* manifest,
- ActionType action_type) override;
-
- private:
- using Plugin::Plugin;
-
- TagPlugin(const PluginInfo& plugin_info, Plugin::ActionType action_type)
- : Plugin(plugin_info), action_type_(action_type) {}
-
- std::string GetFunctionName(ProcessType process, ActionType action) const;
-
- /**
- * @brief CreateDocPtrForPlugin
- * Create copy of xml document with nodes only matching requested
- * tag_name
- * @param doc_ptr original doc ptr of document
- * @param tag_name name of required node/nodes
- * @return requested copy
- */
- xmlDocPtr CreateDocPtrForPlugin(xmlDocPtr doc_ptr,
- const std::string& tag_name) const;
-
- Plugin::ActionType action_type_;
- SCOPE_LOG_TAG(TagPlugin)
-};
-
-} // namespace common_installer
-
-#endif // COMMON_PLUGINS_TYPES_TAG_PLUGIN_H_
#include <memory>
#include <string>
-#include "common/request.h"
+#include "common/utils/request.h"
namespace common_installer {
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#include "common/request.h"
-
-#include <tzplatform_config.h>
-#include <unistd.h>
-
-#include <map>
-#include <string>
-
-#include "common/utils/user_util.h"
-
-namespace bf = boost::filesystem;
-
-namespace common_installer {
-
-const std::map<RequestType, const char*> kRequestTypeStringMap = {
- {RequestType::Unknown, "Unknown"},
- {RequestType::Install, "Install"},
- {RequestType::Update, "Update"},
- {RequestType::Uninstall, "Uninstall"},
- {RequestType::Reinstall, "Reinstall"},
- {RequestType::Delta, "Delta"},
- {RequestType::Move, "Move"},
- {RequestType::Recovery, "Recovery"},
- {RequestType::RecoveryUpdate, "RecoveryUpdate"},
- {RequestType::MountInstall, "MountInstall"},
- {RequestType::MountUpdate, "MountUpdate"},
- {RequestType::ManifestDirectInstall, "ManifestDirectInstall"},
- {RequestType::ManifestDirectUpdate, "ManifestDirectUpdate"},
- {RequestType::ManifestPartialInstall, "ManifestPartialInstall"},
- {RequestType::ManifestPartialUpdate, "ManifestPartialUpdate"},
- {RequestType::PartialUninstall, "PartialUninstall"},
- {RequestType::ReadonlyUpdateInstall, "ReadonlyUpdateInstall"},
- {RequestType::ReadonlyUpdateUninstall, "ReadonlyUpdateUninstall"},
- {RequestType::DisablePkg, "DisablePkg"},
- {RequestType::EnablePkg, "EnablePkg"},
- {RequestType::MigrateExtImg, "MigrateExtImg"},
- {RequestType::RecoverDB, "RecoverDB"},
-};
-
-std::string GetRequestTypeString(RequestType request_type) {
- const auto& it = kRequestTypeStringMap.find(request_type);
- if (it == kRequestTypeStringMap.end())
- return "Unknown";
- else
- return it->second;
-}
-
-RequestMode GetRequestMode(uid_t uid) {
- return (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) ?
- RequestMode::GLOBAL : RequestMode::USER;
-}
-
-// Now, readonly app is always installed RO location.
-const char* GetRootAppPath(bool is_readonly, uid_t uid) {
- if (GetRequestMode(uid) == RequestMode::GLOBAL) {
- return is_readonly ?
- tzplatform_getenv(TZ_SYS_RO_APP) : tzplatform_getenv(TZ_SYS_RW_APP);
- } else {
- tzplatform_set_user(uid);
- const char* rootpath = tzplatform_getenv(TZ_USER_APP);
- tzplatform_reset_user();
- return rootpath;
- }
-}
-
-const char* GetExtendedRootAppPath(uid_t uid) {
- if (GetRequestMode(uid) == RequestMode::GLOBAL) {
- return tzplatform_getenv(TZ_SYS_EXTENDEDSD_APP);
- } else {
- tzplatform_set_user(uid);
- const char* rootpath = tzplatform_getenv(TZ_USER_EXTENDEDSD_APP);
- tzplatform_reset_user();
- return rootpath;
- }
-}
-
-} // namespace common_installer
+++ /dev/null
-// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by an apache-2.0 license that can be
-// found in the LICENSE file.
-
-#ifndef COMMON_REQUEST_H_
-#define COMMON_REQUEST_H_
-
-#include <boost/filesystem/path.hpp>
-
-#include <string>
-
-namespace common_installer {
-
-/** Request type received from pkgmgr_installer */
-enum class RequestType : int {
- Unknown = 0,
- Install,
- Update,
- Uninstall,
- Reinstall,
- Delta,
- Move,
- Recovery,
- RecoveryUpdate,
- MountInstall,
- MountUpdate,
- ManifestDirectInstall,
- ManifestDirectUpdate,
- ManifestPartialInstall,
- ManifestPartialUpdate,
- PartialUninstall,
- ReadonlyUpdateInstall,
- ReadonlyUpdateUninstall,
- DisablePkg,
- EnablePkg,
- MigrateExtImg,
- RecoverDB
-};
-
-/** Request mode (USER vs GLOBAL) */
-enum class RequestMode : int {
- USER,
- GLOBAL
-};
-
-/**
- * Get string of given request type
- *
- * \return request mode
- */
-std::string GetRequestTypeString(RequestType request_type);
-
-/**
- * Get mode for current request (GLOBAL/USER)
- *
- * \return request mode
- */
-RequestMode GetRequestMode(uid_t uid);
-
-/**
- * Get apps root path for current request (GLOBAL/USER)
- *
- * \return root application path (eg. $HOME/apps_rw/)
- */
-const char* GetRootAppPath(bool is_readonly, uid_t uid);
-
-/**
- * Get appt root path at exteded storage for current request (GLOBAL/USER)
- *
- * \return root application path at extended path
- * (eg. $TZ_SYS_MEDIA/extended/globalapps)
- */
-const char* GetExtendedRootAppPath(uid_t uid);
-
-} // namespace common_installer
-
-#endif // COMMON_REQUEST_H_
-
#include <algorithm>
#include <functional>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/privileges.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
#include <vector>
#include <tuple>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/security_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/base64.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
#include <regex>
#include "common/certificate_validation.h"
-#include "common/pkgmgr_query.h"
-#include "common/request.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/glist_range.h"
#include "common/utils/file_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
namespace bi = boost::iostreams;
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
#include <algorithm>
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
#include <cstdint>
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
#include <boost/filesystem/operations.hpp>
-#include "common/paths.h"
+#include "common/utils/paths.h"
namespace bf = boost::filesystem;
#include <string>
#include "common/installer_context.h"
-#include "common/paths.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/paths.h"
+#include "common/utils/pkgmgr_query.h"
namespace {
#include <string>
#include <utility>
-#include "common/pkgmgr_query.h"
-#include "common/request.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
#include "common/feature_validator.h"
#include "common/installer_context.h"
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/privileges.h"
#include "common/pkgmgr_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/step/step.h"
#include "common/utils/glist_range.h"
#include <boost/filesystem.hpp>
-#include <common/app_installer.h>
+#include <common/installer/app_installer.h>
#include <common/installer_context.h>
#include <common/step/step.h>
#include <string>
#include "common/pkgmgr_interface.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
#include <string>
#include "common/external_storage.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace {
#include <string>
#include <vector>
-#include "common/paths.h"
-#include "common/request.h"
+#include "common/utils/paths.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
#include "common/utils/user_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
namespace ci = common_installer;
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "utils/file_util.h"
namespace bf = boost::filesystem;
#include <cstring>
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
namespace common_installer {
#include <string>
#include "common/shared_dirs.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace {
#include <string>
#include "common/security_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace bf = boost::filesystem;
#include "common/external_storage.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/pkgmgr_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
#include <string>
#include "common/external_storage.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace {
#include <string>
#include <vector>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
#include <boost/filesystem/path.hpp>
#include <boost/system/error_code.hpp>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/recovery_file.h"
-#include "common/request.h"
#include "common/utils/file_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
#include <pkgmgrinfo_basic.h>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/privileges.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include <string>
#include <vector>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
#include "common/shared_dirs.h"
#include <string>
#include "common/installer_context.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/shared_dirs.h"
namespace {
#include <string>
#include <vector>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/pkgmgr_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace bs = boost::system;
#include <string>
#include <vector>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/privileges.h"
#include "common/security_registration.h"
#include "common/shared_dirs.h"
#include <cstring>
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
#include <string>
-#include "common/paths.h"
-#include "common/request.h"
+#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
#include "common/utils/file_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
#include <pkgmgrinfo_basic.h>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/utils/file_util.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
#include <string>
-#include "common/paths.h"
-#include "common/request.h"
+#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
#include "common/utils/file_util.h"
+#include "common/utils/request.h"
namespace bf = boost::filesystem;
namespace bs = boost::system;
#include <string>
-#include "common/paths.h"
+#include "common/utils/paths.h"
#include "common/tzip_interface.h"
namespace bf = boost::filesystem;
#include <boost/filesystem.hpp>
#include <boost/filesystem/path.hpp>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/installer_context.h"
#include "common/utils/manifest_util.h"
#include <vector>
#include "common/pkgmgr_dependency.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/glist_range.h"
#include "common/utils/user_util.h"
#include <string>
#include <vector>
-#include "common/app_installer.h"
+#include "common/installer/app_installer.h"
#include "common/pkgmgr_dependency.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace common_installer {
namespace pkgmgr {
#include <vector>
#include "common/pkgmgr_dependency.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace common_installer {
namespace pkgmgr {
#include <boost/filesystem.hpp>
-#include "common/paths.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/paths.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/pkgmgr_registration.h"
namespace bf = boost::filesystem;
#include <string>
#include "common/pkgmgr_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace common_installer {
#include <string>
#include "common/pkgmgr_registration.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
#ifndef COMMON_STEP_PKGMGR_STEP_UPDATE_PKG_DISABLE_INFO_H_
#define COMMON_STEP_PKGMGR_STEP_UPDATE_PKG_DISABLE_INFO_H_
-#include <common/app_installer.h>
+#include <common/installer/app_installer.h>
#include <common/installer_context.h>
#include <common/step/step.h>
#include <string>
#include <utility>
-#include "common/pkgmgr_query.h"
-#include "common/request.h"
+#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
+#include "common/utils/request.h"
#include "common/recovery_file.h"
namespace bf = boost::filesystem;
#include <manifest_parser/utils/logging.h>
-#include "common/request.h"
+#include "common/utils/request.h"
namespace common_installer {
namespace recovery {
#include <string>
#include "common/certificate_validation.h"
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace common_installer {
namespace security {
#include <string>
#include <vector>
-#include "common/paths.h"
#include "common/utils/byte_size_literals.h"
+#include "common/utils/paths.h"
namespace ba = boost::algorithm;
namespace bs = boost::system;
#include <boost/filesystem/path.hpp>
#include <string>
-#include "common/pkgmgr_query.h"
+#include "common/utils/pkgmgr_query.h"
namespace bf = boost::filesystem;
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/utils/paths.h"
+
+#include <manifest_parser/utils/logging.h>
+
+#include <boost/filesystem/operations.hpp>
+
+#include <pwd.h>
+#include <tzplatform_config.h>
+#include <storage-internal.h>
+
+#include <vector>
+
+#include "common/utils/user_util.h"
+
+namespace bf = boost::filesystem;
+namespace ci = common_installer;
+
+namespace {
+
+const char kImageDir[] = ".image";
+const char kBckExtension[] = ".bck";
+
+boost::filesystem::path GetBackupPath(const boost::filesystem::path& pkg_path) {
+ bf::path backup_path = pkg_path;
+ backup_path += kBckExtension;
+ return backup_path;
+}
+
+} // namespace
+
+namespace common_installer {
+
+boost::filesystem::path GetBackupPathForPackagePath(
+ const boost::filesystem::path& pkg_path) {
+ return GetBackupPath(pkg_path);
+}
+
+boost::filesystem::path GetBackupPathForManifestFile(
+ const boost::filesystem::path& manifest_path) {
+ return GetBackupPath(manifest_path);
+}
+
+boost::filesystem::path GetBackupPathForIconFile(
+ const boost::filesystem::path& icon_path) {
+ return GetBackupPath(icon_path);
+}
+
+std::string GetIconFileBackupExtension() {
+ return kBckExtension;
+}
+
+boost::filesystem::path GetBackupPathForZipFile(const bf::path& zip_path) {
+ return GetBackupPath(zip_path);
+}
+
+boost::filesystem::path GetMountLocation(const bf::path& pkg_path) {
+ return pkg_path / ".pkg";
+}
+
+boost::filesystem::path GetZipPackageLocation(
+ const boost::filesystem::path& pkg_path,
+ const std::string& pkgid) {
+ return pkg_path / kImageDir / pkgid;
+}
+
+boost::filesystem::path GetExternalCardPath() {
+ char* sdpath = nullptr;
+ int storage_id = 0;
+ int ret;
+
+ ret = storage_get_primary_sdcard(&storage_id, &sdpath);
+ if (ret != STORAGE_ERROR_NONE) {
+ free(sdpath);
+ return bf::path();
+ }
+
+ if (sdpath) {
+ std::string mount_path(sdpath);
+ free(sdpath);
+ return bf::path(mount_path);
+ }
+
+ return bf::path();
+}
+
+boost::filesystem::path GetExternalTepPath(RequestMode request_mode,
+ uid_t uid) {
+ bf::path result;
+ bf::path ext_mount_path = GetExternalCardPath();
+ if (bf::is_empty(ext_mount_path))
+ return result;
+ result = ext_mount_path / "tep";
+ if (request_mode == RequestMode::USER)
+ result /= ci::GetUsernameByUid(uid);
+ return result;
+}
+
+boost::filesystem::path GetInternalTepPath(
+ const boost::filesystem::path& pkg_path) {
+ return pkg_path / "tep";
+}
+
+boost::filesystem::path GetIconPath(const bf::path& base_path,
+ const std::string& pkgid,
+ const bf::path& icon_filename,
+ const bf::path& root_path) {
+ std::vector<bf::path> paths;
+ bf::path system_path = base_path / icon_filename;
+ bf::path small_system_path = base_path / "default" / "small" / icon_filename;
+ bf::path res_path = root_path / pkgid / "res" / "icons" / icon_filename;
+
+ paths.push_back(system_path);
+ paths.push_back(small_system_path);
+ paths.push_back(res_path);
+
+ for (auto& path : paths) {
+ if (bf::exists(path))
+ return path;
+ }
+
+ return {};
+}
+
+bool IsExtendedStorageAvailable() {
+ bool is_available = false;
+ int ret = storage_foreach_device_supported(
+ [](int, storage_type_e type, storage_state_e state,
+ const char* path, void* user_data) -> bool {
+ if (type != STORAGE_TYPE_EXTENDED_INTERNAL)
+ return true;
+ if (state != STORAGE_STATE_MOUNTED)
+ return true;
+ bool* is_available = static_cast<bool*>(user_data);
+ if (bf::exists(path))
+ *is_available = true;
+ // Stop iteration
+ return false;
+ },
+ &is_available);
+ if (ret != STORAGE_ERROR_NONE) {
+ LOG(ERROR) << "Failed to call storage_foreach_device_supported()";
+ return false;
+ }
+ return is_available;
+}
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_UTILS_PATHS_H_
+#define COMMON_UTILS_PATHS_H_
+
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <unistd.h>
+
+#include <string>
+
+#include "common/utils/request.h"
+
+namespace common_installer {
+
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on package path
+ *
+ * \param pkg_path package path
+ *
+ * \return backup path
+ */
+boost::filesystem::path GetBackupPathForPackagePath(
+ const boost::filesystem::path& pkg_path);
+
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on manifest file path
+ *
+ * \param manifest_path path to manifest file
+ *
+ * \return backup path
+ */
+boost::filesystem::path GetBackupPathForManifestFile(
+ const boost::filesystem::path& manifest_path);
+
+/**
+ * \brief Helper function for getting backup path (used for recovery)
+ * based on icon path
+ *
+ * \param icon_path path to icon file
+ *
+ * \return backup path
+ */
+boost::filesystem::path GetBackupPathForIconFile(
+ const boost::filesystem::path& icon_path);
+
+/**
+ * @brief GetIconFileBackupExtension
+ * @return extension for backup icon files
+ */
+std::string GetIconFileBackupExtension();
+
+/**
+ * \brief Helper function for getting backup path of zip (used for recovery)
+ * based on zip path
+ *
+ * \param zip_path path to zip file
+ *
+ * \return backup path of zip
+ */
+boost::filesystem::path GetBackupPathForZipFile(
+ const boost::filesystem::path& zip_path);
+
+/**
+ * @brief GetZipPackageLocation
+ * Returns location where zip package file must be copied during package
+ * installation.
+ *
+ * @param pkg_path package path
+ * @param pkgid package id
+ *
+ * @return full path of zip package location
+ */
+boost::filesystem::path GetZipPackageLocation(
+ const boost::filesystem::path& pkg_path,
+ const std::string& pkgid);
+
+/**
+ * @brief GetMountLocation
+ * Returns the mount point of zip package. This location is used to
+ * mount package.
+ *
+ * @param pkg_path package path for which zip mount location is being obtained
+ *
+ * @return full path of package mount point
+ */
+boost::filesystem::path GetMountLocation(
+ const boost::filesystem::path& pkg_path);
+
+/**
+ * @brief GetExternalCardPath
+ * Returns full path to mounted filesystem of sd card
+ *
+ * @return path
+ */
+boost::filesystem::path GetExternalCardPath();
+
+/**
+ * @brief GetExternalTepPath
+ * Returns external installation location for tep package
+ * @param request_mode request type
+ * @param uid user id of request
+ *
+ * @return full directory path
+ */
+boost::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
+
+/**
+ * @brief GetInternalTepPath
+ * Returns internal installation location for tep package
+ * @param pkg_path path of installation request
+ *
+ * @return full directory path
+ */
+boost::filesystem::path GetInternalTepPath(
+ const boost::filesystem::path& pkg_path);
+
+/**
+ * @brief GetIconPath
+ * Returns internal location for preinstalled global app icon
+ * @param base_path path of icon in application
+ * @param pkgid package id
+ * @param icon_filename filename of icon
+ * @param root_path root path of application
+ *
+ * @return full icon path
+ */
+boost::filesystem::path GetIconPath(const boost::filesystem::path& base_path,
+ const std::string& pkgid,
+ const boost::filesystem::path& icon_filename,
+ const boost::filesystem::path& root_path);
+
+/**
+ * @brief IsExtendedStorageAvailable
+ * Returns true if the extended storage is available
+ *
+ * @return true is the extended storage is available, otherwise false
+ */
+bool IsExtendedStorageAvailable();
+
+} // namespace common_installer
+
+#endif // COMMON_UTILS_PATHS_H_
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/utils/pkgmgr_query.h"
+
+#include <sys/types.h>
+#include <manifest_parser/utils/logging.h>
+#include <pkgmgr_installer.h>
+#include <pkgmgr_parser.h>
+#include <tzplatform_config.h>
+
+#include <cstring>
+#include <utility>
+
+namespace ci = common_installer;
+
+namespace {
+
+const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
+int PkgmgrForeachPluginCallback(const char* pkgid, const char* appid,
+ const char* plugin_type, const char* plugin_name, void* user_data) {
+ auto* data_list =
+ static_cast<std::vector<ci::PkgQueryInterface::PluginInfo>*>(user_data);
+ data_list->emplace_back(pkgid, appid ? appid : "", plugin_type, plugin_name);
+ return PMINFO_R_OK;
+}
+
+} // namespace
+
+namespace common_installer {
+
+std::shared_ptr<PkgHandle> PkgQueryInterface::PkgQuery::GetResult(
+ const std::string& pkgid, uid_t uid, bool refresh) {
+ const auto& it = query_results_.find(std::make_pair(pkgid, uid));
+ if (it != query_results_.end()) {
+ if (refresh)
+ query_results_.erase(it);
+ else
+ return it->second;
+ }
+
+ pkgmgrinfo_pkginfo_h handle;
+ int error_ = pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid.c_str(), uid,
+ &handle);
+ if (error_ != PMINFO_R_OK) {
+ if (error_ != PMINFO_R_ENOENT)
+ LOG(ERROR) << "Failed to call pkgmgrinfo_pkginfo_get_usr_pkginfo";
+ return nullptr;
+ }
+ auto res = query_results_.emplace(std::make_pair(pkgid, uid),
+ std::make_shared<PkgHandle>(handle));
+ return res.first->second;
+}
+
+PkgQueryInterface::PkgQueryInterface(const std::string& pkgid, uid_t uid,
+ bool refresh)
+ : error_(0), pkgid_(pkgid), uid_(uid) {
+ handle_ = PkgQuery::Instance().GetResult(pkgid_, uid, refresh);
+}
+
+PkgQueryInterface::~PkgQueryInterface() {
+}
+
+bool PkgQueryInterface::IsValid() {
+ return handle_ != nullptr;
+}
+
+int PkgQueryInterface::GetLastOperationError() {
+ return error_;
+}
+
+std::string PkgQueryInterface::Version() {
+ if (!IsValid())
+ return {};
+ char* version = nullptr;
+ error_ = pkgmgrinfo_pkginfo_get_version(handle_->handle, &version);
+ if (error_ != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_version failed with error: "
+ << error_;
+ return {};
+ }
+ std::string version_value;
+ if (version)
+ version_value = version;
+ return version_value;
+}
+
+std::string PkgQueryInterface::TepPath() {
+ if (!IsValid())
+ return {};
+ char* tep_name = nullptr;
+ error_ = pkgmgrinfo_pkginfo_get_tep_name(handle_->handle, &tep_name);
+ if (error_ != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_tep_name failed with error: "
+ << error_;
+ return {};
+ }
+ std::string tep_name_value;
+ if (tep_name)
+ tep_name_value = tep_name;
+ return tep_name_value;
+}
+
+std::string PkgQueryInterface::ZipMountFile() {
+ if (!IsValid())
+ return {};
+ char* zip_mount_file = nullptr;
+ error_ = pkgmgrinfo_pkginfo_get_zip_mount_file(handle_->handle,
+ &zip_mount_file);
+ if (error_ != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_zip_mount_file failed with error: "
+ << error_;
+ return {};
+ }
+ std::string zip_mount_file_value;
+ if (zip_mount_file)
+ zip_mount_file_value = zip_mount_file;
+ return zip_mount_file_value;
+}
+
+std::string PkgQueryInterface::StorageForPkgId() {
+ if (!IsValid())
+ return {};
+ // initial & default : internal
+ std::string installed_location = "installed_internal";
+
+ pkgmgrinfo_installed_storage storage;
+ error_ = pkgmgrinfo_pkginfo_get_installed_storage(handle_->handle, &storage);
+
+ if (error_ != PMINFO_R_OK)
+ return "";
+
+ if (storage == PMINFO_EXTERNAL_STORAGE)
+ installed_location = "installed_external";
+ else if (storage == PMINFO_EXTENDED_STORAGE)
+ installed_location = "installed_extended";
+
+ return installed_location;
+}
+
+std::string PkgQueryInterface::Type() {
+ if (!IsValid())
+ return {};
+ char* type = nullptr;
+ error_ = pkgmgrinfo_pkginfo_get_type(handle_->handle, &type);
+ if (error_ != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_type failed with error: "
+ << error_;
+ return {};
+ }
+ std::string type_value;
+ if (type)
+ type_value = type;
+ return type_value;
+}
+
+bool PkgQueryInterface::IsPackageInstalled() {
+ if (!IsValid())
+ return false;
+ bool is_global = false;
+ if (pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global) !=
+ PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
+ return false;
+ }
+
+ if (uid_ == kGlobalUserUid && is_global)
+ return true;
+ if (uid_ != kGlobalUserUid && is_global)
+ return false;
+ return true;
+}
+
+bool PkgQueryInterface::IsPackageInstalled(RequestMode mode) {
+ if (!IsValid())
+ return false;
+ bool is_global = false;
+ error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
+ return false;
+ }
+
+ if (mode == RequestMode::GLOBAL && !is_global)
+ return false;
+ if (mode == RequestMode::USER && is_global)
+ return false;
+
+ return true;
+}
+
+bool PkgQueryInterface::IsGlobalPackage() {
+ if (!IsValid())
+ return false;
+ bool is_global = false;
+ error_ = pkgmgrinfo_pkginfo_is_for_all_users(handle_->handle, &is_global);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_for_all_users failed";
+ return false;
+ }
+ return is_global;
+}
+
+bool PkgQueryInterface::IsReadonlyPackage() {
+ if (!IsValid())
+ return false;
+ bool is_readonly = false;
+ error_ = pkgmgrinfo_pkginfo_is_readonly(handle_->handle, &is_readonly);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_readonly failed";
+ return false;
+ }
+ return is_readonly;
+}
+
+bool PkgQueryInterface::IsUpdatedPackage() {
+ if (!IsValid())
+ return false;
+ bool is_update = false;
+ error_ = pkgmgrinfo_pkginfo_is_update(handle_->handle, &is_update);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_update failed";
+ return false;
+ }
+ return is_update;
+}
+
+bool PkgQueryInterface::IsPreloadPackage() {
+ if (!IsValid())
+ return false;
+ bool is_preload = false;
+ error_ = pkgmgrinfo_pkginfo_is_preload(handle_->handle, &is_preload);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_preload failed";
+ return false;
+ }
+ return is_preload;
+}
+
+bool PkgQueryInterface::IsSystemPackage() {
+ if (!IsValid())
+ return false;
+ bool is_system = false;
+ error_ = pkgmgrinfo_pkginfo_is_system(handle_->handle, &is_system);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_system failed";
+ return false;
+ }
+ return is_system;
+}
+
+bool PkgQueryInterface::IsRemovablePackage() {
+ if (!IsValid())
+ return false;
+ bool is_removable = false;
+ error_ = pkgmgrinfo_pkginfo_is_removable(handle_->handle, &is_removable);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "pkgmgrinfo_pkginfo_is_removable failed";
+ return false;
+ }
+ return is_removable;
+}
+
+bool PkgQueryInterface::AppidsForPkgId(std::vector<std::string>* result) {
+ if (!IsValid())
+ return false;
+ error_ = pkgmgrinfo_appinfo_get_usr_list(handle_->handle, PMINFO_ALL_APP,
+ [](const pkgmgrinfo_appinfo_h handle, void* user_data) -> int {
+ auto* data = static_cast<std::vector<std::string>*>(user_data);
+ char* app_id = nullptr;
+ if (pkgmgrinfo_appinfo_get_appid(handle, &app_id) != PMINFO_R_OK)
+ return PMINFO_R_ERROR;
+ data->emplace_back(app_id);
+ return PMINFO_R_OK;
+ },
+ result, uid_);
+ return error_ == PMINFO_R_OK;
+}
+
+bool PkgQueryInterface::PrivilegesForPkgId(std::vector<std::string>* result) {
+ if (!IsValid())
+ return false;
+ error_ = pkgmgrinfo_pkginfo_foreach_privilege(handle_->handle,
+ [](const char* privilege_name, void* user_data) -> int {
+ auto* data = static_cast<std::vector<std::string>*>(user_data);
+ data->emplace_back(privilege_name);
+ return PMINFO_R_OK;
+ },
+ result);
+ return error_ == PMINFO_R_OK;
+}
+
+bool PkgQueryInterface::PackagesDependsOn(
+ std::vector<DependencyInfo>* result) {
+ if (!IsValid())
+ return false;
+ error_ = pkgmgrinfo_pkginfo_foreach_depends_on(handle_->handle,
+ [](const char* from, const char* to, const char* type,
+ const char* version, void* user_data) -> int {
+ auto* data =
+ static_cast<std::vector<ci::PkgQueryInterface::DependencyInfo>*>(
+ user_data);
+ data->emplace_back(from, to, type, version ? version : "");
+ return PMINFO_R_OK;
+ },
+ result);
+ return error_ == PMINFO_R_OK;
+}
+
+bool PkgQueryInterface::IsPluginExecuted(const std::string& plugin_type,
+ const std::string& plugin_name) {
+ if (!IsValid())
+ return false;
+ std::vector<PluginInfo> plugin_list;
+ error_ = pkgmgrinfo_pkginfo_foreach_plugin(handle_->handle,
+ &PkgmgrForeachPluginCallback, &plugin_list);
+ if (error_ != PMINFO_R_OK) {
+ LOG(ERROR) << "Failed to get plugin info";
+ return false;
+ }
+
+ for (const auto& plugin : plugin_list) {
+ if (plugin_type.compare(std::get<2>(plugin)) == 0 &&
+ plugin_name.compare(std::get<3>(plugin)) == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool PkgQueryInterface::PluginExecutionInfo(
+ std::vector<PluginInfo>* plugin_list) {
+ if (!IsValid())
+ return false;
+
+ error_ = pkgmgrinfo_pkginfo_foreach_plugin(handle_->handle,
+ &PkgmgrForeachPluginCallback, plugin_list);
+ return error_ == PMINFO_R_OK;
+}
+
+std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
+ uid_t uid) {
+ pkgmgrinfo_certinfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
+ if (ret != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_create_certinfo failed with error: "
+ << ret;
+ return {};
+ }
+ ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid.c_str(), handle, uid);
+ if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_ENOENT)
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_load_certinfo failed with error: "
+ << ret;
+ pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ return {};
+ }
+ const char* author_cert = nullptr;
+ ret = pkgmgrinfo_pkginfo_get_cert_value(handle, PMINFO_AUTHOR_SIGNER_CERT,
+ &author_cert);
+ if (ret != PMINFO_R_OK) {
+ LOG(DEBUG) << "pkgmgrinfo_pkginfo_get_cert_value failed with error: "
+ << ret;
+ pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ return {};
+ }
+ std::string old_author_certificate;
+ if (author_cert)
+ old_author_certificate = author_cert;
+ pkgmgrinfo_pkginfo_destroy_certinfo(handle);
+ return old_author_certificate;
+}
+
+bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid) {
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkg_id.c_str(),
+ uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ if (ret != PMINFO_R_ENOENT)
+ LOG(ERROR) <<
+ "Failed to call pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo";
+ return false;
+ }
+
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return true;
+}
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_UTILS_PKGMGR_QUERY_H_
+#define COMMON_UTILS_PKGMGR_QUERY_H_
+
+#include <unistd.h>
+#include <pkgmgr-info.h>
+#include <sys/types.h>
+
+#include <map>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
+
+#include "common/utils/singleton.h"
+#include "common/utils/request.h"
+
+namespace common_installer {
+
+struct PkgHandle {
+ pkgmgrinfo_pkginfo_h handle;
+ explicit PkgHandle(pkgmgrinfo_pkginfo_h pkginfo_handle) {
+ handle = pkginfo_handle;
+ }
+ ~PkgHandle() {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ }
+};
+
+/**
+ * \brief Adapter interface for external PkgMgr module.
+ */
+class PkgQueryInterface {
+ public:
+ using PluginInfo =
+ std::tuple<std::string, std::string, std::string, std::string>;
+ using DependencyInfo =
+ std::tuple<std::string, std::string, std::string, std::string>;
+ PkgQueryInterface(const std::string& pkgid, uid_t uid, bool refresh = false);
+ ~PkgQueryInterface();
+
+ bool IsValid();
+ int GetLastOperationError();
+
+ /**
+ * \brief Returns package version for given package.
+ *
+ * @return version or empty
+ */
+ std::string Version();
+
+ /**
+ * \brief Returns tizen extension package path for given package.
+ *
+ * @return path or empty
+ */
+ std::string TepPath();
+
+ /**
+ * \brief Returns zip mount path for given package.
+ *
+ * @return path or empty
+ */
+ std::string ZipMountFile();
+
+ /**
+ * \brief Returns storage for given package.
+ *
+ * @return path or empty
+ */
+ std::string StorageForPkgId();
+
+ /**
+ * \brief Returns type for given package.
+ *
+ * @return type or empty
+ */
+ std::string Type();
+
+ /**
+ * \brief Checks if given package is installed/registered.
+ *
+ * \return true if package is installed
+ */
+ bool IsPackageInstalled();
+
+ /**
+ * \brief Checks if given package is installed/registered as request mode.
+ *
+ * \param mode request mode
+ *
+ * \return true if package is installed
+ */
+ bool IsPackageInstalled(RequestMode mode);
+
+ /**
+ * \brief Checks if given package is global package.
+ *
+ * \return true if package is global package
+ */
+ bool IsGlobalPackage();
+
+ /**
+ * \brief Checks if given package is readonly package.
+ *
+ * \return true if package is readonly
+ */
+ bool IsReadonlyPackage();
+
+ /**
+ * \brief Checks if given package is updated package.
+ *
+ * \return true if package is updated
+ */
+ bool IsUpdatedPackage();
+
+ /**
+ * \brief Checks if given package is preloaded package.
+ *
+ * \return true if package is preloaded
+ */
+ bool IsPreloadPackage();
+
+ /**
+ * \brief Checks if given package is system package.
+ *
+ * \return true if package is system package
+ */
+ bool IsSystemPackage();
+
+ /**
+ * \brief Checks if given package is removable package.
+ *
+ * \return true if package is removable package
+ */
+ bool IsRemovablePackage();
+
+ /**
+ * \brief Returns list of appids for given package.
+ *
+ * \param result[out] Output
+ *
+ * \return true if success
+ */
+ bool AppidsForPkgId(std::vector<std::string>* result);
+ /**
+ * \brief Returns list of privileges for given package
+ *
+ * \param result result - privileges
+ *
+ * \return true if success
+ */
+ bool PrivilegesForPkgId(std::vector<std::string>* result);
+
+ /**
+ * \brief Returns whether plugin has executed for given package
+ *
+ * \param plugin_type plugin type
+ * \param plugin_name plugin name
+ *
+ * \return true if success
+ */
+ bool IsPluginExecuted(const std::string& plugin_type,
+ const std::string& plugin_name);
+
+ /**
+ * \brief Returns list of plugins executed with given package
+ *
+ * \param plugin_list[out] plugin list
+ *
+ * \return true if success
+ */
+ bool PluginExecutionInfo(std::vector<PluginInfo>* plugin_list);
+
+
+ /**
+ * \brief Returns list of packages depends on given package
+ *
+ * \param result[out] Output
+ *
+ * \return true if success
+ */
+ bool PackagesDependsOn(std::vector<DependencyInfo>* result);
+
+ private:
+ class PkgQuery : public Singleton<PkgQuery> {
+ CRTP_DECLARE_DEFAULT_CONSTRUCTOR_CLASS(PkgQuery)
+ public:
+ std::shared_ptr<PkgHandle> GetResult(const std::string& pkgid, uid_t uid,
+ bool refresh);
+
+ private:
+ std::map<std::pair<std::string, uid_t>, std::shared_ptr<PkgHandle>>
+ query_results_;
+ };
+
+ int error_;
+ std::string pkgid_;
+ uid_t uid_;
+ std::shared_ptr<PkgHandle> handle_;
+};
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for getting
+ * certificate information for given package
+ *
+ * \param pkgid package pkgid
+ * \param uid user id
+ *
+ * \return returns certificate information
+ */
+std::string QueryCertificateAuthorCertificate(const std::string& pkgid,
+ uid_t uid);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for checking
+ * if given package is disabled package
+ *
+ * \param pkg_id package id
+ * \param uid user id
+ *
+ * \return true if package is disable.
+ */
+bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid);
+
+} // namespace common_installer
+
+#endif // COMMON_UTILS_PKGMGR_QUERY_H_
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/utils/request.h"
+
+#include <tzplatform_config.h>
+#include <unistd.h>
+
+#include <map>
+#include <string>
+
+#include "common/utils/user_util.h"
+
+namespace bf = boost::filesystem;
+
+namespace common_installer {
+
+const std::map<RequestType, const char*> kRequestTypeStringMap = {
+ {RequestType::Unknown, "Unknown"},
+ {RequestType::Install, "Install"},
+ {RequestType::Update, "Update"},
+ {RequestType::Uninstall, "Uninstall"},
+ {RequestType::Reinstall, "Reinstall"},
+ {RequestType::Delta, "Delta"},
+ {RequestType::Move, "Move"},
+ {RequestType::Recovery, "Recovery"},
+ {RequestType::RecoveryUpdate, "RecoveryUpdate"},
+ {RequestType::MountInstall, "MountInstall"},
+ {RequestType::MountUpdate, "MountUpdate"},
+ {RequestType::ManifestDirectInstall, "ManifestDirectInstall"},
+ {RequestType::ManifestDirectUpdate, "ManifestDirectUpdate"},
+ {RequestType::ManifestPartialInstall, "ManifestPartialInstall"},
+ {RequestType::ManifestPartialUpdate, "ManifestPartialUpdate"},
+ {RequestType::PartialUninstall, "PartialUninstall"},
+ {RequestType::ReadonlyUpdateInstall, "ReadonlyUpdateInstall"},
+ {RequestType::ReadonlyUpdateUninstall, "ReadonlyUpdateUninstall"},
+ {RequestType::DisablePkg, "DisablePkg"},
+ {RequestType::EnablePkg, "EnablePkg"},
+ {RequestType::MigrateExtImg, "MigrateExtImg"},
+ {RequestType::RecoverDB, "RecoverDB"},
+};
+
+std::string GetRequestTypeString(RequestType request_type) {
+ const auto& it = kRequestTypeStringMap.find(request_type);
+ if (it == kRequestTypeStringMap.end())
+ return "Unknown";
+ else
+ return it->second;
+}
+
+RequestMode GetRequestMode(uid_t uid) {
+ return (uid == tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) ?
+ RequestMode::GLOBAL : RequestMode::USER;
+}
+
+// Now, readonly app is always installed RO location.
+const char* GetRootAppPath(bool is_readonly, uid_t uid) {
+ if (GetRequestMode(uid) == RequestMode::GLOBAL) {
+ return is_readonly ?
+ tzplatform_getenv(TZ_SYS_RO_APP) : tzplatform_getenv(TZ_SYS_RW_APP);
+ } else {
+ tzplatform_set_user(uid);
+ const char* rootpath = tzplatform_getenv(TZ_USER_APP);
+ tzplatform_reset_user();
+ return rootpath;
+ }
+}
+
+const char* GetExtendedRootAppPath(uid_t uid) {
+ if (GetRequestMode(uid) == RequestMode::GLOBAL) {
+ return tzplatform_getenv(TZ_SYS_EXTENDEDSD_APP);
+ } else {
+ tzplatform_set_user(uid);
+ const char* rootpath = tzplatform_getenv(TZ_USER_EXTENDEDSD_APP);
+ tzplatform_reset_user();
+ return rootpath;
+ }
+}
+
+} // namespace common_installer
--- /dev/null
+// Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_UTILS_REQUEST_H_
+#define COMMON_UTILS_REQUEST_H_
+
+#include <boost/filesystem/path.hpp>
+
+#include <string>
+
+namespace common_installer {
+
+/** Request type received from pkgmgr_installer */
+enum class RequestType : int {
+ Unknown = 0,
+ Install,
+ Update,
+ Uninstall,
+ Reinstall,
+ Delta,
+ Move,
+ Recovery,
+ RecoveryUpdate,
+ MountInstall,
+ MountUpdate,
+ ManifestDirectInstall,
+ ManifestDirectUpdate,
+ ManifestPartialInstall,
+ ManifestPartialUpdate,
+ PartialUninstall,
+ ReadonlyUpdateInstall,
+ ReadonlyUpdateUninstall,
+ DisablePkg,
+ EnablePkg,
+ MigrateExtImg,
+ RecoverDB
+};
+
+/** Request mode (USER vs GLOBAL) */
+enum class RequestMode : int {
+ USER,
+ GLOBAL
+};
+
+/**
+ * Get string of given request type
+ *
+ * \return request mode
+ */
+std::string GetRequestTypeString(RequestType request_type);
+
+/**
+ * Get mode for current request (GLOBAL/USER)
+ *
+ * \return request mode
+ */
+RequestMode GetRequestMode(uid_t uid);
+
+/**
+ * Get apps root path for current request (GLOBAL/USER)
+ *
+ * \return root application path (eg. $HOME/apps_rw/)
+ */
+const char* GetRootAppPath(bool is_readonly, uid_t uid);
+
+/**
+ * Get appt root path at exteded storage for current request (GLOBAL/USER)
+ *
+ * \return root application path at extended path
+ * (eg. $TZ_SYS_MEDIA/extended/globalapps)
+ */
+const char* GetExtendedRootAppPath(uid_t uid);
+
+} // namespace common_installer
+
+#endif // COMMON_UTILS_REQUEST_H_
#include <boost/filesystem/path.hpp>
#include <glib.h>
-#include <common/request.h>
#include <common/utils/file_util.h>
+#include <common/utils/request.h>
#include <common/utils/subprocess.h>
#include <common/utils/user_util.h>
#include <manifest_parser/utils/logging.h>
#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
-#include <common/app_installer.h>
-#include <common/paths.h>
+#include <common/installer/app_installer.h>
+#include <common/utils/paths.h>
#include <common/pkgmgr_interface.h>
-#include <common/pkgmgr_query.h>
+#include <common/utils/pkgmgr_query.h>
#include <common/tzip_interface.h>
#include <list>
#include <common/utils/subprocess.h>
#include <common/utils/user_util.h>
#include <common/utils/file_util.h>
-#include <common/request.h>
+#include <common/utils/request.h>
#include <common/tzip_interface.h>
-#include <common/app_installer.h>
-#include <common/paths.h>
-#include <common/pkgmgr_query.h>
+#include <common/installer/app_installer.h>
+#include <common/utils/paths.h>
+#include <common/utils/pkgmgr_query.h>
#include <common/recovery_file.h>
#include <array>