SET(SRCS
- tpk_mount_path.cc
+ external_dirs.cc
step/configuration/step_parse_preload.cc
step/filesystem/step_check_pkg_directory_path.cc
+ step/filesystem/step_create_external_storage_directories.cc
step/filesystem/step_create_symbolic_link.cc
step/filesystem/step_grant_permission.cc
+ step/filesystem/step_remove_external_storage_directories.cc
step/filesystem/step_tpk_patch_icons.cc
step/filesystem/step_tpk_prepare_package_directory.cc
step/filesystem/step_tpk_update_package_directory.cc
+ step/filesystem/step_update_external_storage_directories.cc
step/pkgmgr/step_convert_xml.cc
step/pkgmgr/step_manifest_adjustment.cc
step/rds/step_tpk_rds_modify.cc
step/security/step_check_tpk_background_category.cc
tpk_app_query_interface.cc
+ tpk_mount_path.cc
tpk_installer.cc
)
ADD_LIBRARY(${TARGET_LIBNAME_TPK} SHARED ${SRCS})
--- /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 "tpk/external_dirs.h"
+
+#include <common/pkgdir_tool_request.h>
+#include <common/privileges.h>
+#include <common/pkgmgr_registration.h>
+#include <common/shared_dirs.h>
+#include <common/utils/glist_range.h>
+#include <manifest_parser/utils/logging.h>
+
+#include <algorithm>
+
+namespace ci = common_installer;
+
+namespace tpk {
+
+bool HasExternalAppdataPrivilege(manifest_x* manifest) {
+ auto privileges = GListRange<char*>(manifest->privileges);
+ return std::find(privileges.begin(), privileges.end(),
+ std::string(common::privileges::kPrivForExternalAppData))
+ != privileges.end();
+}
+
+bool CreateExternalAppdataDirectories(const std::string& pkgid,
+ ci::RequestMode request_mode, uid_t uid) {
+ switch (request_mode) {
+ case ci::RequestMode::GLOBAL: {
+ LOG(DEBUG) << "Creating external directories for all users";
+ ci::RequestCreateExternalDirectories(pkgid);
+ break;
+ }
+ case ci::RequestMode::USER: {
+ LOG(DEBUG) << "Creating external directories for user: " << uid;
+ ci::PerformExternalDirectoryCreationForUser(uid, pkgid);
+ break;
+ }
+ }
+ return true;
+}
+
+bool DeleteExternalAppdataDirectories(const std::string& pkgid,
+ ci::RequestMode request_mode, uid_t uid) {
+ switch (request_mode) {
+ case ci::RequestMode::GLOBAL: {
+ LOG(DEBUG) << "Removing external directories for all users";
+ ci::RequestDeleteExternalDirectories(pkgid);
+ break;
+ }
+ case ci::RequestMode::USER: {
+ // if package is globally installed, leave directories
+ if (ci::IsPackageInstalled(pkgid, GLOBAL_USER))
+ return true;
+
+ LOG(DEBUG) << "Removing external directories for user: " << uid;
+ ci::PerformExternalDirectoryDeletionForUser(uid, pkgid);
+ break;
+ }
+ }
+ return true;
+}
+
+} // namespace tpk
--- /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 TPK_EXTERNAL_DIRS_H_
+#define TPK_EXTERNAL_DIRS_H_
+
+#include <common/request.h>
+#include <pkgmgrinfo_basic.h>
+
+#include <string>
+
+namespace tpk {
+
+/**
+ * @brief HasExternalAppdataPrivilege
+ * Defines conditions upon which package has privilege to create external
+ * appdata directories
+ *
+ * @return true if package has privilege to directories
+ */
+bool HasExternalAppdataPrivilege(manifest_x* manifest);
+
+/**
+ * @brief CreateExternalAppdataDirectories
+ * Creates external appdata directories according to installation
+ * context's uid and request mode
+ *
+ * @param pkgid package id
+ * @param request_mode request mode - user or global
+ * @param uid user id
+ *
+ * @return true if operation succeeded
+ */
+bool CreateExternalAppdataDirectories(const std::string& pkgid,
+ common_installer::RequestMode request_mode, uid_t uid);
+
+/**
+ * @brief RemoveExternalAppdataDirectories
+ * Removes external appdata directories according to installation
+ * context's uid and request mode
+ *
+ * @param pkgid package id
+ * @param request_mode request mode - user or global
+ * @param uid user id
+ *
+ * @return true if operation succeeded
+ */
+bool DeleteExternalAppdataDirectories(const std::string& pkgid,
+ common_installer::RequestMode request_mode, uid_t uid);
+
+} // namespace tpk
+
+#endif // TPK_EXTERNAL_DIRS_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 "tpk/step/filesystem/step_create_external_storage_directories.h"
+
+#include <common/privileges.h>
+#include <common/shared_dirs.h>
+#include <common/utils/glist_range.h>
+
+#include <string>
+#include <vector>
+
+#include "tpk/external_dirs.h"
+
+namespace ci = common_installer;
+
+namespace tpk {
+namespace filesystem {
+
+ci::Step::Status StepCreateExternalStorageDirectories::process() {
+ if (!HasExternalAppdataPrivilege(context_->manifest_data.get())) {
+ LOG(DEBUG) << "External storage privilege not found, skipping.";
+ return Status::OK;
+ } else {
+ if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
+ context_->request_mode.get(),
+ context_->uid.get()))
+ return Status::APP_DIR_ERROR;
+ }
+ return Status::OK;
+}
+
+ci::Step::Status StepCreateExternalStorageDirectories::precheck() {
+ if (!context_->manifest_data.get()) {
+ LOG(ERROR) << "Manifest data not set";
+ return Status::INVALID_VALUE;
+ }
+ return Status::OK;
+}
+
+} // namespace filesystem
+} // namespace tpk
--- /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 TPK_STEP_FILESYSTEM_STEP_CREATE_EXTERNAL_STORAGE_DIRECTORIES_H_
+#define TPK_STEP_FILESYSTEM_STEP_CREATE_EXTERNAL_STORAGE_DIRECTORIES_H_
+
+#include <common/installer_context.h>
+#include <common/step/step.h>
+#include <manifest_parser/utils/logging.h>
+
+namespace tpk {
+namespace filesystem {
+
+class StepCreateExternalStorageDirectories : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ STEP_NAME(CreateExternalStorageDirectories)
+};
+
+} // namespace filesystem
+} // namespace tpk
+
+#endif // TPK_STEP_FILESYSTEM_STEP_CREATE_EXTERNAL_STORAGE_DIRECTORIES_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 "tpk/step/filesystem/step_remove_external_storage_directories.h"
+
+#include "tpk/external_dirs.h"
+
+namespace ci = common_installer;
+
+namespace tpk {
+namespace filesystem {
+
+ci::Step::Status StepRemoveExternalStorageDirectories::process() {
+ if (!DeleteExternalAppdataDirectories(context_->pkgid.get(),
+ context_->request_mode.get(),
+ context_->uid.get()))
+ return Status::APP_DIR_ERROR;
+ return Status::OK;
+}
+
+} // namespace filesystem
+} // namespace tpk
--- /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 TPK_STEP_FILESYSTEM_STEP_REMOVE_EXTERNAL_STORAGE_DIRECTORIES_H_
+#define TPK_STEP_FILESYSTEM_STEP_REMOVE_EXTERNAL_STORAGE_DIRECTORIES_H_
+
+#include <common/installer_context.h>
+#include <common/step/step.h>
+#include <manifest_parser/utils/logging.h>
+
+namespace tpk {
+namespace filesystem {
+
+class StepRemoveExternalStorageDirectories : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ STEP_NAME(RemoveExternalStorageDirectories)
+};
+
+} // namespace filesystem
+} // namespace tpk
+
+#endif // TPK_STEP_FILESYSTEM_STEP_REMOVE_EXTERNAL_STORAGE_DIRECTORIES_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 "tpk/step/filesystem/step_update_external_storage_directories.h"
+
+#include "tpk/external_dirs.h"
+
+namespace ci = common_installer;
+
+namespace tpk {
+namespace filesystem {
+
+ci::Step::Status StepUpdateExternalStorageDirectories::process() {
+ if (!HasExternalAppdataPrivilege(context_->manifest_data.get())) {
+ if (!DeleteExternalAppdataDirectories(context_->pkgid.get(),
+ context_->request_mode.get(),
+ context_->uid.get()))
+ return Status::APP_DIR_ERROR;
+ } else {
+ if (!CreateExternalAppdataDirectories(context_->pkgid.get(),
+ context_->request_mode.get(),
+ context_->uid.get()))
+ return Status::APP_DIR_ERROR;
+ }
+ return Status::OK;
+}
+
+ci::Step::Status StepUpdateExternalStorageDirectories::precheck() {
+ if (!context_->manifest_data.get()) {
+ LOG(ERROR) << "Manifest data not set";
+ return Status::INVALID_VALUE;
+ }
+ return Status::OK;
+}
+
+} // namespace filesystem
+} // namespace tpk
--- /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 TPK_STEP_FILESYSTEM_STEP_UPDATE_EXTERNAL_STORAGE_DIRECTORIES_H_
+#define TPK_STEP_FILESYSTEM_STEP_UPDATE_EXTERNAL_STORAGE_DIRECTORIES_H_
+
+#include <common/installer_context.h>
+#include <common/step/step.h>
+#include <manifest_parser/utils/logging.h>
+
+namespace tpk {
+namespace filesystem {
+
+class StepUpdateExternalStorageDirectories : public common_installer::Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override;
+
+ STEP_NAME(UpdateExternalStorageDirectories)
+};
+
+} // namespace filesystem
+} // namespace tpk
+
+#endif // TPK_STEP_FILESYSTEM_STEP_UPDATE_EXTERNAL_STORAGE_DIRECTORIES_H_
#include <common/step/security/step_update_security.h>
#include "tpk/step/configuration/step_parse_preload.h"
+#include "tpk/step/filesystem/step_create_external_storage_directories.h"
#include "tpk/step/filesystem/step_create_symbolic_link.h"
#include "tpk/step/filesystem/step_check_pkg_directory_path.h"
#include "tpk/step/filesystem/step_grant_permission.h"
+#include "tpk/step/filesystem/step_remove_external_storage_directories.h"
#include "tpk/step/filesystem/step_tpk_patch_icons.h"
#include "tpk/step/filesystem/step_tpk_prepare_package_directory.h"
#include "tpk/step/filesystem/step_tpk_update_package_directory.h"
+#include "tpk/step/filesystem/step_update_external_storage_directories.h"
#include "tpk/step/pkgmgr/step_convert_xml.h"
#include "tpk/step/pkgmgr/step_manifest_adjustment.h"
#include "tpk/step/rds/step_tpk_rds_modify.h"
AddStep<ci::filesystem::StepCopy>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<tpk::filesystem::StepCreateExternalStorageDirectories>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::pkgmgr::StepUpdateTep>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
+ AddStep<tpk::filesystem::StepUpdateExternalStorageDirectories>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<ci::pkgmgr::StepKillApps>();
AddStep<ci::filesystem::StepAcquireExternalStorage>();
AddStep<ci::filesystem::StepRemovePerUserStorageDirectories>();
+ AddStep<tpk::filesystem::StepRemoveExternalStorageDirectories>();
AddStep<ci::pkgmgr::StepUnregisterApplication>();
AddStep<ci::security::StepRollbackDeinstallationSecurity>();
AddStep<ci::filesystem::StepRemoveFiles>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<ci::filesystem::StepCreateIcons>();
+ AddStep<tpk::filesystem::StepUpdateExternalStorageDirectories>();
AddStep<ci::security::StepUpdateSecurity>();
AddStep<tpk::pkgmgr::StepConvertXml>();
AddStep<tpk::filesystem::StepTpkGrantPermission>();
AddStep<ci::filesystem::StepAcquireExternalStorage>();
AddStep<ci::backup::StepCopyBackup>();
AddStep<ci::filesystem::StepCopyStorageDirectories>();
+ AddStep<tpk::filesystem::StepUpdateExternalStorageDirectories>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<tpk::filesystem::StepTpkPreparePackageDirectory>();
AddStep<ci::filesystem::StepCopyTep>();
AddStep<ci::filesystem::StepCreateStorageDirectories>();
+ AddStep<tpk::filesystem::StepCreateExternalStorageDirectories>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<ci::pkgmgr::StepUpdateTep>();
AddStep<tpk::filesystem::StepCreateSymbolicLink>();
AddStep<tpk::filesystem::StepTpkPatchIcons>();
+ AddStep<tpk::filesystem::StepUpdateExternalStorageDirectories>();
AddStep<ci::filesystem::StepCreateIcons>();
AddStep<ci::security::StepUpdateSecurity>();
AddStep<tpk::pkgmgr::StepConvertXml>();