summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--packaging/app-installers.spec1
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/app-installers.pc.in2
-rw-r--r--src/common/app_query_interface.cc21
-rw-r--r--src/common/app_query_interface.h6
-rw-r--r--src/common/certificate_validation.cc28
-rw-r--r--src/common/certificate_validation.h5
-rw-r--r--src/common/dependency_checker.cc14
-rw-r--r--src/common/external_mount.cc9
-rw-r--r--src/common/external_storage.cc22
-rw-r--r--src/common/external_storage.h18
-rw-r--r--src/common/feature_validator.cc9
-rw-r--r--src/common/global_recovery_file.cc40
-rw-r--r--src/common/global_recovery_file.h15
-rw-r--r--src/common/installer/app_installer.cc4
-rw-r--r--src/common/installer/app_installer.h28
-rw-r--r--src/common/installer_context.h21
-rw-r--r--src/common/mount_base.h4
-rw-r--r--src/common/pkgmgr_interface.cc27
-rw-r--r--src/common/pkgmgr_interface.h11
-rw-r--r--src/common/pkgmgr_registration.cc20
-rw-r--r--src/common/pkgmgr_registration.h8
-rw-r--r--src/common/plugins/plugin.h1
-rw-r--r--src/common/plugins/plugin_list_parser.cc25
-rw-r--r--src/common/plugins/plugin_list_parser.h13
-rw-r--r--src/common/plugins/plugin_manager.cc2
-rw-r--r--src/common/plugins/plugin_manager.h7
-rw-r--r--src/common/plugins/plugin_xml_parser.h7
-rw-r--r--src/common/recovery_file.cc36
-rw-r--r--src/common/recovery_file.h19
-rw-r--r--src/common/security_registration.cc37
-rw-r--r--src/common/security_registration.h9
-rw-r--r--src/common/shared_dirs.cc301
-rw-r--r--src/common/shared_dirs.h10
-rw-r--r--src/common/signature.cc51
-rw-r--r--src/common/signature.h25
-rw-r--r--src/common/step/backup/step_backup_icons.cc19
-rw-r--r--src/common/step/backup/step_backup_icons.h7
-rw-r--r--src/common/step/backup/step_backup_manifest.cc19
-rw-r--r--src/common/step/backup/step_copy_backup.cc95
-rw-r--r--src/common/step/backup/step_copy_backup.h12
-rw-r--r--src/common/step/configuration/step_block_cross_update.cc4
-rw-r--r--src/common/step/configuration/step_configure.cc28
-rw-r--r--src/common/step/configuration/step_parse_manifest.cc103
-rw-r--r--src/common/step/configuration/step_parse_manifest.h5
-rw-r--r--src/common/step/configuration/step_parse_preload.cc3
-rw-r--r--src/common/step/filesystem/step_change_ownership_and_permission.cc104
-rw-r--r--src/common/step/filesystem/step_copy.cc23
-rw-r--r--src/common/step/filesystem/step_copy_storage_directories.cc26
-rw-r--r--src/common/step/filesystem/step_copy_storage_directories.h10
-rw-r--r--src/common/step/filesystem/step_copy_tep.cc17
-rw-r--r--src/common/step/filesystem/step_create_icons.cc26
-rw-r--r--src/common/step/filesystem/step_create_icons.h5
-rw-r--r--src/common/step/filesystem/step_create_res_control_directories.cc13
-rw-r--r--src/common/step/filesystem/step_create_storage_directories.cc8
-rw-r--r--src/common/step/filesystem/step_delta_patch.cc85
-rw-r--r--src/common/step/filesystem/step_delta_patch.h3
-rw-r--r--src/common/step/filesystem/step_migrate_legacy_external_image.cc8
-rw-r--r--src/common/step/filesystem/step_move_installed_storage.cc40
-rw-r--r--src/common/step/filesystem/step_move_installed_storage.h10
-rw-r--r--src/common/step/filesystem/step_recover_external_storage.cc8
-rw-r--r--src/common/step/filesystem/step_recover_files.cc53
-rw-r--r--src/common/step/filesystem/step_recover_files.h6
-rw-r--r--src/common/step/filesystem/step_recover_globalapp_symlinks.cc2
-rw-r--r--src/common/step/filesystem/step_recover_icons.cc22
-rw-r--r--src/common/step/filesystem/step_recover_icons.h5
-rw-r--r--src/common/step/filesystem/step_recover_manifest.cc18
-rw-r--r--src/common/step/filesystem/step_recover_storage_directories.cc22
-rw-r--r--src/common/step/filesystem/step_recover_storage_directories.h6
-rw-r--r--src/common/step/filesystem/step_remove_files.cc31
-rw-r--r--src/common/step/filesystem/step_remove_icons.cc16
-rw-r--r--src/common/step/filesystem/step_remove_icons.h2
-rw-r--r--src/common/step/filesystem/step_remove_temporary_directory.cc16
-rw-r--r--src/common/step/filesystem/step_remove_temporary_directory.h6
-rw-r--r--src/common/step/filesystem/step_remove_tep.cc15
-rw-r--r--src/common/step/filesystem/step_remove_user_data.cc13
-rw-r--r--src/common/step/filesystem/step_remove_zip_image.cc11
-rw-r--r--src/common/step/filesystem/step_unzip.cc18
-rw-r--r--src/common/step/filesystem/step_unzip.h2
-rw-r--r--src/common/step/filesystem/step_update_storage_directories.cc16
-rw-r--r--src/common/step/filesystem/step_update_storage_directories.h2
-rw-r--r--src/common/step/filesystem/step_update_tep.cc21
-rw-r--r--src/common/step/filesystem/step_update_tep.h1
-rw-r--r--src/common/step/mount/step_check_mount_path.cc11
-rw-r--r--src/common/step/mount/step_mount_install.cc31
-rw-r--r--src/common/step/mount/step_mount_install.h4
-rw-r--r--src/common/step/mount/step_mount_recover.cc21
-rw-r--r--src/common/step/mount/step_mount_recover.h4
-rw-r--r--src/common/step/mount/step_mount_unpacked.cc16
-rw-r--r--src/common/step/mount/step_mount_unpacked.h4
-rw-r--r--src/common/step/mount/step_mount_update.cc43
-rw-r--r--src/common/step/mount/step_mount_update.h8
-rw-r--r--src/common/step/mount/step_unmount.cc9
-rw-r--r--src/common/step/mount/step_unmount.h4
-rw-r--r--src/common/step/pkgmgr/step_check_force_clean.cc9
-rw-r--r--src/common/step/pkgmgr/step_recover_application.cc8
-rw-r--r--src/common/step/pkgmgr/step_recover_parser_plugins.cc8
-rw-r--r--src/common/step/pkgmgr/step_recover_priv_sharedres.cc2
-rw-r--r--src/common/step/pkgmgr/step_register_app.cc4
-rw-r--r--src/common/step/pkgmgr/step_remove_manifest.cc13
-rw-r--r--src/common/step/pkgmgr/step_remove_priv_sharedres.cc10
-rw-r--r--src/common/step/pkgmgr/step_run_parser_plugins.cc5
-rw-r--r--src/common/step/pkgmgr/step_run_parser_plugins.h5
-rw-r--r--src/common/step/pkgmgr/step_unregister_app.cc5
-rw-r--r--src/common/step/pkgmgr/step_update_app.cc3
-rw-r--r--src/common/step/rds/step_rds_modify.cc91
-rw-r--r--src/common/step/rds/step_rds_modify.h15
-rw-r--r--src/common/step/rds/step_rds_parse.cc6
-rw-r--r--src/common/step/rds/step_rds_parse.h4
-rw-r--r--src/common/step/recovery/step_create_recovery_file.cc7
-rw-r--r--src/common/step/security/step_get_privilege_level.cc2
-rw-r--r--src/common/step/security/step_privacy_privilege.cc2
-rw-r--r--src/common/step/security/step_privilege_compatibility.cc32
-rw-r--r--src/common/step/security/step_recover_security.cc14
-rw-r--r--src/common/step/security/step_recover_signature.cc23
-rw-r--r--src/common/step/security/step_recover_signature.h5
-rw-r--r--src/common/step/security/step_recover_trust_anchor.h1
-rw-r--r--src/common/step/security/step_register_security.cc8
-rw-r--r--src/common/step/security/step_register_trust_anchor.cc34
-rw-r--r--src/common/step/security/step_revoke_security.cc3
-rw-r--r--src/common/step/security/step_revoke_trust_anchor.cc32
-rw-r--r--src/common/step/security/step_rollback_deinstallation_security.cc3
-rw-r--r--src/common/step/security/step_rollback_installation_security.cc1
-rw-r--r--src/common/step/security/step_signature.cc20
-rw-r--r--src/common/step/security/step_signature.h7
-rw-r--r--src/common/step/security/step_unregister_trust_anchor.cc9
-rw-r--r--src/common/step/security/step_update_security.cc6
-rw-r--r--src/common/step/step.h13
-rw-r--r--src/common/tzip_interface.cc31
-rw-r--r--src/common/tzip_interface.h7
-rw-r--r--src/common/utils/base64.cc56
-rw-r--r--src/common/utils/file_util.cc368
-rw-r--r--src/common/utils/file_util.h87
-rw-r--r--src/common/utils/manifest_util.cc10
-rw-r--r--src/common/utils/manifest_util.h7
-rw-r--r--src/common/utils/paths.cc67
-rw-r--r--src/common/utils/paths.h41
-rw-r--r--src/common/utils/request.cc2
-rw-r--r--src/common/utils/request.h2
-rw-r--r--src/common/utils/user_util.cc19
-rw-r--r--src/common/utils/user_util.h19
-rw-r--r--src/common/zip_interface.h4
-rw-r--r--src/pkg_initdb/CMakeLists.txt2
-rw-r--r--src/pkg_initdb/init_pkg_db.cc7
-rw-r--r--src/pkg_initdb/manifest_loader.cc12
-rw-r--r--src/pkg_initdb/manifest_loader.h4
-rw-r--r--src/pkg_initdb/option_checker.cc98
-rw-r--r--src/pkg_initdb/option_checker.h13
-rw-r--r--src/pkg_recovery/CMakeLists.txt1
-rw-r--r--src/pkg_recovery/pkg_recovery.cc44
-rw-r--r--test/smoke_tests/CMakeLists.txt2
-rw-r--r--test/smoke_tests/common/CMakeLists.txt1
-rw-r--r--test/smoke_tests/common/smoke_utils.cc632
-rw-r--r--test/smoke_tests/common/smoke_utils.h105
-rw-r--r--test/smoke_tests/libs/test_assessor.cc2
-rw-r--r--test/smoke_tests/libs/test_assessor.h7
-rw-r--r--test/smoke_tests/libs/test_category_fail_plugin.cc6
-rw-r--r--test/smoke_tests/libs/test_category_plugin.cc5
-rw-r--r--test/smoke_tests/libs/test_metadata_fail_plugin.cc13
-rw-r--r--test/smoke_tests/libs/test_metadata_plugin.cc5
-rw-r--r--test/smoke_tests/libs/test_tag_fail_plugin.cc8
-rw-r--r--test/smoke_tests/libs/test_tag_plugin.cc7
-rw-r--r--test/smoke_tests/plugins_smoketest.cc41
-rw-r--r--test/smoke_tests/signature_smoketest.cc9
165 files changed, 2046 insertions, 2115 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bb55297..1a916535 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,12 +15,12 @@ SET(EXTRA_FLAGS "-Wall -Wextra -Werror -Wnon-virtual-dtor -Wshadow")
SET(EXTRA_OPTIMIZATION_FLAGS "-Wl,--gc-sections -flto -fmerge-all-constants")
SET(CMAKE_C_FLAGS_PROFILING "-O2 ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++14 ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++17 ${EXTRA_FLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++14 -g ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++17 -g ${EXTRA_FLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "-Os ${EXTRA_OPTIMIZATION_FLAGS} ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_RELEASE "-Os -std=c++14 ${EXTRA_OPTIMIZATION_FLAGS} ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++14 -g --coverage ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_RELEASE "-Os -std=c++17 ${EXTRA_OPTIMIZATION_FLAGS} ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++17 -g --coverage ${EXTRA_FLAGS}")
# Linker flags
SET(EXTRA_LINKER_FLAGS "-Wl,--as-needed ${EXTRA_OPTIMIZATION_FLAGS} -fwhole-program")
@@ -67,7 +67,5 @@ PKG_CHECK_MODULES(TTRACE_DEPS REQUIRED ttrace)
PKG_CHECK_MODULES(TRUST_ANCHOR_DEPS REQUIRED tanchor)
PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock)
-FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem program_options iostreams)
-
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
diff --git a/packaging/app-installers.spec b/packaging/app-installers.spec
index 9b39f750..a68c5ffb 100644
--- a/packaging/app-installers.spec
+++ b/packaging/app-installers.spec
@@ -8,7 +8,6 @@ Source0: %{name}-%{version}.tar.gz
Source1000: app-installers.manifest
Source1001: app-installers-tests.manifest
-BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-parser)
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 2ad5f8bf..edf9cfd8 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -54,7 +54,6 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_COMMON} PUBLIC
LIBSYSTEMD_DEPS
TTRACE_DEPS
TRUST_ANCHOR_DEPS
- Boost
)
# Extra
diff --git a/src/common/app-installers.pc.in b/src/common/app-installers.pc.in
index 7dcd30e0..d98e9ecf 100644
--- a/src/common/app-installers.pc.in
+++ b/src/common/app-installers.pc.in
@@ -7,5 +7,5 @@ Name: app-installers
Description: Common library for pkgmgr backends
Version: @FULLVER@
Requires: pkgmgr pkgmgr-installer minizip zlib libtzplatform-config security-manager manifest-parser-utils delta-manifest-handlers cert-svc-vcore pkgmgr-parser pkgmgr-info libxml-2.0 security-privilege-manager app2sd
-Libs: -L${libdir} -lapp-installers -lboost_system
+Libs: -L${libdir} -lapp-installers
Cflags: -I${includedir}/app-installers/
diff --git a/src/common/app_query_interface.cc b/src/common/app_query_interface.cc
index 4f36950d..3523fcbb 100644
--- a/src/common/app_query_interface.cc
+++ b/src/common/app_query_interface.cc
@@ -2,21 +2,22 @@
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
+#include <filesystem>
+
#include "common/app_query_interface.h"
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
bool AppQueryInterface::IsPkgInstalled(const std::string& arg,
uid_t uid) const {
- bs::error_code ec;
+ std::error_code ec;
std::string pkg_id;
// argument from commandline is path to file
- if (bf::exists(arg, ec) && ec.value() == boost::system::errc::success)
+ if (fs::exists(arg, ec) && ec.value() == 0)
pkg_id = GetPkgIdFromPath(arg);
if (pkg_id.empty())
pkg_id = arg;
@@ -28,13 +29,13 @@ std::string AppQueryInterface::GetPkgId(const std::string& arg) const {
return GetPkgIdFromPath(arg);
}
-boost::filesystem::path AppQueryInterface::ExtractManifest(
+fs::path AppQueryInterface::ExtractManifest(
const std::string& from) const {
- if (!bf::exists(from))
+ if (!fs::exists(from))
return {};
- bf::path tmp_path = GenerateTmpDir("/tmp");
- bs::error_code code;
- bf::create_directories(tmp_path, code);
+ fs::path tmp_path = GenerateTmpDir("/tmp");
+ std::error_code code;
+ fs::create_directories(tmp_path, code);
if (code)
return {};
if (!ExtractToTmpDir(from.c_str(), tmp_path,
@@ -46,7 +47,7 @@ boost::filesystem::path AppQueryInterface::ExtractManifest(
}
bool AppQueryInterface::ClearTemporaryFile(
- const boost::filesystem::path& path) const {
+ const fs::path& path) const {
return RemoveAll(path);
}
diff --git a/src/common/app_query_interface.h b/src/common/app_query_interface.h
index 5025e689..f5272ee5 100644
--- a/src/common/app_query_interface.h
+++ b/src/common/app_query_interface.h
@@ -3,9 +3,9 @@
#ifndef COMMON_APP_QUERY_INTERFACE_H_
#define COMMON_APP_QUERY_INTERFACE_H_
-#include <boost/filesystem.hpp>
#include <sys/types.h>
+#include <filesystem>
#include <string>
namespace common_installer {
@@ -37,9 +37,9 @@ class AppQueryInterface {
std::string GetPkgId(const std::string& arg) const;
protected:
- virtual boost::filesystem::path ExtractManifest(
+ virtual std::filesystem::path ExtractManifest(
const std::string& from) const;
- virtual bool ClearTemporaryFile(const boost::filesystem::path& path) const;
+ virtual bool ClearTemporaryFile(const std::filesystem::path& path) const;
private:
virtual std::string GetPkgIdFromPath(const std::string& path) const = 0;
diff --git a/src/common/certificate_validation.cc b/src/common/certificate_validation.cc
index f5dd03f2..4975f96e 100644
--- a/src/common/certificate_validation.cc
+++ b/src/common/certificate_validation.cc
@@ -4,13 +4,11 @@
#include "common/certificate_validation.h"
-#include <boost/format.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/scope_exit.hpp>
#include <vcore/Certificate.h>
#include <vcore/SignatureValidator.h>
#include <algorithm>
+#include <filesystem>
#include <fstream>
#include <regex>
#include <utility>
@@ -20,8 +18,8 @@
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -165,7 +163,7 @@ void SetPrivilegeLevel(const ValidationCore::SignatureData& data,
}
bool ValidateSignatureFile(
- const bf::path& base_path,
+ const fs::path& base_path,
const ValidationCore::SignatureFileInfo& file_info,
common_installer::PrivilegeLevel* level,
common_installer::CertificateInfo* cert_info,
@@ -227,11 +225,11 @@ bool CheckAuthorSignature(const ValidationCore::SignatureFileInfo& file_info) {
bool CheckDistSignature(const ValidationCore::SignatureFileInfo& file_info) {
std::regex distributor_regex(kRegexDistributorSignature);
- bf::path file_path(file_info.getFileName());
+ fs::path file_path(file_info.getFileName());
return std::regex_search(file_path.filename().string(), distributor_regex);
}
-bool ValidateSignatures(const bf::path& base_path,
+bool ValidateSignatures(const fs::path& base_path,
PrivilegeLevel* level, common_installer::CertificateInfo* cert_info,
bool check_reference, std::string* error_message) {
// Find signature files
@@ -276,7 +274,7 @@ bool GetSignatureFromFile(const std::string& pkgid,
CertSvcVisibility visibility = CERTSVC_VISIBILITY_DEVELOPER;
std::string root_cert;
- bf::path file_path((is_readonly_package) ?
+ fs::path file_path((is_readonly_package) ?
tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE));
file_path /= std::string("signatures/" + pkgid + ".txt");
std::ifstream ifs(file_path.c_str(), std::ifstream::in);
@@ -332,6 +330,10 @@ bool GetSignatureFromFile(const std::string& pkgid,
return true;
}
+void FreePrivilegeList(GList* priv) {
+ g_list_free_full(priv, free);
+}
+
bool ValidatePrivilegeLevel(common_installer::PrivilegeLevel level,
uid_t uid, const char* api_version, GList* privileges,
std::string* error_message) {
@@ -346,14 +348,12 @@ bool ValidatePrivilegeLevel(common_installer::PrivilegeLevel level,
GList* native_privileges =
ci::PrivilegeXToPrivilege(privileges, ci::kNativePrivilegeType);
- BOOST_SCOPE_EXIT_ALL(&) {
- g_list_free_full(native_privileges, free);
- };
+ std::unique_ptr<GList, decltype(FreePrivilegeList)*> native_privs_deleter(
+ native_privileges, FreePrivilegeList);
GList* web_privileges =
ci::PrivilegeXToPrivilege(privileges, ci::kWebPrivilegeType);
- BOOST_SCOPE_EXIT_ALL(&) {
- g_list_free_full(web_privileges, free);
- };
+ std::unique_ptr<GList, decltype(FreePrivilegeList)*> web_privs_deleter(
+ web_privileges, FreePrivilegeList);
for (const std::pair<GList*, bool>& pair :
std::initializer_list<std::pair<GList*, bool>>{
diff --git a/src/common/certificate_validation.h b/src/common/certificate_validation.h
index 57498d38..1035e30e 100644
--- a/src/common/certificate_validation.h
+++ b/src/common/certificate_validation.h
@@ -5,7 +5,6 @@
#ifndef COMMON_CERTIFICATE_VALIDATION_H_
#define COMMON_CERTIFICATE_VALIDATION_H_
-#include <boost/filesystem/path.hpp>
#include <privilege_manager.h>
#include <sys/types.h>
#include <vcore/SignatureData.h>
@@ -27,13 +26,13 @@ void SetPrivilegeLevel(const ValidationCore::SignatureData& data,
common_installer::PrivilegeLevel* level);
bool ValidateSignatureFile(
- const boost::filesystem::path& base_path,
+ const std::filesystem::path& base_path,
const ValidationCore::SignatureFileInfo& file_info,
common_installer::PrivilegeLevel* level,
common_installer::CertificateInfo* cert_info,
bool check_reference, std::string* error_message);
-bool ValidateSignatures(const boost::filesystem::path& base_path,
+bool ValidateSignatures(const std::filesystem::path& base_path,
PrivilegeLevel* level, common_installer::CertificateInfo* cert_info,
bool check_reference, std::string* error_message);
diff --git a/src/common/dependency_checker.cc b/src/common/dependency_checker.cc
index 8f28e789..90ebd3a2 100644
--- a/src/common/dependency_checker.cc
+++ b/src/common/dependency_checker.cc
@@ -4,8 +4,6 @@
#include "common/dependency_checker.h"
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgr-info.h>
#include <manifest_parser/utils/logging.h>
@@ -15,6 +13,7 @@
#include <tpk_manifest_handlers/package_handler.h>
#include <tpk_manifest_handlers/tpk_config_parser.h>
+#include <filesystem>
#include <map>
#include <memory>
#include <tuple>
@@ -24,8 +23,7 @@
#include "common/archive_info.h"
#include "common/utils/pkgmgr_query.h"
-namespace bf = boost::filesystem;
-
+namespace fs = std::filesystem;
using Dependency = std::tuple<std::string, std::string, std::string>;
namespace {
@@ -271,11 +269,11 @@ bool DependencyChecker::GetDepInfoFromXML(InstallerPtr installer) {
std::string pkgid = pkgmgr_->GetRequestInfo(installer->GetIndex());
PkgQueryInterface pkg_query(pkgid, pkgmgr_->GetUid());
- bf::path xml_path =
- bf::path(getUserManifestPath(pkgmgr_->GetUid(), true)) /
- bf::path(pkgid + ".xml");
+ fs::path xml_path =
+ fs::path(getUserManifestPath(pkgmgr_->GetUid(), true)) /
+ fs::path(pkgid + ".xml");
- if (!bf::exists(xml_path)) {
+ if (!fs::exists(xml_path)) {
error_ = "xml path is not exist";
return false;
}
diff --git a/src/common/external_mount.cc b/src/common/external_mount.cc
index 525bbc48..332b5141 100644
--- a/src/common/external_mount.cc
+++ b/src/common/external_mount.cc
@@ -7,13 +7,12 @@
#include <app2ext_interface.h>
#include <manifest_parser/utils/logging.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include "common/utils/pkgmgr_query.h"
#include "common/utils/paths.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
@@ -34,8 +33,8 @@ ExternalMount::~ExternalMount() {
}
bool ExternalMount::IsAvailable() const {
- bf::path storage_path = GetExternalCardPath();
- if (!bf::exists(storage_path)) {
+ fs::path storage_path = GetExternalCardPath();
+ if (!fs::exists(storage_path)) {
LOG(WARNING) << "External storage (SD Card) is not mounted.";
return false;
}
diff --git a/src/common/external_storage.cc b/src/common/external_storage.cc
index a70c101e..ca06d47c 100644
--- a/src/common/external_storage.cc
+++ b/src/common/external_storage.cc
@@ -8,11 +8,13 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/utils/byte_size_literals.h"
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -43,7 +45,7 @@ namespace common_installer {
ExternalStorage::ExternalStorage(RequestType type,
const std::string& pkgid, const std::string& package_type,
- const boost::filesystem::path& application_root, uid_t uid)
+ const fs::path& application_root, uid_t uid)
: type_(type),
pkgid_(pkgid),
package_type_(package_type),
@@ -59,7 +61,7 @@ ExternalStorage::ExternalStorage(RequestType type,
ExternalStorage::ExternalStorage(RequestType type,
const std::string& pkgid, const std::string& package_type,
- const boost::filesystem::path& application_root, uid_t uid,
+ const fs::path& application_root, uid_t uid,
bool is_external_move)
: type_(type),
pkgid_(pkgid),
@@ -134,15 +136,15 @@ const std::vector<std::string>& ExternalStorage::external_dirs() const {
}
bool ExternalStorage::Initialize(
- const boost::filesystem::path& space_requirement) {
+ const fs::path& space_requirement) {
// external size in MB, set any-non zero size as default
int external_size = 1;
if (!space_requirement.empty()) {
if (package_type_ != kWgtType) {
for (auto& dir : kExternalDirsForTpk) {
- bf::path requirement = space_requirement / dir;
- if (!bf::exists(requirement))
+ fs::path requirement = space_requirement / dir;
+ if (!fs::exists(requirement))
continue;
external_size +=
SizeInMB(GetDirectorySize(requirement));
@@ -229,7 +231,7 @@ bool ExternalStorage::Initialize(
}
std::unique_ptr<ExternalStorage> ExternalStorage::MoveInstalledStorage(
- RequestType type, const boost::filesystem::path& application_root,
+ RequestType type, const fs::path& application_root,
const std::string& pkgid, const std::string& package_type,
uid_t uid, bool is_external_move) {
@@ -245,9 +247,9 @@ std::unique_ptr<ExternalStorage> ExternalStorage::MoveInstalledStorage(
}
std::unique_ptr<ExternalStorage> ExternalStorage::AcquireExternalStorage(
- RequestType type, const boost::filesystem::path& application_root,
+ RequestType type, const fs::path& application_root,
const std::string& pkgid, const std::string& package_type,
- const boost::filesystem::path& space_requirement,
+ const fs::path& space_requirement,
uid_t uid) {
std::unique_ptr<ExternalStorage> external_storage(
new ExternalStorage(type, pkgid, package_type, application_root, uid));
@@ -262,7 +264,7 @@ std::unique_ptr<ExternalStorage> ExternalStorage::MigrateExternalStorage(
RequestType type, const std::string& pkgid, uid_t uid) {
std::unique_ptr<ExternalStorage> external_storage(
new ExternalStorage(type, pkgid, uid));
- bf::path empty_path("");
+ fs::path empty_path("");
if (!external_storage->Initialize(empty_path)) {
LOG(WARNING) << "Cannot initialize external storage for request";
return nullptr;
diff --git a/src/common/external_storage.h b/src/common/external_storage.h
index f9a70b33..a60f112b 100644
--- a/src/common/external_storage.h
+++ b/src/common/external_storage.h
@@ -5,11 +5,9 @@
#ifndef COMMON_EXTERNAL_STORAGE_H_
#define COMMON_EXTERNAL_STORAGE_H_
-#include <boost/filesystem/path.hpp>
-
-
#include <sys/types.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <vector>
@@ -27,25 +25,25 @@ namespace common_installer {
class ExternalStorage final {
public:
static std::unique_ptr<ExternalStorage> MoveInstalledStorage(
- RequestType type, const boost::filesystem::path& application_root,
+ RequestType type, const std::filesystem::path& application_root,
const std::string& pkgid, const std::string& package_type,
uid_t uid, bool is_external_move);
static std::unique_ptr<ExternalStorage> AcquireExternalStorage(
- RequestType type, const boost::filesystem::path& application_root,
+ RequestType type, const std::filesystem::path& application_root,
const std::string& pkgid, const std::string& package_type,
- const boost::filesystem::path& space_requirement, uid_t uid);
+ const std::filesystem::path& space_requirement, uid_t uid);
static std::unique_ptr<ExternalStorage> MigrateExternalStorage(
RequestType type, const std::string& pkgid, uid_t uid);
ExternalStorage(RequestType type, const std::string& pkgid,
const std::string& package_type,
- const boost::filesystem::path& application_root, uid_t uid);
+ const std::filesystem::path& application_root, uid_t uid);
ExternalStorage(RequestType type, const std::string& pkgid,
const std::string& package_type,
- const boost::filesystem::path& application_root, uid_t uid,
+ const std::filesystem::path& application_root, uid_t uid,
bool is_external_move);
ExternalStorage(RequestType type, const std::string& pkgid, uid_t uid);
~ExternalStorage();
@@ -58,13 +56,13 @@ class ExternalStorage final {
private:
App2ExtDynamicService service;
- bool Initialize(const boost::filesystem::path& space_requirement);
+ bool Initialize(const std::filesystem::path& space_requirement);
bool Finalize(bool success);
RequestType type_;
std::string pkgid_;
std::string package_type_;
- boost::filesystem::path application_root_;
+ std::filesystem::path application_root_;
uid_t uid_;
int move_type_;
std::shared_ptr<app2ext_handle> handle_;
diff --git a/src/common/feature_validator.cc b/src/common/feature_validator.cc
index 3ddc3aa4..5c7b3bea 100644
--- a/src/common/feature_validator.cc
+++ b/src/common/feature_validator.cc
@@ -4,10 +4,11 @@
#include "common/feature_validator.h"
-#include <boost/scope_exit.hpp>
-
#include <system_info.h>
+#include <memory>
+#include <string>
+
namespace common_installer {
FeatureValidator::FeatureValidator(
@@ -77,9 +78,7 @@ bool FeatureValidator::ValidateInteger(
bool FeatureValidator::ValidateString(
const std::string& feature, std::string* error) {
char* text = nullptr;
- BOOST_SCOPE_EXIT_ALL(text) {
- free(text);
- };
+ std::unique_ptr<char, decltype(&std::free)> text_deleter(text, std::free);
int ret = system_info_get_platform_string(feature.c_str(), &text);
if (ret != SYSTEM_INFO_ERROR_NONE) {
*error = std::string("Failed to call system_info_get_platform_string()") +
diff --git a/src/common/global_recovery_file.cc b/src/common/global_recovery_file.cc
index d6a6fe17..f4f57fd2 100644
--- a/src/common/global_recovery_file.cc
+++ b/src/common/global_recovery_file.cc
@@ -4,27 +4,27 @@
#include "common/global_recovery_file.h"
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <unistd.h>
#include <algorithm>
+#include <filesystem>
#include <string>
+#include <system_error>
#include <vector>
#include "common/utils/file_util.h"
#include "common/pkgmgr_interface.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
const char kGlobalTypeName[] = "unified";
-bf::path Backup(const bf::path& filepath) {
- bf::path backup_path(filepath);
+fs::path Backup(const fs::path& filepath) {
+ fs::path backup_path(filepath);
backup_path += ".bck";
if (!ci::MoveFile(filepath, backup_path) ||
@@ -45,16 +45,16 @@ GlobalRecoveryFile::GlobalRecoveryFile(
}
GlobalRecoveryFile::~GlobalRecoveryFile() {
- bs::error_code ec;
- if (bf::exists(recovery_filepath_, ec))
+ std::error_code ec;
+ if (fs::exists(recovery_filepath_, ec))
ci::Remove(recovery_filepath_);
- if (bf::exists(backup_path_, ec))
+ if (fs::exists(backup_path_, ec))
ci::Remove(backup_path_);
}
bool GlobalRecoveryFile::Init() {
- boost::filesystem::path root_path = ci::GetRootAppPath(
+ std::filesystem::path root_path = ci::GetRootAppPath(
pkgmgr_->GetIsPreloadRequest(), pkgmgr_->GetUid());
recovery_filepath_ = GenerateRecoveryFilePath(root_path, kGlobalTypeName);
if (recovery_filepath_.empty())
@@ -65,9 +65,9 @@ bool GlobalRecoveryFile::Init() {
std::string GlobalRecoveryFile::AddPathWithType(
const std::string& pkg_type) {
- boost::filesystem::path root_path = ci::GetRootAppPath(
+ std::filesystem::path root_path = ci::GetRootAppPath(
pkgmgr_->GetIsPreloadRequest(), pkgmgr_->GetUid());
- bf::path recovery_filepath = GenerateRecoveryFilePath(root_path, pkg_type);
+ fs::path recovery_filepath = GenerateRecoveryFilePath(root_path, pkg_type);
if (!AppendString(recovery_filepath.string()))
return {};
@@ -76,7 +76,7 @@ std::string GlobalRecoveryFile::AddPathWithType(
}
bool GlobalRecoveryFile::AppendPath(
- const bf::path& additional_path) {
+ const fs::path& additional_path) {
return AppendString(additional_path.string());
}
@@ -88,7 +88,7 @@ bool GlobalRecoveryFile::AppendString(const std::string& val) {
if (recovery_filepath_.empty())
return true;
- if (bf::exists(recovery_filepath_)) {
+ if (fs::exists(recovery_filepath_)) {
backup_path_ = Backup(recovery_filepath_);
if (backup_path_.empty()) {
LOG(ERROR) << "Failed to backup";
@@ -111,20 +111,20 @@ bool GlobalRecoveryFile::AppendString(const std::string& val) {
return true;
}
-bf::path GlobalRecoveryFile::GenerateRecoveryFilePath(
- const bf::path& path, const std::string& type) {
- bf::path pattern = path;
+fs::path GlobalRecoveryFile::GenerateRecoveryFilePath(
+ const fs::path& path, const std::string& type) {
+ fs::path pattern = path;
pattern += "/";
pattern += type;
pattern += "-recovery-%%%%%%";
- bf::path tmp_path;
+ fs::path tmp_path;
std::vector<std::string>::iterator iter;
do {
- tmp_path = boost::filesystem::unique_path(pattern);
+ tmp_path = ci::GenerateUniquePathString(pattern);
iter = std::find(recovery_list_.begin(), recovery_list_.end(),
tmp_path.string());
- } while (boost::filesystem::exists(tmp_path) ||
+ } while (std::filesystem::exists(tmp_path) ||
iter != recovery_list_.end());
return tmp_path;
diff --git a/src/common/global_recovery_file.h b/src/common/global_recovery_file.h
index da3e78a2..6e52ba63 100644
--- a/src/common/global_recovery_file.h
+++ b/src/common/global_recovery_file.h
@@ -5,14 +5,13 @@
#ifndef COMMON_GLOBAL_RECOVERY_FILE_H_
#define COMMON_GLOBAL_RECOVERY_FILE_H_
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include <vector>
#include "common/pkgmgr_interface.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
@@ -25,18 +24,18 @@ class GlobalRecoveryFile {
std::string AddPathWithType(const std::string& pkg_type);
- bool AppendPath(const bf::path& additional_path);
+ bool AppendPath(const fs::path& additional_path);
bool AppendCleanUp();
private:
bool AppendString(const std::string& val);
- bf::path GenerateRecoveryFilePath(
- const bf::path& path,
+ fs::path GenerateRecoveryFilePath(
+ const fs::path& path,
const std::string& type);
std::shared_ptr<common_installer::PkgMgrInterface> pkgmgr_;
- bf::path recovery_filepath_;
- bf::path backup_path_;
+ fs::path recovery_filepath_;
+ fs::path backup_path_;
std::vector<std::string> recovery_list_;
};
diff --git a/src/common/installer/app_installer.cc b/src/common/installer/app_installer.cc
index bbed0968..f575c8c7 100644
--- a/src/common/installer/app_installer.cc
+++ b/src/common/installer/app_installer.cc
@@ -839,6 +839,10 @@ void AppInstaller::HandleStepError(Step::Status result,
context_->pkgid.get());
}
+void AppInstaller::on_error(Step::Status result, const std::string& error) {
+ HandleStepError(result, error);
+}
+
std::string AppInstaller::GetPackageVersion() {
std::string version;
if (context_->manifest_data.get()) {
diff --git a/src/common/installer/app_installer.h b/src/common/installer/app_installer.h
index 32b0b786..6cb06273 100644
--- a/src/common/installer/app_installer.h
+++ b/src/common/installer/app_installer.h
@@ -8,8 +8,7 @@
#include <manifest_parser/utils/logging.h>
-#include <boost/bind/bind.hpp>
-
+#include <algorithm>
#include <list>
#include <memory>
#include <string>
@@ -30,7 +29,7 @@ namespace common_installer {
* the lists of steps and runs each of the step in the configured
* order.
*/
-class AppInstaller {
+class AppInstaller : public Step::IStepErrorSignal {
public:
/** Enumeration of possible returned Results */
enum class Result {
@@ -52,6 +51,9 @@ class AppInstaller {
/** virtual desctructor */
virtual ~AppInstaller();
+ /** error handler for sending error signal */
+ void on_error(Step::Status result, const std::string& error) override;
+
/**
* \brief Adds new step to installer by specified type
* Type of template parameter is used to create requested step
@@ -68,9 +70,7 @@ class AppInstaller {
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,
- boost::placeholders::_1, boost::placeholders::_2));
+ step->connect(this);
steps_.emplace_back(std::move(step));
}
@@ -108,9 +108,7 @@ class AppInstaller {
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,
- boost::placeholders::_1, boost::placeholders::_2));
+ step->connect(this);
std::list<std::unique_ptr<Step>> tmpList;
tmpList.emplace_back(std::move(step));
auto it = steps_.begin();
@@ -144,9 +142,7 @@ class AppInstaller {
std::unique_ptr<Step> step(
new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this,
- boost::placeholders::_1, boost::placeholders::_2));
+ step->connect(this);
*it = std::move(step);
}
@@ -176,9 +172,7 @@ class AppInstaller {
std::unique_ptr<Step> step(
new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this,
- boost::placeholders::_1, boost::placeholders::_2));
+ step->connect(this);
steps_.insert(it, std::move(step));
}
@@ -208,9 +202,7 @@ class AppInstaller {
std::unique_ptr<Step> step(
new StepT(context_.get(), std::forward<Args>(args)...));
- step->on_error.connect(
- boost::bind(&AppInstaller::HandleStepError, this,
- boost::placeholders::_1, boost::placeholders::_2));
+ step->connect(this);
steps_.insert(++it, std::move(step));
}
diff --git a/src/common/installer_context.h b/src/common/installer_context.h
index c7e03bfb..816a98ee 100644
--- a/src/common/installer_context.h
+++ b/src/common/installer_context.h
@@ -6,14 +6,13 @@
#ifndef COMMON_INSTALLER_CONTEXT_H_
#define COMMON_INSTALLER_CONTEXT_H_
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgr_parser.h>
#include <unistd.h>
#include <sys/types.h>
#include <vcore/Certificate.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <utility>
@@ -118,7 +117,7 @@ class RecoveryInfo {
* \param path path of recovery file to be created
* \param recovery_cleanup path of recovery file to be created
*/
- explicit RecoveryInfo(const boost::filesystem::path& path,
+ explicit RecoveryInfo(const std::filesystem::path& path,
bool recovery_cleanup = false)
: filepath(path), cleanup(recovery_cleanup) {
}
@@ -127,7 +126,7 @@ class RecoveryInfo {
std::unique_ptr<recovery::RecoveryFile> recovery_file;
/** path of recovery file to be created */
- boost::filesystem::path filepath;
+ std::filesystem::path filepath;
/** cleanup flag delivered by global recovery file */
bool cleanup;
@@ -200,7 +199,7 @@ class InstallerContext {
/**
* \brief Returns package directory path containing app data
*/
- inline boost::filesystem::path GetPkgPath() const {
+ inline std::filesystem::path GetPkgPath() const {
return root_application_path.get() / pkgid.get();
}
@@ -238,24 +237,24 @@ class InstallerContext {
/**
* \brief path to xml platform manifest which was generated according
* to maniest_data content */
- Property<boost::filesystem::path> xml_path;
+ Property<std::filesystem::path> xml_path;
/**
* \brief path to backup xml platform manifest which was generated
* according to old_maniest_data content (needed for rollback
* operations)
*/
- Property<boost::filesystem::path> backup_xml_path;
+ Property<std::filesystem::path> backup_xml_path;
/**
* \brief file path used for installation or reinstallation process
*/
- Property<boost::filesystem::path> file_path;
+ Property<std::filesystem::path> file_path;
/**
* \brief tep file path used for TEP installation process
*/
- Property<boost::filesystem::path> tep_path;
+ Property<std::filesystem::path> tep_path;
/**
* \brief boolean property that indicates tep file should be moved or not
@@ -276,7 +275,7 @@ class InstallerContext {
* \brief path to temporary directory when package files are unpacked
* before coping them to final destination
*/
- Property<boost::filesystem::path> unpacked_dir_path;
+ Property<std::filesystem::path> unpacked_dir_path;
/**
* \brief uid of user which installation was triggered for
@@ -289,7 +288,7 @@ class InstallerContext {
* (${TZ_USER_HOME}/${USER}/apps_rw/) or
* tizenglobalapp user (${TZ_SYS_RO_APP} or ${TZ_SYS_RW_APP})
*/
- Property<boost::filesystem::path> root_application_path;
+ Property<std::filesystem::path> root_application_path;
/**
* \brief "void*-like" structure to store backend specific
diff --git a/src/common/mount_base.h b/src/common/mount_base.h
index 0987716c..c5ccde2b 100644
--- a/src/common/mount_base.h
+++ b/src/common/mount_base.h
@@ -5,7 +5,7 @@
#ifndef COMMON_MOUNT_BASE_H_
#define COMMON_MOUNT_BASE_H_
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include "common/step/step.h"
#include "common/zip_interface.h"
@@ -21,7 +21,7 @@ class MountBase {
protected:
virtual std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) = 0;
+ const std::filesystem::path& mount_path) = 0;
};
} // namespace common_installer
diff --git a/src/common/pkgmgr_interface.cc b/src/common/pkgmgr_interface.cc
index a7545850..b7d3ccdf 100644
--- a/src/common/pkgmgr_interface.cc
+++ b/src/common/pkgmgr_interface.cc
@@ -4,14 +4,13 @@
#include "common/pkgmgr_interface.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem.hpp>
-
#include <tzplatform_config.h>
#include <memory>
#include <string>
+#include <filesystem>
#include <fstream>
+#include <optional>
#include "common/app_query_interface.h"
#include "common/utils/pkgmgr_query.h"
@@ -21,7 +20,7 @@
#include "common/utils/manifest_util.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
@@ -33,7 +32,7 @@ const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
bool CheckIfAppFilesExists(const std::string& pkgid,
uid_t uid,
bool is_readonly) {
- return bf::exists(ci::GetManifestLocation(pkgid,
+ return fs::exists(ci::GetManifestLocation(pkgid,
uid, is_readonly));
}
@@ -45,7 +44,7 @@ bool IsDeltaPkg(const std::string& path) {
}
if (!is_delta) {
- std::string extension = bf::path(path).extension().string();
+ std::string extension = fs::path(path).extension().string();
if (extension == kDeltaFileExtension)
is_delta = true;
}
@@ -104,7 +103,7 @@ int PkgMgrInterface::InitInternal(int argc, char** argv) {
return -1;
}
- boost::optional<bool> is_admin_user =
+ std::optional<bool> is_admin_user =
IsAdminUser(pkgmgr_installer_get_uid(pi_));
if (!is_admin_user) {
LOG(ERROR) << "Cannot get admin user info. Aborting.";
@@ -131,7 +130,7 @@ PkgMgrInterface::~PkgMgrInterface() {
// method name?
bool PkgMgrInterface::SetAppQueryInterface(int idx) {
// reset this flag to processing new package
- is_app_installed_ = boost::none;
+ is_app_installed_.reset();
auto it = query_interface_map_.find(idx);
if (it == query_interface_map_.end()) {
@@ -194,7 +193,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
if (request_info.empty())
return RequestType::Unknown;
bool is_delta = IsDeltaPkg(request_info);
- if (!is_app_installed_.get()) {
+ if (!is_app_installed_.value()) {
if (is_delta) {
LOG(ERROR) << "Package is not installed. "
"Cannot update from delta package";
@@ -239,7 +238,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
return RequestType::Uninstall;
}
case PKGMGR_REQ_MANIFEST_DIRECT_INSTALL:
- if (!is_app_installed_.get()) {
+ if (!is_app_installed_.value()) {
if (GetIsPreloadRequest() && GetIsPartialRW())
return RequestType::ManifestPartialInstall;
else
@@ -251,7 +250,7 @@ RequestType PkgMgrInterface::GetRequestType(int idx) const {
return RequestType::ManifestDirectUpdate;
}
case PKGMGR_REQ_MOUNT_INSTALL: {
- if (!is_app_installed_.get()) {
+ if (!is_app_installed_.value()) {
return RequestType::MountInstall;
} else {
std::string pkgid = query_interface->GetPkgId(GetRequestInfo(idx));
@@ -283,11 +282,11 @@ std::string PkgMgrInterface::GetRequestInfo(int idx) const {
return request_info;
}
-boost::filesystem::path PkgMgrInterface::GetTepPath() const {
+std::filesystem::path PkgMgrInterface::GetTepPath() const {
if (pkgmgr_installer_get_tep_path(pi_) == nullptr)
- return boost::filesystem::path("");
+ return std::filesystem::path("");
else
- return boost::filesystem::path(pkgmgr_installer_get_tep_path(pi_));
+ return std::filesystem::path(pkgmgr_installer_get_tep_path(pi_));
}
bool PkgMgrInterface::GetIsTepMove() const {
diff --git a/src/common/pkgmgr_interface.h b/src/common/pkgmgr_interface.h
index e085018d..78a93c9f 100644
--- a/src/common/pkgmgr_interface.h
+++ b/src/common/pkgmgr_interface.h
@@ -5,14 +5,13 @@
#ifndef COMMON_PKGMGR_INTERFACE_H_
#define COMMON_PKGMGR_INTERFACE_H_
-#include <boost/filesystem/path.hpp>
-#include <boost/none.hpp>
-#include <boost/optional/optional.hpp>
#include <manifest_parser/utils/logging.h>
#include <pkgmgr_installer.h>
+#include <filesystem>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include "common/app_query_interface.h"
@@ -138,7 +137,7 @@ class PkgMgrInterface {
*
* \return TEP path retrieved from pkgmgr_installer
*/
- boost::filesystem::path GetTepPath() const;
+ std::filesystem::path GetTepPath() const;
/**
* Returns True if TEP file should be moved. Otherwise, return false
@@ -270,14 +269,14 @@ class PkgMgrInterface {
std::shared_ptr<AppQueryInterface> interface)
: pi_(nullptr),
install_mode_(InstallationMode::ONLINE),
- is_app_installed_(boost::none),
+ is_app_installed_(std::nullopt),
pkgmgr_installer_interface_(pkgmgr_installer_interface),
query_interface_(interface) {}
int InitInternal(int argc, char** argv);
pkgmgr_installer* pi_;
InstallationMode install_mode_;
- mutable boost::optional<bool> is_app_installed_;
+ mutable std::optional<bool> is_app_installed_;
PkgmgrInstallerInterface* pkgmgr_installer_interface_;
std::shared_ptr<AppQueryInterface> query_interface_;
diff --git a/src/common/pkgmgr_registration.cc b/src/common/pkgmgr_registration.cc
index 57d3554d..4f754072 100644
--- a/src/common/pkgmgr_registration.cc
+++ b/src/common/pkgmgr_registration.cc
@@ -16,7 +16,7 @@
#include "common/utils/glist_range.h"
#include "common/utils/manifest_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -102,13 +102,13 @@ bool RegisterAppInPkgmgr(manifest_x* manifest,
uid_t uid,
Storage storage,
RequestMode request_mode,
- const boost::filesystem::path& tep_path) {
+ const std::filesystem::path& tep_path) {
// Fill "non-xml" elements
if (!tep_path.empty())
manifest->tep_name = strdup(tep_path.c_str());
if (storage == Storage::EXTENDED) {
- bf::path ext_path = bf::path(GetExtendedRootAppPath(uid)) / pkgid;
+ fs::path ext_path = fs::path(GetExtendedRootAppPath(uid)) / pkgid;
manifest->external_path = strdup(ext_path.c_str());
} else if (storage == Storage::EXTERNAL) {
App2ExtDynamicService service;
@@ -142,7 +142,7 @@ bool UpgradeAppInPkgmgr(manifest_x* manifest,
Storage storage,
RequestMode request_mode) {
if (storage == Storage::EXTENDED) {
- bf::path ext_path = bf::path(GetExtendedRootAppPath(uid)) / pkgid;
+ fs::path ext_path = fs::path(GetExtendedRootAppPath(uid)) / pkgid;
manifest->external_path = strdup(ext_path.c_str());
} else if (storage == Storage::EXTERNAL) {
App2ExtDynamicService service;
@@ -201,13 +201,13 @@ bool UnregisterAppInPkgmgr(manifest_x* manifest,
return true;
}
-bool UpdateTepInfoInPkgmgr(const bf::path& tep_path, const std::string& pkgid,
+bool UpdateTepInfoInPkgmgr(const fs::path& tep_path, const std::string& pkgid,
uid_t uid, RequestMode request_mode) {
int ret = request_mode != RequestMode::GLOBAL ?
pkgmgr_parser_usr_update_tep(
- pkgid.c_str(), tep_path.string().c_str(), uid) :
+ pkgid.c_str(), tep_path.c_str(), uid) :
pkgmgr_parser_update_tep(
- pkgid.c_str(), tep_path.string().c_str());
+ pkgid.c_str(), tep_path.c_str());
if (ret != 0) {
LOG(ERROR) << "Failed to upgrade tep info: " << pkgid;
@@ -217,7 +217,7 @@ bool UpdateTepInfoInPkgmgr(const bf::path& tep_path, const std::string& pkgid,
return true;
}
-bool UpdateInstalledStorageInPkgmgr(Storage storage, const bf::path& ext_path,
+bool UpdateInstalledStorageInPkgmgr(Storage storage, const fs::path& ext_path,
const std::string& pkgid, uid_t uid) {
// FIXME: refactor this
INSTALL_LOCATION install_location;
@@ -227,10 +227,10 @@ bool UpdateInstalledStorageInPkgmgr(Storage storage, const bf::path& ext_path,
path = "";
} else if (storage == Storage::EXTERNAL) {
install_location = INSTALL_EXTERNAL;
- path = ext_path.string().c_str();
+ path = ext_path.c_str();
} else {
install_location = INSTALL_EXTENDED;
- path = ext_path.string().c_str();
+ path = ext_path.c_str();
}
int ret = pkgmgrinfo_pkginfo_set_usr_installed_storage(
pkgid.c_str(), install_location, path, uid);
diff --git a/src/common/pkgmgr_registration.h b/src/common/pkgmgr_registration.h
index 6e9d21ad..8604e23f 100644
--- a/src/common/pkgmgr_registration.h
+++ b/src/common/pkgmgr_registration.h
@@ -5,10 +5,10 @@
#ifndef COMMON_PKGMGR_REGISTRATION_H_
#define COMMON_PKGMGR_REGISTRATION_H_
-#include <boost/filesystem.hpp>
#include <pkgmgr-info.h>
#include <unistd.h>
+#include <filesystem>
#include <string>
#include "common/installer_context.h"
@@ -33,7 +33,7 @@ bool RegisterAppInPkgmgr(manifest_x* manifest,
uid_t uid,
Storage storage,
RequestMode request_mode,
- const boost::filesystem::path& tep_path);
+ const std::filesystem::path& tep_path);
/**
* \brief Adapter interface for external PkgMgr module used for upgrading
@@ -95,7 +95,7 @@ bool UnregisterAppInPkgmgr(manifest_x* manifest,
*
* \return true if success
*/
-bool UpdateTepInfoInPkgmgr(const boost::filesystem::path& tep_path,
+bool UpdateTepInfoInPkgmgr(const std::filesystem::path& tep_path,
const std::string& pkgid,
uid_t uid,
RequestMode request_mode);
@@ -112,7 +112,7 @@ bool UpdateTepInfoInPkgmgr(const boost::filesystem::path& tep_path,
* \return true if success
*/
bool UpdateInstalledStorageInPkgmgr(Storage storage,
- const boost::filesystem::path& ext_path,
+ const std::filesystem::path& ext_path,
const std::string& pkgid,
uid_t uid);
diff --git a/src/common/plugins/plugin.h b/src/common/plugins/plugin.h
index cb4e5c23..bee8ec36 100644
--- a/src/common/plugins/plugin.h
+++ b/src/common/plugins/plugin.h
@@ -5,7 +5,6 @@
#ifndef COMMON_PLUGINS_PLUGIN_H_
#define COMMON_PLUGINS_PLUGIN_H_
-#include <boost/filesystem/path.hpp>
#include <dlfcn.h>
#include <manifest_parser/utils/logging.h>
#include <libxml2/libxml/tree.h>
diff --git a/src/common/plugins/plugin_list_parser.cc b/src/common/plugins/plugin_list_parser.cc
index aa3490be..9bf9af5a 100644
--- a/src/common/plugins/plugin_list_parser.cc
+++ b/src/common/plugins/plugin_list_parser.cc
@@ -4,20 +4,17 @@
#include "common/plugins/plugin_list_parser.h"
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
+#include <manifest_parser/utils/string_util.h>
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+#include <filesystem>
+
+namespace fs = std::filesystem;
namespace common_installer {
PluginInfo::PluginInfo(std::string type,
std::string name,
- boost::filesystem::path path,
+ std::filesystem::path path,
bool vitalness)
: type_(std::move(type)),
name_(std::move(name)),
@@ -28,7 +25,7 @@ const std::string& PluginInfo::type() const { return type_; }
const std::string& PluginInfo::name() const { return name_; }
-const boost::filesystem::path& PluginInfo::path() const { return path_; }
+const std::filesystem::path& PluginInfo::path() const { return path_; }
bool PluginInfo::vitalness() const {
return vitalness_;
@@ -129,10 +126,10 @@ const PluginsListParser::PluginList& PluginsListParser::PluginInfoList() const {
}
bool PluginsListParser::ReadLinesFromFile(std::vector<std::string>* lines) {
- for (bf::directory_iterator file(path_); file != bf::directory_iterator();
+ for (fs::directory_iterator file(path_); file != fs::directory_iterator();
++file) {
- bs::error_code error;
- bool is_file = bf::is_regular_file(file->path(), error);
+ std::error_code error;
+ bool is_file = fs::is_regular_file(file->path(), error);
if (!is_file || error)
continue;
@@ -193,7 +190,7 @@ bool PluginsListParser::ParsePluginsRawData(
}
plugin_info_list_.push_back(std::make_shared<PluginInfo>(std::move(type),
- std::move(name), boost::filesystem::path(std::move(path)),
+ std::move(name), std::filesystem::path(std::move(path)),
(vitalness.compare("true") == 0 ? true : false)));
}
@@ -205,7 +202,7 @@ bool PluginsListParser::SplitPluginLine(const std::string& line,
static const char kPartsInLine = 3;
std::vector<std::string> _parts;
- boost::algorithm::split(_parts, line, boost::algorithm::is_any_of(";"));
+ parser::utils::Split(_parts, line, ';');
if (_parts.size() != kPartsInLine && _parts.size() != kPartsInLine + 1) {
LOG(ERROR) << "Invalid number of parts";
diff --git a/src/common/plugins/plugin_list_parser.h b/src/common/plugins/plugin_list_parser.h
index ed859780..2e310dde 100644
--- a/src/common/plugins/plugin_list_parser.h
+++ b/src/common/plugins/plugin_list_parser.h
@@ -5,14 +5,13 @@
#ifndef COMMON_PLUGINS_PLUGIN_LIST_PARSER_H_
#define COMMON_PLUGINS_PLUGIN_LIST_PARSER_H_
-#include <boost/filesystem/path.hpp>
-
#include <libxml/parser.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlschemas.h>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
#include <fstream>
#include <iostream>
#include <memory>
@@ -29,16 +28,16 @@ namespace common_installer {
class PluginInfo {
public:
PluginInfo(std::string type, std::string name,
- boost::filesystem::path path, bool vitalness);
+ std::filesystem::path path, bool vitalness);
const std::string& type() const;
const std::string& name() const;
- const boost::filesystem::path& path() const;
+ const std::filesystem::path& path() const;
bool vitalness() const;
private:
std::string type_;
std::string name_;
- boost::filesystem::path path_;
+ std::filesystem::path path_;
bool vitalness_;
};
@@ -46,7 +45,7 @@ class PluginInfo {
class PluginsListParser {
public:
using PluginList = std::vector<std::shared_ptr<PluginInfo>>;
- explicit PluginsListParser(const boost::filesystem::path& path)
+ explicit PluginsListParser(const std::filesystem::path& path)
: path_(path) {}
bool Parse();
@@ -69,7 +68,7 @@ class PluginsListParser {
bool ValidName(const std::string& name);
bool ValidPath(const std::string& path);
- const boost::filesystem::path path_;
+ const std::filesystem::path path_;
std::vector<std::shared_ptr<PluginInfo>> plugin_info_list_;
};
diff --git a/src/common/plugins/plugin_manager.cc b/src/common/plugins/plugin_manager.cc
index 7d01590f..550d6d8f 100644
--- a/src/common/plugins/plugin_manager.cc
+++ b/src/common/plugins/plugin_manager.cc
@@ -6,8 +6,6 @@
#include <pkgmgr-info.h>
-#include <boost/filesystem.hpp>
-
#include <algorithm>
#include <string>
#include <utility>
diff --git a/src/common/plugins/plugin_manager.h b/src/common/plugins/plugin_manager.h
index 5f6c47ce..f5b0e844 100644
--- a/src/common/plugins/plugin_manager.h
+++ b/src/common/plugins/plugin_manager.h
@@ -5,10 +5,9 @@
#ifndef COMMON_PLUGINS_PLUGIN_MANAGER_H_
#define COMMON_PLUGINS_PLUGIN_MANAGER_H_
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <vector>
@@ -25,8 +24,8 @@ class PluginManager {
public:
using PluginInfoList = std::vector<std::shared_ptr<PluginInfo>>;
- PluginManager(const boost::filesystem::path& xml_path,
- const boost::filesystem::path& list_path,
+ PluginManager(const std::filesystem::path& xml_path,
+ const std::filesystem::path& list_path,
const std::string& pkgid,
manifest_x* manifest,
uid_t uid)
diff --git a/src/common/plugins/plugin_xml_parser.h b/src/common/plugins/plugin_xml_parser.h
index d747d06c..d4e04328 100644
--- a/src/common/plugins/plugin_xml_parser.h
+++ b/src/common/plugins/plugin_xml_parser.h
@@ -5,10 +5,9 @@
#ifndef COMMON_PLUGINS_PLUGIN_XML_PARSER_H_
#define COMMON_PLUGINS_PLUGIN_XML_PARSER_H_
-#include <boost/filesystem/path.hpp>
-
#include <libxml2/libxml/xmlreader.h>
+#include <filesystem>
#include <string>
#include <vector>
#include <set>
@@ -18,7 +17,7 @@ namespace common_installer {
/** this class parse xml file*/
class PluginsXmlParser {
public:
- explicit PluginsXmlParser(const boost::filesystem::path& path)
+ explicit PluginsXmlParser(const std::filesystem::path& path)
: path_(path), doc_ptr_(nullptr) {}
~PluginsXmlParser();
bool Parse();
@@ -26,7 +25,7 @@ class PluginsXmlParser {
xmlDocPtr doc_ptr();
private:
- const boost::filesystem::path path_;
+ const std::filesystem::path path_;
xmlDocPtr doc_ptr_;
std::vector<std::string> tags_;
int NextChildElement(xmlTextReaderPtr reader, int depth);
diff --git a/src/common/recovery_file.cc b/src/common/recovery_file.cc
index ace24146..d7999ab4 100644
--- a/src/common/recovery_file.cc
+++ b/src/common/recovery_file.cc
@@ -4,26 +4,21 @@
#include "common/recovery_file.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/iostreams/stream.hpp>
-#include <boost/iostreams/device/file_descriptor.hpp>
-#include <boost/system/error_code.hpp>
-
#include <manifest_parser/utils/logging.h>
#include <array>
#include <cstring>
+#include <fstream>
#include <string>
+#include <system_error>
#include <map>
#include <utility>
#include "common/installer_context.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace bi = boost::iostreams;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -65,8 +60,8 @@ namespace common_installer {
namespace recovery {
std::unique_ptr<RecoveryFile> RecoveryFile::CreateRecoveryFile(
- const boost::filesystem::path& path, RequestType type) {
- if (bf::exists(path)) {
+ const std::filesystem::path& path, RequestType type) {
+ if (fs::exists(path)) {
LOG(ERROR) << "Recovery file already exists!";
return nullptr;
}
@@ -79,8 +74,8 @@ std::unique_ptr<RecoveryFile> RecoveryFile::CreateRecoveryFile(
}
std::unique_ptr<RecoveryFile> RecoveryFile::OpenRecoveryFile(
- const boost::filesystem::path& path) {
- if (!bf::exists(path)) {
+ const std::filesystem::path& path) {
+ if (!fs::exists(path)) {
LOG(ERROR) << "Cannot open recovery file";
return nullptr;
}
@@ -93,7 +88,7 @@ std::unique_ptr<RecoveryFile> RecoveryFile::OpenRecoveryFile(
return file;
}
-RecoveryFile::RecoveryFile(const bf::path& path, RequestType type, bool load)
+RecoveryFile::RecoveryFile(const fs::path& path, RequestType type, bool load)
: type_(type), path_(path), backup_done_(false), cleanup_(false),
security_operation_done_(false) {
backup_path_ = path_.string() + ".bck";
@@ -128,7 +123,7 @@ bool RecoveryFile::is_detached() const {
}
void RecoveryFile::set_unpacked_dir(
- boost::filesystem::path unpacked_dir) {
+ std::filesystem::path unpacked_dir) {
unpacked_dir_ = std::move(unpacked_dir);
}
@@ -149,7 +144,7 @@ void RecoveryFile::set_security_operation_done(bool security_operation_done) {
security_operation_done_ = security_operation_done;
}
-const boost::filesystem::path& RecoveryFile::unpacked_dir() const {
+const std::filesystem::path& RecoveryFile::unpacked_dir() const {
return unpacked_dir_;
}
@@ -236,9 +231,9 @@ bool RecoveryFile::ReadFileContent() {
}
bool RecoveryFile::WriteAndCommitFileContent() {
- if (bf::exists(path_)) {
- bs::error_code error;
- bf::rename(path_, backup_path_, error);
+ if (fs::exists(path_)) {
+ std::error_code error;
+ fs::rename(path_, backup_path_, error);
if (error) {
LOG(ERROR) << "Cannot backup recovery file:" << path_ <<
", error: " << error;
@@ -246,7 +241,7 @@ bool RecoveryFile::WriteAndCommitFileContent() {
}
}
- bi::stream<bi::file_descriptor_sink> ofs(path_);
+ std::ofstream ofs(path_);
if (!ofs) {
LOG(ERROR) << "Cannot write recovery file";
return false;
@@ -290,8 +285,8 @@ bool RecoveryFile::WriteAndCommitFileContent() {
ofs << (cleanup_ ? "cleanup" : "rollback") << std::endl;
ofs << (security_operation_done_ ? "true" : "false") << std::endl;
ofs.flush();
- ::fsync(ofs->handle());
ofs.close();
+ SyncFile(path_);
Remove(backup_path_);
return true;
@@ -299,4 +294,3 @@ bool RecoveryFile::WriteAndCommitFileContent() {
} // namespace recovery
} // namespace common_installer
-
diff --git a/src/common/recovery_file.h b/src/common/recovery_file.h
index d68fb605..f2d32608 100644
--- a/src/common/recovery_file.h
+++ b/src/common/recovery_file.h
@@ -5,9 +5,8 @@
#ifndef COMMON_RECOVERY_FILE_H_
#define COMMON_RECOVERY_FILE_H_
-#include <boost/filesystem/path.hpp>
-
#include <cstdio>
+#include <filesystem>
#include <memory>
#include <string>
@@ -33,7 +32,7 @@ class RecoveryFile {
* \return new RecoveryFile object
*/
static std::unique_ptr<RecoveryFile> CreateRecoveryFile(
- const boost::filesystem::path& path, RequestType type);
+ const std::filesystem::path& path, RequestType type);
/**
* Opens RecoveryFile object for given request
@@ -43,7 +42,7 @@ class RecoveryFile {
* \return new RecoveryFile object
*/
static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
- const boost::filesystem::path& path);
+ const std::filesystem::path& path);
/** Desctructor */
~RecoveryFile();
@@ -64,7 +63,7 @@ class RecoveryFile {
*
* \param unpacked_dir new unpacked_dir value
*/
- void set_unpacked_dir(boost::filesystem::path unpacked_dir);
+ void set_unpacked_dir(std::filesystem::path unpacked_dir);
/**
* setter for pkgid
@@ -99,7 +98,7 @@ class RecoveryFile {
*
* \return current unpacked_dir
*/
- const boost::filesystem::path& unpacked_dir() const;
+ const std::filesystem::path& unpacked_dir() const;
/**
* getter for pkgid
@@ -144,17 +143,17 @@ class RecoveryFile {
bool WriteAndCommitFileContent();
private:
- RecoveryFile(const boost::filesystem::path& path, RequestType type,
+ RecoveryFile(const std::filesystem::path& path, RequestType type,
bool load);
bool ReadFileContent();
RequestType type_;
- boost::filesystem::path unpacked_dir_;
+ std::filesystem::path unpacked_dir_;
std::string pkgid_;
- boost::filesystem::path path_;
- boost::filesystem::path backup_path_;
+ std::filesystem::path path_;
+ std::filesystem::path backup_path_;
bool backup_done_;
bool cleanup_;
bool security_operation_done_;
diff --git a/src/common/security_registration.cc b/src/common/security_registration.cc
index 56447e83..1204e3d9 100644
--- a/src/common/security_registration.cc
+++ b/src/common/security_registration.cc
@@ -4,9 +4,6 @@
#include "common/security_registration.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/format.hpp>
-
#include <unistd.h>
#include <sys/types.h>
#include <manifest_parser/utils/logging.h>
@@ -23,7 +20,7 @@
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
@@ -32,7 +29,7 @@ using AppDefinedPrivInfo = std::vector<std::pair<std::string, std::string>>;
const std::vector<std::pair<const char*,
app_install_path_type>> kSecurityPolicies = {
- {"/", SECURITY_MANAGER_PATH_PUBLIC_RO},
+ {".", SECURITY_MANAGER_PATH_PUBLIC_RO},
{"bin", SECURITY_MANAGER_PATH_RO},
{"data", SECURITY_MANAGER_PATH_RW},
{"cache", SECURITY_MANAGER_PATH_RW},
@@ -123,7 +120,7 @@ class SecurityContextRequest {
bool PrepareAdditional(const std::string& author_id,
const std::string& api_version,
- const boost::filesystem::path& path,
+ const std::filesystem::path& path,
bool cross_app_rules) {
if (cross_app_rules) {
int error = security_manager_app_inst_req_set_hybrid(req_);
@@ -151,7 +148,7 @@ class SecurityContextRequest {
if (!path.empty()) {
app_install_type type = SM_APP_INSTALL_NONE;
for (auto& policy : kPathPolicies) {
- bf::path root = bf::path(policy.first);
+ fs::path root = fs::path(policy.first);
if (ci::IsSubDir(path, root)) {
type = policy.second;
break;
@@ -325,7 +322,7 @@ class SecurityContextPathRequest {
}
bool PreparePath(const std::string& pkg_type,
- const boost::filesystem::path& path, bool is_readonly_pkg,
+ const std::filesystem::path& path, bool is_readonly_pkg,
bool is_extonly) {
if (path.empty()) {
LOG(ERROR) << "Path is empty. This value must be set";
@@ -333,7 +330,7 @@ class SecurityContextPathRequest {
}
app_install_type type = SM_APP_INSTALL_NONE;
for (auto& policy : kPathPolicies) {
- bf::path root = bf::path(policy.first);
+ fs::path root = fs::path(policy.first);
if (ci::IsSubDir(path, root)) {
type = policy.second;
break;
@@ -358,7 +355,7 @@ class SecurityContextPathRequest {
else
policies = kSecurityPolicies;
for (auto& policy : policies) {
- bf::path subpath = path / policy.first;
+ fs::path subpath = path / policy.first;
if (is_extonly) {
// Now, this is for legacy migraton.
// do not try to access any file before changing label,
@@ -367,9 +364,9 @@ class SecurityContextPathRequest {
if (pkg_type == "wgt" && (subdir == "bin" || subdir == "lib"))
continue;
} else {
- if (!bf::exists(subpath))
+ if (!fs::exists(subpath))
continue;
- if (bf::is_symlink(symlink_status(subpath)) &&
+ if (fs::is_symlink(symlink_status(subpath)) &&
policy.second != SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO) {
LOG(DEBUG) << "Path " << subpath << " is a symlink."
<< "Path will not be registered";
@@ -385,8 +382,8 @@ class SecurityContextPathRequest {
// this is for lib rpk installation. set public RO for contents only.
if (pkg_type == "rpk" && std::string(policy.first) == "lib") {
- for (bf::directory_iterator iter(subpath);
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(subpath);
+ iter != fs::directory_iterator(); ++iter) {
error = security_manager_path_req_add_path(req_,
iter->path().string().c_str(), SECURITY_MANAGER_PATH_PUBLIC_RO);
if (error!= SECURITY_MANAGER_SUCCESS) {
@@ -440,7 +437,7 @@ bool RegisterSecurityContextForManifest(const ci::InstallerContext* context,
std::string* error_message) {
std::string pkg_id = context->pkgid.get();
std::string pkg_type = context->pkg_type.get();
- bf::path path = context->GetPkgPath();
+ fs::path path = context->GetPkgPath();
uid_t uid = context->uid.get();
const ci::CertificateInfo* cert_info = &(context->certificate_info.get());
manifest_x* manifest = context->manifest_data.get();
@@ -562,7 +559,7 @@ bool UnregisterSecurityContextForPkgId(const std::string &pkg_id,
}
bool RegisterSecurityContextForPath(const std::string &pkg_id,
- const std::string& pkg_type, const boost::filesystem::path& path,
+ const std::string& pkg_type, const std::filesystem::path& path,
uid_t uid, bool is_readonly_pkg, std::string* error_message) {
SecurityContextPathRequest req;
if (!req.IsValid()) {
@@ -583,7 +580,7 @@ bool RegisterSecurityContextForPath(const std::string &pkg_id,
}
bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
- const std::string &pkg_type, const boost::filesystem::path& path,
+ const std::string &pkg_type, const std::filesystem::path& path,
uid_t uid, std::string* error_message) {
SecurityContextPathRequest req;
if (!req.IsValid()) {
@@ -603,14 +600,14 @@ bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
return result;
}
-bool HasOwnerRwOtherRoPaths(const boost::filesystem::path& path) {
+bool HasOwnerRwOtherRoPaths(const std::filesystem::path& path) {
for (auto& policy : kSecurityPolicies) {
if (policy.second != SECURITY_MANAGER_PATH_OWNER_RW_OTHER_RO)
continue;
- bf::path subpath = path / policy.first;
+ fs::path subpath = path / policy.first;
LOG(ERROR) << "subpath : " << subpath;
- if (bf::exists(subpath))
+ if (fs::exists(subpath))
return true;
}
diff --git a/src/common/security_registration.h b/src/common/security_registration.h
index cf0ed35e..d4274b98 100644
--- a/src/common/security_registration.h
+++ b/src/common/security_registration.h
@@ -5,10 +5,9 @@
#ifndef COMMON_SECURITY_REGISTRATION_H_
#define COMMON_SECURITY_REGISTRATION_H_
-#include <boost/filesystem/path.hpp>
-
#include <sys/types.h>
+#include <filesystem>
#include <string>
#include <vector>
@@ -85,7 +84,7 @@ bool UnregisterSecurityContextForPkgId(const std::string& pkg_id,
* \return true if success
*/
bool RegisterSecurityContextForPath(const std::string &pkg_id,
- const std::string& pkg_type, const boost::filesystem::path& path,
+ const std::string& pkg_type, const std::filesystem::path& path,
uid_t uid, bool is_readonly_pkg, std::string* error_message);
/**
@@ -103,10 +102,10 @@ bool RegisterSecurityContextForPath(const std::string &pkg_id,
* \return true if success
*/
bool RegisterSecurityContextForPathExternalOnly(const std::string &pkg_id,
- const std::string &pkg_type, const boost::filesystem::path& path,
+ const std::string &pkg_type, const std::filesystem::path& path,
uid_t uid, std::string* error_message);
-bool HasOwnerRwOtherRoPaths(const boost::filesystem::path& path);
+bool HasOwnerRwOtherRoPaths(const std::filesystem::path& path);
} // namespace common_installer
diff --git a/src/common/shared_dirs.cc b/src/common/shared_dirs.cc
index 88fd0ba3..c0f0641c 100644
--- a/src/common/shared_dirs.cc
+++ b/src/common/shared_dirs.cc
@@ -7,11 +7,6 @@
#include <manifest_parser/utils/logging.h>
#include <manifest_parser/utils/version_number.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
-
#include <glib.h>
#include <gio/gio.h>
#include <vcore/Certificate.h>
@@ -27,9 +22,12 @@
#include <cstring>
#include <cstdio>
#include <exception>
+#include <filesystem>
#include <iterator>
+#include <optional>
#include <regex>
#include <string>
+#include <system_error>
#include <utility>
#include <vector>
#include <tuple>
@@ -42,10 +40,8 @@
#include "common/utils/user_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bpo = boost::program_options;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -84,37 +80,40 @@ const char kExternalStoragePrivilege[] =
"http://tizen.org/privilege/externalstorage.appdata";
const char kSystemShareGroupName[] = "system_share";
const char kSubssesionDir[] = "subsession";
+
// the input path should be root directory of package.
// for example: "../apps_rw/pkgid" or "../.shared/pkgid"
-bool SetPackageDirectoryOwnerAndPermissions(const bf::path& path, uid_t uid) {
- boost::optional<gid_t> gid = ci::GetGidByUid(uid);
+bool SetPackageDirectoryOwnerAndPermissions(const fs::path& path, uid_t uid) {
+ std::optional<gid_t> gid = ci::GetGidByUid(uid);
if (!gid)
return false;
- bf::perms perms755 = bf::all_all ^ bf::group_write ^ bf::others_write;
- bf::perms perms644 =
- bf::owner_read | bf::owner_write | bf::group_read | bf::others_read;
- bf::perms perms_setgid = perms755 | bf::set_gid_on_exe;
- boost::optional<gid_t> system_share =
+ using fs::perms;
+ perms perms755 = perms::all ^ perms::group_write ^ perms::others_write;
+ perms perms644 = perms::owner_read | perms::owner_write |
+ perms::group_read | perms::others_read;
+ perms perms_setgid = perms755 | perms::set_gid;
+
+ std::optional<gid_t> system_share =
ci::GetGidByGroupName(kSystemShareGroupName);
// root path
if (!ci::SetDirOwnershipAndPermissions(path, perms755, uid, *gid))
return false;
- for (bf::recursive_directory_iterator iter(path);
- iter != bf::recursive_directory_iterator(); ++iter) {
- if (bf::is_symlink(symlink_status(iter->path()))) {
+ for (fs::recursive_directory_iterator iter(path);
+ iter != fs::recursive_directory_iterator(); ++iter) {
+ if (fs::is_symlink(symlink_status(iter->path()))) {
// skip symlink path
continue;
- } else if (bf::is_directory(iter->path()) && iter.level() == 0 &&
+ } else if (fs::is_directory(iter->path()) && iter.depth() == 0 &&
(iter->path().filename() == ".mmc" ||
iter->path().filename() == ".pkg" ||
iter->path().filename() == "tep")) {
// skip path which is related to mount or directory installer creates
continue;
- } else if (bf::is_directory(iter->path())) {
+ } else if (fs::is_directory(iter->path())) {
bool is_rw = false;
- if (iter.level() == 0 &&
+ if (iter.depth() == 0 &&
(iter->path().filename() == kData ||
iter->path().filename() == kCache))
is_rw = true;
@@ -124,7 +123,7 @@ bool SetPackageDirectoryOwnerAndPermissions(const bf::path& path, uid_t uid) {
return false;
} else {
bool is_bin = false;
- if (iter.level() == 1 && iter->path().parent_path().filename() == "bin")
+ if (iter.depth() == 1 && iter->path().parent_path().filename() == "bin")
is_bin = true;
if (!ci::SetDirOwnershipAndPermissions(
iter->path(), is_bin ? perms755 : perms644, uid, *gid))
@@ -134,17 +133,17 @@ bool SetPackageDirectoryOwnerAndPermissions(const bf::path& path, uid_t uid) {
return true;
}
-bf::path GetDirectoryPathForStorage(uid_t user, std::string apps_prefix) {
+fs::path GetDirectoryPathForStorage(uid_t user, std::string apps_prefix) {
std::string username = ci::GetUsernameByUid(user);
if (username.empty())
return {};
- bf::path apps_rw;
- apps_rw = bf::path(apps_prefix.c_str()) / username / "apps_rw";
+ fs::path apps_rw;
+ apps_rw = fs::path(apps_prefix.c_str()) / username / "apps_rw";
return apps_rw;
}
-bool DeleteSharedDataDirectories(const bf::path& path,
+bool DeleteSharedDataDirectories(const fs::path& path,
const std::string& pkgid) {
if (!ci::RemoveAll(path / pkgid / kSharedDataDir))
return false;
@@ -158,20 +157,20 @@ bool DeleteSharedDataDirectories(const bf::path& path,
return true;
}
-bool CreateSharedDataDirectories(const bf::path& path,
+bool CreateSharedDataDirectories(const fs::path& path,
const std::string& pkgid) {
if (!ci::CreateDir(path / kSharedDir / pkgid / kData) ||
!ci::CreateDir(path / kSharedTmpDir / pkgid) ||
!ci::CreateDir(path / pkgid / kShared))
return false;
- bf::current_path(path / pkgid / kShared);
- if (bf::exists(path / pkgid / kShared / kData))
+ fs::current_path(path / pkgid / kShared);
+ if (fs::exists(path / pkgid / kShared / kData))
return true;
- bf::path relative_path = ci::RelativePath(path / kSharedDir / pkgid / kData,
- bf::current_path() / kData);
- bs::error_code error;
- bf::create_symlink(relative_path, kData, error);
+ fs::path relative_path = fs::relative(path / kSharedDir / pkgid / kData,
+ fs::current_path());
+ std::error_code error;
+ fs::create_symlink(relative_path, kData, error);
if (error) {
LOG(ERROR) << "Failed to create symlink : " << error.message();
return false;
@@ -180,8 +179,8 @@ bool CreateSharedDataDirectories(const bf::path& path,
return true;
}
-bool DeleteDirectories(const bf::path& app_dir, const std::string& pkgid) {
- bf::path base_dir = app_dir / pkgid;
+bool DeleteDirectories(const fs::path& app_dir, const std::string& pkgid) {
+ fs::path base_dir = app_dir / pkgid;
if (!ci::RemoveAll(base_dir))
return false;
if (!DeleteSharedDataDirectories(app_dir, pkgid))
@@ -189,35 +188,35 @@ bool DeleteDirectories(const bf::path& app_dir, const std::string& pkgid) {
return true;
}
-bool CreateSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
+bool CreateSymlinkFiles(const fs::path& src_dir, const fs::path& dst_dir) {
std::vector<std::string> rofiles(kReadOnlyEntries);
- for (bf::directory_iterator file(src_dir);
- file != bf::directory_iterator();
+ for (fs::directory_iterator file(src_dir);
+ file != fs::directory_iterator();
++file) {
- if (bf::is_regular_file(file->path())) {
- bf::path current(file->path());
- bf::path file_name = current.filename();
+ if (fs::is_regular_file(file->path())) {
+ fs::path current(file->path());
+ fs::path file_name = current.filename();
LOG(DEBUG) << "file_name: " << file_name;
rofiles.push_back(file_name.string());
}
}
- bs::error_code error;
+ std::error_code error;
for (auto& entry : rofiles) {
- bf::path src_path = src_dir / entry;
- bf::path dst_path = dst_dir / entry;
- if (!bf::exists(src_path)) {
+ fs::path src_path = src_dir / entry;
+ fs::path dst_path = dst_dir / entry;
+ if (!fs::exists(src_path)) {
// check if symlink for .mmc/bin,lib,res, then do not skip
- if (!bf::is_symlink(symlink_status(src_path))) {
+ if (!fs::is_symlink(symlink_status(src_path))) {
LOG(INFO) << "src_path not exist : " << src_path;
continue;
}
}
- if (bf::exists(dst_path) || bf::is_symlink(symlink_status(dst_path))) {
+ if (fs::exists(dst_path) || fs::is_symlink(symlink_status(dst_path))) {
LOG(WARNING) << "dst_path exist, skip : " << dst_path;
continue;
}
- bf::create_symlink(src_path, dst_path, error);
+ fs::create_symlink(src_path, dst_path, error);
if (error) {
LOG(ERROR) << "Symlink creation failure src_path: " << src_path
<< " dst_path: " << dst_path;
@@ -228,15 +227,15 @@ bool CreateSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
return true;
}
-bool DeleteSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
- bs::error_code error;
- for (bf::directory_iterator file(dst_dir);
- file != bf::directory_iterator();
+bool DeleteSymlinkFiles(const fs::path& src_dir, const fs::path& dst_dir) {
+ std::error_code error;
+ for (fs::directory_iterator file(dst_dir);
+ file != fs::directory_iterator();
++file) {
- bf::path current(file->path());
- if (!bf::is_symlink(symlink_status(current)))
+ fs::path current(file->path());
+ if (!fs::is_symlink(symlink_status(current)))
continue;
- bf::path resolved_path = bf::read_symlink(current, error);
+ fs::path resolved_path = fs::read_symlink(current, error);
if (error) {
LOG(ERROR) << "Failed to get resolved path of symlink: " << current
<< ", error: " << error.message();
@@ -244,13 +243,13 @@ bool DeleteSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
}
LOG(DEBUG) << "resolved_path: " << resolved_path;
- bf::path parent = resolved_path.parent_path();
+ fs::path parent = resolved_path.parent_path();
if (parent.empty() || (parent != src_dir)) {
LOG(WARNING) << "Parent is empty or not equal to src, parent: ("
<< parent << ")";
continue;
}
- bf::remove(current, error);
+ fs::remove(current, error);
if (error) {
LOG(ERROR) << "Symlink deletion failure for: " << current
<< ", error: " << error.message();
@@ -258,9 +257,9 @@ bool DeleteSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
}
LOG(DEBUG) << "removed: " << current;
}
- bf::path shared_res = dst_dir / kSharedResDir;
- if (bf::is_symlink(symlink_status(shared_res))) {
- bf::remove(shared_res, error);
+ fs::path shared_res = dst_dir / kSharedResDir;
+ if (fs::is_symlink(symlink_status(shared_res))) {
+ fs::remove(shared_res, error);
if (error) {
LOG(ERROR) << "Symlink deletion failure for: " << shared_res
<< ", error: " << error.message();
@@ -270,11 +269,11 @@ bool DeleteSymlinkFiles(const bf::path& src_dir, const bf::path& dst_dir) {
return true;
}
-bool CreateStorageDirectories(const boost::filesystem::path& root_path,
+bool CreateStorageDirectories(const fs::path& root_path,
const std::string& pkgid,
bool trusted, bool shareddata,
const std::vector<const char*> additional_dirs) {
- bf::path path(root_path / pkgid);
+ fs::path path(root_path / pkgid);
if (!ci::CreateDir(path)) {
LOG(ERROR) << "Failed to create dir: " << path;
return false;
@@ -285,9 +284,9 @@ bool CreateStorageDirectories(const boost::filesystem::path& root_path,
if (trusted)
dirs.push_back(kSharedTrustedDir);
- bs::error_code error;
+ std::error_code error;
for (auto& entry : dirs) {
- bf::path subpath = path / entry;
+ fs::path subpath = path / entry;
if (!ci::CreateDir(subpath)) {
LOG(ERROR) << "Failed to create directory: " << subpath;
return false;
@@ -302,7 +301,7 @@ bool CreateStorageDirectories(const boost::filesystem::path& root_path,
return false;
}
- bf::path shared_cache_path = path / kSharedCacheDir;
+ fs::path shared_cache_path = path / kSharedCacheDir;
// remove shared/cache (do not support)
if (!ci::RemoveAll(shared_cache_path))
return false;
@@ -310,7 +309,7 @@ bool CreateStorageDirectories(const boost::filesystem::path& root_path,
return true;
}
-bool BackupSharedDataDirectories(const bf::path& apps_rw,
+bool BackupSharedDataDirectories(const fs::path& apps_rw,
const std::string& pkgid) {
if (!ci::MakeBackup(apps_rw / pkgid / kSharedDataDir))
return false;
@@ -321,7 +320,7 @@ bool BackupSharedDataDirectories(const bf::path& apps_rw,
return true;
}
-bool RestoreSharedDataDirectories(const bf::path& apps_rw,
+bool RestoreSharedDataDirectories(const fs::path& apps_rw,
const std::string& pkgid) {
if (!ci::RestoreBackup(apps_rw / pkgid / kSharedDataDir))
return false;
@@ -332,7 +331,7 @@ bool RestoreSharedDataDirectories(const bf::path& apps_rw,
return true;
}
-bool RemoveBackupSharedDataDirectories(const bf::path& apps_rw,
+bool RemoveBackupSharedDataDirectories(const fs::path& apps_rw,
const std::string& pkgid) {
if (!ci::RemoveBackup(apps_rw / pkgid / kSharedDataDir))
return false;
@@ -345,7 +344,7 @@ bool RemoveBackupSharedDataDirectories(const bf::path& apps_rw,
bool CreateExternalUserDirectories(uid_t user, const std::string& pkgid,
const std::string& apps_prefix) {
- boost::optional<gid_t> gid = ci::GetGidByUid(user);
+ std::optional<gid_t> gid = ci::GetGidByUid(user);
if (!gid)
return false;
@@ -358,7 +357,7 @@ bool CreateExternalUserDirectories(uid_t user, const std::string& pkgid,
LOG(DEBUG) << "Creating directories for uid: " << user << ", gid: "
<< *gid;
- bf::path apps_rw = GetDirectoryPathForStorage(user, apps_prefix);
+ fs::path apps_rw = GetDirectoryPathForStorage(user, apps_prefix);
if (apps_rw.empty()) {
LOG(DEBUG) << "Directory not exists: " << apps_rw;
return false;
@@ -391,17 +390,17 @@ std::string GetDirectoryPathForExternalStorage() {
bool PerformExternalDirectoryCreationForUser(uid_t user,
const std::string& pkgid) {
- bf::path storage_path = GetExternalCardPath();
+ fs::path storage_path = GetExternalCardPath();
- if (!bf::exists(storage_path)) {
+ if (!fs::exists(storage_path)) {
LOG(WARNING) << "External storage (SD Card) is not mounted.";
return false;
}
- bf::path storage_apps_path = storage_path / "apps";
- if (!bf::exists(storage_apps_path)) {
- bs::error_code error;
- bf::create_directories(storage_apps_path, error);
+ fs::path storage_apps_path = storage_path / "apps";
+ if (!fs::exists(storage_apps_path)) {
+ std::error_code error;
+ fs::create_directories(storage_apps_path, error);
if (error) {
LOG(ERROR) << "Failed to create directory: "
<< storage_apps_path.c_str();
@@ -413,11 +412,11 @@ bool PerformExternalDirectoryCreationForUser(uid_t user,
return false;
for (auto& lw_user : GetLightUserList(user)) {
- bf::path storage_apps_lw_path = storage_apps_path
+ fs::path storage_apps_lw_path = storage_apps_path
/ kSubssesionDir / lw_user / "apps";
- if (!bf::exists(storage_apps_lw_path)) {
- bs::error_code error;
- bf::create_directories(storage_apps_lw_path, error);
+ if (!fs::exists(storage_apps_lw_path)) {
+ std::error_code error;
+ fs::create_directories(storage_apps_lw_path, error);
if (error) {
LOG(ERROR) << "Failed to create directory: "
<< storage_apps_lw_path.c_str();
@@ -435,20 +434,20 @@ bool PerformExternalDirectoryCreationForUser(uid_t user,
bool PerformExternalDirectoryDeletionForUser(uid_t user,
const std::string& pkgid) {
- bf::path storage_path = GetExternalCardPath();
- if (!bf::exists(storage_path)) {
+ fs::path storage_path = GetExternalCardPath();
+ if (!fs::exists(storage_path)) {
LOG(WARNING) << "External storage (SD Card) is not mounted. "
<< "It will be ignored";
return true;
}
- bf::path storage_apps_path = bf::path(storage_path) / "apps";
+ fs::path storage_apps_path = fs::path(storage_path) / "apps";
if (!DeleteDirectories(
GetDirectoryPathForStorage(user, storage_apps_path.string()), pkgid))
return false;
for (auto& lw_user : GetLightUserList(user)) {
- bf::path storage_apps_lw_path =
+ fs::path storage_apps_lw_path =
storage_apps_path / kSubssesionDir / lw_user / "apps";
if (!DeleteDirectories(
GetDirectoryPathForStorage(user, storage_apps_lw_path.string()),
@@ -534,8 +533,8 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid, bool trusted,
bool shareddata, bool is_readonly,
const std::vector<const char*> additional_dirs) {
// create skel dir
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!::CreateStorageDirectories(skel_apps_rw, pkgid, trusted, shareddata,
additional_dirs)) {
LOG(ERROR) << "Failed to create skeleton storage directories";
@@ -551,7 +550,7 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid, bool trusted,
}
if (!is_readonly) {
- bf::path src_dir = bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
+ fs::path src_dir = fs::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
if (!CreateSymlinkFiles(src_dir, skel_apps_rw / pkgid))
return false;
}
@@ -560,8 +559,8 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid, bool trusted,
UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
@@ -582,7 +581,7 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid, bool trusted,
if (shareddata) {
std::vector<std::string> shared_dirs(kSharedDataEntries);
for (const auto& entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
+ fs::path shared_dst = apps_rw / entry / pkgid;
if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
return false;
}
@@ -603,8 +602,8 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid, bool trusted,
bool DeletePerUserStorageDirectories(const std::string& pkgid,
bool keep_rwdata) {
// delete skel dir
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!ci::RemoveAll(skel_apps_rw / pkgid)) {
LOG(ERROR) << "Failed to delete skeleton storage directories";
return false;
@@ -617,8 +616,8 @@ bool DeletePerUserStorageDirectories(const std::string& pkgid,
UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
@@ -642,7 +641,7 @@ bool DeletePerUserStorageDirectories(const std::string& pkgid,
return true;
}
-bool CreateStorageDirectories(const boost::filesystem::path& path,
+bool CreateStorageDirectories(const fs::path& path,
const std::string& pkgid, uid_t uid,
bool trusted, bool shareddata) {
if (!::CreateStorageDirectories(path, pkgid, trusted,
@@ -657,7 +656,7 @@ bool CreateStorageDirectories(const boost::filesystem::path& path,
if (shareddata) {
std::vector<std::string> shared_dirs(kSharedDataEntries);
for (const auto& entry : shared_dirs) {
- bf::path shared_dst = path / entry / pkgid;
+ fs::path shared_dst = path / entry / pkgid;
if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
return false;
}
@@ -674,7 +673,7 @@ bool CreateStorageDirectories(const boost::filesystem::path& path,
return true;
}
-void RemoveRWDirectories(const boost::filesystem::path& root) {
+void RemoveRWDirectories(const fs::path& root) {
if (!RemoveAll(root / kCache))
LOG(ERROR) << "Failed to remove packaged cache directory";
if (!RemoveAll(root / kData))
@@ -687,7 +686,7 @@ void RemoveRWDirectories(const boost::filesystem::path& root) {
LOG(ERROR) << "Failed to remove packaged shared/trusted directory";
}
-bool DeleteSharedDirectories(const bf::path& path,
+bool DeleteSharedDirectories(const fs::path& path,
const std::string& pkgid) {
return DeleteSharedDataDirectories(path, pkgid);
}
@@ -704,13 +703,13 @@ bool DeleteUserExternalDirectories(const std::string& pkgid) {
LOG(DEBUG) << "Deleting external directories of " << pkgid
<< ", for uid: " << uid;
- bf::path apps_rw(std::get<2>(l) / "apps_rw");
+ fs::path apps_rw(std::get<2>(l) / "apps_rw");
if (!DeleteDirectories(apps_rw, pkgid)) {
return false;
}
for (auto& lw_user : GetLightUserList(uid)) {
- bf::path apps_rw_lw(std::get<2>(l) / kSubssesionDir / lw_user / "apps_rw");
+ fs::path apps_rw_lw(std::get<2>(l) / kSubssesionDir / lw_user / "apps_rw");
if (!DeleteDirectories(apps_rw_lw, pkgid))
return false;
}
@@ -720,8 +719,8 @@ bool DeleteUserExternalDirectories(const std::string& pkgid) {
}
bool CreateGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
- bf::path src_dir = bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
- if (!bf::exists(src_dir)) {
+ fs::path src_dir = fs::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
+ if (!fs::exists(src_dir)) {
LOG(ERROR) << "src_dir not exists";
return false;
}
@@ -735,8 +734,8 @@ bool CreateGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
if (pkg_query.IsPackageInstalled())
continue;
- bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
@@ -744,8 +743,8 @@ bool CreateGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
"apps_rw");
for (auto& apps_rw : apps_rw_paths) {
- bf::path dst_dir = apps_rw / pkgid;
- if (!bf::exists(dst_dir)) {
+ fs::path dst_dir = apps_rw / pkgid;
+ if (!fs::exists(dst_dir)) {
LOG(WARNING) << "dst_dir not exists";
continue;
}
@@ -759,16 +758,16 @@ bool CreateGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
}
bool CreateGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
- bf::path src_dir = bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
- if (!bf::exists(src_dir)) {
+ fs::path src_dir = fs::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
+ if (!fs::exists(src_dir)) {
LOG(WARNING) << "src_dir(" << src_dir << ") not exists";
return true;
}
tzplatform_set_user(uid);
- bf::path dst_dir = bf::path(tzplatform_getenv(TZ_USER_APP)) / pkgid;
+ fs::path dst_dir = fs::path(tzplatform_getenv(TZ_USER_APP)) / pkgid;
tzplatform_reset_user();
- if (!bf::exists(dst_dir)) {
+ if (!fs::exists(dst_dir)) {
LOG(WARNING) << "dst_dir not exists";
return true;
}
@@ -778,8 +777,8 @@ bool CreateGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
}
bool DeleteGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
- bf::path src_dir = bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
- if (!bf::exists(src_dir)) {
+ fs::path src_dir = fs::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
+ if (!fs::exists(src_dir)) {
LOG(WARNING) << "src_dir(" << src_dir << ") not exists";
return true;
}
@@ -794,16 +793,16 @@ bool DeleteGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
if (pkg_query.IsPackageInstalled())
continue;
- bf::path owner_apps_rw = std::get<2>(l) / "apps_rw";
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = std::get<2>(l) / "apps_rw";
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
"apps_rw");
for (auto& apps_rw : apps_rw_paths) {
- bf::path dst_dir = apps_rw / pkgid;
- if (!bf::exists(dst_dir)) {
+ fs::path dst_dir = apps_rw / pkgid;
+ if (!fs::exists(dst_dir)) {
LOG(WARNING) << "dst_dir not exists";
continue;
}
@@ -817,16 +816,16 @@ bool DeleteGlobalAppSymlinksForAllUsers(const std::string& pkgid) {
}
bool DeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
- bf::path src_dir = bf::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
- if (!bf::exists(src_dir)) {
+ fs::path src_dir = fs::path(tzplatform_getenv(TZ_SYS_RW_APP)) / pkgid;
+ if (!fs::exists(src_dir)) {
LOG(ERROR) << "src_dir not exists";
return false;
}
tzplatform_set_user(uid);
- bf::path dst_dir = bf::path(tzplatform_getenv(TZ_USER_APP)) / pkgid;
+ fs::path dst_dir = fs::path(tzplatform_getenv(TZ_USER_APP)) / pkgid;
tzplatform_reset_user();
- if (!bf::exists(dst_dir)) {
+ if (!fs::exists(dst_dir)) {
LOG(WARNING) << "dst_dir not exists";
return true;
}
@@ -834,12 +833,12 @@ bool DeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid) {
return result;
}
-bool SetPackageDirectoryOwnerAndPermissions(const bf::path& path, uid_t uid) {
+bool SetPackageDirectoryOwnerAndPermissions(const fs::path& path, uid_t uid) {
return ::SetPackageDirectoryOwnerAndPermissions(path, uid);
}
bool ShouldSupportLegacySharedDataDir(const std::string& api_version) {
- if (bf::exists(kDisableLegacySharedDataDirSupport))
+ if (fs::exists(kDisableLegacySharedDataDirSupport))
return false;
utils::VersionNumber api_ver(api_version);
if (api_ver < ver30)
@@ -849,11 +848,11 @@ bool ShouldSupportLegacySharedDataDir(const std::string& api_version) {
}
bool CreateSharedDataDir(const std::string& pkgid, uid_t uid) {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
if (!CreateSharedDataDirectories(apps_rw, pkgid))
return false;
- bf::path path = apps_rw / pkgid;
+ fs::path path = apps_rw / pkgid;
std::string error_message;
if (!ci::RegisterSecurityContextForPath(pkgid, {}, path, uid, false,
&error_message)) {
@@ -867,8 +866,8 @@ bool CreateSharedDataDir(const std::string& pkgid, uid_t uid) {
bool CreatePerUserSharedDataDir(const std::string& pkgid) {
// create skel dir
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
LOG(DEBUG) << "Creating directory : " << skel_apps_rw;
if (!CreateSharedDataDirectories(skel_apps_rw, pkgid))
return false;
@@ -887,8 +886,8 @@ bool CreatePerUserSharedDataDir(const std::string& pkgid) {
uid_t uid = std::get<0>(l);
LOG(DEBUG) << "Adding shareddata directory for uid: " << uid;
- bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
@@ -900,7 +899,7 @@ bool CreatePerUserSharedDataDir(const std::string& pkgid) {
std::vector<std::string> shared_dirs(kSharedDataEntries);
for (const auto& entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
+ fs::path shared_dst = apps_rw / entry / pkgid;
if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
return false;
}
@@ -918,13 +917,13 @@ bool CreatePerUserSharedDataDir(const std::string& pkgid) {
}
bool DeleteSharedDataDir(const std::string& pkgid, uid_t uid) {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
return DeleteSharedDataDirectories(apps_rw, pkgid);
}
bool DeletePerUserSharedDataDir(const std::string& pkgid) {
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!DeleteSharedDataDirectories(skel_apps_rw, pkgid))
return false;
@@ -932,8 +931,8 @@ bool DeletePerUserSharedDataDir(const std::string& pkgid) {
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
@@ -948,21 +947,21 @@ bool DeletePerUserSharedDataDir(const std::string& pkgid) {
}
bool BackupSharedDataDir(const std::string& pkgid, uid_t uid) {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
return BackupSharedDataDirectories(apps_rw, pkgid);
}
bool BackupPerUserSharedDataDir(const std::string& pkgid) {
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!BackupSharedDataDirectories(skel_apps_rw, pkgid))
return false;
ci::UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
@@ -978,7 +977,7 @@ bool BackupPerUserSharedDataDir(const std::string& pkgid) {
}
bool RestoreSharedDataDir(const std::string& pkgid, uid_t uid) {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
if (!RestoreSharedDataDirectories(apps_rw, pkgid))
return false;
@@ -987,7 +986,7 @@ bool RestoreSharedDataDir(const std::string& pkgid, uid_t uid) {
std::vector<std::string> shared_dirs(kSharedDataEntries);
for (const auto& entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
+ fs::path shared_dst = apps_rw / entry / pkgid;
if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
return false;
}
@@ -1004,8 +1003,8 @@ bool RestoreSharedDataDir(const std::string& pkgid, uid_t uid) {
}
bool RestorePerUserSharedDataDir(const std::string& pkgid) {
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!RestoreSharedDataDirectories(skel_apps_rw, pkgid))
return false;
@@ -1013,8 +1012,8 @@ bool RestorePerUserSharedDataDir(const std::string& pkgid) {
ci::UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
@@ -1029,7 +1028,7 @@ bool RestorePerUserSharedDataDir(const std::string& pkgid) {
std::vector<std::string> shared_dirs(kSharedDataEntries);
for (const auto& entry : shared_dirs) {
- bf::path shared_dst = apps_rw / entry / pkgid;
+ fs::path shared_dst = apps_rw / entry / pkgid;
if (!::SetPackageDirectoryOwnerAndPermissions(shared_dst, uid))
return false;
}
@@ -1047,21 +1046,21 @@ bool RestorePerUserSharedDataDir(const std::string& pkgid) {
}
bool RemoveBackupSharedDataDir(const std::string& pkgid, uid_t uid) {
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
return RemoveBackupSharedDataDirectories(apps_rw, pkgid);
}
bool RemoveBackupPerUserSharedDataDir(const std::string& pkgid) {
- bf::path skel_apps_rw = bf::path(tzplatform_getenv(TZ_SYS_ETC)) /
- bf::path(kSkelAppDir);
+ fs::path skel_apps_rw = fs::path(tzplatform_getenv(TZ_SYS_ETC)) /
+ fs::path(kSkelAppDir);
if (!RemoveBackupSharedDataDirectories(skel_apps_rw, pkgid))
return false;
ci::UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw = ci::GetRootAppPath(false, uid);
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw = ci::GetRootAppPath(false, uid);
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
diff --git a/src/common/shared_dirs.h b/src/common/shared_dirs.h
index 939aa4a4..f73ae842 100644
--- a/src/common/shared_dirs.h
+++ b/src/common/shared_dirs.h
@@ -5,9 +5,9 @@
#ifndef COMMON_SHARED_DIRS_H_
#define COMMON_SHARED_DIRS_H_
-#include <boost/filesystem/path.hpp>
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
#include <string>
#include <vector>
@@ -92,7 +92,7 @@ bool CreatePerUserStorageDirectories(const std::string& pkgid,
*
* \return true if succeed, false otherwise
*/
-bool CreateStorageDirectories(const boost::filesystem::path& path,
+bool CreateStorageDirectories(const std::filesystem::path& path,
const std::string& pkgid, uid_t uid,
bool trusted, bool shareddata);
@@ -113,7 +113,7 @@ bool DeletePerUserStorageDirectories(const std::string& pkgid,
*
* \param path base path, which contains rw directories
*/
-void RemoveRWDirectories(const boost::filesystem::path& root);
+void RemoveRWDirectories(const std::filesystem::path& root);
/**
* \brief Deletes shared directories in path
@@ -123,7 +123,7 @@ void RemoveRWDirectories(const boost::filesystem::path& root);
*
* \return true if succeed, false otherwise
*/
-bool DeleteSharedDirectories(const boost::filesystem::path& path,
+bool DeleteSharedDirectories(const std::filesystem::path& path,
const std::string& pkgid);
/**
@@ -192,7 +192,7 @@ bool DeleteGlobalAppSymlinksForUser(const std::string& pkgid, uid_t uid);
*
* \return true if succeed, false otherwise
*/
-bool SetPackageDirectoryOwnerAndPermissions(const boost::filesystem::path& path,
+bool SetPackageDirectoryOwnerAndPermissions(const std::filesystem::path& path,
uid_t uid);
/**
diff --git a/src/common/signature.cc b/src/common/signature.cc
index eb3c2ea1..1e1f661b 100644
--- a/src/common/signature.cc
+++ b/src/common/signature.cc
@@ -7,6 +7,8 @@
#include <tzplatform_config.h>
#include <unistd.h>
+#include <filesystem>
+#include <fstream>
#include <string>
#include <regex>
@@ -16,14 +18,13 @@
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
-namespace bi = boost::iostreams;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
bool Signature::SetPath() {
- bf::path path = bf::path((is_readonly_package_) ?
+ fs::path path = fs::path((is_readonly_package_) ?
tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE)) /
"signatures";
if (!CreateDir(path))
@@ -31,15 +32,15 @@ bool Signature::SetPath() {
file_path_ = path / std::string(pkgid_ + ".txt");
backup_path_ = path / std::string(pkgid_ + "_backup.txt");
- if (bf::exists(backup_path_))
- bf::remove(backup_path_);
- if (bf::exists(file_path_))
- bf::rename(file_path_, backup_path_);
+ if (fs::exists(backup_path_))
+ fs::remove(backup_path_);
+ if (fs::exists(file_path_))
+ fs::rename(file_path_, backup_path_);
return true;
}
bool Signature::CheckSignatures(bool check_reference, PrivilegeLevel* level,
- boost::filesystem::path sig_root_path,
+ std::filesystem::path sig_root_path,
std::string *error_message) {
if (!ValidateSignatures(sig_root_path, level, cert_info_,
check_reference, error_message))
@@ -47,7 +48,7 @@ bool Signature::CheckSignatures(bool check_reference, PrivilegeLevel* level,
return true;
}
-bool Signature::GetPrivilegeLevel(boost::filesystem::path sig_root_path,
+bool Signature::GetPrivilegeLevel(std::filesystem::path sig_root_path,
PrivilegeLevel* level,
std::string* error_message) {
bool check_reference = true;
@@ -86,21 +87,21 @@ bool Signature::CheckMetadataPrivilege(PrivilegeLevel level,
return true;
}
-bool Signature::StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
+bool Signature::StoreSignature(std::ofstream* ofs,
const ValidationCore::CertificatePtr& cert,
const ValidationCore::CertificatePtr& im_cert,
const ValidationCore::CertificatePtr& root_cert) {
if (!ofs)
return false;
- *ofs << ((cert) ? cert->getBase64().c_str() : "") << std::endl;
- *ofs << ((im_cert) ? im_cert->getBase64().c_str() : "") << std::endl;
- *ofs << ((root_cert) ? root_cert->getBase64().c_str() : "") << std::endl;
+ *ofs << ((cert) ? cert->getBase64() : "") << std::endl;
+ *ofs << ((im_cert) ? im_cert->getBase64() : "") << std::endl;
+ *ofs << ((root_cert) ? root_cert->getBase64() : "") << std::endl;
return true;
}
bool Signature::Store() {
bool ret = true;
- bi::stream<bi::file_descriptor_sink> ofs(file_path_);
+ std::ofstream ofs(file_path_);
if (!StoreSignature(&ofs,
cert_info_->dist2_cert.get(),
cert_info_->dist2_im_cert.get(),
@@ -111,25 +112,25 @@ bool Signature::Store() {
cert_info_->dist_root_cert.get()))
ret = false;
ofs.flush();
- ::fsync(ofs->handle());
ofs.close();
+ SyncFile(file_path_);
return ret;
}
-bool Signature::RemoveSignature(const bf::path& path) {
+bool Signature::RemoveSignature(const fs::path& path) {
// dist signatures cannot be removed when mount install/update
if (request_type_ == RequestType::MountInstall ||
request_type_ == RequestType::MountUpdate)
return true;
- for (bf::directory_iterator file(path);
- file != bf::directory_iterator();
+ for (fs::directory_iterator file(path);
+ file != fs::directory_iterator();
++file) {
try {
- bf::path file_path(file->path());
+ fs::path file_path(file->path());
- if (bf::is_symlink(symlink_status(file_path)) ||
- bf::is_directory(file_path))
+ if (fs::is_symlink(symlink_status(file_path)) ||
+ fs::is_directory(file_path))
continue;
std::regex distributor_regex("^(signature)([1-9][0-9]*)(\\.xml)");
@@ -139,7 +140,7 @@ bool Signature::RemoveSignature(const bf::path& path) {
return false;
}
}
- } catch (const bf::filesystem_error& error) {
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to remove signature files: " << error.what();
return false;
}
@@ -149,17 +150,17 @@ bool Signature::RemoveSignature(const bf::path& path) {
return true;
}
-bool Signature::SaveSignature(const bf::path& path) {
+bool Signature::SaveSignature(const fs::path& path) {
if (!SetPath() || !Store() || !RemoveSignature(path))
return false;
return true;
}
-const bf::path& Signature::GetFilePath() const {
+const fs::path& Signature::GetFilePath() const {
return file_path_;
}
-const bf::path& Signature::GetBackupPath() const {
+const fs::path& Signature::GetBackupPath() const {
return backup_path_;
}
diff --git a/src/common/signature.h b/src/common/signature.h
index 24847f61..499237dc 100644
--- a/src/common/signature.h
+++ b/src/common/signature.h
@@ -7,15 +7,12 @@
#include <pkgmgrinfo_basic.h>
-#include <boost/iostreams/stream.hpp>
-#include <boost/iostreams/device/file_descriptor.hpp>
-
+#include <filesystem>
#include <string>
#include "common/installer_context.h"
-namespace bf = boost::filesystem;
-namespace bi = boost::iostreams;
+namespace fs = std::filesystem;
namespace common_installer {
@@ -31,24 +28,24 @@ class Signature {
virtual ~Signature() = default;
virtual bool CheckSignatures(bool check_reference, PrivilegeLevel* level,
- boost::filesystem::path sig_root_path,
+ std::filesystem::path sig_root_path,
std::string* error_message);
- bool GetPrivilegeLevel(boost::filesystem::path sig_root_path,
+ bool GetPrivilegeLevel(std::filesystem::path sig_root_path,
PrivilegeLevel* level,
std::string* error_message);
bool CheckMetadataPrivilege(PrivilegeLevel level, manifest_x* manifest,
std::string* error_message);
bool CheckSignatureMismatch(std::string* error_message);
bool SetPath();
- bool StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
+ bool StoreSignature(std::ofstream* ofs,
const ValidationCore::CertificatePtr& cert,
const ValidationCore::CertificatePtr& im_cert,
const ValidationCore::CertificatePtr& root_cert);
bool Store();
- bool RemoveSignature(const bf::path& path);
- bool SaveSignature(const bf::path& path);
- const bf::path& GetFilePath() const;
- const bf::path& GetBackupPath() const;
+ bool RemoveSignature(const fs::path& path);
+ bool SaveSignature(const fs::path& path);
+ const fs::path& GetFilePath() const;
+ const fs::path& GetBackupPath() const;
protected:
RequestType request_type_;
@@ -56,8 +53,8 @@ class Signature {
bool is_readonly_package_;
bool skip_check_reference_;
CertificateInfo* cert_info_;
- bf::path file_path_;
- bf::path backup_path_;
+ fs::path file_path_;
+ fs::path backup_path_;
};
} // namespace common_installer
diff --git a/src/common/step/backup/step_backup_icons.cc b/src/common/step/backup/step_backup_icons.cc
index b8171fb0..690049be 100644
--- a/src/common/step/backup/step_backup_icons.cc
+++ b/src/common/step/backup/step_backup_icons.cc
@@ -6,17 +6,14 @@
#include <pkgmgr-info.h>
-#include <boost/filesystem.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <filesystem>
#include <string>
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace backup {
@@ -75,26 +72,26 @@ void StepBackupIcons::RemoveBackupIcons() {
}
void StepBackupIcons::GetIconInfo() {
- for (auto iter = bf::directory_iterator(extra_icon_path_);
- iter != bf::directory_iterator(); ++iter) {
- if (!bf::is_regular_file(iter->path()))
+ for (auto iter = fs::directory_iterator(extra_icon_path_);
+ iter != fs::directory_iterator(); ++iter) {
+ if (!fs::is_regular_file(iter->path()))
continue;
AddAppIconToList(iter->path());
}
}
-void StepBackupIcons::AddAppIconToList(boost::filesystem::path path) {
+void StepBackupIcons::AddAppIconToList(std::filesystem::path path) {
for (application_x* app : GListRange<application_x*>(
context_->old_manifest_data.get()->application)) {
if (!app->icon)
continue;
- bf::path filename = path.filename();
+ fs::path filename = path.filename();
filename.replace_extension();
std::string id = filename.string();
if (id == app->appid) {
- bf::path icon_backup = GetBackupPathForIconFile(path);
+ fs::path icon_backup = GetBackupPathForIconFile(path);
icons_.emplace_back(path, icon_backup);
}
}
diff --git a/src/common/step/backup/step_backup_icons.h b/src/common/step/backup/step_backup_icons.h
index 4c3a5f4d..a4865b59 100644
--- a/src/common/step/backup/step_backup_icons.h
+++ b/src/common/step/backup/step_backup_icons.h
@@ -5,8 +5,9 @@
#ifndef COMMON_STEP_BACKUP_STEP_BACKUP_ICONS_H_
#define COMMON_STEP_BACKUP_STEP_BACKUP_ICONS_H_
-#include <boost/filesystem/path.hpp>
#include <manifest_parser/utils/logging.h>
+
+#include <filesystem>
#include <utility>
#include <vector>
@@ -52,9 +53,9 @@ class StepBackupIcons : public Step {
bool BackupIcons();
void RemoveBackupIcons();
void GetIconInfo();
- void AddAppIconToList(boost::filesystem::path path);
+ void AddAppIconToList(std::filesystem::path path);
- std::vector<std::pair<boost::filesystem::path, boost::filesystem::path>>
+ std::vector<std::pair<std::filesystem::path, std::filesystem::path>>
icons_;
const char* extra_icon_path_;
diff --git a/src/common/step/backup/step_backup_manifest.cc b/src/common/step/backup/step_backup_manifest.cc
index c9149f7b..fdaad813 100644
--- a/src/common/step/backup/step_backup_manifest.cc
+++ b/src/common/step/backup/step_backup_manifest.cc
@@ -4,28 +4,25 @@
#include "common/step/backup/step_backup_manifest.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
#include <pkgmgr-info.h>
#include <pkgmgr_installer.h>
#include <algorithm>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace backup {
Step::Status StepBackupManifest::precheck() {
- if (!bf::exists(context_->xml_path.get())) {
+ if (!fs::exists(context_->xml_path.get())) {
LOG(ERROR) << "Xml manifest file does not exist";
return Status::MANIFEST_NOT_FOUND;
}
@@ -35,7 +32,7 @@ Step::Status StepBackupManifest::precheck() {
Step::Status StepBackupManifest::process() {
// set backup file path
- bf::path backup_xml_path =
+ fs::path backup_xml_path =
GetBackupPathForManifestFile(context_->xml_path.get());
context_->backup_xml_path.set(backup_xml_path);
if (!MoveFile(context_->xml_path.get(), backup_xml_path, true) ||
@@ -56,11 +53,11 @@ Step::Status StepBackupManifest::clean() {
}
Step::Status StepBackupManifest::undo() {
- if (!bf::exists(context_->backup_xml_path.get()))
+ if (!fs::exists(context_->backup_xml_path.get()))
return Status::OK;
- bs::error_code error;
- bf::remove(context_->xml_path.get(), error);
+ std::error_code error;
+ fs::remove(context_->xml_path.get(), error);
if (error) {
LOG(ERROR) << "Failed to remove newly generated xml file in revert";
return Status::MANIFEST_ERROR;
diff --git a/src/common/step/backup/step_copy_backup.cc b/src/common/step/backup/step_copy_backup.cc
index 09a22523..6460cf2b 100644
--- a/src/common/step/backup/step_copy_backup.cc
+++ b/src/common/step/backup/step_copy_backup.cc
@@ -7,28 +7,27 @@
#include <sys/types.h>
#include <tzplatform_config.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <algorithm>
#include <cassert>
#include <cstdint>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
const char kExternalMemoryMountPoint[] = ".mmc";
const char kSharedResPath[] = "shared/res";
-bool CheckFreeSpace(const bf::path& backup_path, const bf::path& shared_path) {
+bool CheckFreeSpace(const fs::path& backup_path, const fs::path& shared_path) {
int64_t shared_size = ci::GetDirectorySize(shared_path);
if (!ci::CheckFreeSpaceAtPath(shared_size, backup_path))
@@ -37,10 +36,10 @@ bool CheckFreeSpace(const bf::path& backup_path, const bf::path& shared_path) {
return true;
}
-bool CreateSharedRes(const bf::path& src, const bf::path& dst) {
- bs::error_code error;
+bool CreateSharedRes(const fs::path& src, const fs::path& dst) {
+ std::error_code error;
- bf::create_directories(dst / kSharedResPath, error);
+ fs::create_directories(dst / kSharedResPath, error);
if (error) {
LOG(ERROR) << "Cannot create package directory";
return false;
@@ -54,10 +53,10 @@ bool CreateSharedRes(const bf::path& src, const bf::path& dst) {
return true;
}
-bool Move(const boost::filesystem::path& from,
- const boost::filesystem::path& to,
+bool Move(const std::filesystem::path& from,
+ const std::filesystem::path& to,
common_installer::FSFlag flag = common_installer::FSFlag::FS_NONE) {
- if (bf::is_directory(from)) {
+ if (fs::is_directory(from)) {
if (!common_installer::MoveDir(from, to / from.filename(), flag)) {
LOG(ERROR) << "Failed to move directory: " << from;
return false;
@@ -93,8 +92,8 @@ Step::Status StepCopyBackup::precheck() {
// We only "copy" shared dir for backup.
// So if there is no shared dir, we don't need to check free space.
- bf::path shared_dir = install_path_ / "shared";
- if (!bf::exists(shared_dir))
+ fs::path shared_dir = install_path_ / "shared";
+ if (!fs::exists(shared_dir))
return Status::OK;
if (!CheckFreeSpace(backup_path_, shared_dir)) {
@@ -134,7 +133,7 @@ Step::Status StepCopyBackup::undo() {
if (context_->external_storage)
context_->external_storage->Abort();
- if (!bf::exists(backup_path_))
+ if (!fs::exists(backup_path_))
return Status::OK;
if (!RollbackApplicationDirectory()) {
@@ -148,18 +147,18 @@ Step::Status StepCopyBackup::undo() {
}
bool StepCopyBackup::Backup() {
- bs::error_code error;
+ std::error_code error;
- if (!bf::exists(backup_path_)) {
- bf::create_directories(backup_path_, error);
+ if (!fs::exists(backup_path_)) {
+ fs::create_directories(backup_path_, error);
if (error) {
LOG(ERROR) << "Failed to create backup directory: " << backup_path_;
return false;
}
}
// create copy of old package content skipping the external memory mount point
- for (bf::directory_iterator iter(context_->GetPkgPath());
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(context_->GetPkgPath());
+ iter != fs::directory_iterator(); ++iter) {
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
@@ -168,7 +167,7 @@ bool StepCopyBackup::Backup() {
if (context_->external_storage) {
auto& ext_dirs = context_->external_storage->external_dirs();
auto found = std::find(ext_dirs.begin(), ext_dirs.end(),
- iter->path().filename());
+ iter->path().filename().string());
if (found != ext_dirs.end()) {
bool done = MoveMountPointContent(iter->path(),
backup_path_ / iter->path().filename());
@@ -191,15 +190,15 @@ bool StepCopyBackup::Backup() {
}
-bool StepCopyBackup::MoveMountPointContent(const boost::filesystem::path& from,
- const boost::filesystem::path& to) {
- bs::error_code error;
- bf::create_directories(to, error);
+bool StepCopyBackup::MoveMountPointContent(const std::filesystem::path& from,
+ const std::filesystem::path& to) {
+ std::error_code error;
+ fs::create_directories(to, error);
- for (bf::directory_iterator iter(from);
- iter != bf::directory_iterator(); ++iter) {
- if (bf::is_symlink(symlink_status(iter->path()))) {
- bf::copy_symlink(iter->path(), to / iter->path().filename(), error);
+ for (fs::directory_iterator iter(from);
+ iter != fs::directory_iterator(); ++iter) {
+ if (fs::is_symlink(symlink_status(iter->path()))) {
+ fs::copy_symlink(iter->path(), to / iter->path().filename(), error);
if (error) {
LOG(ERROR) << "Failed to backup package symlink: " << iter->path();
return false;
@@ -217,11 +216,11 @@ bool StepCopyBackup::MoveMountPointContent(const boost::filesystem::path& from,
void StepCopyBackup::RemoveContent() {
if (context_->request_type.get() == RequestType::Update &&
- !context_->external_storage && bf::exists(install_path_ / ".mmc")) {
+ !context_->external_storage && fs::exists(install_path_ / ".mmc")) {
LOG(WARNING) << "Remove unnecessary files for external storage";
- bs::error_code error;
- bf::remove((install_path_ / ".mmc"), error);
+ std::error_code error;
+ fs::remove((install_path_ / ".mmc"), error);
if (error)
LOG(WARNING) << "error while remove files";
}
@@ -230,8 +229,8 @@ void StepCopyBackup::RemoveContent() {
bool StepCopyBackup::NewContent() {
ci::RemoveRWDirectories(context_->unpacked_dir_path.get());
- bs::error_code error;
- bf::create_directories(install_path_.parent_path(), error);
+ std::error_code error;
+ fs::create_directories(install_path_.parent_path(), error);
if (error) {
LOG(ERROR) << "Cannot create package directory";
return false;
@@ -242,8 +241,8 @@ bool StepCopyBackup::NewContent() {
return false;
}
- for (bf::directory_iterator iter(context_->unpacked_dir_path.get());
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(context_->unpacked_dir_path.get());
+ iter != fs::directory_iterator(); ++iter) {
if (!Move(iter->path(), install_path_, FS_MERGE_SKIP))
return false;
}
@@ -252,12 +251,12 @@ bool StepCopyBackup::NewContent() {
// it will be failed due to permission deny. Set its permission before
// StepChangeOwnershipAndPermission to prevent it.
uid_t uid = context_->uid.get();
- boost::optional<gid_t> gid = common_installer::GetGidByUid(uid);
+ std::optional<gid_t> gid = common_installer::GetGidByUid(uid);
if (!gid) {
LOG(ERROR) << "Failed to get gid";
return false;
}
- if (bf::exists(install_path_ / "shared/res") &&
+ if (fs::exists(install_path_ / "shared/res") &&
!common_installer::SetOwnershipAll(
install_path_ / "shared/res", uid, *gid)) {
LOG(ERROR) << "Failed to set ownership";
@@ -275,19 +274,19 @@ bool StepCopyBackup::CleanBackupDirectory() {
}
bool StepCopyBackup::RollbackApplicationDirectory() {
- bs::error_code error;
- bf::path root_path = context_->GetPkgPath();
- if (bf::exists(root_path)) {
- for (bf::directory_iterator iter(root_path);
- iter != bf::directory_iterator(); ++iter) {
- bf::remove_all(iter->path(), error);
+ std::error_code error;
+ fs::path root_path = context_->GetPkgPath();
+ if (fs::exists(root_path)) {
+ for (fs::directory_iterator iter(root_path);
+ iter != fs::directory_iterator(); ++iter) {
+ fs::remove_all(iter->path(), error);
if (error)
return false;
}
}
- for (bf::directory_iterator iter(backup_path_);
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(backup_path_);
+ iter != fs::directory_iterator(); ++iter) {
if (!Move(iter->path(), root_path)) {
LOG(ERROR) << "Failed to recovery backup file(" << iter->path() << ")";
return false;
@@ -311,8 +310,8 @@ void StepCopyBackup::AddRecoveryInfo() {
}
bool StepCopyBackup::ShouldBackupSharedRes() {
- if (bf::exists(backup_path_ / kSharedResPath) &&
- bf::exists(context_->unpacked_dir_path.get() / kSharedResPath))
+ if (fs::exists(backup_path_ / kSharedResPath) &&
+ fs::exists(context_->unpacked_dir_path.get() / kSharedResPath))
return true;
return false;
diff --git a/src/common/step/backup/step_copy_backup.h b/src/common/step/backup/step_copy_backup.h
index ee5ab7a5..77766600 100644
--- a/src/common/step/backup/step_copy_backup.h
+++ b/src/common/step/backup/step_copy_backup.h
@@ -5,10 +5,10 @@
#ifndef COMMON_STEP_BACKUP_STEP_COPY_BACKUP_H_
#define COMMON_STEP_BACKUP_STEP_COPY_BACKUP_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/step.h"
@@ -58,13 +58,13 @@ class StepCopyBackup : public Step {
void RemoveContent();
bool CleanBackupDirectory();
bool RollbackApplicationDirectory();
- bool MoveMountPointContent(const boost::filesystem::path& from,
- const boost::filesystem::path& to);
+ bool MoveMountPointContent(const std::filesystem::path& from,
+ const std::filesystem::path& to);
void AddRecoveryInfo();
bool ShouldBackupSharedRes();
- boost::filesystem::path install_path_;
- boost::filesystem::path backup_path_;
+ std::filesystem::path install_path_;
+ std::filesystem::path backup_path_;
STEP_NAME(CopyBackup)
};
diff --git a/src/common/step/configuration/step_block_cross_update.cc b/src/common/step/configuration/step_block_cross_update.cc
index 72332fbc..331b3da6 100644
--- a/src/common/step/configuration/step_block_cross_update.cc
+++ b/src/common/step/configuration/step_block_cross_update.cc
@@ -4,12 +4,8 @@
#include "common/step/configuration/step_block_cross_update.h"
-#include <boost/filesystem/operations.hpp>
-
#include "common/utils/paths.h"
-namespace bf = boost::filesystem;
-
namespace common_installer {
namespace configuration {
diff --git a/src/common/step/configuration/step_configure.cc b/src/common/step/configuration/step_configure.cc
index 6608e03c..7450bbbd 100644
--- a/src/common/step/configuration/step_configure.cc
+++ b/src/common/step/configuration/step_configure.cc
@@ -4,16 +4,17 @@
#include "common/step/configuration/step_configure.h"
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgr-info.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <tzplatform_config.h>
+#include <filesystem>
#include <memory>
+#include <optional>
#include <string>
+#include <system_error>
#include <utility>
#include "common/utils/pkgmgr_query.h"
@@ -21,7 +22,7 @@
#include "common/utils/user_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace configuration {
@@ -70,7 +71,7 @@ Step::Status StepConfigure::process() {
break;
case RequestType::Reinstall:
context_->unpacked_dir_path.set(
- bf::path(tzplatform_getenv(TZ_SDK_TOOLS)) / "tmp" /
+ fs::path(tzplatform_getenv(TZ_SDK_TOOLS)) / "tmp" /
pkgmgr_->GetRequestInfo(context_->index.get()));
context_->pkgid.set(pkgmgr_->GetRequestInfo(context_->index.get()));
context_->file_path.set(kStrEmpty);
@@ -109,10 +110,10 @@ Step::Status StepConfigure::process() {
request_type == RequestType::ManifestPartialUpdate)
SetupIsPartialRW();
context_->pkgid.set(pkgmgr_->GetRequestInfo(context_->index.get()));
- bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(),
+ fs::path xml_path =
+ fs::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
- / bf::path(context_->pkgid.get());
+ / fs::path(context_->pkgid.get());
xml_path += ".xml";
context_->unpacked_dir_path.set(context_->GetPkgPath());
context_->xml_path.set(xml_path);
@@ -129,8 +130,8 @@ Step::Status StepConfigure::process() {
}
case RequestType::ReadonlyUpdateUninstall: {
context_->pkgid.set(pkgmgr_->GetRequestInfo(context_->index.get()));
- bf::path original_path =
- bf::path(tzplatform_getenv(TZ_SYS_RO_APP)) / context_->pkgid.get();
+ fs::path original_path =
+ fs::path(tzplatform_getenv(TZ_SYS_RO_APP)) / context_->pkgid.get();
context_->unpacked_dir_path.set(original_path);
context_->file_path.set(kStrEmpty);
SetupIsKeepRWData();
@@ -180,7 +181,7 @@ Step::Status StepConfigure::precheck() {
if (getuid() == 0)
return Status::OK;
- boost::optional<uid_t> appfw_uid = GetUidByUserName(kAppFWUser);
+ std::optional<uid_t> appfw_uid = GetUidByUserName(kAppFWUser);
if (!appfw_uid)
return Status::ERROR;
@@ -202,10 +203,9 @@ bool StepConfigure::SetupRootAppDirectory() {
context_->root_application_path.set(root_app_path);
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
- boost::system::error_code error;
- boost::filesystem::create_directories(
- context_->root_application_path.get());
+ if (!fs::exists(context_->root_application_path.get())) {
+ std::error_code error;
+ fs::create_directories(context_->root_application_path.get());
if (error) {
LOG(ERROR) << "Cannot create directory: "
<< context_->root_application_path.get();
diff --git a/src/common/step/configuration/step_parse_manifest.cc b/src/common/step/configuration/step_parse_manifest.cc
index 39a33417..633c509b 100644
--- a/src/common/step/configuration/step_parse_manifest.cc
+++ b/src/common/step/configuration/step_parse_manifest.cc
@@ -4,8 +4,6 @@
#include "common/step/configuration/step_parse_manifest.h"
-#include <boost/tokenizer.hpp>
-
#include <pkgmgr/pkgmgr_parser.h>
#include <pkgmgr-info.h>
@@ -31,7 +29,9 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
#include <memory>
+#include <regex>
#include <set>
#include <type_traits>
#include <string>
@@ -48,7 +48,7 @@
#include "common/utils/time_util.h"
namespace app_keys = tpk::application_keys;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -102,26 +102,26 @@ Step::Status StepParseManifest::precheck() {
}
bool StepParseManifest::LocateConfigFile() {
- boost::filesystem::path manifest;
+ std::filesystem::path manifest;
switch (manifest_location_) {
case ManifestLocation::RECOVERY: {
- bf::path backup_path = common_installer::GetBackupPathForPackagePath(
+ fs::path backup_path = common_installer::GetBackupPathForPackagePath(
context_->GetPkgPath()) / kManifestFileName;
- bf::path in_package_path = context_->GetPkgPath() / kManifestFileName;
- bf::path install_path =
- bf::path(getUserManifestPath(context_->uid.get(),
+ fs::path in_package_path = context_->GetPkgPath() / kManifestFileName;
+ fs::path install_path =
+ fs::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
- / bf::path(context_->pkgid.get());
+ / fs::path(context_->pkgid.get());
install_path += ".xml";
- bf::path backup_install_path =
+ fs::path backup_install_path =
common_installer::GetBackupPathForManifestFile(install_path);
- if (bf::exists(backup_install_path))
+ if (fs::exists(backup_install_path))
manifest = backup_install_path;
- else if (bf::exists(backup_path))
+ else if (fs::exists(backup_path))
manifest = backup_path;
- else if (bf::exists(install_path))
+ else if (fs::exists(install_path))
manifest = install_path;
- else if (bf::exists(in_package_path))
+ else if (fs::exists(in_package_path))
manifest = in_package_path;
break;
}
@@ -133,13 +133,13 @@ bool StepParseManifest::LocateConfigFile() {
uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
else
uid = context_->uid.get();
- bf::path xml_path =
- bf::path(getUserManifestPath(uid, is_readonly))
- / bf::path(context_->pkgid.get());
+ fs::path xml_path =
+ fs::path(getUserManifestPath(uid, is_readonly))
+ / fs::path(context_->pkgid.get());
xml_path += ".xml";
context_->xml_path.set(xml_path);
manifest = context_->xml_path.get();
- if (!boost::filesystem::exists(manifest)) {
+ if (!std::filesystem::exists(manifest)) {
/* This routine has added for platform update */
manifest = context_->unpacked_dir_path.get();
manifest /= kManifestFileName;
@@ -159,7 +159,7 @@ bool StepParseManifest::LocateConfigFile() {
LOG(DEBUG) << "manifest path: " << manifest;
- if (!boost::filesystem::exists(manifest))
+ if (!std::filesystem::exists(manifest))
return false;
path_ = manifest;
@@ -374,7 +374,7 @@ bool StepParseManifest::FillPrivileges(manifest_x* manifest) {
privilege->value = strdup(priv.privilege.c_str());
privilege->type = strdup(priv.type.c_str());
if (!priv.license.empty()) {
- if (bf::path(priv.license).is_absolute())
+ if (fs::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
privilege->license = strdup((context_->GetPkgPath()
@@ -410,7 +410,7 @@ bool StepParseManifest::FillProvidesAppDefinedPrivileges(
privilege->value = strdup(priv.privilege.c_str());
privilege->type = strdup(priv.type.c_str());
if (!priv.license.empty()) {
- if (bf::path(priv.license).is_absolute())
+ if (fs::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
privilege->license = strdup((context_->GetPkgPath()
@@ -478,7 +478,7 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
else
widget_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, widget_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
widget_app->exec = strdup(application.app_info.exec().c_str());
else
widget_app->exec = strdup((context_->root_application_path.get()
@@ -554,7 +554,7 @@ bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
else
service_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, service_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
service_app->exec = strdup(application.app_info.exec().c_str());
else
service_app->exec = strdup((context_->root_application_path.get()
@@ -657,7 +657,7 @@ bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
else
ui_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, ui_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
ui_app->exec = strdup(application.app_info.exec().c_str());
else
ui_app->exec = strdup((context_->root_application_path.get()
@@ -709,7 +709,7 @@ bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
}
watch_app->appid = strdup(watch_application.app_info.appid().c_str());
- if (bf::path(watch_application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(watch_application.app_info.exec().c_str()).is_absolute())
watch_app->exec = strdup(watch_application.app_info.exec().c_str());
else
watch_app->exec = strdup(
@@ -924,8 +924,8 @@ bool StepParseManifest::FillApplicationIconPaths(application_x* app,
LOG(ERROR) << "Out of memory";
return false;
}
- bf::path text;
- if (bf::path(application_icon.path()).is_absolute()) {
+ fs::path text;
+ if (fs::path(application_icon.path()).is_absolute()) {
text = application_icon.path();
} else {
text = context_->root_application_path.get()
@@ -1013,11 +1013,11 @@ void StepParseManifest::AppendSplashScreen(application_x* app,
LOG(ERROR) << "Out of memory";
return;
}
- if (bf::path(src).is_absolute()) {
+ if (fs::path(src).is_absolute()) {
splashscreen->src = strdup(src.c_str());
} else {
- bf::path full_path = context_->GetPkgPath() / src;
- splashscreen->src = strdup(full_path.string().c_str());
+ fs::path full_path = context_->GetPkgPath() / src;
+ splashscreen->src = strdup(full_path.c_str());
}
if (src.substr(src.find_last_of(".") + 1) == "edj")
splashscreen->type = strdup("edj");
@@ -1053,7 +1053,7 @@ bool StepParseManifest::FillSplashScreen(application_x* app,
if (context_->is_readonly_package.get())
src = splash_screen.src();
else
- src = bf::path(context_->root_application_path.get()
+ src = fs::path(context_->root_application_path.get()
/ app->package / "shared" / "res" / splash_screen.src()).string();
AppendSplashScreen(app, src, splash_screen.type(), splash_screen.dpi(),
@@ -1093,12 +1093,9 @@ bool StepParseManifest::FillResControl(application_x* app,
void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
const std::string& key, const std::string& val) {
std::string operation;
- if (key.find(kOperationEffectKey) != std::string::npos) {
- boost::char_separator<char> sep("=");
- boost::tokenizer<boost::char_separator<char>> tokens(key, sep);
- auto iter = tokens.begin();
- iter++;
- operation = *iter;
+ auto pos = key.find(kOperationEffectKey);
+ if (pos != std::string::npos) {
+ operation = key.substr(pos + 1, key.size());
} else if (key.find(kLaunchEffectKey) != std::string::npos) {
operation = std::string("launch-effect");
} else {
@@ -1106,25 +1103,23 @@ void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
return;
}
- boost::char_separator<char> sep("=|");
- boost::tokenizer<boost::char_separator<char>> tokens(val, sep);
- auto iter = tokens.begin();
std::string portrait_src;
std::string landscape_src;
std::string indicatordisplay;
- while (iter != tokens.end()) {
- if (!(*iter).compare(kPortraitEffectImageValue)) {
- iter++;
- portrait_src = *iter;
- } else if (!(*iter).compare(kLandscapeEffectImageValue)) {
- iter++;
- landscape_src = *iter;
- } else if (!(*iter).compare(kIndicatorDisplayValue)) {
- iter++;
- indicatordisplay = *iter;
- }
- iter++;
+
+ std::regex re("[=|]");
+ std::sregex_token_iterator first(val.begin(), val.end(), re, -1);
+ std::sregex_token_iterator last;
+ std::vector<std::string> tokens(first, last);
+ for (const auto t : tokens) {
+ if (t.compare(kPortraitEffectImageValue))
+ portrait_src = t;
+ else if (t.compare(kLandscapeEffectImageValue))
+ landscape_src = t;
+ else if (t.compare(kIndicatorDisplayValue))
+ indicatordisplay = t;
}
+
if (!portrait_src.empty())
AppendSplashScreen(app, portrait_src, {}, {}, kPortraitOrientation,
indicatordisplay, operation, {});
@@ -1268,7 +1263,7 @@ bool StepParseManifest::FillComponentBasedApplicationInfo(
app->splash_screen_display =
strdup(application.app_info.splash_screen_display().c_str());
manifest->application = g_list_append(manifest->application, app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
+ if (fs::path(application.app_info.exec().c_str()).is_absolute()) {
app->exec = strdup(application.app_info.exec().c_str());
} else {
app->exec = strdup((context_->root_application_path.get()
@@ -1348,7 +1343,7 @@ Step::Status StepParseManifest::process() {
if (!parser_->ParseManifest(path_)) {
if (manifest_location_ == ManifestLocation::RECOVERY) {
LOG(DEBUG) << "Manifest for recovery is invalid";
- bf::remove(path_);
+ fs::remove(path_);
return Step::Status::OK;
}
LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage();
diff --git a/src/common/step/configuration/step_parse_manifest.h b/src/common/step/configuration/step_parse_manifest.h
index 58f360b4..ba09c759 100644
--- a/src/common/step/configuration/step_parse_manifest.h
+++ b/src/common/step/configuration/step_parse_manifest.h
@@ -5,8 +5,6 @@
#ifndef COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
#define COMMON_STEP_CONFIGURATION_STEP_PARSE_MANIFEST_H_
-#include <boost/filesystem.hpp>
-
#include <common/installer/app_installer.h>
#include <common/installer_context.h>
#include <common/step/step.h>
@@ -16,6 +14,7 @@
#include <tpk_manifest_handlers/tpk_config_parser.h>
#include <tpk_manifest_handlers/ui_and_service_application_infos.h>
+#include <filesystem>
#include <memory>
#include <set>
#include <string>
@@ -58,7 +57,7 @@ class StepParseManifest : public common_installer::Step {
protected:
bool LocateConfigFile();
- boost::filesystem::path path_;
+ std::filesystem::path path_;
private:
bool FillInstallationInfo(manifest_x* manifest);
diff --git a/src/common/step/configuration/step_parse_preload.cc b/src/common/step/configuration/step_parse_preload.cc
index d926bdc0..b872c1b8 100644
--- a/src/common/step/configuration/step_parse_preload.cc
+++ b/src/common/step/configuration/step_parse_preload.cc
@@ -7,8 +7,6 @@
#include <pkgmgr-info.h>
#include <unistd.h>
-#include <boost/filesystem.hpp>
-
#include <cstring>
#include <cstdio>
#include <string>
@@ -17,7 +15,6 @@
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
namespace common_installer {
diff --git a/src/common/step/filesystem/step_change_ownership_and_permission.cc b/src/common/step/filesystem/step_change_ownership_and_permission.cc
index 7b8013c7..2b86ee95 100644
--- a/src/common/step/filesystem/step_change_ownership_and_permission.cc
+++ b/src/common/step/filesystem/step_change_ownership_and_permission.cc
@@ -5,15 +5,15 @@
#include "common/step/filesystem/step_change_ownership_and_permission.h"
-#include <boost/range/iterator_range.hpp>
-
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <pkgmgr-info.h>
-#include <cassert>
+#include <cassert>
#include <cstring>
+#include <filesystem>
+#include <optional>
#include <string>
#include <vector>
@@ -24,8 +24,8 @@
#include "common/utils/user_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -36,51 +36,50 @@ const std::vector<const char*> kDataDirEntries = {
{"cache"},
};
-bool GrantPermission755(const bf::path& path) {
- auto permission = bf::perms::owner_all |
- bf::perms::group_read | bf::perms::group_exe |
- bf::perms::others_read | bf::perms::others_exe;
+bool GrantPermission755(const fs::path& path) {
+ auto permission = fs::perms::owner_all |
+ fs::perms::group_read | fs::perms::group_exec |
+ fs::perms::others_read | fs::perms::others_exec;
if (!ci::SetDirPermissions(path, permission)) {
LOG(ERROR) << "Grant permission error" << " path: " << path
- << " permission: " << permission;
+ << " permission: 755";
return false;
}
return true;
}
-bool GrantPermission644(const bf::path& path) {
- auto permission = bf::perms::owner_read | bf::perms::owner_write |
- bf::perms::group_read | bf::perms::others_read;
+bool GrantPermission644(const fs::path& path) {
+ auto permission = fs::perms::owner_read | fs::perms::owner_write |
+ fs::perms::group_read | fs::perms::others_read;
if (!ci::SetDirPermissions(path, permission)) {
LOG(ERROR) << "Grant permission error" << " path: " << path
- << " permission: " << permission;
+ << " permission: 644";
return false;
}
return true;
}
-bool ChangeDataDir(const bf::path& pkg_path, uid_t uid) {
+bool ChangeDataDir(const fs::path& pkg_path, uid_t uid) {
if (ci::GetRequestMode(uid) == ci::RequestMode::GLOBAL)
return true;
- boost::optional<gid_t> gid = ci::GetGidByGroupName(kSystemShareGroupName);
+ std::optional<gid_t> gid = ci::GetGidByGroupName(kSystemShareGroupName);
if (!gid) {
LOG(ERROR) << "Failed to get gid of " << kSystemShareGroupName;
return false;
}
- bf::perms prms = bf::add_perms | bf::group_write | bf::set_gid_on_exe;
+ fs::perms prms = fs::perms::group_write | fs::perms::set_gid;
for (auto& entry : kDataDirEntries) {
- bf::path path = pkg_path / entry;
- if (!bf::exists(path))
+ fs::path path = pkg_path / entry;
+ if (!fs::exists(path))
continue;
if (!ci::SetOwnership(path, uid, *gid)) {
LOG(ERROR) << "Failed to change owner: " << path
<< "(" << uid << ", " << *gid << ")";
return false;
}
- if (!ci::SetDirPermissions(path, prms)) {
- LOG(ERROR) << "Failed to change permission: " << path
- << std::oct << prms;
+ if (!ci::SetDirPermissions(path, prms, true)) {
+ LOG(ERROR) << "Failed to add data dir permission: " << path;
return false;
}
}
@@ -88,66 +87,59 @@ bool ChangeDataDir(const bf::path& pkg_path, uid_t uid) {
return true;
}
-bool GrantDefaultPermissions(bf::path pkg_path, bool skip_symlink) {
- if (bf::is_directory(pkg_path)) {
+bool GrantDefaultPermissions(fs::path pkg_path, bool skip_symlink) {
+ if (fs::is_directory(pkg_path)) {
if (!GrantPermission755(pkg_path))
return false;
}
- for (auto& entry :
- boost::make_iterator_range(bf::directory_iterator(pkg_path), {})) {
- const auto& path = entry.path();
-
- if (skip_symlink && bf::is_symlink(symlink_status(path)))
- continue;
+ for (auto& entry : fs::directory_iterator(pkg_path)) {
+ if (skip_symlink && fs::is_symlink(symlink_status(entry)))
+ continue;
// skip path, which is related to mount or directory installer creates
- if (bf::is_directory(path) &&
- (path.filename() == ".mmc" || path.filename() == ".pkg" ||
- path.filename() == "tep"))
+ if (fs::is_directory(entry) &&
+ (entry.path().filename() == ".mmc" || entry.path().filename() == ".pkg" ||
+ entry.path().filename() == "tep"))
continue;
- if (bf::is_directory(path) && path.filename() == "bin") {
- if (!GrantPermission755(path))
+ if (fs::is_directory(entry) && entry.path().filename() == "bin") {
+ if (!GrantPermission755(entry))
return false;
- for (auto& bin_entry :
- boost::make_iterator_range(bf::directory_iterator(path), {})) {
- const auto& bin_path = bin_entry.path();
- if (bf::is_symlink(symlink_status(bin_path)))
+ for (auto& bin_entry : fs::directory_iterator(entry)) {
+ if (fs::is_symlink(symlink_status(bin_entry)))
continue;
- if (bf::is_regular_file(bin_path)) {
- if (!GrantPermission755(bin_path))
+ if (fs::is_regular_file(bin_entry)) {
+ if (!GrantPermission755(bin_entry))
return false;
}
}
continue;
}
- if (bf::is_directory(path) && path.filename() == "lib") {
- if (!GrantPermission755(path))
+ if (fs::is_directory(entry) && entry.path().filename() == "lib") {
+ if (!GrantPermission755(entry))
return false;
- for (auto& lib_entry :
- boost::make_iterator_range(bf::directory_iterator(path), {})) {
- const auto& lib_path = lib_entry.path();
- if (bf::is_symlink(symlink_status(lib_path)))
+ for (auto& lib_entry : fs::directory_iterator(entry)) {
+ if (fs::is_symlink(fs::symlink_status(lib_entry)))
continue;
- if (bf::is_regular_file(lib_path)) {
- if (!GrantPermission644(lib_path))
+ if (fs::is_regular_file(lib_entry)) {
+ if (!GrantPermission644(lib_entry))
return false;
}
}
continue;
}
- if (bf::is_directory(path)) {
- if (!GrantPermission755(path))
+ if (fs::is_directory(entry)) {
+ if (!GrantPermission755(entry))
return false;
continue;
}
- if (bf::is_regular_file(path)) {
- if (!GrantPermission644(path))
+ if (fs::is_regular_file(entry)) {
+ if (!GrantPermission644(entry))
return false;
continue;
}
@@ -173,7 +165,7 @@ Step::Status StepChangeOwnershipAndPermission::precheck() {
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ if (!std::filesystem::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -190,7 +182,7 @@ Step::Status StepChangeOwnershipAndPermission::precheck() {
Step::Status StepChangeOwnershipAndPermission::process() {
uid_t uid = context_->uid.get();
- boost::optional<gid_t> gid = ci::GetGidByUid(uid);
+ std::optional<gid_t> gid = ci::GetGidByUid(uid);
if (!gid)
return Status::ERROR;
@@ -215,8 +207,8 @@ Step::Status StepChangeOwnershipAndPermission::process() {
continue;
icon_x* icon = reinterpret_cast<icon_x*>(app->icon->data);
- bf::path icon_path = icon->text;
- bf::path found_icon_path = GetIconPath(iconpath,
+ fs::path icon_path = icon->text;
+ fs::path found_icon_path = GetIconPath(iconpath,
context_->pkgid.get(), icon_path.filename(),
context_->root_application_path.get());
if (!found_icon_path.empty()) {
diff --git a/src/common/step/filesystem/step_copy.cc b/src/common/step/filesystem/step_copy.cc
index b90c6c04..9e92a4ed 100644
--- a/src/common/step/filesystem/step_copy.cc
+++ b/src/common/step/filesystem/step_copy.cc
@@ -7,14 +7,15 @@
#include <cassert>
#include <cstring>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/shared_dirs.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -24,7 +25,7 @@ Step::Status StepCopy::precheck() {
LOG(ERROR) << "root_application_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ if (!std::filesystem::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -35,7 +36,7 @@ Step::Status StepCopy::precheck() {
LOG(ERROR) << "unpacked_dir_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->unpacked_dir_path.get())) {
+ if (!std::filesystem::exists(context_->unpacked_dir_path.get())) {
LOG(ERROR) << "unpacked_dir_path ("
<< context_->unpacked_dir_path.get()
<< ") path does not exist";
@@ -56,9 +57,9 @@ Step::Status StepCopy::precheck() {
}
Step::Status StepCopy::process() {
- bf::path install_path;
+ fs::path install_path;
if (context_->storage.get() == Storage::EXTENDED) {
- install_path = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ install_path = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
} else {
install_path = context_->GetPkgPath();
@@ -66,8 +67,8 @@ Step::Status StepCopy::process() {
ci::RemoveRWDirectories(context_->unpacked_dir_path.get());
- bs::error_code error;
- bf::create_directories(install_path.parent_path(), error);
+ std::error_code error;
+ fs::create_directories(install_path.parent_path(), error);
if (error) {
LOG(ERROR) << "Cannot create directory: "
<< install_path.parent_path().string();
@@ -83,7 +84,7 @@ Step::Status StepCopy::process() {
<< " to: " << install_path << " directory";
if (context_->storage.get() == Storage::EXTENDED) {
- bf::create_symlink(install_path, context_->GetPkgPath(), error);
+ fs::create_symlink(install_path, context_->GetPkgPath(), error);
if (error) {
LOG(ERROR) << "Failed to create symlink for extended path: "
<< error.message();
@@ -102,8 +103,8 @@ Step::Status StepCopy::undo() {
if (context_->external_storage) {
context_->external_storage->Abort();
} else if (context_->storage.get() == Storage::EXTENDED) {
- bf::path install_path =
- bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ fs::path install_path =
+ fs::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
RemoveAll(install_path);
}
diff --git a/src/common/step/filesystem/step_copy_storage_directories.cc b/src/common/step/filesystem/step_copy_storage_directories.cc
index b4ffb01c..a31c6c38 100644
--- a/src/common/step/filesystem/step_copy_storage_directories.cc
+++ b/src/common/step/filesystem/step_copy_storage_directories.cc
@@ -4,16 +4,14 @@
#include "common/step/filesystem/step_copy_storage_directories.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
@@ -27,12 +25,12 @@ namespace common_installer {
namespace filesystem {
bool StepCopyStorageDirectories::CopyAppStorage(
- const bf::path& in_src,
- const bf::path& in_dst,
+ const fs::path& in_src,
+ const fs::path& in_dst,
const char *key,
bool merge_dirs) {
- bf::path src = in_src / key;
- bf::path dst = in_dst / key;
+ fs::path src = in_src / key;
+ fs::path dst = in_dst / key;
return common_installer::CopyDir(src, dst,
merge_dirs ? common_installer::FS_MERGE_SKIP |
common_installer::FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS
@@ -43,8 +41,8 @@ common_installer::Step::Status StepCopyStorageDirectories::precheck() {
backup_path_ =
common_installer::GetBackupPathForPackagePath(context_->GetPkgPath());
- bs::error_code error_code;
- if (!bf::exists(backup_path_, error_code)) {
+ std::error_code error_code;
+ if (!fs::exists(backup_path_, error_code)) {
LOG(DEBUG) << "Cannot restore storage directories from: " << backup_path_;
return Status::INVALID_VALUE;
}
@@ -76,9 +74,9 @@ common_installer::Step::Status StepCopyStorageDirectories::process() {
}
bool StepCopyStorageDirectories::CacheDir() {
- bs::error_code error_code;
- bf::path cache_path = context_->GetPkgPath() / kCache;
- bf::create_directory(cache_path, error_code);
+ std::error_code error_code;
+ fs::path cache_path = context_->GetPkgPath() / kCache;
+ fs::create_directory(cache_path, error_code);
if (error_code) {
LOG(ERROR) << "Failed to create cache directory for package";
return false;
diff --git a/src/common/step/filesystem/step_copy_storage_directories.h b/src/common/step/filesystem/step_copy_storage_directories.h
index 7954a285..26dbbdf4 100644
--- a/src/common/step/filesystem/step_copy_storage_directories.h
+++ b/src/common/step/filesystem/step_copy_storage_directories.h
@@ -5,10 +5,10 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_COPY_STORAGE_DIRECTORIES_H_
#define COMMON_STEP_FILESYSTEM_STEP_COPY_STORAGE_DIRECTORIES_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/step/step.h"
namespace common_installer {
@@ -40,12 +40,12 @@ class StepCopyStorageDirectories : public common_installer::Step {
Status precheck() override;
protected:
- bool CopyAppStorage(const boost::filesystem::path& in_src,
- const boost::filesystem::path& in_dst,
+ bool CopyAppStorage(const std::filesystem::path& in_src,
+ const std::filesystem::path& in_dst,
const char *key, bool merge_dirs = false);
bool CacheDir();
void RemoveAll();
- boost::filesystem::path backup_path_;
+ std::filesystem::path backup_path_;
STEP_NAME(CopyStorageDirectories)
};
diff --git a/src/common/step/filesystem/step_copy_tep.cc b/src/common/step/filesystem/step_copy_tep.cc
index b79b3fb7..a9fb3a35 100644
--- a/src/common/step/filesystem/step_copy_tep.cc
+++ b/src/common/step/filesystem/step_copy_tep.cc
@@ -7,7 +7,9 @@
#include <cassert>
#include <cstring>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
@@ -15,8 +17,7 @@
namespace common_installer {
namespace filesystem {
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
Step::Status StepCopyTep::precheck() {
if (context_->root_application_path.get().empty()) {
@@ -24,7 +25,7 @@ Step::Status StepCopyTep::precheck() {
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ if (!std::filesystem::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -42,7 +43,7 @@ Step::Status StepCopyTep::precheck() {
Step::Status StepCopyTep::process() {
if (context_->tep_path.get().empty())
return Step::Status::OK;
- bf::path tep_path;
+ fs::path tep_path;
if (context_->external_storage) {
tep_path = GetExternalTepPath(context_->request_mode.get(),
context_->uid.get());
@@ -54,9 +55,9 @@ Step::Status StepCopyTep::process() {
// appstore uses to identify version of tep on device.
tep_path /= context_->tep_path.get().filename();
- if (!bf::exists(tep_path.parent_path())) {
- bs::error_code error;
- bf::create_directories(tep_path.parent_path(), error);
+ if (!fs::exists(tep_path.parent_path())) {
+ std::error_code error;
+ fs::create_directories(tep_path.parent_path(), error);
if (error) {
LOG(ERROR) << "Cannot create tep parent directory";
return Status::APP_DIR_ERROR;
@@ -86,7 +87,7 @@ Step::Status StepCopyTep::undo() {
RemoveAll(context_->tep_path.get());
// remove tep file is installed outside package path
if (context_->external_storage) {
- bf::path tep_path = GetExternalTepPath(context_->request_mode.get(),
+ fs::path tep_path = GetExternalTepPath(context_->request_mode.get(),
context_->uid.get());
tep_path /= context_->tep_path.get().filename();
RemoveAll(tep_path);
diff --git a/src/common/step/filesystem/step_create_icons.cc b/src/common/step/filesystem/step_create_icons.cc
index 391f20e0..86f52931 100644
--- a/src/common/step/filesystem/step_create_icons.cc
+++ b/src/common/step/filesystem/step_create_icons.cc
@@ -4,15 +4,15 @@
#include "common/step/filesystem/step_create_icons.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
+#include <filesystem>
+#include <system_error>
+
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -30,10 +30,10 @@ Step::Status StepCreateIcons::process() {
if (!extra_icon_path)
return Status::OK;
- bf::path destination = extra_icon_path;
- bs::error_code error;
- if (!bf::exists(destination)) {
- bf::create_directories(destination, error);
+ fs::path destination = extra_icon_path;
+ std::error_code error;
+ if (!fs::exists(destination)) {
+ fs::create_directories(destination, error);
if (error) {
LOG(ERROR) << "Cannot create directory of application icons: "
<< destination;
@@ -49,17 +49,17 @@ Step::Status StepCreateIcons::process() {
continue;
icon_x* icon = reinterpret_cast<icon_x*>(app->icon->data);
- bf::path source(icon->text);
- if (!bf::exists(source))
+ fs::path source(icon->text);
+ if (!fs::exists(source))
continue;
- bf::path destination_path = destination / app->appid;
+ fs::path destination_path = destination / app->appid;
if (source.has_extension())
destination_path += source.extension();
else
destination_path += ".png";
- bf::copy_file(source, destination_path,
- bf::copy_option::overwrite_if_exists, error);
+ fs::copy_file(source, destination_path,
+ fs::copy_options::overwrite_existing, error);
if (error) {
LOG(ERROR) << "Cannot create package icon: " << destination_path
<< " , error: " << error;
diff --git a/src/common/step/filesystem/step_create_icons.h b/src/common/step/filesystem/step_create_icons.h
index 1e9d0d51..8fdf1653 100644
--- a/src/common/step/filesystem/step_create_icons.h
+++ b/src/common/step/filesystem/step_create_icons.h
@@ -5,10 +5,9 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_CREATE_ICONS_H_
#define COMMON_STEP_FILESYSTEM_STEP_CREATE_ICONS_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
#include <string>
#include <utility>
#include <vector>
@@ -43,7 +42,7 @@ class StepCreateIcons : public Step {
Status precheck() override { return Status::OK; }
private:
- std::vector<boost::filesystem::path> icons_;
+ std::vector<std::filesystem::path> icons_;
STEP_NAME(CreateIcons)
};
diff --git a/src/common/step/filesystem/step_create_res_control_directories.cc b/src/common/step/filesystem/step_create_res_control_directories.cc
index fd68f35c..8dcf3660 100644
--- a/src/common/step/filesystem/step_create_res_control_directories.cc
+++ b/src/common/step/filesystem/step_create_res_control_directories.cc
@@ -4,22 +4,21 @@
#include "common/step/filesystem/step_create_res_control_directories.h"
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
constexpr char kAllowedDir[] = "res/mount/allowed";
constexpr char kGlobalDir[] = "res/mount/global";
-bool CreateResControlDirs(const bf::path& root) {
+bool CreateResControlDirs(const fs::path& root) {
if (!ci::CreateDir(root / kAllowedDir))
return false;
if (!ci::CreateDir(root / kGlobalDir))
@@ -27,7 +26,7 @@ bool CreateResControlDirs(const bf::path& root) {
return true;
}
-bool RemoveResControlDirs(const bf::path& root) {
+bool RemoveResControlDirs(const fs::path& root) {
if (!ci::RemoveAll(root / kAllowedDir))
return false;
if (!ci::RemoveAll(root / kGlobalDir))
@@ -69,7 +68,7 @@ Step::Status StepCreateResControlDirectories::process() {
if (!HasResControl(context_->manifest_data.get()))
return Status::OK;
- bf::path root = context_->GetPkgPath();
+ fs::path root = context_->GetPkgPath();
if (!CreateResControlDirs(root)) {
LOG(ERROR) << "Failed to create res-control directories";
return Status::APP_DIR_ERROR;
@@ -81,7 +80,7 @@ Step::Status StepCreateResControlDirectories::undo() {
if (!HasResControl(context_->manifest_data.get()))
return Status::OK;
- bf::path root = context_->GetPkgPath();
+ fs::path root = context_->GetPkgPath();
if (!RemoveResControlDirs(root)) {
LOG(ERROR) << "Failed to remove res-control directories";
return Status::APP_DIR_ERROR;
diff --git a/src/common/step/filesystem/step_create_storage_directories.cc b/src/common/step/filesystem/step_create_storage_directories.cc
index 93d430f2..c3a8d69c 100644
--- a/src/common/step/filesystem/step_create_storage_directories.cc
+++ b/src/common/step/filesystem/step_create_storage_directories.cc
@@ -6,10 +6,7 @@
#include <pkgmgrinfo_basic.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <filesystem>
#include <string>
#include <vector>
@@ -18,9 +15,8 @@
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
diff --git a/src/common/step/filesystem/step_delta_patch.cc b/src/common/step/filesystem/step_delta_patch.cc
index 5e65e5f9..28966395 100644
--- a/src/common/step/filesystem/step_delta_patch.cc
+++ b/src/common/step/filesystem/step_delta_patch.cc
@@ -4,8 +4,6 @@
#include "common/step/filesystem/step_delta_patch.h"
-#include <boost/system/error_code.hpp>
-#include <boost/filesystem/path.hpp>
#include <delta/delta_handler.h>
#include <delta/delta_parser.h>
#include <sys/types.h>
@@ -14,14 +12,15 @@
#include <algorithm>
#include <cstdlib>
+#include <filesystem>
#include <memory>
+#include <system_error>
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -52,26 +51,26 @@ bool ValidateDeltaInfo(const delta::DeltaInfo& info) {
return true;
}
-void RemoveBinarySymlinks(const bf::path& dir) {
- for (bf::directory_iterator iter(dir / kBinaryDir);
- iter != bf::directory_iterator(); ++iter) {
- if (bf::is_symlink(symlink_status(iter->path()))) {
+void RemoveBinarySymlinks(const fs::path& dir) {
+ for (fs::directory_iterator iter(dir / kBinaryDir);
+ iter != fs::directory_iterator(); ++iter) {
+ if (fs::is_symlink(symlink_status(iter->path()))) {
// FIXME: note that this assumes that it is not possible to create
// explicitly symlinks in bin/ directory pointing to whatever
- bs::error_code error;
+ std::error_code error;
ci::Remove(iter->path());
}
}
}
-void RemoveStorageDirectories(const bf::path& dir) {
+void RemoveStorageDirectories(const fs::path& dir) {
ci::RemoveAll(dir / kDataDir);
ci::RemoveAll(dir / kCacheDir);
ci::RemoveAll(dir / kSharedData);
ci::RemoveAll(dir / kSharedTrusted);
}
-void RemoveExtraIconFiles(const bf::path& dir, const bf::path& pkg_dir,
+void RemoveExtraIconFiles(const fs::path& dir, const fs::path& pkg_dir,
manifest_x* manifest) {
for (application_x* app : GListRange<application_x*>(manifest->application)) {
if (strcmp("webapp", app->type) != 0)
@@ -79,15 +78,15 @@ void RemoveExtraIconFiles(const bf::path& dir, const bf::path& pkg_dir,
auto range = GListRange<icon_x*>(app->icon);
auto iter = range.begin();
if (iter != range.end()) {
- bs::error_code error;
+ std::error_code error;
std::string old_path((*iter)->text);
- bf::path icon_copy = dir / old_path.substr(pkg_dir.string().size());
+ fs::path icon_copy = dir / old_path.substr(pkg_dir.string().size());
ci::Remove(icon_copy);
}
}
}
-bool ApplyDeletedFiles(const delta::DeltaInfo& info, const bf::path& app_dir) {
+bool ApplyDeletedFiles(const delta::DeltaInfo& info, const fs::path& app_dir) {
for (auto& relative : info.removed()) {
if (!ci::Remove(app_dir / relative))
return false;
@@ -96,15 +95,15 @@ bool ApplyDeletedFiles(const delta::DeltaInfo& info, const bf::path& app_dir) {
return true;
}
-bool ApplyModifiedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
- const bf::path& patch_dir, bool is_readonly,
+bool ApplyModifiedFiles(const delta::DeltaInfo& info, const fs::path& app_dir,
+ const fs::path& patch_dir, bool is_readonly,
uid_t uid) {
for (auto& relative : info.modified()) {
- bf::path temp_file = ci::GenerateTemporaryPath(
- bf::path(ci::GetRootAppPath(is_readonly, uid)) / "tmp_file");
- bf::path patch_file = patch_dir / relative;
- bf::path input = app_dir / relative;
- if (!bf::is_regular_file(input)) {
+ fs::path temp_file = ci::GenerateTemporaryPath(
+ fs::path(ci::GetRootAppPath(is_readonly, uid)) / "tmp_file");
+ fs::path patch_file = patch_dir / relative;
+ fs::path input = app_dir / relative;
+ if (!fs::is_regular_file(input)) {
LOG(ERROR) << "Cannot modify. Not a regular file: " << input;
return false;
}
@@ -136,12 +135,12 @@ bool ApplyModifiedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
return false;
}
}
- bs::error_code error;
- bf::copy_file(temp_file, input, bf::copy_option::overwrite_if_exists,
+ std::error_code error;
+ fs::copy_file(temp_file, input, fs::copy_options::overwrite_existing,
error);
if (error) {
LOG(ERROR) << "Failed to copy from " << temp_file << " to " << input;
- bf::remove(temp_file, error);
+ fs::remove(temp_file, error);
return false;
}
ci::Remove(temp_file);
@@ -150,14 +149,14 @@ bool ApplyModifiedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
return true;
}
-bool ApplyAddedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
- const bf::path& patch_dir) {
+bool ApplyAddedFiles(const delta::DeltaInfo& info, const fs::path& app_dir,
+ const fs::path& patch_dir) {
for (auto& relative : info.added()) {
- bf::path source = patch_dir / relative;
- bf::path target = app_dir / relative;
- bs::error_code error;
- if (bf::is_directory(source)) {
- bf::create_directories(target, error);
+ fs::path source = patch_dir / relative;
+ fs::path target = app_dir / relative;
+ std::error_code error;
+ if (fs::is_directory(source)) {
+ fs::create_directories(target, error);
if (error) {
LOG(ERROR) << "Failed to add: " << relative;
return false;
@@ -165,8 +164,8 @@ bool ApplyAddedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
} else {
if (!ci::Remove(target))
return false;
- if (!bf::exists(target.parent_path())) {
- bf::create_directories(target.parent_path(), error);
+ if (!fs::exists(target.parent_path())) {
+ fs::create_directories(target.parent_path(), error);
if (error) {
LOG(ERROR) << "Cannot create directory: " << target.parent_path();
return false;
@@ -182,8 +181,8 @@ bool ApplyAddedFiles(const delta::DeltaInfo& info, const bf::path& app_dir,
return true;
}
-bool ApplyPatch(const delta::DeltaInfo& info, const bf::path& app_dir,
- const bf::path& patch_dir, bool is_readonly, uid_t uid) {
+bool ApplyPatch(const delta::DeltaInfo& info, const fs::path& app_dir,
+ const fs::path& patch_dir, bool is_readonly, uid_t uid) {
if (!ApplyDeletedFiles(info, app_dir))
return false;
if (!ApplyModifiedFiles(info, app_dir, patch_dir, is_readonly, uid))
@@ -193,25 +192,25 @@ bool ApplyPatch(const delta::DeltaInfo& info, const bf::path& app_dir,
return true;
}
-bool CopySkipMount(const bf::path& from, const bf::path& to) {
- bs::error_code error;
- bf::create_directory(to, error);
+bool CopySkipMount(const fs::path& from, const fs::path& to) {
+ std::error_code error;
+ fs::create_directory(to, error);
if (error) {
LOG(ERROR) << "Failed to create target directory";
return false;
}
- for (bf::directory_iterator iter(from); iter != bf::directory_iterator();
+ for (fs::directory_iterator iter(from); iter != fs::directory_iterator();
++iter) {
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
- if (bf::is_directory(iter->path())) {
+ if (fs::is_directory(iter->path())) {
if (!ci::CopyDir(iter->path(), to / iter->path().filename())) {
LOG(ERROR) << "Failed to create copy of: " << iter->path();
return false;
}
} else {
- bf::copy(iter->path(), to / iter->path().filename(), error);
+ fs::copy(iter->path(), to / iter->path().filename(), error);
if (error) {
LOG(ERROR) << "Failed to create copy of: " << iter->path();
return false;
@@ -245,8 +244,8 @@ Step::Status StepDeltaPatch::precheck() {
}
Step::Status StepDeltaPatch::process() {
- bf::path delta_file = context_->unpacked_dir_path.get() / kDeltaFile;
- if (!bf::exists(delta_file)) {
+ fs::path delta_file = context_->unpacked_dir_path.get() / kDeltaFile;
+ if (!fs::exists(delta_file)) {
LOG(ERROR) << "Delta file doesn't exist in package.";
return Status::DELTA_ERROR;
}
diff --git a/src/common/step/filesystem/step_delta_patch.h b/src/common/step/filesystem/step_delta_patch.h
index 3bb36884..0c651661 100644
--- a/src/common/step/filesystem/step_delta_patch.h
+++ b/src/common/step/filesystem/step_delta_patch.h
@@ -7,6 +7,7 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
#include <string>
#include "common/installer_context.h"
@@ -45,7 +46,7 @@ class StepDeltaPatch : public Step {
Status precheck() override;
private:
- boost::filesystem::path patch_dir_;
+ std::filesystem::path patch_dir_;
std::string delta_root_;
STEP_NAME(DeltaPatch)
diff --git a/src/common/step/filesystem/step_migrate_legacy_external_image.cc b/src/common/step/filesystem/step_migrate_legacy_external_image.cc
index 07e30022..1c4f3e17 100644
--- a/src/common/step/filesystem/step_migrate_legacy_external_image.cc
+++ b/src/common/step/filesystem/step_migrate_legacy_external_image.cc
@@ -4,16 +4,16 @@
#include "common/step/filesystem/step_migrate_legacy_external_image.h"
-#include <boost/filesystem.hpp>
#include <app2ext_interface.h>
#include <tzplatform_config.h>
+#include <filesystem>
#include <string>
#include "common/security_registration.h"
#include "common/utils/pkgmgr_query.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -38,7 +38,7 @@ Step::Status StepMigrateLegacyExtImage::precheck() {
LOG(ERROR) << "pkg_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->GetPkgPath())) {
+ if (!std::filesystem::exists(context_->GetPkgPath())) {
LOG(ERROR) << "pkg_path ("
<< context_->GetPkgPath()
<< ") path does not exist";
@@ -81,7 +81,7 @@ Step::Status StepMigrateLegacyExtImage::process() {
uid, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
diff --git a/src/common/step/filesystem/step_move_installed_storage.cc b/src/common/step/filesystem/step_move_installed_storage.cc
index f61b1dd8..257b5d9c 100644
--- a/src/common/step/filesystem/step_move_installed_storage.cc
+++ b/src/common/step/filesystem/step_move_installed_storage.cc
@@ -4,12 +4,12 @@
#include "common/step/filesystem/step_move_installed_storage.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
#include <tzplatform_config.h>
-#include <string>
#include <cstring>
+#include <filesystem>
+#include <string>
+#include <system_error>
#include "common/external_storage.h"
#include "common/shared_dirs.h"
@@ -18,17 +18,16 @@
#include "common/pkgmgr_registration.h"
#include "common/utils/pkgmgr_query.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
const char kInternalOnly[] = "internal-only";
-bool MoveFileAndUpdateTepInfo(const boost::filesystem::path& src,
- const boost::filesystem::path& dst,
+bool MoveFileAndUpdateTepInfo(const std::filesystem::path& src,
+ const std::filesystem::path& dst,
const common_installer::InstallerContext* context) {
- if (!bf::exists(src))
+ if (!fs::exists(src))
return true;
if (!common_installer::MoveFile(src, dst)) {
@@ -121,9 +120,9 @@ void StepMoveInstalledStorage::SetTepPaths() {
}
bool StepMoveInstalledStorage::MoveTep() {
- if (!bf::exists(new_tep_location_.parent_path())) {
- bs::error_code error;
- bf::create_directory(new_tep_location_.parent_path(), error);
+ if (!fs::exists(new_tep_location_.parent_path())) {
+ std::error_code error;
+ fs::create_directory(new_tep_location_.parent_path(), error);
if (error) {
LOG(ERROR) << "Failed to destination path for new tep location";
return false;
@@ -171,13 +170,13 @@ bool StepMoveInstalledStorage::MoveBackExternal() {
bool StepMoveInstalledStorage::MoveExtended() {
if (move_type_ == MoveType::TO_EXTENDED) {
old_pkg_location_ = context_->GetPkgPath();
- new_pkg_location_ = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ new_pkg_location_ = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
context_->storage.set(Storage::EXTENDED);
} else {
- old_pkg_location_ = bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ old_pkg_location_ = fs::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
- new_pkg_location_ = bf::path(GetRootAppPath(
+ new_pkg_location_ = fs::path(GetRootAppPath(
context_->is_readonly_package.get(), context_->uid.get())) /
context_->pkgid.get();
context_->storage.set(Storage::INTERNAL);
@@ -194,8 +193,8 @@ bool StepMoveInstalledStorage::MoveExtended() {
// create symlink for extended path
if (move_type_ == MoveType::TO_EXTENDED) {
- bs::error_code error;
- bf::create_symlink(new_pkg_location_, old_pkg_location_, error);
+ std::error_code error;
+ fs::create_symlink(new_pkg_location_, old_pkg_location_, error);
if (error) {
LOG(ERROR) << "Failed to create symlink for extended path: "
<< error.message();
@@ -217,8 +216,8 @@ bool StepMoveInstalledStorage::MoveExtended() {
bool StepMoveInstalledStorage::MoveBackExtended() {
if (move_type_ == MoveType::TO_EXTENDED) {
// Remove symlink if exist
- if (bf::exists(old_pkg_location_) &&
- bf::is_symlink(symlink_status(old_pkg_location_))) {
+ if (fs::exists(old_pkg_location_) &&
+ fs::is_symlink(symlink_status(old_pkg_location_))) {
if (!Remove(old_pkg_location_)) {
LOG(ERROR) << "Failed to remove symlink for extended path";
return false;
@@ -227,8 +226,8 @@ bool StepMoveInstalledStorage::MoveBackExtended() {
}
MoveDir(new_pkg_location_, old_pkg_location_);
if (move_type_ == MoveType::TO_INTERNAL) {
- bs::error_code error;
- bf::create_symlink(old_pkg_location_, new_pkg_location_, error);
+ std::error_code error;
+ fs::create_symlink(old_pkg_location_, new_pkg_location_, error);
if (error) {
LOG(ERROR) << "Failed to create symlink for extended path: "
<< error.message();
@@ -247,4 +246,3 @@ bool StepMoveInstalledStorage::MoveBackExtended() {
} // namespace filesystem
} // namespace common_installer
-
diff --git a/src/common/step/filesystem/step_move_installed_storage.h b/src/common/step/filesystem/step_move_installed_storage.h
index 89d1844e..38e73538 100644
--- a/src/common/step/filesystem/step_move_installed_storage.h
+++ b/src/common/step/filesystem/step_move_installed_storage.h
@@ -5,6 +5,8 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_MOVE_INSTALLED_STORAGE_H_
#define COMMON_STEP_FILESYSTEM_STEP_MOVE_INSTALLED_STORAGE_H_
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/step.h"
@@ -32,10 +34,10 @@ class StepMoveInstalledStorage : public Step {
bool MoveExtended();
bool MoveBackExtended();
- boost::filesystem::path old_tep_location_;
- boost::filesystem::path new_tep_location_;
- boost::filesystem::path old_pkg_location_;
- boost::filesystem::path new_pkg_location_;
+ std::filesystem::path old_tep_location_;
+ std::filesystem::path new_tep_location_;
+ std::filesystem::path old_pkg_location_;
+ std::filesystem::path new_pkg_location_;
MoveType move_type_;
STEP_NAME(MoveInstalledStorage)
diff --git a/src/common/step/filesystem/step_recover_external_storage.cc b/src/common/step/filesystem/step_recover_external_storage.cc
index 99419834..95ae4723 100644
--- a/src/common/step/filesystem/step_recover_external_storage.cc
+++ b/src/common/step/filesystem/step_recover_external_storage.cc
@@ -4,14 +4,11 @@
#include "common/step/filesystem/step_recover_external_storage.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -27,4 +24,3 @@ Step::Status StepRecoverExternalStorage::process() {
} // namespace filesystem
} // namespace common_installer
-
diff --git a/src/common/step/filesystem/step_recover_files.cc b/src/common/step/filesystem/step_recover_files.cc
index a4ef3e81..7932af1e 100644
--- a/src/common/step/filesystem/step_recover_files.cc
+++ b/src/common/step/filesystem/step_recover_files.cc
@@ -4,26 +4,23 @@
#include "common/step/filesystem/step_recover_files.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
#include "common/utils/paths.h"
#include "common/recovery_file.h"
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
const char kExternalMemoryMountPoint[] = ".mmc";
-bool Move(const boost::filesystem::path& from,
- const boost::filesystem::path& to,
+bool Move(const std::filesystem::path& from,
+ const std::filesystem::path& to,
common_installer::FSFlag flag = common_installer::FSFlag::FS_NONE) {
- if (bf::is_directory(from)) {
+ if (fs::is_directory(from)) {
if (!common_installer::MoveDir(from, to / from.filename(), flag)) {
LOG(ERROR) << "Failed to move directory: " << from;
return false;
@@ -55,12 +52,12 @@ Step::Status StepRecoverFiles::RecoveryUpdate() {
recovery::RecoveryFile* recovery_file =
context_->recovery_info.get().recovery_file.get();
bool backup_done = recovery_file->backup_done();
- bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
- if (bf::exists(backup_path)) {
+ fs::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
+ if (fs::exists(backup_path)) {
// Remove pkgdir only if backup original contents is completely done.
if (backup_done) {
- for (bf::directory_iterator iter(context_->GetPkgPath());
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(context_->GetPkgPath());
+ iter != fs::directory_iterator(); ++iter) {
if (iter->path().filename() == kExternalMemoryMountPoint)
continue;
@@ -75,8 +72,8 @@ Step::Status StepRecoverFiles::RecoveryUpdate() {
}
// create copy of old package content skipping the external memory mount point
- for (bf::directory_iterator iter(backup_path);
- iter != bf::directory_iterator(); ++iter) {
+ for (fs::directory_iterator iter(backup_path);
+ iter != fs::directory_iterator(); ++iter) {
if (!Move(iter->path(), context_->GetPkgPath()))
return Status::RECOVERY_ERROR;
}
@@ -88,7 +85,7 @@ Step::Status StepRecoverFiles::RecoveryUpdate() {
}
Step::Status StepRecoverFiles::RecoveryMountNew() {
- bf::path zip_location = GetZipPackageLocation(
+ fs::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
Remove(zip_location);
ClearPath(context_->GetPkgPath());
@@ -97,10 +94,10 @@ Step::Status StepRecoverFiles::RecoveryMountNew() {
}
Step::Status StepRecoverFiles::RecoveryMountUpdate() {
- bf::path zip_location = GetZipPackageLocation(
+ fs::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
- bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
- if (bf::exists(backup_zip_location)) {
+ fs::path backup_zip_location = GetBackupPathForZipFile(zip_location);
+ if (fs::exists(backup_zip_location)) {
Remove(zip_location);
if (!MoveFile(backup_zip_location, zip_location))
LOG(ERROR) << "Failed to move " << backup_zip_location << " to "
@@ -112,10 +109,10 @@ Step::Status StepRecoverFiles::RecoveryMountUpdate() {
// directories without mounting zip package file. In other words in mount
// install or mount update mode we don't mount everything - some files are
// still unpacked due to necessity.
- bf::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
- if (bf::exists(backup_path)) {
- for (bf::directory_iterator iter(backup_path);
- iter != bf::directory_iterator(); ++iter) {
+ fs::path backup_path = GetBackupPathForPackagePath(context_->GetPkgPath());
+ if (fs::exists(backup_path)) {
+ for (fs::directory_iterator iter(backup_path);
+ iter != fs::directory_iterator(); ++iter) {
ClearPath(context_->GetPkgPath() / iter->path().filename());
if (!Move(iter->path(), context_->GetPkgPath())) {
LOG(ERROR) << "Failed to recovery backup file(" << iter->path()
@@ -132,8 +129,8 @@ Step::Status StepRecoverFiles::RecoveryMountUpdate() {
Step::Status StepRecoverFiles::RecoveryReadonlyUpdateInstall() {
// Remove package directory at RW area
- bf::path pkg_path =
- bf::path(GetRootAppPath(false, context_->uid.get())) /
+ fs::path pkg_path =
+ fs::path(GetRootAppPath(false, context_->uid.get())) /
context_->pkgid.get();
if (!ClearPath(pkg_path))
return Status::RECOVERY_ERROR;
@@ -145,11 +142,11 @@ Step::Status StepRecoverFiles::RecoveryReadonlyUpdateInstall() {
Step::Status StepRecoverFiles::Cleanup() {
recovery::RecoveryFile* recovery_file =
context_->recovery_info.get().recovery_file.get();
- bf::path root_path(GetRootAppPath(
+ fs::path root_path(GetRootAppPath(
context_->is_readonly_package.get(), context_->uid.get()));
- bf::path backup_path = GetBackupPathForPackagePath(
+ fs::path backup_path = GetBackupPathForPackagePath(
root_path / recovery_file->pkgid());
- if (!bf::exists(backup_path))
+ if (!fs::exists(backup_path))
return Status::OK;
if (!ClearPath(backup_path)) {
@@ -160,7 +157,7 @@ Step::Status StepRecoverFiles::Cleanup() {
return Status::OK;
}
-bool StepRecoverFiles::ClearPath(const bf::path& path) {
+bool StepRecoverFiles::ClearPath(const fs::path& path) {
return RemoveAll(path);
}
diff --git a/src/common/step/filesystem/step_recover_files.h b/src/common/step/filesystem/step_recover_files.h
index 0b1dcd31..0c798622 100644
--- a/src/common/step/filesystem/step_recover_files.h
+++ b/src/common/step/filesystem/step_recover_files.h
@@ -5,10 +5,10 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_RECOVER_FILES_H_
#define COMMON_STEP_FILESYSTEM_STEP_RECOVER_FILES_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/recovery/step_recovery.h"
@@ -35,7 +35,7 @@ class StepRecoverFiles : public recovery::StepRecovery {
Status Cleanup() override;
protected:
- virtual bool ClearPath(const boost::filesystem::path& path);
+ virtual bool ClearPath(const std::filesystem::path& path);
STEP_NAME(RecoverFiles)
};
diff --git a/src/common/step/filesystem/step_recover_globalapp_symlinks.cc b/src/common/step/filesystem/step_recover_globalapp_symlinks.cc
index 5b5b6991..5ed11cca 100644
--- a/src/common/step/filesystem/step_recover_globalapp_symlinks.cc
+++ b/src/common/step/filesystem/step_recover_globalapp_symlinks.cc
@@ -6,7 +6,7 @@
#include "common/shared_dirs.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
diff --git a/src/common/step/filesystem/step_recover_icons.cc b/src/common/step/filesystem/step_recover_icons.cc
index bf648ee6..28508335 100644
--- a/src/common/step/filesystem/step_recover_icons.cc
+++ b/src/common/step/filesystem/step_recover_icons.cc
@@ -4,16 +4,15 @@
#include "common/step/filesystem/step_recover_icons.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
+#include <filesystem>
+
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -36,7 +35,7 @@ Step::Status StepRecoverIcons::RecoveryUpdate() {
return Status::OK;
}
for (auto& pair : icons_) {
- if (bf::exists(pair.second)) {
+ if (fs::exists(pair.second)) {
if (!Remove(pair.first)) {
LOG(ERROR) << "Cannot move icon to restore its correct location";
return Status::RECOVERY_ERROR;
@@ -57,18 +56,18 @@ bool StepRecoverIcons::TryGatherIcons() {
context_->is_readonly_package.get());
if (!extra_icon_path)
return true;
- for (auto iter = bf::directory_iterator(extra_icon_path);
- iter != bf::directory_iterator(); ++iter) {
- if (!bf::is_regular_file(iter->path()))
+ for (auto iter = fs::directory_iterator(extra_icon_path);
+ iter != fs::directory_iterator(); ++iter) {
+ if (!fs::is_regular_file(iter->path()))
continue;
for (application_x* app : GListRange<application_x*>(
context_->manifest_data.get()->application)) {
if (app->icon) {
- bf::path p = iter->path();
+ fs::path p = iter->path();
std::string filename = iter->path().filename().string();
if (filename.find(app->appid) == 0) {
- bf::path icon;
- bf::path icon_backup;
+ fs::path icon;
+ fs::path icon_backup;
if (p.extension() == GetIconFileBackupExtension()) {
icon_backup = p;
icon = p.replace_extension("");
@@ -86,4 +85,3 @@ bool StepRecoverIcons::TryGatherIcons() {
} // namespace filesystem
} // namespace common_installer
-
diff --git a/src/common/step/filesystem/step_recover_icons.h b/src/common/step/filesystem/step_recover_icons.h
index 4e3692e0..da3bf4cb 100644
--- a/src/common/step/filesystem/step_recover_icons.h
+++ b/src/common/step/filesystem/step_recover_icons.h
@@ -5,10 +5,9 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_RECOVER_ICONS_H_
#define COMMON_STEP_FILESYSTEM_STEP_RECOVER_ICONS_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
#include <set>
#include <string>
#include <utility>
@@ -37,7 +36,7 @@ class StepRecoverIcons : public recovery::StepRecovery {
private:
bool TryGatherIcons();
- std::set<std::pair<boost::filesystem::path, boost::filesystem::path>>
+ std::set<std::pair<std::filesystem::path, std::filesystem::path>>
icons_;
STEP_NAME(RecoverIcons)
diff --git a/src/common/step/filesystem/step_recover_manifest.cc b/src/common/step/filesystem/step_recover_manifest.cc
index 55d0ec99..21e9d9b6 100644
--- a/src/common/step/filesystem/step_recover_manifest.cc
+++ b/src/common/step/filesystem/step_recover_manifest.cc
@@ -4,16 +4,14 @@
#include "common/step/filesystem/step_recover_manifest.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
+#include <filesystem>
+
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -33,7 +31,7 @@ Step::Status StepRecoverManifest::RecoveryUpdate() {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
- if (bf::exists(context_->backup_xml_path.get())) {
+ if (fs::exists(context_->backup_xml_path.get())) {
if (!Remove(context_->xml_path.get())) {
LOG(ERROR) << "Cannot move manifest file to restore its location";
return Status::RECOVERY_ERROR;
@@ -49,7 +47,7 @@ Step::Status StepRecoverManifest::RecoveryReadonlyUpdateInstall() {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
- if (bf::exists(context_->xml_path.get())) {
+ if (fs::exists(context_->xml_path.get())) {
if (!Remove(context_->xml_path.get())) {
LOG(ERROR) << "Cannot move manifest file to restore its location";
return Status::RECOVERY_ERROR;
@@ -64,7 +62,7 @@ Step::Status StepRecoverManifest::Cleanup() {
LOG(DEBUG) << "Manifest recovery not needed";
return Status::OK;
}
- if (bf::exists(context_->backup_xml_path.get())) {
+ if (fs::exists(context_->backup_xml_path.get())) {
if (!Remove(context_->backup_xml_path.get())) {
LOG(ERROR) << "Cannot remove backup manifest file";
return Status::RECOVERY_ERROR;
@@ -77,8 +75,8 @@ Step::Status StepRecoverManifest::Cleanup() {
bool StepRecoverManifest::SetXmlPaths(bool is_readonly_package) {
if (context_->pkgid.get().empty())
return false;
- bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(), is_readonly_package))
+ fs::path xml_path =
+ fs::path(getUserManifestPath(context_->uid.get(), is_readonly_package))
/ context_->pkgid.get();
xml_path += ".xml";
context_->xml_path.set(xml_path);
diff --git a/src/common/step/filesystem/step_recover_storage_directories.cc b/src/common/step/filesystem/step_recover_storage_directories.cc
index 0bb69994..784c9f85 100644
--- a/src/common/step/filesystem/step_recover_storage_directories.cc
+++ b/src/common/step/filesystem/step_recover_storage_directories.cc
@@ -5,11 +5,10 @@
#include "common/step/filesystem/step_recover_storage_directories.h"
#include "common/step/filesystem/step_remove_per_user_storage_directories.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
+
#include "common/utils/paths.h"
#include "common/privileges.h"
#include "common/shared_dirs.h"
@@ -17,8 +16,8 @@
#include "common/utils/glist_range.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -51,21 +50,21 @@ Step::Status StepRecoverStorageDirectories::RecoveryNew() {
}
bool StepRecoverStorageDirectories::MoveAppStorage(
- const bf::path& in_src,
- const bf::path& in_dst,
+ const fs::path& in_src,
+ const fs::path& in_dst,
const char *key) {
- bf::path src = in_src / key;
- if (!bf::exists(src))
+ fs::path src = in_src / key;
+ if (!fs::exists(src))
return false;
- bf::path dst = in_dst / key;
+ fs::path dst = in_dst / key;
return common_installer::MoveDir(src, dst);
}
Step::Status StepRecoverStorageDirectories::RecoveryUpdate() {
if (!context_->GetPkgPath().empty()) {
- bf::path backup_path = common_installer::GetBackupPathForPackagePath(
+ fs::path backup_path = common_installer::GetBackupPathForPackagePath(
context_->GetPkgPath());
- if (bf::exists(backup_path)) {
+ if (fs::exists(backup_path)) {
MoveAppStorage(context_->GetPkgPath(), backup_path, kDataLocation);
MoveAppStorage(context_->GetPkgPath(), backup_path, kSharedResLocation);
}
@@ -106,4 +105,3 @@ Step::Status StepRecoverStorageDirectories::RecoveryMountUpdate() {
} // namespace filesystem
} // namespace common_installer
-
diff --git a/src/common/step/filesystem/step_recover_storage_directories.h b/src/common/step/filesystem/step_recover_storage_directories.h
index 36de8cb3..5a385945 100644
--- a/src/common/step/filesystem/step_recover_storage_directories.h
+++ b/src/common/step/filesystem/step_recover_storage_directories.h
@@ -7,6 +7,8 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/recovery/step_recovery.h"
@@ -35,8 +37,8 @@ class StepRecoverStorageDirectories : public recovery::StepRecovery {
* @param key directory name
* @return true if operation successful
*/
- bool MoveAppStorage(const boost::filesystem::path& in_src,
- const boost::filesystem::path& in_dst,
+ bool MoveAppStorage(const std::filesystem::path& in_src,
+ const std::filesystem::path& in_dst,
const char *key);
STEP_NAME(RecoverStorageDirectories)
diff --git a/src/common/step/filesystem/step_remove_files.cc b/src/common/step/filesystem/step_remove_files.cc
index 63d3c6ca..77f1b90a 100644
--- a/src/common/step/filesystem/step_remove_files.cc
+++ b/src/common/step/filesystem/step_remove_files.cc
@@ -4,13 +4,11 @@
#include "common/step/filesystem/step_remove_files.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
#include <sys/types.h>
#include <tzplatform_config.h>
#include <algorithm>
+#include <filesystem>
#include <string>
#include <vector>
@@ -19,15 +17,14 @@
#include "common/utils/user_util.h"
#include "common/shared_dirs.h"
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
const char kSubsesionDir[] = "subsession";
-bool SkipRWDirectories(const bf::path& path) {
+bool SkipRWDirectories(const fs::path& path) {
static const std::vector<std::string> dirs_to_ignore = {
{"cache"},
{"data"},
@@ -40,7 +37,7 @@ bool SkipRWDirectories(const bf::path& path) {
}
bool RemoveSignature(const std::string& pkgid, bool is_readonly) {
- bf::path signature_path = bf::path(is_readonly ?
+ fs::path signature_path = fs::path(is_readonly ?
tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE)) /
"signatures";
signature_path /= std::string(pkgid + ".txt");
@@ -66,7 +63,7 @@ Step::Status StepRemoveFiles::precheck() {
// to remove the files
if (context_->GetPkgPath().empty())
LOG(ERROR) << "pkg_path attribute is empty";
- else if (!bf::exists(context_->GetPkgPath()))
+ else if (!fs::exists(context_->GetPkgPath()))
LOG(ERROR) << "pkg_path ("
<< context_->GetPkgPath()
<< ") path does not exist";
@@ -89,7 +86,7 @@ Step::Status StepRemoveFiles::process() {
}
bool is_error = false;
- std::vector<bf::path> root_paths;
+ std::vector<fs::path> root_paths;
// Use RootAppPath + Pkgid because of ReadonlyUpdateUninstall
root_paths.push_back(context_->root_application_path.get());
@@ -100,10 +97,10 @@ Step::Status StepRemoveFiles::process() {
for (auto& root_path : root_paths) {
if (is_keep_rwdata) {
bool ret;
- for (bf::directory_iterator itr(root_path / context_->pkgid.get());
- itr != bf::directory_iterator(); ++itr) {
- if (bf::is_directory(itr->status())) {
- if (SkipRWDirectories(itr->path().leaf())) {
+ for (fs::directory_iterator itr(root_path / context_->pkgid.get());
+ itr != fs::directory_iterator(); ++itr) {
+ if (fs::is_directory(itr->status())) {
+ if (SkipRWDirectories(itr->path().filename())) {
LOG(DEBUG) << "Skipping remove dir:" << itr->path().c_str();
continue;
}
@@ -127,8 +124,8 @@ Step::Status StepRemoveFiles::process() {
// Remove package files at extended storage
if (context_->storage.get() == Storage::EXTENDED) {
- bf::path extended_path =
- bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ fs::path extended_path =
+ fs::path(GetExtendedRootAppPath(context_->uid.get())) /
context_->pkgid.get();
if (!RemoveAll(extended_path))
return Status::APP_DIR_ERROR;
@@ -136,8 +133,8 @@ Step::Status StepRemoveFiles::process() {
for (auto& lw_user : GetLightUserList(context_->uid.get())) {
if (context_->storage.get() == Storage::EXTENDED) {
- bf::path extended_path =
- bf::path(GetExtendedRootAppPath(context_->uid.get())) /
+ fs::path extended_path =
+ fs::path(GetExtendedRootAppPath(context_->uid.get())) /
kSubsesionDir / lw_user / context_->pkgid.get();
if (!RemoveAll(extended_path))
return Status::APP_DIR_ERROR;
diff --git a/src/common/step/filesystem/step_remove_icons.cc b/src/common/step/filesystem/step_remove_icons.cc
index e256c590..0bc5e098 100644
--- a/src/common/step/filesystem/step_remove_icons.cc
+++ b/src/common/step/filesystem/step_remove_icons.cc
@@ -4,19 +4,17 @@
#include "common/step/filesystem/step_remove_icons.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
#include <pkgmgr-info.h>
#include <cstring>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
-
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -35,11 +33,11 @@ Step::Status StepRemoveIcons::process() {
context_->is_readonly_package.get());
if (!extra_icon_path)
return Status::OK;
- for (auto iter = bf::directory_iterator(extra_icon_path);
- iter != bf::directory_iterator(); ++iter) {
- if (!bf::is_regular_file(iter->path()))
+ for (auto iter = fs::directory_iterator(extra_icon_path);
+ iter != fs::directory_iterator(); ++iter) {
+ if (!fs::is_regular_file(iter->path()))
continue;
- bs::error_code error;
+ std::error_code error;
for (application_x* app :
GListRange<application_x*>(
context_->manifest_data.get()->application)) {
diff --git a/src/common/step/filesystem/step_remove_icons.h b/src/common/step/filesystem/step_remove_icons.h
index 60eb11b7..5183b8b6 100644
--- a/src/common/step/filesystem/step_remove_icons.h
+++ b/src/common/step/filesystem/step_remove_icons.h
@@ -5,8 +5,6 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_REMOVE_ICONS_H_
#define COMMON_STEP_FILESYSTEM_STEP_REMOVE_ICONS_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
#include <utility>
diff --git a/src/common/step/filesystem/step_remove_temporary_directory.cc b/src/common/step/filesystem/step_remove_temporary_directory.cc
index 626b8879..a9b2a9f4 100644
--- a/src/common/step/filesystem/step_remove_temporary_directory.cc
+++ b/src/common/step/filesystem/step_remove_temporary_directory.cc
@@ -3,8 +3,7 @@
// found in the LICENSE file.
#include "common/step/filesystem/step_remove_temporary_directory.h"
-#include <boost/filesystem.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
#include "common/installer_context.h"
#include "common/utils/file_util.h"
@@ -12,7 +11,7 @@
namespace common_installer {
namespace filesystem {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
Step::Status StepRemoveTemporaryDirectory::RecoveryUpdate() {
return RemoveFiles();
@@ -27,10 +26,10 @@ Step::Status StepRemoveTemporaryDirectory::Cleanup() {
}
Step::Status StepRemoveTemporaryDirectory::RemoveFiles() {
- bf::path unpack_dir_path = context_->unpacked_dir_path.get();
- bf::path patch_dir_path = unpack_dir_path;
- bf::path mount_dir_path = unpack_dir_path;
- bf::path shared_res_backup_dir_path = unpack_dir_path;
+ fs::path unpack_dir_path = context_->unpacked_dir_path.get();
+ fs::path patch_dir_path = unpack_dir_path;
+ fs::path mount_dir_path = unpack_dir_path;
+ fs::path shared_res_backup_dir_path = unpack_dir_path;
patch_dir_path += ".patch";
mount_dir_path += ".bck";
shared_res_backup_dir_path += ".SharedRes";
@@ -44,10 +43,9 @@ Step::Status StepRemoveTemporaryDirectory::RemoveFiles() {
return Step::Status::OK;
}
-bool StepRemoveTemporaryDirectory::ClearPath(const bf::path& path) {
+bool StepRemoveTemporaryDirectory::ClearPath(const fs::path& path) {
return RemoveAll(path);
}
} // namespace filesystem
} // namespace common_installer
-
diff --git a/src/common/step/filesystem/step_remove_temporary_directory.h b/src/common/step/filesystem/step_remove_temporary_directory.h
index 75fca261..1f62e392 100644
--- a/src/common/step/filesystem/step_remove_temporary_directory.h
+++ b/src/common/step/filesystem/step_remove_temporary_directory.h
@@ -5,10 +5,10 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_REMOVE_TEMPORARY_DIRECTORY_H_
#define COMMON_STEP_FILESYSTEM_STEP_REMOVE_TEMPORARY_DIRECTORY_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/step/recovery/step_recovery.h"
namespace common_installer {
@@ -31,7 +31,7 @@ class StepRemoveTemporaryDirectory : public recovery::StepRecovery {
Status Cleanup() override;
protected:
- virtual bool ClearPath(const boost::filesystem::path& path);
+ virtual bool ClearPath(const std::filesystem::path& path);
private:
/**
diff --git a/src/common/step/filesystem/step_remove_tep.cc b/src/common/step/filesystem/step_remove_tep.cc
index ef415d30..c7cd6499 100644
--- a/src/common/step/filesystem/step_remove_tep.cc
+++ b/src/common/step/filesystem/step_remove_tep.cc
@@ -4,22 +4,19 @@
#include "common/step/filesystem/step_remove_tep.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
+#include <filesystem>
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
Step::Status StepRemoveTep::process() {
if (context_->manifest_data.get()->tep_name) {
- bf::path tep_path(context_->manifest_data.get()->tep_name);
- if (bf::exists(tep_path)) {
- bs::error_code error;
- bf::remove(tep_path, error);
+ fs::path tep_path(context_->manifest_data.get()->tep_name);
+ if (fs::exists(tep_path)) {
+ std::error_code error;
+ fs::remove(tep_path, error);
if (error) {
// Deinstallation should not fail even if sd card is not inserted
// In spite of this, we print only warning
diff --git a/src/common/step/filesystem/step_remove_user_data.cc b/src/common/step/filesystem/step_remove_user_data.cc
index e6a81e43..4999aa4c 100644
--- a/src/common/step/filesystem/step_remove_user_data.cc
+++ b/src/common/step/filesystem/step_remove_user_data.cc
@@ -4,6 +4,7 @@
#include "common/step/filesystem/step_remove_user_data.h"
+#include <filesystem>
#include <string>
#include <utility>
#include <vector>
@@ -13,7 +14,7 @@
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
@@ -23,11 +24,11 @@ const char kCacheDir[] = "cache";
const char kSharedDir[] = ".shared";
const char kSubssesionDir[] = "subsession";
-bool RemoveContents(const bf::path& path) {
- if (!bf::exists(path))
+bool RemoveContents(const fs::path& path) {
+ if (!fs::exists(path))
return true;
- for (bf::directory_iterator iter(path); iter != bf::directory_iterator();
+ for (fs::directory_iterator iter(path); iter != fs::directory_iterator();
++iter) {
if (!ci::RemoveAll(iter->path()))
return false;
@@ -49,8 +50,8 @@ Step::Status StepRemoveUserData::process() {
UserList list = ci::GetUserList();
for (const auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path owner_apps_rw(std::get<2>(l) / "apps_rw");
- std::vector<bf::path> apps_rw_paths;
+ fs::path owner_apps_rw(std::get<2>(l) / "apps_rw");
+ std::vector<fs::path> apps_rw_paths;
apps_rw_paths.push_back(std::move(owner_apps_rw));
for (auto& lw_user : GetLightUserList(uid))
apps_rw_paths.push_back(std::get<2>(l) / kSubssesionDir / lw_user /
diff --git a/src/common/step/filesystem/step_remove_zip_image.cc b/src/common/step/filesystem/step_remove_zip_image.cc
index e6b020d2..212a167e 100644
--- a/src/common/step/filesystem/step_remove_zip_image.cc
+++ b/src/common/step/filesystem/step_remove_zip_image.cc
@@ -4,10 +4,8 @@
#include "common/step/filesystem/step_remove_zip_image.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
#include <algorithm>
+#include <filesystem>
#include <string>
#include <vector>
@@ -16,8 +14,7 @@
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -29,9 +26,9 @@ Step::Status StepRemoveZipImage::precheck() {
}
Step::Status StepRemoveZipImage::process() {
- bf::path zip_image_path =
+ fs::path zip_image_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
- if (bf::exists(zip_image_path)) {
+ if (fs::exists(zip_image_path)) {
if (Remove(zip_image_path))
LOG(INFO) << "Zip image file removed: " << zip_image_path;
}
diff --git a/src/common/step/filesystem/step_unzip.cc b/src/common/step/filesystem/step_unzip.cc
index 0f82ec8e..ed47f22c 100644
--- a/src/common/step/filesystem/step_unzip.cc
+++ b/src/common/step/filesystem/step_unzip.cc
@@ -7,20 +7,18 @@
#include <tzplatform_config.h>
-#include <boost/filesystem.hpp>
-#include <boost/chrono/detail/system.hpp>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <climits>
#include <cstring>
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
@@ -36,7 +34,7 @@ Step::Status StepUnzip::precheck() {
LOG(ERROR) << "file_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->file_path.get())) {
+ if (!std::filesystem::exists(context_->file_path.get())) {
LOG(ERROR) << "file_path ("
<< context_->file_path.get()
<< ") path does not exist";
@@ -47,7 +45,7 @@ Step::Status StepUnzip::precheck() {
LOG(ERROR) << "root_application_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ if (!std::filesystem::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -58,7 +56,7 @@ Step::Status StepUnzip::precheck() {
}
Step::Status StepUnzip::process() {
- bf::path tmp_dir = GenerateTmpDir(kPackageUnpackDirPath);
+ fs::path tmp_dir = GenerateTmpDir(kPackageUnpackDirPath);
int64_t required_size =
GetUnpackedPackageSize(context_->file_path.get());
@@ -77,7 +75,7 @@ Step::Status StepUnzip::process() {
}
if (!CheckFreeSpaceAtPath(required_size,
- bf::path(context_->root_application_path.get()))) {
+ fs::path(context_->root_application_path.get()))) {
LOG(ERROR) << "There is not enough space to install application files";
return Step::Status::OUT_OF_SPACE;
}
@@ -94,7 +92,7 @@ Step::Status StepUnzip::process() {
}
- if (!ExtractToTmpDir(context_->file_path.get().string().c_str(), tmp_dir)) {
+ if (!ExtractToTmpDir(context_->file_path.get().c_str(), tmp_dir)) {
LOG(ERROR) << "Failed to process unpack step";
RemoveAll(tmp_dir);
return Step::Status::UNZIP_ERROR;
@@ -107,7 +105,7 @@ Step::Status StepUnzip::process() {
}
Step::Status StepUnzip::undo() {
- if (access(context_->unpacked_dir_path.get().string().c_str(), F_OK) == 0) {
+ if (access(context_->unpacked_dir_path.get().c_str(), F_OK) == 0) {
RemoveAll(context_->unpacked_dir_path.get());
LOG(DEBUG) << "remove temp dir: " << context_->unpacked_dir_path.get();
}
diff --git a/src/common/step/filesystem/step_unzip.h b/src/common/step/filesystem/step_unzip.h
index 7d9651e9..f69ae415 100644
--- a/src/common/step/filesystem/step_unzip.h
+++ b/src/common/step/filesystem/step_unzip.h
@@ -6,8 +6,6 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_UNZIP_H_
#define COMMON_STEP_FILESYSTEM_STEP_UNZIP_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
#include "common/installer_context.h"
diff --git a/src/common/step/filesystem/step_update_storage_directories.cc b/src/common/step/filesystem/step_update_storage_directories.cc
index d8d2abc0..abba647d 100644
--- a/src/common/step/filesystem/step_update_storage_directories.cc
+++ b/src/common/step/filesystem/step_update_storage_directories.cc
@@ -4,10 +4,7 @@
#include "common/step/filesystem/step_update_storage_directories.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
+#include <filesystem>
#include <string>
#include <vector>
@@ -19,8 +16,7 @@
#include "common/utils/glist_range.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
@@ -94,15 +90,15 @@ Step::Status StepUpdateStorageDirectories::precheck() {
if (!context_->manifest_data.get())
return Status::INVALID_VALUE;
- bf::path path;
+ fs::path path;
if (context_->request_mode.get() == RequestMode::GLOBAL)
- path = bf::path(tzplatform_getenv(TZ_SYS_ETC)) / bf::path(kSkelAppDir) /
+ path = fs::path(tzplatform_getenv(TZ_SYS_ETC)) / fs::path(kSkelAppDir) /
context_->pkgid.get() / kSharedDataDir;
else
- path = bf::path(ci::GetRootAppPath(false, context_->uid.get())) /
+ path = fs::path(ci::GetRootAppPath(false, context_->uid.get())) /
context_->pkgid.get() / kSharedDataDir;
- old_shared_data_exists_ = bf::exists(path);
+ old_shared_data_exists_ = fs::exists(path);
should_create_shared_data_ = ShouldCreateSharedDataDir(
context_->manifest_data.get());
diff --git a/src/common/step/filesystem/step_update_storage_directories.h b/src/common/step/filesystem/step_update_storage_directories.h
index a7390e2c..4231781f 100644
--- a/src/common/step/filesystem/step_update_storage_directories.h
+++ b/src/common/step/filesystem/step_update_storage_directories.h
@@ -5,8 +5,6 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_UPDATE_STORAGE_DIRECTORIES_H_
#define COMMON_STEP_FILESYSTEM_STEP_UPDATE_STORAGE_DIRECTORIES_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
#include "common/step/step.h"
diff --git a/src/common/step/filesystem/step_update_tep.cc b/src/common/step/filesystem/step_update_tep.cc
index 41b51176..c2931da3 100644
--- a/src/common/step/filesystem/step_update_tep.cc
+++ b/src/common/step/filesystem/step_update_tep.cc
@@ -6,17 +6,16 @@
#include <pkgmgr-info.h>
-#include <boost/filesystem.hpp>
-
#include <cstring>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
@@ -50,14 +49,14 @@ Step::Status StepUpdateTep::process() {
// copy if necessary
if (!context_->external_storage) {
- bf::path new_path = context_->manifest_data.get()->tep_name;
- bf::path backup_path =
+ fs::path new_path = context_->manifest_data.get()->tep_name;
+ fs::path backup_path =
GetInternalTepPath(
GetBackupPathForPackagePath(context_->GetPkgPath()));
backup_path /= new_path.filename();
- if (!bf::exists(new_path.parent_path())) {
- bs::error_code error;
- bf::create_directory(new_path.parent_path(), error);
+ if (!fs::exists(new_path.parent_path())) {
+ std::error_code error;
+ fs::create_directory(new_path.parent_path(), error);
if (error) {
LOG(ERROR) << "Cannot recreate directory for tep file";
return Status::APP_DIR_ERROR;
@@ -77,7 +76,7 @@ Step::Status StepUpdateTep::clean() {
if (context_->old_manifest_data.get()->tep_name &&
strcmp(context_->old_manifest_data.get()->tep_name,
context_->manifest_data.get()->tep_name)) {
- bf::path old_tep = context_->old_manifest_data.get()->tep_name;
+ fs::path old_tep = context_->old_manifest_data.get()->tep_name;
Remove(old_tep);
}
}
@@ -85,7 +84,7 @@ Step::Status StepUpdateTep::clean() {
}
Step::Status StepUpdateTep::undo() {
- const bf::path& remove_path = context_->tep_path.get();
+ const fs::path& remove_path = context_->tep_path.get();
RemoveAll(context_->old_manifest_data.get()->tep_name ?
remove_path : remove_path.parent_path());
return Status::OK;
diff --git a/src/common/step/filesystem/step_update_tep.h b/src/common/step/filesystem/step_update_tep.h
index fb76c347..c84ed454 100644
--- a/src/common/step/filesystem/step_update_tep.h
+++ b/src/common/step/filesystem/step_update_tep.h
@@ -5,7 +5,6 @@
#ifndef COMMON_STEP_FILESYSTEM_STEP_UPDATE_TEP_H_
#define COMMON_STEP_FILESYSTEM_STEP_UPDATE_TEP_H_
-#include <boost/filesystem/path.hpp>
#include <manifest_parser/utils/logging.h>
#include "common/installer_context.h"
diff --git a/src/common/step/mount/step_check_mount_path.cc b/src/common/step/mount/step_check_mount_path.cc
index 5339bcc7..e075b8fa 100644
--- a/src/common/step/mount/step_check_mount_path.cc
+++ b/src/common/step/mount/step_check_mount_path.cc
@@ -4,23 +4,20 @@
#include "step/mount/step_check_mount_path.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/utils/paths.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace mount {
Step::Status StepCheckMountPath::process() {
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
- if (!bf::exists(zip_destination_path))
+ if (!fs::exists(zip_destination_path))
return Status::OK;
context_->manifest_data.get()->zip_mount_file =
diff --git a/src/common/step/mount/step_mount_install.cc b/src/common/step/mount/step_mount_install.cc
index a10d2918..d4313f9d 100644
--- a/src/common/step/mount/step_mount_install.cc
+++ b/src/common/step/mount/step_mount_install.cc
@@ -4,9 +4,7 @@
#include "step/mount/step_mount_install.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/shared_dirs.h"
@@ -16,9 +14,8 @@
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace mount {
@@ -30,11 +27,11 @@ Step::Status StepMountInstall::process() {
return Status::APP_DIR_ERROR;
}
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
- if (!bf::exists(zip_destination_path.parent_path())) {
- bs::error_code error;
- bf::create_directories(zip_destination_path.parent_path(), error);
+ if (!fs::exists(zip_destination_path.parent_path())) {
+ std::error_code error;
+ fs::create_directories(zip_destination_path.parent_path(), error);
if (error) {
LOG(ERROR) << "Failed to create diretory: "
<< zip_destination_path.parent_path();
@@ -49,7 +46,7 @@ Step::Status StepMountInstall::process() {
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
@@ -61,7 +58,7 @@ Step::Status StepMountInstall::process() {
}
Step::Status StepMountInstall::UmountPackagePath() {
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
@@ -72,15 +69,15 @@ Step::Status StepMountInstall::UmountPackagePath() {
}
Step::Status StepMountInstall::undo() {
- bs::error_code error;
+ std::error_code error;
UmountPackagePath();
- bf::remove(GetZipPackageLocation(context_->GetPkgPath(),
+ fs::remove(GetZipPackageLocation(context_->GetPkgPath(),
context_->pkgid.get()), error);
if (error) {
LOG(ERROR) << "Failed to remove zip package";
return Status::APP_DIR_ERROR;
}
- bf::remove_all(context_->GetPkgPath(), error);
+ fs::remove_all(context_->GetPkgPath(), error);
if (error) {
LOG(ERROR) << "Failed to remove package content";
return Status::APP_DIR_ERROR;
@@ -93,7 +90,7 @@ Step::Status StepMountInstall::precheck() {
LOG(ERROR) << "root_application_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!bf::exists(context_->root_application_path.get())) {
+ if (!fs::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -104,7 +101,7 @@ Step::Status StepMountInstall::precheck() {
LOG(ERROR) << "unpacked_dir_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!bf::exists(context_->unpacked_dir_path.get())) {
+ if (!fs::exists(context_->unpacked_dir_path.get())) {
LOG(ERROR) << "unpacked_dir_path ("
<< context_->unpacked_dir_path.get()
<< ") path does not exist";
@@ -120,7 +117,7 @@ Step::Status StepMountInstall::precheck() {
}
std::unique_ptr<IZipInterface> StepMountInstall::CreateZipInterface(
- const boost::filesystem::path& mount_path) {
+ const fs::path& mount_path) {
std::unique_ptr<IZipInterface> zip_interface(
new TzipInterface(mount_path));
return zip_interface;
diff --git a/src/common/step/mount/step_mount_install.h b/src/common/step/mount/step_mount_install.h
index 2a2242f6..b30b54f2 100644
--- a/src/common/step/mount/step_mount_install.h
+++ b/src/common/step/mount/step_mount_install.h
@@ -7,6 +7,8 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
@@ -39,7 +41,7 @@ class StepMountInstall : public MountBase, public Step {
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
Status UmountPackagePath();
STEP_NAME(MountInstall);
diff --git a/src/common/step/mount/step_mount_recover.cc b/src/common/step/mount/step_mount_recover.cc
index 65e1c3b4..be839f60 100644
--- a/src/common/step/mount/step_mount_recover.cc
+++ b/src/common/step/mount/step_mount_recover.cc
@@ -4,29 +4,28 @@
#include "step/mount/step_mount_recover.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
+
#include "common/utils/file_util.h"
#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace mount {
Step::Status StepMountRecover::RecoveryMountUpdate() {
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
manifest_x* manifest = context_->manifest_data.get();
if (manifest)
manifest->zip_mount_file = strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
@@ -47,11 +46,11 @@ Step::Status StepMountRecover::Cleanup() {
if (recovery_file->type() != RequestType::MountUpdate)
return Status::OK;
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
- bf::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path);
+ fs::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path);
- if (bf::exists(backup_zip_location)) {
+ if (fs::exists(backup_zip_location)) {
if (!Remove(backup_zip_location)) {
LOG(ERROR) << "Fail to remove backup zip location : "
<< backup_zip_location;
@@ -93,7 +92,7 @@ Step::Status StepMountRecover::undo() {
}
Step::Status StepMountRecover::UmountPackagePath() {
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
@@ -104,7 +103,7 @@ Step::Status StepMountRecover::UmountPackagePath() {
}
std::unique_ptr<IZipInterface> StepMountRecover::CreateZipInterface(
- const boost::filesystem::path& mount_path) {
+ const std::filesystem::path& mount_path) {
std::unique_ptr<IZipInterface> zip_interface(
new TzipInterface(mount_path));
return zip_interface;
diff --git a/src/common/step/mount/step_mount_recover.h b/src/common/step/mount/step_mount_recover.h
index 9236b76f..23535fb0 100644
--- a/src/common/step/mount/step_mount_recover.h
+++ b/src/common/step/mount/step_mount_recover.h
@@ -7,6 +7,8 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/recovery/step_recovery.h"
@@ -34,7 +36,7 @@ class StepMountRecover : public MountBase, public recovery::StepRecovery {
private:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
Status UmountPackagePath();
STEP_NAME(MountRecover)
diff --git a/src/common/step/mount/step_mount_unpacked.cc b/src/common/step/mount/step_mount_unpacked.cc
index e0fe999d..95e6ce3f 100644
--- a/src/common/step/mount/step_mount_unpacked.cc
+++ b/src/common/step/mount/step_mount_unpacked.cc
@@ -4,10 +4,9 @@
#include "common/step/mount/step_mount_unpacked.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
#include <unistd.h>
+#include <filesystem>
#include <string>
#include "common/utils/paths.h"
@@ -15,8 +14,7 @@
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
@@ -28,7 +26,7 @@ namespace common_installer {
namespace mount {
Step::Status StepMountUnpacked::process() {
- bf::path tmp_dir = GenerateTmpDir(kPackageUnpackDirPath);
+ fs::path tmp_dir = GenerateTmpDir(kPackageUnpackDirPath);
context_->unpacked_dir_path.set(tmp_dir);
// write unpacked directory for recovery file
// to remove unpacked dir properly when recovery mode
@@ -57,7 +55,7 @@ Step::Status StepMountUnpacked::undo() {
RemoveAll(context_->unpacked_dir_path.get());
if (context_->request_type.get() == RequestType::MountUpdate) {
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after revoke";
@@ -72,7 +70,7 @@ Step::Status StepMountUnpacked::precheck() {
LOG(ERROR) << "file_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!bf::exists(context_->file_path.get())) {
+ if (!fs::exists(context_->file_path.get())) {
LOG(ERROR) << "file_path ("
<< context_->file_path.get()
<< ") path does not exist";
@@ -82,7 +80,7 @@ Step::Status StepMountUnpacked::precheck() {
LOG(ERROR) << "root_application_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!bf::exists(context_->root_application_path.get())) {
+ if (!fs::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -92,7 +90,7 @@ Step::Status StepMountUnpacked::precheck() {
}
std::unique_ptr<IZipInterface> StepMountUnpacked::CreateZipInterface(
- const boost::filesystem::path& mount_path) {
+ const fs::path& mount_path) {
std::unique_ptr<IZipInterface> zip_interface(
new TzipInterface(mount_path));
return zip_interface;
diff --git a/src/common/step/mount/step_mount_unpacked.h b/src/common/step/mount/step_mount_unpacked.h
index f1d8b400..bd37e2aa 100644
--- a/src/common/step/mount/step_mount_unpacked.h
+++ b/src/common/step/mount/step_mount_unpacked.h
@@ -7,6 +7,8 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
@@ -36,7 +38,7 @@ class StepMountUnpacked : public MountBase, public Step {
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
STEP_NAME(MountUnpacked)
};
diff --git a/src/common/step/mount/step_mount_update.cc b/src/common/step/mount/step_mount_update.cc
index fcba92d4..486c3df8 100644
--- a/src/common/step/mount/step_mount_update.cc
+++ b/src/common/step/mount/step_mount_update.cc
@@ -4,9 +4,7 @@
#include "common/step/mount/step_mount_update.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/shared_dirs.h"
@@ -16,18 +14,17 @@
#include "common/utils/file_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace mount {
Step::Status StepMountUpdate::process() {
- bs::error_code error;
+ std::error_code error;
- if (!bf::exists(backup_path_)) {
- bf::create_directories(backup_path_, error);
+ if (!fs::exists(backup_path_)) {
+ fs::create_directories(backup_path_, error);
if (error) {
LOG(ERROR) << "Failed to create backup directory: " << backup_path_;
return Status::APP_DIR_ERROR;
@@ -40,9 +37,9 @@ Step::Status StepMountUpdate::process() {
return Status::APP_DIR_ERROR;
}
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
- bf::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path);
+ fs::path backup_zip_location = GetBackupPathForZipFile(zip_destination_path);
if (!MoveFile(zip_destination_path, backup_zip_location)) {
LOG(ERROR) << "Files to create backup of zip package file";
@@ -56,7 +53,7 @@ Step::Status StepMountUpdate::process() {
context_->manifest_data.get()->zip_mount_file =
strdup(zip_destination_path.c_str());
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
@@ -68,7 +65,7 @@ Step::Status StepMountUpdate::process() {
}
Step::Status StepMountUpdate::UmountPackagePath() {
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
if (!zip_final->UnmountZip()) {
LOG(ERROR) << "Failed to unmount zip package after installation";
@@ -79,12 +76,12 @@ Step::Status StepMountUpdate::UmountPackagePath() {
}
Step::Status StepMountUpdate::clean() {
- bf::path backup_zip_location =
+ fs::path backup_zip_location =
GetBackupPathForZipFile(GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get()));
Remove(backup_zip_location);
- if (bf::exists(backup_path_))
+ if (fs::exists(backup_path_))
RemoveAll(backup_path_);
return Status::OK;
@@ -93,11 +90,11 @@ Step::Status StepMountUpdate::clean() {
Step::Status StepMountUpdate::undo() {
UmountPackagePath();
- bf::path zip_location = GetZipPackageLocation(
+ fs::path zip_location = GetZipPackageLocation(
context_->GetPkgPath(), context_->pkgid.get());
- bf::path backup_zip_location = GetBackupPathForZipFile(zip_location);
+ fs::path backup_zip_location = GetBackupPathForZipFile(zip_location);
- if (bf::exists(backup_zip_location)) {
+ if (fs::exists(backup_zip_location)) {
if (!Remove(zip_location))
return Status::APP_DIR_ERROR;
if (!MoveFile(backup_zip_location, zip_location)) {
@@ -107,9 +104,9 @@ Step::Status StepMountUpdate::undo() {
}
// mount previous file for re-registration of trust anchor
- bf::path mount_point = GetMountLocation(context_->GetPkgPath());
+ fs::path mount_point = GetMountLocation(context_->GetPkgPath());
auto zip_final = CreateZipInterface(mount_point);
- bf::path zip_destination_path =
+ fs::path zip_destination_path =
GetZipPackageLocation(context_->GetPkgPath(), context_->pkgid.get());
if (!zip_final->MountZip(zip_destination_path)) {
LOG(ERROR) << "Failed to mount zip package in installation path";
@@ -117,7 +114,7 @@ Step::Status StepMountUpdate::undo() {
}
}
- if (bf::exists(backup_path_))
+ if (fs::exists(backup_path_))
RemoveAll(backup_path_);
return Status::OK;
@@ -128,7 +125,7 @@ Step::Status StepMountUpdate::precheck() {
LOG(ERROR) << "root_application_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->root_application_path.get())) {
+ if (!std::filesystem::exists(context_->root_application_path.get())) {
LOG(ERROR) << "root_application_path ("
<< context_->root_application_path.get()
<< ") path does not exist";
@@ -139,7 +136,7 @@ Step::Status StepMountUpdate::precheck() {
LOG(ERROR) << "unpacked_dir_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->unpacked_dir_path.get())) {
+ if (!std::filesystem::exists(context_->unpacked_dir_path.get())) {
LOG(ERROR) << "unpacked_dir_path ("
<< context_->unpacked_dir_path.get()
<< ") path does not exist";
@@ -157,7 +154,7 @@ Step::Status StepMountUpdate::precheck() {
}
std::unique_ptr<IZipInterface> StepMountUpdate::CreateZipInterface(
- const boost::filesystem::path& mount_path) {
+ const fs::path& mount_path) {
std::unique_ptr<IZipInterface> zip_interface(
new TzipInterface(mount_path));
return zip_interface;
diff --git a/src/common/step/mount/step_mount_update.h b/src/common/step/mount/step_mount_update.h
index 99ed4fef..8f12b511 100644
--- a/src/common/step/mount/step_mount_update.h
+++ b/src/common/step/mount/step_mount_update.h
@@ -5,10 +5,10 @@
#ifndef COMMON_STEP_MOUNT_STEP_MOUNT_UPDATE_H_
#define COMMON_STEP_MOUNT_STEP_MOUNT_UPDATE_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
@@ -41,11 +41,11 @@ class StepMountUpdate : public MountBase, public Step {
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
Status UmountPackagePath();
private:
- boost::filesystem::path backup_path_;
+ std::filesystem::path backup_path_;
STEP_NAME(MountUpdate)
};
diff --git a/src/common/step/mount/step_unmount.cc b/src/common/step/mount/step_unmount.cc
index 7fad89d9..5977536b 100644
--- a/src/common/step/mount/step_unmount.cc
+++ b/src/common/step/mount/step_unmount.cc
@@ -4,17 +4,14 @@
#include "step/mount/step_unmount.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/utils/paths.h"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace mount {
@@ -32,7 +29,7 @@ Step::Status StepUnmount::process() {
}
std::unique_ptr<IZipInterface> StepUnmount::CreateZipInterface(
- const boost::filesystem::path& mount_path) {
+ const fs::path& mount_path) {
std::unique_ptr<IZipInterface> zip_interface(
new TzipInterface(mount_path));
return zip_interface;
diff --git a/src/common/step/mount/step_unmount.h b/src/common/step/mount/step_unmount.h
index 9df55ea9..84fc39cc 100644
--- a/src/common/step/mount/step_unmount.h
+++ b/src/common/step/mount/step_unmount.h
@@ -7,6 +7,8 @@
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
@@ -30,7 +32,7 @@ class StepUnmount : public MountBase, public Step {
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
STEP_NAME(Unmount);
};
diff --git a/src/common/step/pkgmgr/step_check_force_clean.cc b/src/common/step/pkgmgr/step_check_force_clean.cc
index de31a698..f8269248 100644
--- a/src/common/step/pkgmgr/step_check_force_clean.cc
+++ b/src/common/step/pkgmgr/step_check_force_clean.cc
@@ -8,14 +8,13 @@
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include "common/utils/pkgmgr_query.h"
#include "common/installer_context.h"
#include "common/utils/manifest_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
@@ -26,13 +25,13 @@ Step::Status StepCheckForceClean::process() {
context_->request_type.get() != RequestType::PartialUninstall)
return Status::OK;
- bf::path xml_path = GetManifestLocation(context_->pkgid.get(),
+ fs::path xml_path = GetManifestLocation(context_->pkgid.get(),
context_->uid.get(),
context_->is_readonly_package.get());
// if manifeset not found but pkg exist in db for target uid, do clean
PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
- if (!bf::exists(xml_path) &&
+ if (!fs::exists(xml_path) &&
pkg_query.IsPackageInstalled()) {
context_->force_clean_from_db.set(true);
manifest_x* manifest = PkgmgrGenerateManifestInfoFromDB(
diff --git a/src/common/step/pkgmgr/step_recover_application.cc b/src/common/step/pkgmgr/step_recover_application.cc
index e33090d7..768aad95 100644
--- a/src/common/step/pkgmgr/step_recover_application.cc
+++ b/src/common/step/pkgmgr/step_recover_application.cc
@@ -4,13 +4,13 @@
#include "common/step/pkgmgr/step_recover_application.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include "common/utils/paths.h"
#include "common/utils/pkgmgr_query.h"
#include "common/pkgmgr_registration.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace pkgmgr {
@@ -56,8 +56,8 @@ Step::Status StepRecoverApplication::RecoveryReadonlyUpdateInstall() {
bool StepRecoverApplication::SetXmlPaths() {
if (context_->pkgid.get().empty())
return false;
- bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(),
+ fs::path xml_path =
+ fs::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
/ context_->pkgid.get();
xml_path += ".xml";
diff --git a/src/common/step/pkgmgr/step_recover_parser_plugins.cc b/src/common/step/pkgmgr/step_recover_parser_plugins.cc
index 4d221cc7..4513ae99 100644
--- a/src/common/step/pkgmgr/step_recover_parser_plugins.cc
+++ b/src/common/step/pkgmgr/step_recover_parser_plugins.cc
@@ -6,14 +6,14 @@
#include <pkgmgr-info.h>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include "common/plugins/plugin.h"
#include "common/step/pkgmgr/step_run_parser_plugins.h"
#include "common/utils/paths.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -73,8 +73,8 @@ Step::Status StepRecoverParserPlugin::RecoverPlugin() {
bool StepRecoverParserPlugin::SetXmlPath() {
if (context_->pkgid.get().empty())
return false;
- bf::path xml_path =
- bf::path(getUserManifestPath(context_->uid.get(),
+ fs::path xml_path =
+ fs::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
/ context_->pkgid.get();
xml_path += ".xml";
diff --git a/src/common/step/pkgmgr/step_recover_priv_sharedres.cc b/src/common/step/pkgmgr/step_recover_priv_sharedres.cc
index 3478e6d9..adf4df18 100644
--- a/src/common/step/pkgmgr/step_recover_priv_sharedres.cc
+++ b/src/common/step/pkgmgr/step_recover_priv_sharedres.cc
@@ -4,8 +4,6 @@
#include "common/step/pkgmgr/step_recover_priv_sharedres.h"
-#include <boost/filesystem.hpp>
-
#include "common/utils/paths.h"
#include "common/utils/pkgmgr_query.h"
#include "common/pkgmgr_registration.h"
diff --git a/src/common/step/pkgmgr/step_register_app.cc b/src/common/step/pkgmgr/step_register_app.cc
index a30dbc4a..fb45052a 100644
--- a/src/common/step/pkgmgr/step_register_app.cc
+++ b/src/common/step/pkgmgr/step_register_app.cc
@@ -2,8 +2,6 @@
#include "common/step/pkgmgr/step_register_app.h"
-#include <boost/filesystem.hpp>
-
#include <unistd.h>
#include <cassert>
#include <cstring>
@@ -13,8 +11,6 @@
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-
namespace common_installer {
namespace pkgmgr {
diff --git a/src/common/step/pkgmgr/step_remove_manifest.cc b/src/common/step/pkgmgr/step_remove_manifest.cc
index c56feb96..62e6cc84 100644
--- a/src/common/step/pkgmgr/step_remove_manifest.cc
+++ b/src/common/step/pkgmgr/step_remove_manifest.cc
@@ -4,30 +4,25 @@
#include "common/step/pkgmgr/step_remove_manifest.h"
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/system/error_code.hpp>
-
#include <pkgmgr-info.h>
#include <pkgmgr_installer.h>
#include <tzplatform_config.h>
-#include <algorithm>
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace common_installer {
namespace pkgmgr {
common_installer::Step::Status StepRemoveManifest::clean() {
- bf::path manifest_path;
+ fs::path manifest_path;
if (context_->request_type.get() == RequestType::ReadonlyUpdateUninstall) {
- manifest_path = bf::path(tzplatform_getenv(TZ_SYS_RW_PACKAGES)) /
+ manifest_path = fs::path(tzplatform_getenv(TZ_SYS_RW_PACKAGES)) /
context_->pkgid.get();
manifest_path += ".xml";
} else {
diff --git a/src/common/step/pkgmgr/step_remove_priv_sharedres.cc b/src/common/step/pkgmgr/step_remove_priv_sharedres.cc
index 828e51b2..ed596900 100644
--- a/src/common/step/pkgmgr/step_remove_priv_sharedres.cc
+++ b/src/common/step/pkgmgr/step_remove_priv_sharedres.cc
@@ -7,16 +7,16 @@
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include "common/utils/file_util.h"
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
-bf::path GetRootPathForUid(uid_t uid) {
+fs::path GetRootPathForUid(uid_t uid) {
tzplatform_set_user(uid);
const char* rootpath = tzplatform_getenv(TZ_USER_HOME);
tzplatform_reset_user();
@@ -24,9 +24,9 @@ bf::path GetRootPathForUid(uid_t uid) {
}
bool RemoveResForUid(const std::string& pkgid, uid_t uid) {
- bf::path target_path = GetRootPathForUid(uid) / pkgid;
+ fs::path target_path = GetRootPathForUid(uid) / pkgid;
- if (bf::exists(target_path))
+ if (fs::exists(target_path))
return true;
if (!common_installer::RemoveAll(target_path))
diff --git a/src/common/step/pkgmgr/step_run_parser_plugins.cc b/src/common/step/pkgmgr/step_run_parser_plugins.cc
index 0dc1b02a..85423314 100644
--- a/src/common/step/pkgmgr/step_run_parser_plugins.cc
+++ b/src/common/step/pkgmgr/step_run_parser_plugins.cc
@@ -4,6 +4,7 @@
#include "common/step/pkgmgr/step_run_parser_plugins.h"
+#include <filesystem>
#include <string>
#include <vector>
@@ -14,7 +15,7 @@ namespace common_installer {
namespace pkgmgr {
bool StepRunParserPlugin::InitPluginManager(
- const boost::filesystem::path& xml_path, manifest_x* manifest, uid_t uid) {
+ const std::filesystem::path& xml_path, manifest_x* manifest, uid_t uid) {
// PLUGINS_LIST_INSTALL_PATH path generated from cmake
const std::string listPath(PLUGINS_LIST_INSTALL_PATH);
plugin_manager_.reset(
@@ -38,7 +39,7 @@ StepRunParserPlugin::StepRunParserPlugin(
: Step(context), action_type_(action_type) {}
bool StepRunParserPlugin::ProcessPlugins(
- const boost::filesystem::path& xml_path, manifest_x* manifest,
+ const std::filesystem::path& xml_path, manifest_x* manifest,
Plugin::ActionType action_type) {
if (!plugin_manager_.get()) {
if (!InitPluginManager(xml_path, manifest, context_->uid.get()))
diff --git a/src/common/step/pkgmgr/step_run_parser_plugins.h b/src/common/step/pkgmgr/step_run_parser_plugins.h
index 47b0cafe..e8d409cf 100644
--- a/src/common/step/pkgmgr/step_run_parser_plugins.h
+++ b/src/common/step/pkgmgr/step_run_parser_plugins.h
@@ -9,6 +9,7 @@
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <vector>
@@ -31,11 +32,11 @@ class StepRunParserPlugin : public Step {
Step::Status precheck() { return Status::OK; }
private:
- bool ProcessPlugins(const boost::filesystem::path& xml_path,
+ bool ProcessPlugins(const std::filesystem::path& xml_path,
manifest_x* manifest,
Plugin::ActionType action_type);
- bool InitPluginManager(const boost::filesystem::path& xml_path,
+ bool InitPluginManager(const std::filesystem::path& xml_path,
manifest_x* manifest, uid_t uid);
Plugin::ActionType action_type_;
diff --git a/src/common/step/pkgmgr/step_unregister_app.cc b/src/common/step/pkgmgr/step_unregister_app.cc
index 964f357e..94e4e639 100644
--- a/src/common/step/pkgmgr/step_unregister_app.cc
+++ b/src/common/step/pkgmgr/step_unregister_app.cc
@@ -6,12 +6,11 @@
#include <unistd.h>
-#include <boost/filesystem.hpp>
-#include <boost/system/error_code.hpp>
#include <pkgmgr_installer.h>
#include <vcore/Certificate.h>
#include <cassert>
+#include <filesystem>
#include <string>
#include "common/pkgmgr_registration.h"
@@ -35,7 +34,7 @@ Step::Status StepUnregisterApplication::precheck() {
return Status::MANIFEST_NOT_FOUND;
}
- if (!boost::filesystem::exists(context_->xml_path.get())) {
+ if (!std::filesystem::exists(context_->xml_path.get())) {
LOG(ERROR) << "xml_path ("
<< context_->xml_path.get()
<< ") path does not exist";
diff --git a/src/common/step/pkgmgr/step_update_app.cc b/src/common/step/pkgmgr/step_update_app.cc
index 31344775..a46932fc 100644
--- a/src/common/step/pkgmgr/step_update_app.cc
+++ b/src/common/step/pkgmgr/step_update_app.cc
@@ -8,7 +8,6 @@
#include <sys/types.h>
#include <unistd.h>
-#include <boost/filesystem.hpp>
#include <vcore/Certificate.h>
#include <cassert>
@@ -20,8 +19,6 @@
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-
namespace common_installer {
namespace pkgmgr {
diff --git a/src/common/step/rds/step_rds_modify.cc b/src/common/step/rds/step_rds_modify.cc
index de6736f1..018595d0 100644
--- a/src/common/step/rds/step_rds_modify.cc
+++ b/src/common/step/rds/step_rds_modify.cc
@@ -4,18 +4,18 @@
#include "common/step/rds/step_rds_modify.h"
-#include <boost/system/error_code.hpp>
-
#include <manifest_parser/utils/logging.h>
-#include <common/utils/file_util.h>
+#include <filesystem>
+
+#include "common/utils/file_util.h"
+
+namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace common_installer {
namespace rds {
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace ci = common_installer;
StepRDSModify::StepRDSModify(InstallerContext* context)
: Step(context) {}
@@ -25,7 +25,7 @@ Step::Status StepRDSModify::precheck() {
LOG(ERROR) << "unpacked dir path is not set";
return common_installer::Step::Status::INVALID_VALUE;
}
- if (!bf::exists(context_->unpacked_dir_path.get())) {
+ if (!fs::exists(context_->unpacked_dir_path.get())) {
LOG(ERROR) << "unpacked_dir_path ("
<< context_->unpacked_dir_path.get()
<< ") path does not exist";
@@ -52,8 +52,8 @@ Step::Status StepRDSModify::process() {
LOG(ERROR) << "unable to setup temp directory";
return Step::Status::ERROR;
}
- bf::path install_path = context_->GetPkgPath();
- bf::path unzip_path = context_->unpacked_dir_path.get();
+ fs::path install_path = context_->GetPkgPath();
+ fs::path unzip_path = context_->unpacked_dir_path.get();
if (!AddFiles(unzip_path, install_path) ||
!ModifyFiles(unzip_path, install_path) ||
!DeleteFiles(install_path)) {
@@ -73,29 +73,29 @@ Step::Status StepRDSModify::clean() {
return Step::Status::OK;
}
-bool StepRDSModify::AddFiles(bf::path unzip_path, bf::path install_path) {
+bool StepRDSModify::AddFiles(fs::path unzip_path, fs::path install_path) {
LOG(INFO) << "about to add files";
- bs::error_code error;
+ std::error_code error;
for (const auto& file : context_->files_to_add.get()) {
if (!PerformBackup(file, Operation::ADD)) {
LOG(ERROR) << "unable to perform backup of added file";
return false;
}
- bf::path temp_install_path(install_path / file);
- if (bf::is_directory(temp_install_path)) {
- if (!bf::exists(temp_install_path) &&
+ fs::path temp_install_path(install_path / file);
+ if (fs::is_directory(temp_install_path)) {
+ if (!fs::exists(temp_install_path) &&
(!CreateDir(temp_install_path))) {
LOG(ERROR) << "unable to create dir for temp backup data";
return false;
}
} else {
- if (!bf::exists(temp_install_path.parent_path()) &&
+ if (!fs::exists(temp_install_path.parent_path()) &&
!CreateDir(temp_install_path.parent_path())) {
LOG(ERROR) << "unable to create dir for temp backup data";
return false;
}
- bf::path temp_unzip_path(unzip_path / file);
- bf::copy_file(temp_unzip_path, temp_install_path, error);
+ fs::path temp_unzip_path(unzip_path / file);
+ fs::copy_file(temp_unzip_path, temp_install_path, error);
if (error) {
LOG(ERROR) << "unable to add file " << error.message();
return false;
@@ -105,18 +105,18 @@ bool StepRDSModify::AddFiles(bf::path unzip_path, bf::path install_path) {
return true;
}
-bool StepRDSModify::ModifyFiles(bf::path unzip_path, bf::path install_path) {
+bool StepRDSModify::ModifyFiles(fs::path unzip_path, fs::path install_path) {
LOG(INFO) << "about to modify files";
- bs::error_code error;
+ std::error_code error;
for (const auto& file : context_->files_to_modify.get()) {
- bf::path temp_install_path(install_path / file);
- bf::path temp_unzip_path(unzip_path / file);
+ fs::path temp_install_path(install_path / file);
+ fs::path temp_unzip_path(unzip_path / file);
if (!PerformBackup(file, Operation::MODIFY)) {
LOG(ERROR) << "unable to perform backup of to be modified file";
return false;
}
- bf::copy_file(temp_unzip_path, temp_install_path,
- bf::copy_option::overwrite_if_exists, error);
+ fs::copy_file(temp_unzip_path, temp_install_path,
+ fs::copy_options::overwrite_existing, error);
if (error) {
LOG(ERROR) << "unable to modify file " << error.message();
return false;
@@ -125,7 +125,7 @@ bool StepRDSModify::ModifyFiles(bf::path unzip_path, bf::path install_path) {
return true;
}
-bool StepRDSModify::DeleteFiles(bf::path install_path) {
+bool StepRDSModify::DeleteFiles(fs::path install_path) {
LOG(INFO) << "about to delete files";
for (const auto& file : context_->files_to_delete.get()) {
if (!PerformBackup(file, Operation::DELETE)) {
@@ -140,10 +140,9 @@ bool StepRDSModify::DeleteFiles(bf::path install_path) {
bool StepRDSModify::SetUpTempBackupDir() {
LOG(INFO) << "about to setup tmp backup dir";
- bs::error_code error;
backup_temp_dir_ = "/tmp/" /
- bf::unique_path("%%%%-%%%%-%%%%-%%%%", error);
- if (error || !CreateDir(backup_temp_dir_)) {
+ ci::GenerateUniquePathString("%%%%-%%%%-%%%%-%%%%");
+ if (!CreateDir(backup_temp_dir_)) {
LOG(ERROR) << "unable to create backup data temp dir";
return false;
}
@@ -156,22 +155,22 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
if (backup_temp_dir_.empty())
return false;
if (operation == Operation::DELETE || operation == Operation::MODIFY) {
- bf::path app_path = context_->GetPkgPath();
- bf::path source_path = app_path / relative_path;
- if (bf::is_directory(source_path)) {
+ fs::path app_path = context_->GetPkgPath();
+ fs::path source_path = app_path / relative_path;
+ if (fs::is_directory(source_path)) {
if (!CreateDir(backup_temp_dir_ / relative_path)) {
LOG(ERROR) << "unable to create dir for temp backup data";
return false;
}
} else {
- bs::error_code error;
- bf::path tmp_dest_path = backup_temp_dir_ / relative_path;
- if (!bf::exists((tmp_dest_path).parent_path()) &&
+ std::error_code error;
+ fs::path tmp_dest_path = backup_temp_dir_ / relative_path;
+ if (!fs::exists((tmp_dest_path).parent_path()) &&
(!CreateDir((tmp_dest_path).parent_path()))) {
LOG(ERROR) << "unable to create dir for temp backup data";
return false;
}
- bf::copy_file(source_path, tmp_dest_path, error);
+ fs::copy_file(source_path, tmp_dest_path, error);
if (error) {
LOG(ERROR) << "unable to backup file: "
<< source_path << " : " << error.message();
@@ -185,32 +184,32 @@ bool StepRDSModify::PerformBackup(std::string relative_path,
void StepRDSModify::RestoreFiles() {
LOG(ERROR) << "error occured about to restore files";
- bf::path app_path(context_->GetPkgPath());
+ fs::path app_path(context_->GetPkgPath());
for (std::pair<std::string, Operation>& modification :
success_modifications_) {
- bf::path source_path(backup_temp_dir_ / modification.first);
- bf::path destination_path(app_path / modification.first);
+ fs::path source_path(backup_temp_dir_ / modification.first);
+ fs::path destination_path(app_path / modification.first);
if (modification.second == Operation::ADD) {
- if (bf::is_directory(source_path)) {
- bf::remove_all(destination_path);
+ if (fs::is_directory(source_path)) {
+ fs::remove_all(destination_path);
} else {
- bf::remove(destination_path);
+ fs::remove(destination_path);
}
} else if (modification.second == Operation::MODIFY) {
- bf::copy_file(source_path, destination_path,
- bf::copy_option::overwrite_if_exists);
+ fs::copy_file(source_path, destination_path,
+ fs::copy_options::overwrite_existing);
} else {
- if (bf::is_directory(source_path)) {
+ if (fs::is_directory(source_path)) {
if (!CreateDir(destination_path))
LOG(ERROR) << "Failed to create dir: " << destination_path;
} else {
- bf::copy_file(source_path, destination_path,
- bf::copy_option::overwrite_if_exists);
+ fs::copy_file(source_path, destination_path,
+ fs::copy_options::overwrite_existing);
}
}
}
// after files are restore delete temporary location
- bf::remove_all(backup_temp_dir_);
+ fs::remove_all(backup_temp_dir_);
}
} // namespace rds
diff --git a/src/common/step/rds/step_rds_modify.h b/src/common/step/rds/step_rds_modify.h
index 62e01d92..f2a4ba1d 100644
--- a/src/common/step/rds/step_rds_modify.h
+++ b/src/common/step/rds/step_rds_modify.h
@@ -5,8 +5,9 @@
#ifndef COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
#define COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
-#include <boost/filesystem.hpp>
#include <common/step/step.h>
+
+#include <filesystem>
#include <string>
#include <utility>
#include <vector>
@@ -65,18 +66,18 @@ class StepRDSModify : public Step {
DELETE
};
- bool AddFiles(boost::filesystem::path unzip_path,
- boost::filesystem::path install_path);
- bool ModifyFiles(boost::filesystem::path unzip_path,
- boost::filesystem::path install_path);
- bool DeleteFiles(boost::filesystem::path install_path);
+ bool AddFiles(std::filesystem::path unzip_path,
+ std::filesystem::path install_path);
+ bool ModifyFiles(std::filesystem::path unzip_path,
+ std::filesystem::path install_path);
+ bool DeleteFiles(std::filesystem::path install_path);
bool SetUpTempBackupDir();
void DeleteTempBackupDir();
bool PerformBackup(std::string relative_path, Operation operation);
void RestoreFiles();
std::vector<std::pair<std::string, Operation>> success_modifications_;
- boost::filesystem::path backup_temp_dir_;
+ std::filesystem::path backup_temp_dir_;
std::vector<std::string> files_to_modify_;
std::vector<std::string> files_to_add_;
std::vector<std::string> files_to_delete_;
diff --git a/src/common/step/rds/step_rds_parse.cc b/src/common/step/rds/step_rds_parse.cc
index f843e301..c1d7cb81 100644
--- a/src/common/step/rds/step_rds_parse.cc
+++ b/src/common/step/rds/step_rds_parse.cc
@@ -14,11 +14,11 @@
namespace common_installer {
namespace rds {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
Step::Status StepRDSParse::precheck() {
- bf::path rdsPath(context_->unpacked_dir_path.get() / ".rds_delta");
- if (!bf::exists(rdsPath)) {
+ fs::path rdsPath(context_->unpacked_dir_path.get() / ".rds_delta");
+ if (!fs::exists(rdsPath)) {
LOG(ERROR) << "no rds_delta file";
return Step::Status::INVALID_VALUE;
}
diff --git a/src/common/step/rds/step_rds_parse.h b/src/common/step/rds/step_rds_parse.h
index d676dccf..ca192094 100644
--- a/src/common/step/rds/step_rds_parse.h
+++ b/src/common/step/rds/step_rds_parse.h
@@ -7,7 +7,7 @@
#include <common/step/step.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include <vector>
@@ -46,7 +46,7 @@ class StepRDSParse : public Step {
Status precheck() override;
private:
- boost::filesystem::path rds_file_path_;
+ std::filesystem::path rds_file_path_;
STEP_NAME(RDSParse)
};
diff --git a/src/common/step/recovery/step_create_recovery_file.cc b/src/common/step/recovery/step_create_recovery_file.cc
index ee515b09..f2e139ce 100644
--- a/src/common/step/recovery/step_create_recovery_file.cc
+++ b/src/common/step/recovery/step_create_recovery_file.cc
@@ -4,14 +4,13 @@
#include "common/step/recovery/step_create_recovery_file.h"
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgr-info.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <tzplatform_config.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <utility>
@@ -22,13 +21,13 @@
#include "common/utils/request.h"
#include "common/recovery_file.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace recovery {
Step::Status StepCreateRecoveryFile::process() {
- bf::path recovery_filename = context_->recovery_info.get().filepath;
+ fs::path recovery_filename = context_->recovery_info.get().filepath;
if (recovery_filename.empty()) {
std::string file_format = context_->pkg_type.get() + "-recovery";
diff --git a/src/common/step/security/step_get_privilege_level.cc b/src/common/step/security/step_get_privilege_level.cc
index c9cf06d4..15fc06eb 100644
--- a/src/common/step/security/step_get_privilege_level.cc
+++ b/src/common/step/security/step_get_privilege_level.cc
@@ -23,7 +23,7 @@ Step::Status StepGetPrivilegeLevel::process() {
if (level == PrivilegeLevel::UNTRUSTED) {
std::string error_message =
"Failed to get privilege level from file";
- on_error(Status::CERT_ERROR, error_message);
+ on_error_->on_error(Status::CERT_ERROR, error_message);
return Status::CERT_ERROR;
}
diff --git a/src/common/step/security/step_privacy_privilege.cc b/src/common/step/security/step_privacy_privilege.cc
index d2e3fb27..eb460efe 100644
--- a/src/common/step/security/step_privacy_privilege.cc
+++ b/src/common/step/security/step_privacy_privilege.cc
@@ -4,8 +4,6 @@
#include "common/step/security/step_privacy_privilege.h"
-#include <boost/scope_exit.hpp>
-
#include <map>
#include <string>
#include <vector>
diff --git a/src/common/step/security/step_privilege_compatibility.cc b/src/common/step/security/step_privilege_compatibility.cc
index dd03728c..3c1e37c4 100644
--- a/src/common/step/security/step_privilege_compatibility.cc
+++ b/src/common/step/security/step_privilege_compatibility.cc
@@ -4,8 +4,6 @@
#include "common/step/security/step_privilege_compatibility.h"
-#include <boost/scope_exit.hpp>
-
#include <pkgmgrinfo_basic.h>
#include <privilege_manager.h>
@@ -70,6 +68,14 @@ std::string GetAPIVersion(manifest_x* m, bool is_web) {
return api_version;
}
+void FreePrivilegeList(GList* priv) {
+ g_list_free_full(priv, free);
+}
+
+void FreePrivilegeXList(GList* priv) {
+ g_list_free_full(priv, &ci::FreePrivilegeX);
+}
+
bool TranslatePrivilegesForCompatibility(manifest_x* m) {
if (!m->api_version) {
LOG(WARNING) << "Skipping privileges mapping because api-version "
@@ -90,14 +96,19 @@ bool TranslatePrivilegesForCompatibility(manifest_x* m) {
GList* mapped_web_privileges = nullptr;
GList* converted_native_privileges = nullptr;
GList* converted_web_privileges = nullptr;
- BOOST_SCOPE_EXIT_ALL(&) {
- g_list_free_full(native_privileges, free);
- g_list_free_full(web_privileges, free);
- g_list_free_full(mapped_native_privileges, free);
- g_list_free_full(mapped_web_privileges, free);
- g_list_free_full(converted_native_privileges, &ci::FreePrivilegeX);
- g_list_free_full(converted_web_privileges, &ci::FreePrivilegeX);
- };
+ std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter1(
+ native_privileges, &::FreePrivilegeList);
+ std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter2(
+ web_privileges, &::FreePrivilegeList);
+ std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter3(
+ mapped_native_privileges, &::FreePrivilegeList);
+ std::unique_ptr<GList, decltype(::FreePrivilegeList)*> deleter4(
+ mapped_web_privileges, &::FreePrivilegeList);
+ std::unique_ptr<GList, decltype(::FreePrivilegeXList)*> deleter5(
+ converted_native_privileges, &::FreePrivilegeXList);
+ std::unique_ptr<GList, decltype(::FreePrivilegeXList)*> deleter6(
+ converted_web_privileges, &::FreePrivilegeXList);
+
if (!MapPrivileges(native_privileges, &mapped_native_privileges, false,
GetAPIVersion(m, false).c_str()))
return false;
@@ -189,4 +200,3 @@ Step::Status StepPrivilegeCompatibility::process() {
} // namespace security
} // namespace common_installer
-
diff --git a/src/common/step/security/step_recover_security.cc b/src/common/step/security/step_recover_security.cc
index a7a62fcc..950bc3b7 100644
--- a/src/common/step/security/step_recover_security.cc
+++ b/src/common/step/security/step_recover_security.cc
@@ -4,7 +4,7 @@
#include "common/step/security/step_recover_security.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/security_registration.h"
@@ -15,7 +15,7 @@ namespace security {
bool StepRecoverSecurity::Check(bool is_update) {
if (context_->GetPkgPath().empty())
return false;
- if (!boost::filesystem::exists(context_->GetPkgPath()) && is_update)
+ if (!std::filesystem::exists(context_->GetPkgPath()) && is_update)
return false;
if (context_->pkgid.get().empty())
return false;
@@ -38,7 +38,7 @@ Step::Status StepRecoverSecurity::RecoveryNew() {
LOG(ERROR) << "Unsuccessful install";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::RECOVERY_ERROR, error_message);
+ on_error_->on_error(Status::RECOVERY_ERROR, error_message);
}
return Status::RECOVERY_ERROR;
}
@@ -48,7 +48,7 @@ Step::Status StepRecoverSecurity::RecoveryNew() {
LOG(ERROR) << "Unsuccessful install";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::RECOVERY_ERROR, error_message);
+ on_error_->on_error(Status::RECOVERY_ERROR, error_message);
}
return Status::RECOVERY_ERROR;
}
@@ -71,7 +71,7 @@ Step::Status StepRecoverSecurity::RecoveryUpdate() {
LOG(ERROR) << "Unsuccessful update";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::RECOVERY_ERROR, error_message);
+ on_error_->on_error(Status::RECOVERY_ERROR, error_message);
}
return Status::RECOVERY_ERROR;
}
@@ -84,7 +84,7 @@ Step::Status StepRecoverSecurity::RecoveryUpdate() {
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::RECOVERY_ERROR, error_message);
+ on_error_->on_error(Status::RECOVERY_ERROR, error_message);
}
return Status::RECOVERY_ERROR;
}
@@ -107,7 +107,7 @@ Step::Status StepRecoverSecurity::RecoveryReadonlyUpdateInstall() {
LOG(ERROR) << "Unsuccessful update";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::RECOVERY_ERROR, error_message);
+ on_error_->on_error(Status::RECOVERY_ERROR, error_message);
}
return Status::RECOVERY_ERROR;
}
diff --git a/src/common/step/security/step_recover_signature.cc b/src/common/step/security/step_recover_signature.cc
index e53b1e07..e0b63bb9 100644
--- a/src/common/step/security/step_recover_signature.cc
+++ b/src/common/step/security/step_recover_signature.cc
@@ -4,36 +4,35 @@
#include "common/step/security/step_recover_signature.h"
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <string>
#include "common/certificate_validation.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
-bf::path GetSignatureFilePath(bool is_readonly) {
- return bf::path((is_readonly) ?
+fs::path GetSignatureFilePath(bool is_readonly) {
+ return fs::path((is_readonly) ?
tzplatform_getenv(TZ_SYS_RO_SHARE) : tzplatform_getenv(TZ_SYS_SHARE)) /
"signatures";
}
bool RemoveSignatureBackup(const std::string& pkgid, bool is_readonly) {
- bf::path path = GetSignatureFilePath(is_readonly);
- bf::path backup_path = bf::path(path) / std::string(pkgid + "_backup.txt");
+ fs::path path = GetSignatureFilePath(is_readonly);
+ fs::path backup_path = fs::path(path) / std::string(pkgid + "_backup.txt");
return common_installer::Remove(backup_path);
}
bool RecoverSignatureFile(const std::string& pkgid, bool is_readonly) {
- bf::path path = GetSignatureFilePath(is_readonly);
- bf::path target_path = bf::path(path) / std::string(pkgid + ".txt");
- bf::path backup_path = bf::path(path) / std::string(pkgid + "_backup.txt");
+ fs::path path = GetSignatureFilePath(is_readonly);
+ fs::path target_path = fs::path(path) / std::string(pkgid + ".txt");
+ fs::path backup_path = fs::path(path) / std::string(pkgid + "_backup.txt");
- if (bf::exists(backup_path) &&
+ if (fs::exists(backup_path) &&
!common_installer::MoveFile(backup_path, target_path, true))
return false;
@@ -46,7 +45,7 @@ namespace common_installer {
namespace security {
Step::Status StepRecoverSignature::RecoveryNew() {
- bf::path path = GetSignatureFilePath(context_->is_readonly_package.get());
+ fs::path path = GetSignatureFilePath(context_->is_readonly_package.get());
path /= std::string(context_->pkgid.get() + ".txt");
if (!common_installer::Remove(path))
return Status::CERT_ERROR;
diff --git a/src/common/step/security/step_recover_signature.h b/src/common/step/security/step_recover_signature.h
index 25e3dcf3..b45a6980 100644
--- a/src/common/step/security/step_recover_signature.h
+++ b/src/common/step/security/step_recover_signature.h
@@ -5,9 +5,10 @@
#ifndef COMMON_STEP_SECURITY_STEP_RECOVER_SIGNATURE_H_
#define COMMON_STEP_SECURITY_STEP_RECOVER_SIGNATURE_H_
-#include <boost/filesystem/path.hpp>
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/recovery/step_recovery.h"
@@ -34,7 +35,7 @@ class StepRecoverSignature : public recovery::StepRecovery {
Status Cleanup() override;
private:
- virtual boost::filesystem::path GetSignatureRoot() = 0;
+ virtual std::filesystem::path GetSignatureRoot() = 0;
STEP_NAME(RecoverSignature)
};
diff --git a/src/common/step/security/step_recover_trust_anchor.h b/src/common/step/security/step_recover_trust_anchor.h
index fb8845e8..ada9341d 100644
--- a/src/common/step/security/step_recover_trust_anchor.h
+++ b/src/common/step/security/step_recover_trust_anchor.h
@@ -5,7 +5,6 @@
#ifndef COMMON_STEP_SECURITY_STEP_RECOVER_TRUST_ANCHOR_H_
#define COMMON_STEP_SECURITY_STEP_RECOVER_TRUST_ANCHOR_H_
-#include <boost/filesystem/path.hpp>
#include <manifest_parser/utils/logging.h>
#include "common/installer_context.h"
diff --git a/src/common/step/security/step_register_security.cc b/src/common/step/security/step_register_security.cc
index b044e904..fc6d1081 100644
--- a/src/common/step/security/step_register_security.cc
+++ b/src/common/step/security/step_register_security.cc
@@ -4,7 +4,7 @@
#include "common/step/security/step_register_security.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/security_registration.h"
@@ -17,7 +17,7 @@ Step::Status StepRegisterSecurity::precheck() {
LOG(ERROR) << "pkg_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->GetPkgPath())) {
+ if (!std::filesystem::exists(context_->GetPkgPath())) {
LOG(ERROR) << "pkg_path ("
<< context_->GetPkgPath()
<< ") path does not exist";
@@ -45,7 +45,7 @@ Step::Status StepRegisterSecurity::process() {
!RegisterSecurityContextForManifest(context_, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
@@ -56,7 +56,7 @@ Step::Status StepRegisterSecurity::process() {
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
diff --git a/src/common/step/security/step_register_trust_anchor.cc b/src/common/step/security/step_register_trust_anchor.cc
index c9986e6f..06a2b54c 100644
--- a/src/common/step/security/step_register_trust_anchor.cc
+++ b/src/common/step/security/step_register_trust_anchor.cc
@@ -5,8 +5,8 @@
#include "common/step/security/step_register_trust_anchor.h"
#include <trust-anchor.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
@@ -14,7 +14,7 @@
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -22,12 +22,12 @@ const char kTpkTrustAnchorPath[] = "res/.trust-anchor";
const char kWgtTrustAnchorPath[] = ".trust-anchor";
const char kWgt[] = "wgt";
-bool RemoveWgtTrustAnchorSymLinks(const bf::path& path) {
- for (bf::directory_iterator file(path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
- if (bf::is_symlink(symlink_status(current)) &&
- !bf::remove(current))
+bool RemoveWgtTrustAnchorSymLinks(const fs::path& path) {
+ for (fs::directory_iterator file(path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
+ if (fs::is_symlink(symlink_status(current)) &&
+ !fs::remove(current))
return false;
}
return true;
@@ -57,7 +57,7 @@ Step::Status StepRegisterTrustAnchor::precheck() {
Step::Status StepRegisterTrustAnchor::process() {
int ret;
- bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
+ fs::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
manifest_x* manifest = context_->manifest_data.get();
if (register_type_ == RegisterType::UPDATE) {
@@ -70,7 +70,7 @@ Step::Status StepRegisterTrustAnchor::process() {
if (!context_->partial_rw.get() &&
!context_->pkg_type.get().compare(kWgt)) {
- if (bf::exists(pkg_certs_path) &&
+ if (fs::exists(pkg_certs_path) &&
!RemoveWgtTrustAnchorSymLinks(pkg_certs_path))
return Step::Status::APP_DIR_ERROR;
}
@@ -89,14 +89,14 @@ Step::Status StepRegisterTrustAnchor::process() {
if (!common_installer::CreateDir(pkg_certs_path))
return Step::Status::APP_DIR_ERROR;
- bf::path pkg_certs_src_path =
+ fs::path pkg_certs_src_path =
context_->GetPkgPath() / "res/wgt" / kWgtTrustAnchorPath;
- for (bf::directory_iterator file(pkg_certs_src_path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
+ for (fs::directory_iterator file(pkg_certs_src_path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
try {
- bf::create_symlink(current, pkg_certs_path / current.filename());
- } catch (const bf::filesystem_error& error) {
+ fs::create_symlink(current, pkg_certs_path / current.filename());
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to make trust anchor symlink : " << error.what();
return Step::Status::APP_DIR_ERROR;
}
@@ -104,7 +104,7 @@ Step::Status StepRegisterTrustAnchor::process() {
}
ret = trust_anchor_install(context_->pkgid.get().c_str(),
- context_->uid.get(), pkg_certs_path.string().c_str(),
+ context_->uid.get(), pkg_certs_path.c_str(),
(strcasecmp(manifest->use_system_certs, "true") == 0) ? true : false);
if (ret != TRUST_ANCHOR_ERROR_NONE) {
diff --git a/src/common/step/security/step_revoke_security.cc b/src/common/step/security/step_revoke_security.cc
index ec5bf381..ac5c09df 100644
--- a/src/common/step/security/step_revoke_security.cc
+++ b/src/common/step/security/step_revoke_security.cc
@@ -4,7 +4,6 @@
#include "common/step/security/step_revoke_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
@@ -35,7 +34,7 @@ Step::Status StepRevokeSecurity::clean() {
<< context_->pkgid.get();
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
} else {
LOG(DEBUG) << "Security context uninstalled";
diff --git a/src/common/step/security/step_revoke_trust_anchor.cc b/src/common/step/security/step_revoke_trust_anchor.cc
index bf299c7d..85d5a176 100644
--- a/src/common/step/security/step_revoke_trust_anchor.cc
+++ b/src/common/step/security/step_revoke_trust_anchor.cc
@@ -5,8 +5,8 @@
#include "common/step/security/step_revoke_trust_anchor.h"
#include <trust-anchor.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
@@ -14,7 +14,7 @@
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -34,16 +34,16 @@ Step::Status StepRevokeTrustAnchor::undo() {
if (!manifest->use_system_certs)
return Step::Status::OK;
- bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
+ fs::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
if (!context_->pkg_type.get().compare(kWgt)) {
// For wgt package,
// create [pkg_root]/res/.trust-anchor directory and create symbolic link
- if (bf::exists(pkg_certs_path)) {
- for (bf::directory_iterator file(pkg_certs_path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
- if (bf::is_symlink(symlink_status(current))) {
- if (!bf::remove(current)) {
+ if (fs::exists(pkg_certs_path)) {
+ for (fs::directory_iterator file(pkg_certs_path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
+ if (fs::is_symlink(symlink_status(current))) {
+ if (!fs::remove(current)) {
LOG(ERROR) << "Failed to remove previous symlink : " << current;
return Step::Status::APP_DIR_ERROR;
}
@@ -54,14 +54,14 @@ Step::Status StepRevokeTrustAnchor::undo() {
return Step::Status::APP_DIR_ERROR;
}
- bf::path pkg_certs_src_path =
+ fs::path pkg_certs_src_path =
context_->GetPkgPath() / "res/wgt" / kWgtTrustAnchorPath;
- for (bf::directory_iterator file(pkg_certs_src_path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
+ for (fs::directory_iterator file(pkg_certs_src_path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
try {
- bf::create_symlink(current, pkg_certs_path / current.filename());
- } catch (const bf::filesystem_error& error) {
+ fs::create_symlink(current, pkg_certs_path / current.filename());
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to make trust anchor symlink : " << error.what();
return Step::Status::APP_DIR_ERROR;
}
@@ -69,7 +69,7 @@ Step::Status StepRevokeTrustAnchor::undo() {
}
int ret = trust_anchor_install(context_->pkgid.get().c_str(),
- context_->uid.get(), pkg_certs_path.string().c_str(),
+ context_->uid.get(), pkg_certs_path.c_str(),
(strcasecmp(manifest->use_system_certs, "true") == 0) ? true : false);
if (ret != TRUST_ANCHOR_ERROR_NONE) {
diff --git a/src/common/step/security/step_rollback_deinstallation_security.cc b/src/common/step/security/step_rollback_deinstallation_security.cc
index 876534ee..2e6f9d38 100644
--- a/src/common/step/security/step_rollback_deinstallation_security.cc
+++ b/src/common/step/security/step_rollback_deinstallation_security.cc
@@ -4,7 +4,6 @@
#include "common/step/security/step_rollback_deinstallation_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
@@ -40,7 +39,7 @@ Step::Status StepRollbackDeinstallationSecurity::undo() {
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
diff --git a/src/common/step/security/step_rollback_installation_security.cc b/src/common/step/security/step_rollback_installation_security.cc
index 00ceae58..b6a5c8cc 100644
--- a/src/common/step/security/step_rollback_installation_security.cc
+++ b/src/common/step/security/step_rollback_installation_security.cc
@@ -4,7 +4,6 @@
#include "common/step/security/step_rollback_installation_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
diff --git a/src/common/step/security/step_signature.cc b/src/common/step/security/step_signature.cc
index 3a63882c..65578e16 100644
--- a/src/common/step/security/step_signature.cc
+++ b/src/common/step/security/step_signature.cc
@@ -13,7 +13,7 @@
#include "common/certificate_validation.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
@@ -51,7 +51,7 @@ Step::Status StepSignature::precheck() {
LOG(ERROR) << "unpacked_dir_path attribute is empty";
return Step::Status::INVALID_VALUE;
}
- if (!boost::filesystem::exists(context_->unpacked_dir_path.get())) {
+ if (!std::filesystem::exists(context_->unpacked_dir_path.get())) {
LOG(ERROR) << "unpacked_dir_path ("
<< context_->unpacked_dir_path.get()
<< ") path does not exist";
@@ -64,7 +64,7 @@ Step::Status StepSignature::precheck() {
return Step::Status::OK;
}
-boost::filesystem::path StepSignature::GetSignatureRoot() const {
+std::filesystem::path StepSignature::GetSignatureRoot() const {
return context_->unpacked_dir_path.get();
}
@@ -76,7 +76,7 @@ Step::Status StepSignature::CheckPrivilegeLevel(PrivilegeLevel level) {
context_->manifest_data.get()->privileges, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SIGNATURE_ERROR, error_message);
+ on_error_->on_error(Status::SIGNATURE_ERROR, error_message);
}
return Status::SIGNATURE_ERROR;
}
@@ -95,13 +95,13 @@ Step::Status StepSignature::process() {
std::string error_message;
if (!signature_->GetPrivilegeLevel(GetSignatureRoot(),
&level, &error_message)) {
- on_error(Status::CERT_ERROR, error_message);
+ on_error_->on_error(Status::CERT_ERROR, error_message);
return Status::CERT_ERROR;
}
if (level == PrivilegeLevel::UNTRUSTED) {
error_message = "Unsigned applications can not be installed";
- on_error(Status::SIGNATURE_ERROR, error_message);
+ on_error_->on_error(Status::SIGNATURE_ERROR, error_message);
return Status::SIGNATURE_ERROR;
}
@@ -118,7 +118,7 @@ Step::Status StepSignature::process() {
&error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SIGNATURE_ERROR, error_message);
+ on_error_->on_error(Status::SIGNATURE_ERROR, error_message);
}
return Status::SIGNATURE_ERROR;
}
@@ -135,9 +135,9 @@ Step::Status StepSignature::undo() {
if (signature_ == nullptr)
return Step::Status::OK;
- bf::remove(signature_->GetFilePath());
- if (bf::exists(signature_->GetBackupPath()))
- bf::rename(signature_->GetBackupPath(), signature_->GetFilePath());
+ fs::remove(signature_->GetFilePath());
+ if (fs::exists(signature_->GetBackupPath()))
+ fs::rename(signature_->GetBackupPath(), signature_->GetFilePath());
return Step::Status::OK;
}
diff --git a/src/common/step/security/step_signature.h b/src/common/step/security/step_signature.h
index 2969cebf..1534d1a8 100644
--- a/src/common/step/security/step_signature.h
+++ b/src/common/step/security/step_signature.h
@@ -5,10 +5,9 @@
#ifndef COMMON_STEP_SECURITY_STEP_SIGNATURE_H_
#define COMMON_STEP_SECURITY_STEP_SIGNATURE_H_
-#include <boost/filesystem/path.hpp>
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
#include <memory>
#include "common/installer_context.h"
@@ -36,12 +35,12 @@ class StepSignature : public Step {
Status precheck() override;
protected:
- virtual boost::filesystem::path GetSignatureRoot() const;
+ virtual std::filesystem::path GetSignatureRoot() const;
virtual Status CheckPrivilegeLevel(PrivilegeLevel level);
private:
bool save_signature_;
- boost::filesystem::path backup_path_;
+ std::filesystem::path backup_path_;
std::unique_ptr<Signature> signature_;
STEP_NAME(Signature)
diff --git a/src/common/step/security/step_unregister_trust_anchor.cc b/src/common/step/security/step_unregister_trust_anchor.cc
index 2f905d9f..b99a8489 100644
--- a/src/common/step/security/step_unregister_trust_anchor.cc
+++ b/src/common/step/security/step_unregister_trust_anchor.cc
@@ -5,13 +5,14 @@
#include "common/step/security/step_unregister_trust_anchor.h"
#include <trust-anchor.h>
-#include <boost/filesystem.hpp>
+
+#include <filesystem>
#include <string>
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
const char kTpkTrustAnchorPath[] = "res/.trust-anchor";
@@ -46,9 +47,9 @@ Step::Status StepUnregisterTrustAnchor::undo() {
if (!manifest->use_system_certs)
return Step::Status::OK;
- bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
+ fs::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
int ret = trust_anchor_install(context_->pkgid.get().c_str(),
- context_->uid.get(), pkg_certs_path.string().c_str(),
+ context_->uid.get(), pkg_certs_path.c_str(),
(strcasecmp(manifest->use_system_certs, "true") == 0) ? true : false);
if (ret != TRUST_ANCHOR_ERROR_NONE) {
diff --git a/src/common/step/security/step_update_security.cc b/src/common/step/security/step_update_security.cc
index 644c00a9..4e2d871e 100644
--- a/src/common/step/security/step_update_security.cc
+++ b/src/common/step/security/step_update_security.cc
@@ -18,7 +18,7 @@ Step::Status StepUpdateSecurity::process() {
if (!RegisterSecurityContextForManifest(context_, &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
@@ -28,7 +28,7 @@ Step::Status StepUpdateSecurity::process() {
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
@@ -50,7 +50,7 @@ Step::Status StepUpdateSecurity::undo() {
context_->is_readonly_package.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
- on_error(Status::SECURITY_ERROR, error_message);
+ on_error_->on_error(Status::SECURITY_ERROR, error_message);
}
return Status::SECURITY_ERROR;
}
diff --git a/src/common/step/step.h b/src/common/step/step.h
index a91480a8..9e5b6af2 100644
--- a/src/common/step/step.h
+++ b/src/common/step/step.h
@@ -28,7 +28,6 @@
#include <pkgmgr_installer_error.h>
-#include <boost/signals2.hpp>
#include <string>
#include "common/installer_context.h"
@@ -80,8 +79,11 @@ class Step {
RECOVERY_DONE = PKGMGR_INSTALLER_ERRCODE_OK + 1
};
- using StepErrorSignal =
- boost::signals2::signal<void(Step::Status result, const std::string&)>;
+ class IStepErrorSignal {
+ public:
+ virtual ~IStepErrorSignal() {}
+ virtual void on_error(Step::Status result, const std::string& error) = 0;
+ };
/** Standard constructor */
explicit Step(InstallerContext* context) : context_(context) { }
@@ -104,10 +106,13 @@ class Step {
/** Returns step name */
virtual const char* name() const = 0;
- StepErrorSignal on_error;
+ void connect(IStepErrorSignal* signal) {
+ on_error_ = signal;
+ }
protected:
InstallerContext* context_;
+ IStepErrorSignal* on_error_;
};
} // namespace common_installer
diff --git a/src/common/tzip_interface.cc b/src/common/tzip_interface.cc
index f215674d..fb6d6e3d 100644
--- a/src/common/tzip_interface.cc
+++ b/src/common/tzip_interface.cc
@@ -6,15 +6,14 @@
#include <manifest_parser/utils/logging.h>
-#include <boost/filesystem.hpp>
-
#include <gio/gio.h>
#include <glib.h>
#include <cstdlib>
#include <functional>
+#include <filesystem>
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -88,10 +87,10 @@ class DBusProxy {
class TzipInterface::Pimpl {
public:
- explicit Pimpl(const boost::filesystem::path& mount_path) :
+ explicit Pimpl(const std::filesystem::path& mount_path) :
mount_path_(mount_path), dbus_proxy_(new DBusProxy()) { }
- bool MountZip(const boost::filesystem::path& zip_path) {
+ bool MountZip(const std::filesystem::path& zip_path) {
zip_path_ = zip_path;
if (IsMounted()) {
@@ -100,19 +99,19 @@ class TzipInterface::Pimpl {
UnmountZip();
}
- if (bf::exists(mount_path_)) {
+ if (fs::exists(mount_path_)) {
LOG(WARNING) << "Mount path(" << mount_path_ << ") already exists! "
<< "We will remove it...";
- bf::remove(mount_path_);
+ fs::remove(mount_path_);
}
- if (!bf::exists(zip_path)) {
+ if (!fs::exists(zip_path)) {
LOG(WARNING) << "zip path(" << zip_path << ") doesn't exist!";
return false;
}
- const char* mount_path_str = mount_path_.string().c_str();
- const char* zip_path_str = zip_path_.string().c_str();
+ const char* mount_path_str = mount_path_.c_str();
+ const char* zip_path_str = zip_path_.c_str();
const char* tzip_smack_rule = kTzipSmackRule;
GVariant* r = dbus_proxy_->ProxyCallSync(kTzipMountMethod,
@@ -129,7 +128,7 @@ class TzipInterface::Pimpl {
}
bool UnmountZip() {
- const char* mount_path_str = mount_path_.string().c_str();
+ const char* mount_path_str = mount_path_.c_str();
GVariant* r = dbus_proxy_->ProxyCallSync(kTzipUnmountMethod,
g_variant_new("(s)", mount_path_str));
@@ -146,7 +145,7 @@ class TzipInterface::Pimpl {
private:
bool IsMounted() {
- const char* mount_path_str = mount_path_.string().c_str();
+ const char* mount_path_str = mount_path_.c_str();
GVariant* r = dbus_proxy_->ProxyCallSync(kTzipIsMountedMethod,
g_variant_new("(s)", mount_path_str));
if (!r)
@@ -181,17 +180,17 @@ class TzipInterface::Pimpl {
return true;
}
- boost::filesystem::path mount_path_;
- boost::filesystem::path zip_path_;
+ std::filesystem::path mount_path_;
+ std::filesystem::path zip_path_;
std::unique_ptr<DBusProxy> dbus_proxy_;
};
-TzipInterface::TzipInterface(const boost::filesystem::path& mount_path)
+TzipInterface::TzipInterface(const std::filesystem::path& mount_path)
: impl_(new Pimpl(mount_path)) {}
TzipInterface::~TzipInterface() { }
-bool TzipInterface::MountZip(const boost::filesystem::path& zip_path) {
+bool TzipInterface::MountZip(const std::filesystem::path& zip_path) {
return impl_->MountZip(zip_path);
}
diff --git a/src/common/tzip_interface.h b/src/common/tzip_interface.h
index 69e00262..87fde014 100644
--- a/src/common/tzip_interface.h
+++ b/src/common/tzip_interface.h
@@ -5,10 +5,9 @@
#ifndef COMMON_TZIP_INTERFACE_H_
#define COMMON_TZIP_INTERFACE_H_
-#include <boost/filesystem/path.hpp>
-
#include <common/zip_interface.h>
+#include <filesystem>
#include <memory>
#include <string>
@@ -16,10 +15,10 @@ namespace common_installer {
class TzipInterface : public common_installer::IZipInterface {
public:
- explicit TzipInterface(const boost::filesystem::path& mount_path);
+ explicit TzipInterface(const std::filesystem::path& mount_path);
~TzipInterface();
- bool MountZip(const boost::filesystem::path& zip_path) override;
+ bool MountZip(const std::filesystem::path& zip_path) override;
bool UnmountZip() override;
private:
diff --git a/src/common/utils/base64.cc b/src/common/utils/base64.cc
index 1517b799..5e9c75e0 100644
--- a/src/common/utils/base64.cc
+++ b/src/common/utils/base64.cc
@@ -4,29 +4,63 @@
#include "common/utils/base64.h"
-#include <boost/archive/iterators/base64_from_binary.hpp>
-#include <boost/archive/iterators/transform_width.hpp>
-
#include <algorithm>
#include <sstream>
#include <string>
-namespace bai = boost::archive::iterators;
-
namespace {
-typedef bai::base64_from_binary<bai::transform_width<const char*, 6, 8>>
- base64_encode;
+const char kBase64Chars[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
} // namespace
namespace common_installer {
+// from https://stackoverflow.com/a/13935718
std::string EncodeBase64(unsigned char* val, size_t len) {
- std::stringstream os;
- std::copy(base64_encode(val), base64_encode(val + len),
- std::ostream_iterator<char>(os));
- return os.str();
+ std::string ret;
+ int i = 0;
+ int j = 0;
+ unsigned char char_array_3[3];
+ unsigned char char_array_4[4];
+
+ while (len--) {
+ char_array_3[i++] = *(val++);
+ if (i == 3) {
+ char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+ char_array_4[1] = ((char_array_3[0] & 0x03) << 4) +
+ ((char_array_3[1] & 0xf0) >> 4);
+ char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) +
+ ((char_array_3[2] & 0xc0) >> 6);
+ char_array_4[3] = char_array_3[2] & 0x3f;
+
+ for(i = 0; (i <4) ; i++)
+ ret += kBase64Chars[char_array_4[i]];
+ i = 0;
+ }
+ }
+
+ if (i) {
+ for(j = i; j < 3; j++)
+ char_array_3[j] = '\0';
+
+ char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+ char_array_4[1] = ((char_array_3[0] & 0x03) << 4) +
+ ((char_array_3[1] & 0xf0) >> 4);
+ char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) +
+ ((char_array_3[2] & 0xc0) >> 6);
+ char_array_4[3] = char_array_3[2] & 0x3f;
+
+ for (j = 0; (j < i + 1); j++)
+ ret += kBase64Chars[char_array_4[j]];
+
+ while((i++ < 3))
+ ret += '=';
+ }
+
+ return ret;
}
} // namespace common_installer
diff --git a/src/common/utils/file_util.cc b/src/common/utils/file_util.cc
index 8df33f45..aa87c788 100644
--- a/src/common/utils/file_util.cc
+++ b/src/common/utils/file_util.cc
@@ -8,34 +8,30 @@
#include <unzip.h>
#include <zlib.h>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/system/error_code.hpp>
-
#include <manifest_parser/utils/logging.h>
#include <algorithm>
+#include <filesystem>
+#include <random>
+#include <regex>
#include <string>
+#include <system_error>
#include <vector>
#include "common/utils/byte_size_literals.h"
#include "common/utils/paths.h"
-namespace ba = boost::algorithm;
-namespace bs = boost::system;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
unsigned kZipBufSize = 8_kB;
unsigned kZipMaxPath = PATH_MAX;
-int64_t GetBlockSizeForPath(const bf::path& path_in_partition) {
+int64_t GetBlockSizeForPath(const fs::path& path_in_partition) {
struct stat stats;
- if (stat(path_in_partition.string().c_str(), &stats)) {
- LOG(ERROR) << "stat(" << path_in_partition.string()
+ if (stat(path_in_partition.c_str(), &stats)) {
+ LOG(ERROR) << "stat(" << path_in_partition
<< ") failed - error code: " << errno;
return -1;
}
@@ -97,7 +93,7 @@ FSFlag operator|(FSFlag a, FSFlag b) {
return static_cast<FSFlag>(static_cast<int>(a) | static_cast<int>(b));
}
-bool SetOwnership(const bf::path& path, uid_t uid, gid_t gid) {
+bool SetOwnership(const fs::path& path, uid_t uid, gid_t gid) {
int ret = lchown(path.c_str(), uid, gid);
if (ret != 0) {
LOG(ERROR) << "Failed to change owner of: " << path;
@@ -106,51 +102,51 @@ bool SetOwnership(const bf::path& path, uid_t uid, gid_t gid) {
return true;
}
-bool SetOwnershipAll(const bf::path& path, uid_t uid, gid_t gid) {
+bool SetOwnershipAll(const fs::path& path, uid_t uid, gid_t gid) {
if (!SetOwnership(path, uid, gid))
return false;
- if (!bf::is_directory(path))
+ if (!fs::is_directory(path))
return true;
- for (bf::recursive_directory_iterator iter(path);
- iter != bf::recursive_directory_iterator();
+ for (fs::recursive_directory_iterator iter(path);
+ iter != fs::recursive_directory_iterator();
++iter) {
- bf::path current(iter->path());
+ fs::path current(iter->path());
if (!SetOwnership(current, uid, gid))
return false;
}
return true;
}
-bool CreateDir(const bf::path& path) {
- if (bf::exists(path))
+bool CreateDir(const fs::path& path) {
+ if (fs::exists(path))
return true;
- boost::system::error_code error;
- bf::create_directories(path, error);
+ std::error_code error;
+ fs::create_directories(path, error);
if (error) {
- LOG(ERROR) << "Failed to create directory: "
- << boost::system::system_error(error).what();
+ LOG(ERROR) << "Failed to create directory: " << error.message();
return false;
}
return true;
}
-bool SetDirPermissions(const boost::filesystem::path& path,
- boost::filesystem::perms permissions) {
- boost::system::error_code error;
- bf::permissions(path, permissions, error);
+bool SetDirPermissions(const fs::path& path,
+ fs::perms permissions, bool add_perms) {
+ std::error_code error;
+ fs::permissions(path, permissions,
+ add_perms ? fs::perm_options::add : fs::perm_options::replace, error);
if (error) {
LOG(ERROR) << "Failed to set permissions for directory: " << path
- << boost::system::system_error(error).what();
+ << error.message();
return false;
}
return true;
}
-bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
- boost::filesystem::perms permissions, uid_t uid,
+bool SetDirOwnershipAndPermissions(const fs::path& path,
+ fs::perms permissions, uid_t uid,
gid_t gid) {
if (!SetOwnership(path, uid, gid)) {
LOG(ERROR) << "Failed to change owner: " << path
@@ -158,22 +154,20 @@ bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
return false;
}
if (!SetDirPermissions(path, permissions)) {
- LOG(ERROR) << "Failed to change permission: " << path
- << std::oct << permissions;
+ LOG(ERROR) << "Failed to change permission: " << path;
return false;
}
return true;
}
-bool CopyOwnershipAndPermissions(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
- if (!bf::exists(src)) {
+bool CopyOwnershipAndPermissions(const fs::path& src, const fs::path& dst) {
+ if (!fs::exists(src)) {
LOG(ERROR) << "Failed to copy ownership and permissions"
<< " from " << src << " to " << dst;
return false;
}
- bf::perms permissions = bf::status(src).permissions();
+ fs::perms permissions = fs::status(src).permissions();
struct stat stats;
if (stat(src.c_str(), &stats) != 0)
return false;
@@ -186,16 +180,16 @@ bool CopyOwnershipAndPermissions(const boost::filesystem::path& src,
return true;
}
-bool CopyDir(const bf::path& src, const bf::path& dst,
+bool CopyDir(const fs::path& src, const fs::path& dst,
FSFlag flags, bool skip_symlink) {
try {
// Check whether the function call is valid
- if (!bf::exists(src) || !bf::is_directory(src)) {
+ if (!fs::exists(src) || !fs::is_directory(src)) {
LOG(ERROR) << "Source directory " << src
<< " does not exist or is not a directory.";
return false;
}
- if (!bf::exists(dst)) {
+ if (!fs::exists(dst)) {
// Create the destination directory
if (!CreateDir(dst)) {
LOG(ERROR) << "Unable to create destination directory" << dst;
@@ -212,62 +206,59 @@ bool CopyDir(const bf::path& src, const bf::path& dst,
if (flags & (FS_MERGE_OVERWRITE | FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS))
CopyOwnershipAndPermissions(src, dst);
}
- } catch (const bf::filesystem_error& error) {
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to copy directory: " << error.what();
return false;
}
// Iterate through the source directory
- for (bf::directory_iterator file(src);
- file != bf::directory_iterator();
- ++file) {
+ for (const auto& current : fs::directory_iterator(src)) {
try {
- bf::path current(file->path());
- bf::path target = dst / current.filename();
+ fs::path target = dst / current.path().filename();
- if (bf::is_symlink(symlink_status(current))) {
+ if (fs::is_symlink(symlink_status(current))) {
if (skip_symlink)
continue;
if ((flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE)) &&
- bf::exists(target))
+ fs::exists(target))
continue;
- bs::error_code error;
- bf::copy_symlink(current, target, error);
+ std::error_code error;
+ fs::copy_symlink(current, target, error);
if (error) {
LOG(ERROR) << "Failed to copy symlink: " << current << ", "
<< error.message();
return false;
}
- } else if (bf::is_directory(current)) {
+ } else if (fs::is_directory(current)) {
// Found directory: Recursion
if (!CopyDir(current, target, flags, skip_symlink)) {
return false;
}
} else {
- if ((flags & FS_MERGE_SKIP) && bf::exists(target))
+ if ((flags & FS_MERGE_SKIP) && fs::exists(target))
continue;
- bf::path destination = target;
+ fs::path destination = target;
if (flags & FS_COMMIT_COPY_FILE)
- destination =
- bf::unique_path(target.parent_path() / "%%%%-%%%%-%%%%-%%%%");
+ destination = target.parent_path() /
+ GenerateUniquePathString("%%%%-%%%%-%%%%-%%%%");
if (flags & FS_MERGE_OVERWRITE)
- bf::copy_file(current, destination,
- bf::copy_option::overwrite_if_exists);
+ fs::copy_file(current, destination,
+ fs::copy_options::overwrite_existing);
else
- bf::copy_file(current, destination);
+ fs::copy_file(current, destination);
if (flags & FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS)
CopyOwnershipAndPermissions(current, destination);
if (flags & FS_COMMIT_COPY_FILE) {
if (flags & FS_MERGE_OVERWRITE)
- bf::remove(target);
- bf::rename(destination, target);
+ fs::remove(target);
+ fs::rename(destination, target);
}
}
- } catch (const bf::filesystem_error& error) {
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to copy directory: " << error.what();
return false;
}
@@ -275,10 +266,10 @@ bool CopyDir(const bf::path& src, const bf::path& dst,
return true;
}
-bool CopyFile(const bf::path& src, const bf::path& dst) {
- bs::error_code error;
+bool CopyFile(const fs::path& src, const fs::path& dst) {
+ std::error_code error;
- bf::copy_file(src, dst, bf::copy_option::overwrite_if_exists, error);
+ fs::copy_file(src, dst, fs::copy_options::overwrite_existing, error);
if (error) {
LOG(WARNING) << "copy file " << src << " due to error [" << error << "]";
return false;
@@ -286,41 +277,41 @@ bool CopyFile(const bf::path& src, const bf::path& dst) {
return true;
}
-bool RestoreBackup(const bf::path& path) {
- bf::path backup_path = GetBackupPathForPackagePath(path);
- if (!bf::exists(backup_path) &&
- !bf::is_symlink(bf::symlink_status(backup_path))) {
+bool RestoreBackup(const fs::path& path) {
+ fs::path backup_path = GetBackupPathForPackagePath(path);
+ if (!fs::exists(backup_path) &&
+ !fs::is_symlink(fs::symlink_status(backup_path))) {
LOG(WARNING) << backup_path << " does not exist";
return true;
}
return MoveDir(backup_path, path);
}
-bool MakeBackup(const bf::path& path) {
- if (!bf::exists(path) && !bf::is_symlink(bf::symlink_status(path))) {
+bool MakeBackup(const fs::path& path) {
+ if (!fs::exists(path) && !fs::is_symlink(fs::symlink_status(path))) {
LOG(WARNING) << path << " does not exist";
return true;
}
- bf::path backup_path = GetBackupPathForPackagePath(path);
+ fs::path backup_path = GetBackupPathForPackagePath(path);
return MoveDir(path, backup_path);
}
-bool RemoveBackup(const bf::path& path) {
- bf::path backup_path = GetBackupPathForPackagePath(path);
- if (!bf::exists(backup_path) &&
- !bf::is_symlink(bf::symlink_status(backup_path))) {
+bool RemoveBackup(const fs::path& path) {
+ fs::path backup_path = GetBackupPathForPackagePath(path);
+ if (!fs::exists(backup_path) &&
+ !fs::is_symlink(fs::symlink_status(backup_path))) {
LOG(WARNING) << backup_path << " does not exist";
return true;
}
return RemoveAll(backup_path);
}
-bool RemoveAll(const bf::path& path) {
- if (!bf::exists(path) && !bf::is_symlink(bf::symlink_status(path)))
+bool RemoveAll(const fs::path& path) {
+ if (!fs::exists(path) && !fs::is_symlink(fs::symlink_status(path)))
return true;
- bs::error_code error;
- bf::remove_all(path, error);
+ std::error_code error;
+ fs::remove_all(path, error);
if (error) {
LOG(ERROR) << "Cannot remove: " << path << ", " << error.message();
@@ -330,12 +321,12 @@ bool RemoveAll(const bf::path& path) {
return true;
}
-bool Remove(const bf::path& path) {
- bs::error_code error;
- if (!bf::exists(bf::symlink_status(path, error)))
+bool Remove(const fs::path& path) {
+ std::error_code error;
+ if (!fs::exists(fs::symlink_status(path, error)))
return true;
- bf::remove(path, error);
+ fs::remove(path, error);
if (error) {
LOG(ERROR) << "Cannot remove: " << path << ", " << error.message();
return false;
@@ -343,22 +334,22 @@ bool Remove(const bf::path& path) {
return true;
}
-bool MoveDir(const bf::path& src, const bf::path& dst, FSFlag flags) {
- if (bf::exists(dst) &&
+bool MoveDir(const fs::path& src, const fs::path& dst, FSFlag flags) {
+ if (fs::exists(dst) &&
!(flags & (FS_MERGE_SKIP | FS_MERGE_OVERWRITE))) {
LOG(ERROR) << "Destination directory does exist: " << dst;
return false;
}
- bs::error_code error;
- bf::rename(src, dst, error);
+ std::error_code error;
+ fs::rename(src, dst, error);
if (error) {
LOG(WARNING) << "Cannot move directory: " << src << ". Will copy/remove...";
if (!CopyDir(src, dst, flags, false)) {
LOG(ERROR) << "Cannot copy directory: " << src;
return false;
}
- bf::remove_all(src, error);
+ fs::remove_all(src, error);
if (error) {
LOG(ERROR) << "Cannot remove old directory when coping: " << src;
return false;
@@ -367,21 +358,21 @@ bool MoveDir(const bf::path& src, const bf::path& dst, FSFlag flags) {
return true;
}
-bool MoveFile(const bf::path& src, const bf::path& dst, bool force) {
- if (!force && bf::exists(dst))
+bool MoveFile(const fs::path& src, const fs::path& dst, bool force) {
+ if (!force && fs::exists(dst))
return false;
- bs::error_code error;
- bf::rename(src, dst, error);
+ std::error_code error;
+ fs::rename(src, dst, error);
if (error) {
LOG(WARNING) << "Cannot move file: " << src <<
". Will copy/remove... with error [" << error << "]";
- bf::copy_file(src, dst, bf::copy_option::overwrite_if_exists, error);
+ fs::copy_file(src, dst, fs::copy_options::overwrite_existing, error);
if (error) {
LOG(WARNING) << "Cannot copy file " << src <<
" due to error [" << error << "]";
return false;
}
- bf::remove_all(src, error);
+ fs::remove_all(src, error);
if (error) {
LOG(ERROR) << "Cannot remove old file when coping: " << src <<
"with error [" << error << "]";
@@ -390,9 +381,9 @@ bool MoveFile(const bf::path& src, const bf::path& dst, bool force) {
return true;
}
-bool BackupDir(const boost::filesystem::path& src,
- const boost::filesystem::path& dst, const std::string& entry) {
- if (!bf::exists(src / entry))
+bool BackupDir(const fs::path& src,
+ const fs::path& dst, const std::string& entry) {
+ if (!fs::exists(src / entry))
return true;
if (!MoveDir(src / entry, dst / entry,
@@ -406,7 +397,7 @@ bool BackupDir(const boost::filesystem::path& src,
return true;
}
-int64_t GetUnpackedPackageSize(const bf::path& path) {
+int64_t GetUnpackedPackageSize(const fs::path& path) {
int64_t size = 0;
int64_t block_size = GetBlockSizeForPath(path);
@@ -417,7 +408,7 @@ int64_t GetUnpackedPackageSize(const bf::path& path) {
unz_file_info64 raw_file_info;
char raw_file_name_in_zip[kZipMaxPath];
- unzFile* zip_file = static_cast<unzFile*>(unzOpen(path.string().c_str()));
+ unzFile* zip_file = static_cast<unzFile*>(unzOpen(path.c_str()));
if (zip_file == nullptr) {
LOG(ERROR) << "Failed to open the source dir: " << path.string();
return -1;
@@ -445,15 +436,15 @@ int64_t GetUnpackedPackageSize(const bf::path& path) {
return size;
}
-int64_t GetDirectorySize(const boost::filesystem::path& path) {
+int64_t GetDirectorySize(const fs::path& path) {
int64_t block_size = GetBlockSizeForPath(path);
if (block_size == -1)
return -1;
int64_t size = 0;
- for (bf::recursive_directory_iterator iter(path);
- iter != bf::recursive_directory_iterator(); ++iter) {
+ for (fs::recursive_directory_iterator iter(path);
+ iter != fs::recursive_directory_iterator(); ++iter) {
struct stat buf;
if (lstat(iter->path().c_str(), &buf) == -1) {
LOG(ERROR) << "lstat() failed for: " << iter->path();
@@ -467,19 +458,19 @@ int64_t GetDirectorySize(const boost::filesystem::path& path) {
}
bool CheckFreeSpaceAtPath(int64_t required_size,
- const boost::filesystem::path& target_location) {
- bs::error_code error;
- boost::filesystem::path root = target_location;
+ const fs::path& target_location) {
+ std::error_code error;
+ fs::path root = target_location;
- while (!bf::exists(root) && root != root.root_path())
+ while (!fs::exists(root) && root != root.root_path())
root = root.parent_path();
- if (!bf::exists(root)) {
+ if (!fs::exists(root)) {
LOG(ERROR) << "No mount point for path: " << target_location;
return false;
}
- bf::space_info space_info = bf::space(root, error);
+ fs::space_info space_info = fs::space(root, error);
if (error) {
LOG(ERROR) << "Failed to get space_info: " << error.message();
return false;
@@ -488,41 +479,38 @@ bool CheckFreeSpaceAtPath(int64_t required_size,
return (space_info.free >= static_cast<uint64_t>(required_size));
}
-boost::filesystem::path GenerateTmpDir(const bf::path &app_path) {
- boost::filesystem::path install_tmp_dir;
- boost::filesystem::path tmp_dir(app_path);
+fs::path GenerateTmpDir(const fs::path &app_path) {
+ fs::path install_tmp_dir;
+ fs::path tmp_dir(app_path);
do {
- boost::filesystem::path model;
- boost::filesystem::path unique_dir =
- boost::filesystem::unique_path(model = "unpack-%%%%%%");
+ fs::path unique_dir = GenerateUniquePathString("unpack-%%%%%%");
install_tmp_dir = tmp_dir /= unique_dir;
- } while (boost::filesystem::exists(install_tmp_dir) &&
- boost::filesystem::is_directory(install_tmp_dir));
+ } while (fs::exists(install_tmp_dir) &&
+ fs::is_directory(install_tmp_dir));
return install_tmp_dir;
}
-boost::filesystem::path GenerateTemporaryPath(
- const boost::filesystem::path& path) {
- bf::path pattern = path;
+fs::path GenerateTemporaryPath(const fs::path& path) {
+ fs::path pattern = path;
pattern += "-%%%%%%";
- bf::path tmp_path;
+ fs::path tmp_path;
do {
- tmp_path = boost::filesystem::unique_path(pattern);
- } while (boost::filesystem::exists(tmp_path));
+ tmp_path = GenerateUniquePathString(pattern);
+ } while (fs::exists(tmp_path));
return tmp_path;
}
bool ExtractToTmpDir(const char* zip_path,
- const boost::filesystem::path& tmp_dir) {
+ const fs::path& tmp_dir) {
return ExtractToTmpDir(zip_path, tmp_dir, "");
}
-bool ExtractToTmpDir(const char* zip_path, const bf::path& tmp_dir,
+bool ExtractToTmpDir(const char* zip_path, const fs::path& tmp_dir,
const std::string& filter_prefix) {
unz_global_info info;
char read_buffer[kZipBufSize];
@@ -561,7 +549,7 @@ bool ExtractToTmpDir(const char* zip_path, const bf::path& tmp_dir,
// unpack if filter is empty or path is matched
if (filter_prefix.empty() ||
std::string(raw_file_name_in_zip).find(filter_prefix) == 0) {
- bf::path filename_in_zip_path(raw_file_name_in_zip);
+ fs::path filename_in_zip_path(raw_file_name_in_zip);
if (HasDirectoryClimbing(filename_in_zip_path)) {
LOG(ERROR) << "Relative path in widget in malformed";
@@ -618,7 +606,7 @@ bool ExtractToTmpDir(const char* zip_path, const bf::path& tmp_dir,
}
bool CheckPathInZipArchive(const char* zip_archive_path,
- const boost::filesystem::path& relative_zip_path,
+ const fs::path& relative_zip_path,
bool* found) {
*found = false;
UnzFilePointer zip_file;
@@ -667,17 +655,18 @@ bool CheckPathInZipArchive(const char* zip_archive_path,
return true;
}
-bool HasDirectoryClimbing(const boost::filesystem::path& path) {
- std::vector<std::string> segments;
- ba::split(segments, path.string(), ba::is_any_of("/\\"));
- return std::any_of(segments.begin(), segments.end(),
- [](const std::string& segment) {
- return segment == "..";
- });
+bool HasDirectoryClimbing(const fs::path& path) {
+ std::regex re("[\\/\\\\]");
+ std::string path_str = path.string();
+ std::sregex_token_iterator first(path_str.begin(), path_str.end(), re, -1);
+ std::sregex_token_iterator last;
+ std::vector<std::string> segments(first, last);
+
+ return std::find(segments.begin(), segments.end(), "..") != segments.end();
}
-boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
- const boost::filesystem::path& base) {
+fs::path MakeRelativePath(const fs::path& input,
+ const fs::path& base) {
if (input.string().find(base.string()) == std::string::npos) {
LOG(ERROR) << base.string() << " is not base path for " << input.string();
return input;
@@ -686,72 +675,75 @@ boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
return input.string().substr(base.string().length() + 1);
}
-bool IsSubDir(const boost::filesystem::path& path,
- const boost::filesystem::path& root) {
- boost::filesystem::path p = path;
- while (p != boost::filesystem::path()) {
- if (bf::equivalent(p, root))
- return true;
- else
- p = p.parent_path();
- }
-
- return false;
+bool IsSubDir(const fs::path& path, const fs::path& root) {
+ std::string relative = fs::relative(path, root);
+ return relative.size() == 1 || (relative[0] != '.' && relative[1] != '.');
}
-bf::path RelativePath(const bf::path& from,
- const bf::path& to) {
- bf::path::const_iterator itr_path = from.begin();
- bf::path::const_iterator itr_relative_to = to.begin();
-
- while (itr_path != from.end() && itr_relative_to != to.end() &&
- *itr_path == *itr_relative_to) {
- ++itr_path;
- ++itr_relative_to;
- }
-
- bf::path result;
- if (itr_relative_to != to.end()) {
- ++itr_relative_to;
- while (itr_relative_to != to.end()) {
- result /= "..";
- ++itr_relative_to;
- }
- }
+std::vector<std::string> GetDirectoryList(const fs::path& cwd) {
+ if (!fs::exists(cwd))
+ return {};
- while (itr_path != from.end()) {
- result /= *itr_path;
- ++itr_path;
+ std::vector<std::string> list;
+ for (fs::directory_iterator file(cwd); file != fs::directory_iterator();
+ ++file) {
+ if (!fs::is_directory(file->path()))
+ continue;
+ list.emplace_back(file->path().filename().string());
}
- bs::error_code error;
- bf::path resolved_path = bf::canonical(result, error);
- if (error) {
- LOG(ERROR) << "Failed to get canonical path";
- return {};
- }
+ return list;
+}
- if (from != resolved_path) {
- LOG(ERROR) << "Failed to get right relative path :" << resolved_path;
- return {};
- }
+// To replace with std::filesystem::unique_path()
+fs::path GenerateUniquePathString(const std::string& format) {
+ static constexpr auto chars =
+ "0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz";
+ std::random_device rd;
+ std::mt19937 gen(rd());
+ auto dist = std::uniform_int_distribution{{}, std::strlen(chars) - 1};
+ size_t len = std::count_if(format.begin(), format.end(),
+ [](char c) { return c == '%'; });
+
+ auto random_string = std::string(len, '\0');
+ std::generate_n(begin(random_string), len,
+ [&]() {
+ return chars[dist(gen)];
+ });
+
+ auto iter = random_string.begin();
+ std::string result(format);
+ std::transform(result.begin(), result.end(), result.begin(),
+ [&](char c) {
+ return c == '%' ? *iter++ : c;
+ });
return result;
}
-std::vector<std::string> GetDirectoryList(const boost::filesystem::path& cwd) {
- if (!bf::exists(cwd))
- return {};
+bool SyncFile(const fs::path& path) {
+ if (!fs::exists(path)) {
+ LOG(ERROR) << "File does not exist: " << path;
+ return false;
+ }
- std::vector<std::string> list;
- for (bf::directory_iterator file(cwd); file != bf::directory_iterator();
- ++file) {
- if (!bf::is_directory(file->path()))
- continue;
- list.emplace_back(file->path().filename().string());
+ int fd = open(path.c_str(), O_WRONLY);
+ if (fd == -1) {
+ LOG(ERROR) << "Failed to open file: " << path << ", errno: " << errno;
+ return false;
}
- return list;
+ int ret = fsync(fd);
+ if (ret == -1) {
+ LOG(ERROR) << "Failed to fsync() file: " << path << ", errno: " << errno;
+ close(fd);
+ return false;
+ }
+
+ close(fd);
+ return true;
}
} // namespace common_installer
diff --git a/src/common/utils/file_util.h b/src/common/utils/file_util.h
index 943f0835..501633eb 100644
--- a/src/common/utils/file_util.h
+++ b/src/common/utils/file_util.h
@@ -5,8 +5,7 @@
#include <sys/types.h>
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <string>
#include <vector>
@@ -22,83 +21,85 @@ enum FSFlag : int {
FSFlag operator|(FSFlag a, FSFlag b);
-bool SetOwnership(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+bool SetOwnership(const std::filesystem::path& path, uid_t uid, gid_t gid);
-bool SetOwnershipAll(const boost::filesystem::path& path, uid_t uid, gid_t gid);
+bool SetOwnershipAll(const std::filesystem::path& path, uid_t uid, gid_t gid);
-bool CreateDir(const boost::filesystem::path& path);
+bool CreateDir(const std::filesystem::path& path);
-bool CopyDir(const boost::filesystem::path& src,
- const boost::filesystem::path& dst,
+bool CopyDir(const std::filesystem::path& src,
+ const std::filesystem::path& dst,
FSFlag flags = FS_NONE, bool skip_symlink = false);
-bool CopyFile(const boost::filesystem::path& src,
- const boost::filesystem::path& dst);
+bool CopyFile(const std::filesystem::path& src,
+ const std::filesystem::path& dst);
-bool RestoreBackup(const boost::filesystem::path& path);
+bool RestoreBackup(const std::filesystem::path& path);
-bool MakeBackup(const boost::filesystem::path& path);
+bool MakeBackup(const std::filesystem::path& path);
-bool RemoveBackup(const boost::filesystem::path& path);
+bool RemoveBackup(const std::filesystem::path& path);
-bool RemoveAll(const boost::filesystem::path& path);
+bool RemoveAll(const std::filesystem::path& path);
-bool Remove(const boost::filesystem::path& path);
+bool Remove(const std::filesystem::path& path);
-bool MoveDir(const boost::filesystem::path& src,
- const boost::filesystem::path& dst, FSFlag flags = FS_NONE);
+bool MoveDir(const std::filesystem::path& src,
+ const std::filesystem::path& dst, FSFlag flags = FS_NONE);
-bool MoveFile(const boost::filesystem::path& src,
- const boost::filesystem::path& dst, bool force = false);
+bool MoveFile(const std::filesystem::path& src,
+ const std::filesystem::path& dst, bool force = false);
-bool BackupDir(const boost::filesystem::path& src,
- const boost::filesystem::path& dst, const std::string& entry);
+bool BackupDir(const std::filesystem::path& src,
+ const std::filesystem::path& dst, const std::string& entry);
-bool SetDirPermissions(const boost::filesystem::path& path,
- boost::filesystem::perms permissions);
+bool SetDirPermissions(const std::filesystem::path& path,
+ std::filesystem::perms permissions,
+ bool add_perms = false);
-bool SetDirOwnershipAndPermissions(const boost::filesystem::path& path,
- boost::filesystem::perms permissions, uid_t uid,
+bool SetDirOwnershipAndPermissions(const std::filesystem::path& path,
+ std::filesystem::perms permissions, uid_t uid,
gid_t gid);
-bool CopyOwnershipAndPermissions(const boost::filesystem::path& src,
- const boost::filesystem::path& dst);
+bool CopyOwnershipAndPermissions(const std::filesystem::path& src,
+ const std::filesystem::path& dst);
-int64_t GetUnpackedPackageSize(const boost::filesystem::path& path);
+int64_t GetUnpackedPackageSize(const std::filesystem::path& path);
-int64_t GetDirectorySize(const boost::filesystem::path& path);
+int64_t GetDirectorySize(const std::filesystem::path& path);
bool CheckFreeSpaceAtPath(int64_t required_size,
- const boost::filesystem::path& target_location);
+ const std::filesystem::path& target_location);
-boost::filesystem::path GenerateTmpDir(const boost::filesystem::path& app_path);
+std::filesystem::path GenerateTmpDir(const std::filesystem::path& app_path);
-boost::filesystem::path GenerateTemporaryPath(
- const boost::filesystem::path& path);
+std::filesystem::path GenerateTemporaryPath(
+ const std::filesystem::path& path);
bool ExtractToTmpDir(const char* zip_path,
- const boost::filesystem::path& tmp_dir);
+ const std::filesystem::path& tmp_dir);
bool ExtractToTmpDir(const char* zip_path,
- const boost::filesystem::path& tmp_dir,
+ const std::filesystem::path& tmp_dir,
const std::string& filter_prefix);
bool CheckPathInZipArchive(const char* zip_archive_path,
- const boost::filesystem::path& relative_zip_path,
+ const std::filesystem::path& relative_zip_path,
bool* found);
-bool HasDirectoryClimbing(const boost::filesystem::path& path);
+bool HasDirectoryClimbing(const std::filesystem::path& path);
-boost::filesystem::path MakeRelativePath(const boost::filesystem::path& input,
- const boost::filesystem::path& base);
+std::filesystem::path MakeRelativePath(const std::filesystem::path& input,
+ const std::filesystem::path& base);
-bool IsSubDir(const boost::filesystem::path& path,
- const boost::filesystem::path& root);
+bool IsSubDir(const std::filesystem::path& path,
+ const std::filesystem::path& root);
-boost::filesystem::path RelativePath(const boost::filesystem::path& from,
- const boost::filesystem::path& to);
+std::vector<std::string> GetDirectoryList(const std::filesystem::path& cwd);
-std::vector<std::string> GetDirectoryList(const boost::filesystem::path& cwd);
+std::filesystem::path GenerateUniquePathString(const std::string& format) ;
+
+bool SyncFile(const std::filesystem::path& path);
} // namespace common_installer
diff --git a/src/common/utils/manifest_util.cc b/src/common/utils/manifest_util.cc
index 23b81e58..9f709bcf 100644
--- a/src/common/utils/manifest_util.cc
+++ b/src/common/utils/manifest_util.cc
@@ -9,12 +9,12 @@
#include <pkgmgr-info.h>
#include <tzplatform_config.h>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <string>
#include "common/utils/pkgmgr_query.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -61,7 +61,7 @@ int PkgmgrAppInfoCallback(const pkgmgrinfo_appinfo_h handle,
namespace common_installer {
-bf::path GetManifestLocation(const std::string& pkgid,
+fs::path GetManifestLocation(const std::string& pkgid,
uid_t uid,
bool is_readonly) {
PkgQueryInterface pkg_query(pkgid, uid);
@@ -69,8 +69,8 @@ bf::path GetManifestLocation(const std::string& pkgid,
uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
is_readonly = pkg_query.IsReadonlyPackage();
}
- bf::path xml_path = bf::path(getUserManifestPath(uid, is_readonly))
- / bf::path(pkgid.c_str());
+ fs::path xml_path = fs::path(getUserManifestPath(uid, is_readonly))
+ / fs::path(pkgid.c_str());
xml_path += ".xml";
return xml_path;
diff --git a/src/common/utils/manifest_util.h b/src/common/utils/manifest_util.h
index e2f07ea3..d29582fe 100644
--- a/src/common/utils/manifest_util.h
+++ b/src/common/utils/manifest_util.h
@@ -8,16 +8,17 @@
#include <pkgmgr-info.h>
#include <pkgmgr/pkgmgr_parser.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
+
namespace common_installer {
manifest_x* PkgmgrGenerateManifestInfoFromDB(const std::string& pkgid,
uid_t uid);
-bf::path GetManifestLocation(const std::string& pkgid,
+fs::path GetManifestLocation(const std::string& pkgid,
uid_t uid,
bool is_readonly);
diff --git a/src/common/utils/paths.cc b/src/common/utils/paths.cc
index 01b89491..e3127831 100644
--- a/src/common/utils/paths.cc
+++ b/src/common/utils/paths.cc
@@ -6,26 +6,25 @@
#include <manifest_parser/utils/logging.h>
-#include <boost/filesystem/operations.hpp>
-
#include <pwd.h>
#include <tzplatform_config.h>
#include <storage-internal.h>
+#include <filesystem>
#include <vector>
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
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;
+std::filesystem::path GetBackupPath(const std::filesystem::path& pkg_path) {
+ fs::path backup_path = pkg_path;
backup_path += kBckExtension;
return backup_path;
}
@@ -34,18 +33,18 @@ boost::filesystem::path GetBackupPath(const boost::filesystem::path& pkg_path) {
namespace common_installer {
-boost::filesystem::path GetBackupPathForPackagePath(
- const boost::filesystem::path& pkg_path) {
+std::filesystem::path GetBackupPathForPackagePath(
+ const std::filesystem::path& pkg_path) {
return GetBackupPath(pkg_path);
}
-boost::filesystem::path GetBackupPathForManifestFile(
- const boost::filesystem::path& manifest_path) {
+std::filesystem::path GetBackupPathForManifestFile(
+ const std::filesystem::path& manifest_path) {
return GetBackupPath(manifest_path);
}
-boost::filesystem::path GetBackupPathForIconFile(
- const boost::filesystem::path& icon_path) {
+std::filesystem::path GetBackupPathForIconFile(
+ const std::filesystem::path& icon_path) {
return GetBackupPath(icon_path);
}
@@ -53,21 +52,21 @@ std::string GetIconFileBackupExtension() {
return kBckExtension;
}
-boost::filesystem::path GetBackupPathForZipFile(const bf::path& zip_path) {
+std::filesystem::path GetBackupPathForZipFile(const fs::path& zip_path) {
return GetBackupPath(zip_path);
}
-boost::filesystem::path GetMountLocation(const bf::path& pkg_path) {
+std::filesystem::path GetMountLocation(const fs::path& pkg_path) {
return pkg_path / ".pkg";
}
-boost::filesystem::path GetZipPackageLocation(
- const boost::filesystem::path& pkg_path,
+std::filesystem::path GetZipPackageLocation(
+ const std::filesystem::path& pkg_path,
const std::string& pkgid) {
return pkg_path / kImageDir / pkgid;
}
-boost::filesystem::path GetExternalCardPath() {
+std::filesystem::path GetExternalCardPath() {
char* sdpath = nullptr;
int storage_id = 0;
int ret;
@@ -75,23 +74,23 @@ boost::filesystem::path GetExternalCardPath() {
ret = storage_get_primary_sdcard(&storage_id, &sdpath);
if (ret != STORAGE_ERROR_NONE) {
free(sdpath);
- return bf::path();
+ return fs::path();
}
if (sdpath) {
std::string mount_path(sdpath);
free(sdpath);
- return bf::path(mount_path);
+ return fs::path(mount_path);
}
- return bf::path();
+ return fs::path();
}
-boost::filesystem::path GetExternalTepPath(RequestMode request_mode,
+std::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))
+ fs::path result;
+ fs::path ext_mount_path = GetExternalCardPath();
+ if (fs::is_empty(ext_mount_path))
return result;
result = ext_mount_path / "tep";
if (request_mode == RequestMode::USER)
@@ -99,26 +98,26 @@ boost::filesystem::path GetExternalTepPath(RequestMode request_mode,
return result;
}
-boost::filesystem::path GetInternalTepPath(
- const boost::filesystem::path& pkg_path) {
+std::filesystem::path GetInternalTepPath(
+ const std::filesystem::path& pkg_path) {
return pkg_path / "tep";
}
-boost::filesystem::path GetIconPath(const bf::path& base_path,
+std::filesystem::path GetIconPath(const fs::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;
+ const fs::path& icon_filename,
+ const fs::path& root_path) {
+ std::vector<fs::path> paths;
+ fs::path system_path = base_path / icon_filename;
+ fs::path small_system_path = base_path / "default" / "small" / icon_filename;
+ fs::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))
+ if (fs::exists(path))
return path;
}
@@ -135,7 +134,7 @@ bool IsExtendedStorageAvailable() {
if (state != STORAGE_STATE_MOUNTED)
return true;
bool* available = static_cast<bool*>(user_data);
- if (bf::exists(path))
+ if (fs::exists(path))
*available = true;
// Stop iteration
return false;
diff --git a/src/common/utils/paths.h b/src/common/utils/paths.h
index 996b6a95..6796b7a4 100644
--- a/src/common/utils/paths.h
+++ b/src/common/utils/paths.h
@@ -5,10 +5,9 @@
#ifndef COMMON_UTILS_PATHS_H_
#define COMMON_UTILS_PATHS_H_
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
#include <unistd.h>
+#include <filesystem>
#include <string>
#include "common/utils/request.h"
@@ -23,8 +22,8 @@ namespace common_installer {
*
* \return backup path
*/
-boost::filesystem::path GetBackupPathForPackagePath(
- const boost::filesystem::path& pkg_path);
+std::filesystem::path GetBackupPathForPackagePath(
+ const std::filesystem::path& pkg_path);
/**
* \brief Helper function for getting backup path (used for recovery)
@@ -34,8 +33,8 @@ boost::filesystem::path GetBackupPathForPackagePath(
*
* \return backup path
*/
-boost::filesystem::path GetBackupPathForManifestFile(
- const boost::filesystem::path& manifest_path);
+std::filesystem::path GetBackupPathForManifestFile(
+ const std::filesystem::path& manifest_path);
/**
* \brief Helper function for getting backup path (used for recovery)
@@ -45,8 +44,8 @@ boost::filesystem::path GetBackupPathForManifestFile(
*
* \return backup path
*/
-boost::filesystem::path GetBackupPathForIconFile(
- const boost::filesystem::path& icon_path);
+std::filesystem::path GetBackupPathForIconFile(
+ const std::filesystem::path& icon_path);
/**
* @brief GetIconFileBackupExtension
@@ -62,8 +61,8 @@ std::string GetIconFileBackupExtension();
*
* \return backup path of zip
*/
-boost::filesystem::path GetBackupPathForZipFile(
- const boost::filesystem::path& zip_path);
+std::filesystem::path GetBackupPathForZipFile(
+ const std::filesystem::path& zip_path);
/**
* @brief GetZipPackageLocation
@@ -75,8 +74,8 @@ boost::filesystem::path GetBackupPathForZipFile(
*
* @return full path of zip package location
*/
-boost::filesystem::path GetZipPackageLocation(
- const boost::filesystem::path& pkg_path,
+std::filesystem::path GetZipPackageLocation(
+ const std::filesystem::path& pkg_path,
const std::string& pkgid);
/**
@@ -88,8 +87,8 @@ boost::filesystem::path GetZipPackageLocation(
*
* @return full path of package mount point
*/
-boost::filesystem::path GetMountLocation(
- const boost::filesystem::path& pkg_path);
+std::filesystem::path GetMountLocation(
+ const std::filesystem::path& pkg_path);
/**
* @brief GetExternalCardPath
@@ -97,7 +96,7 @@ boost::filesystem::path GetMountLocation(
*
* @return path
*/
-boost::filesystem::path GetExternalCardPath();
+std::filesystem::path GetExternalCardPath();
/**
* @brief GetExternalTepPath
@@ -107,7 +106,7 @@ boost::filesystem::path GetExternalCardPath();
*
* @return full directory path
*/
-boost::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
+std::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
/**
* @brief GetInternalTepPath
@@ -116,8 +115,8 @@ boost::filesystem::path GetExternalTepPath(RequestMode request_mode, uid_t uid);
*
* @return full directory path
*/
-boost::filesystem::path GetInternalTepPath(
- const boost::filesystem::path& pkg_path);
+std::filesystem::path GetInternalTepPath(
+ const std::filesystem::path& pkg_path);
/**
* @brief GetIconPath
@@ -129,10 +128,10 @@ boost::filesystem::path GetInternalTepPath(
*
* @return full icon path
*/
-boost::filesystem::path GetIconPath(const boost::filesystem::path& base_path,
+std::filesystem::path GetIconPath(const std::filesystem::path& base_path,
const std::string& pkgid,
- const boost::filesystem::path& icon_filename,
- const boost::filesystem::path& root_path);
+ const std::filesystem::path& icon_filename,
+ const std::filesystem::path& root_path);
/**
* @brief IsExtendedStorageAvailable
diff --git a/src/common/utils/request.cc b/src/common/utils/request.cc
index f109908b..85ff2a7a 100644
--- a/src/common/utils/request.cc
+++ b/src/common/utils/request.cc
@@ -12,7 +12,7 @@
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
diff --git a/src/common/utils/request.h b/src/common/utils/request.h
index b9df0e20..09d5a130 100644
--- a/src/common/utils/request.h
+++ b/src/common/utils/request.h
@@ -5,8 +5,6 @@
#ifndef COMMON_UTILS_REQUEST_H_
#define COMMON_UTILS_REQUEST_H_
-#include <boost/filesystem/path.hpp>
-
#include <string>
namespace common_installer {
diff --git a/src/common/utils/user_util.cc b/src/common/utils/user_util.cc
index 7e0b78a0..db8d36c1 100644
--- a/src/common/utils/user_util.cc
+++ b/src/common/utils/user_util.cc
@@ -7,20 +7,19 @@
#include <manifest_parser/utils/logging.h>
#include <tzplatform_config.h>
-#include <boost/filesystem/path.hpp>
-
#include <glib.h>
#include <grp.h>
#include <gum/gum-user.h>
#include <gum/gum-user-service.h>
#include <gum/common/gum-user-types.h>
+#include <filesystem>
#include <vector>
#include "common/utils/file_util.h"
#include "common/utils/glist_range.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
@@ -92,7 +91,7 @@ UserList GetUserList() {
LOG(WARNING) << "No homedir for uid: " << uid;
continue;
}
- list.emplace_back(uid, gid, bf::path(homedir));
+ list.emplace_back(uid, gid, fs::path(homedir));
g_free(homedir);
}
g_strfreev(user_type_strv);
@@ -100,7 +99,7 @@ UserList GetUserList() {
return list;
}
-boost::optional<bool> IsAdminUser(uid_t uid) {
+std::optional<bool> IsAdminUser(uid_t uid) {
GumUser* guser;
int count = 0;
bool is_offline = getuid() == 0;
@@ -130,7 +129,7 @@ boost::optional<bool> IsAdminUser(uid_t uid) {
return is_admin;
}
-boost::optional<gid_t> GetGidByGroupName(const char* groupname) {
+std::optional<gid_t> GetGidByGroupName(const char* groupname) {
char buf[kGRBufSize];
struct group entry;
struct group* ge;
@@ -150,7 +149,7 @@ std::string GetUsernameByUid(uid_t user) {
return pwd.pw_name;
}
-boost::optional<uid_t> GetUidByUserName(const char* username) {
+std::optional<uid_t> GetUidByUserName(const char* username) {
struct passwd pwd;
struct passwd* pwd_result;
char buf[kPWBufSize];
@@ -160,7 +159,7 @@ boost::optional<uid_t> GetUidByUserName(const char* username) {
return pwd.pw_uid;
}
-boost::optional<gid_t> GetGidByUid(uid_t uid) {
+std::optional<gid_t> GetGidByUid(uid_t uid) {
struct passwd pwd;
struct passwd* pwd_result;
char buf[kPWBufSize];
@@ -189,8 +188,8 @@ std::vector<std::string> GetLightUserList(uid_t uid) {
}
tzplatform_set_user(uid);
- bf::path subsession_dir =
- bf::path(tzplatform_getenv(TZ_USER_HOME)) / kSubsessionDir;
+ fs::path subsession_dir =
+ fs::path(tzplatform_getenv(TZ_USER_HOME)) / kSubsessionDir;
tzplatform_reset_user();
// Get subsuession user list by directory name instead of using sessiond API
diff --git a/src/common/utils/user_util.h b/src/common/utils/user_util.h
index 4c456198..c1bf0c9d 100644
--- a/src/common/utils/user_util.h
+++ b/src/common/utils/user_util.h
@@ -5,28 +5,27 @@
#ifndef COMMON_UTILS_USER_UTIL_H_
#define COMMON_UTILS_USER_UTIL_H_
-#include <boost/filesystem/path.hpp>
-#include <boost/optional.hpp>
-
#include <sys/types.h>
-#include <vector>
+#include <filesystem>
+#include <optional>
#include <string>
#include <tuple>
+#include <vector>
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
-typedef std::vector<std::tuple<uid_t, gid_t, bf::path>> UserList;
+typedef std::vector<std::tuple<uid_t, gid_t, fs::path>> UserList;
UserList GetUserList();
-boost::optional<bool> IsAdminUser(uid_t uid);
-boost::optional<gid_t> GetGidByUid(uid_t uid);
+std::optional<bool> IsAdminUser(uid_t uid);
+std::optional<gid_t> GetGidByUid(uid_t uid);
std::string GetGroupNameByGid(gid_t gid);
std::string GetUsernameByUid(uid_t user);
-boost::optional<uid_t> GetUidByUserName(const char* username);
-boost::optional<gid_t> GetGidByGroupName(const char* groupname);
+std::optional<uid_t> GetUidByUserName(const char* username);
+std::optional<gid_t> GetGidByGroupName(const char* groupname);
std::vector<std::string> GetLightUserList(uid_t uid);
} // namespace common_installer
diff --git a/src/common/zip_interface.h b/src/common/zip_interface.h
index 9d458c3c..f4ba9a1b 100644
--- a/src/common/zip_interface.h
+++ b/src/common/zip_interface.h
@@ -5,7 +5,7 @@
#ifndef COMMON_ZIP_INTERFACE_H_
#define COMMON_ZIP_INTERFACE_H_
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
namespace common_installer {
@@ -16,7 +16,7 @@ class IZipInterface {
public:
virtual ~IZipInterface() = default;
- virtual bool MountZip(const boost::filesystem::path& zip_path) = 0;
+ virtual bool MountZip(const std::filesystem::path& zip_path) = 0;
virtual bool UnmountZip() = 0;
};
diff --git a/src/pkg_initdb/CMakeLists.txt b/src/pkg_initdb/CMakeLists.txt
index 83241fe1..9f835674 100644
--- a/src/pkg_initdb/CMakeLists.txt
+++ b/src/pkg_initdb/CMakeLists.txt
@@ -13,7 +13,7 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_PKG_INITDB} PUBLIC "${CMAKE_CURRENT_SOURCE_D
# Target - deps
APPLY_PKG_CONFIG(${TARGET_PKG_INITDB} PUBLIC
PKGMGR_DEPS
- Boost
+
)
# Target - in-package deps
TARGET_LINK_LIBRARIES(${TARGET_PKG_INITDB} PUBLIC ${TARGET_LIBNAME_COMMON})
diff --git a/src/pkg_initdb/init_pkg_db.cc b/src/pkg_initdb/init_pkg_db.cc
index cae88699..c98fa8db 100644
--- a/src/pkg_initdb/init_pkg_db.cc
+++ b/src/pkg_initdb/init_pkg_db.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
#include <tzplatform_config.h>
#include <pkgmgr_parser_db.h>
#include <pkgmgr-info.h>
+#include <filesystem>
#include <iostream>
#include <list>
#include <string>
@@ -20,8 +19,8 @@
#include "common/utils/file_util.h"
#include "common/utils/subprocess.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -66,7 +65,7 @@ bool InitPkgDB::Init(int argc, char *argv[]) {
bool InitPkgDB::RunBackend(const std::string& pkgid,
const std::string& type, bool preload) {
- bf::path backend_path(kBackendDirectoryPath);
+ fs::path backend_path(kBackendDirectoryPath);
backend_path /= type;
ci::Subprocess backend(backend_path.string());
auto params = option_checker_.GetParams(preload, pkgid);
diff --git a/src/pkg_initdb/manifest_loader.cc b/src/pkg_initdb/manifest_loader.cc
index 96ad6a32..c2f7c082 100644
--- a/src/pkg_initdb/manifest_loader.cc
+++ b/src/pkg_initdb/manifest_loader.cc
@@ -2,32 +2,30 @@
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/operations.hpp>
-
#include <tzplatform_config.h>
#include <tpk_manifest_handlers/package_handler.h>
#include <tpk_manifest_handlers/tpk_config_parser.h>
+#include <filesystem>
#include <iostream>
#include <list>
#include <string>
#include "pkg_initdb/manifest_loader.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
ManifestLoader::ManifestLoader(const std::string& path) {
- path_ = bf::path(path);
+ path_ = fs::path(path);
}
std::list<ManifestInfo> ManifestLoader::LoadManifest() {
std::list<ManifestInfo> list;
std::cerr << "Loading manifest files from " << path_ << std::endl;
- for (bf::directory_iterator iter(path_); iter != bf::directory_iterator();
+ for (fs::directory_iterator iter(path_); iter != fs::directory_iterator();
++iter) {
- if (!bf::is_regular_file(iter->path()))
+ if (!fs::is_regular_file(iter->path()))
continue;
tpk::parse::TPKConfigParser parser;
diff --git a/src/pkg_initdb/manifest_loader.h b/src/pkg_initdb/manifest_loader.h
index d2f61358..f9386055 100644
--- a/src/pkg_initdb/manifest_loader.h
+++ b/src/pkg_initdb/manifest_loader.h
@@ -9,7 +9,7 @@
#include <string>
#include <tuple>
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
using ManifestInfo = std::tuple<std::string, std::string, std::string>;
@@ -19,7 +19,7 @@ class ManifestLoader {
std::list<ManifestInfo> LoadManifest();
private:
- bf::path path_;
+ fs::path path_;
};
#endif // PKG_INITDB_MANIFEST_LOADER_H_
diff --git a/src/pkg_initdb/option_checker.cc b/src/pkg_initdb/option_checker.cc
index d94989d3..de572323 100644
--- a/src/pkg_initdb/option_checker.cc
+++ b/src/pkg_initdb/option_checker.cc
@@ -2,12 +2,9 @@
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
-#include <boost/exception/diagnostic_information.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
-
#include <tzplatform_config.h>
+#include <getopt.h>
+#include <unistd.h>
#include <string>
#include <iostream>
@@ -15,51 +12,78 @@
#include "pkg_initdb/option_checker.h"
-namespace bpo = boost::program_options;
-
namespace {
const uid_t kRootUserUid = 0;
const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+const struct option long_opts[] = {
+ { "uid", required_argument, nullptr, 'u' },
+ { "partial-rw", no_argument, nullptr, 'p' },
+ { "ro", no_argument, nullptr, 'o' },
+ { "rw", no_argument, nullptr, 'w' },
+ { "keep-db", no_argument, nullptr, 'k' },
+ { "help", no_argument, nullptr, 'h' },
+ { "recover-db", no_argument, nullptr, 'r' },
+ { 0, 0, 0, 0 }
+};
+const char kHelpMessage[] = R"(Allowed options:
+ -u [ --uid ] arg (=0) user id
+ --partial-rw rw-partition only
+ --ro readonly packages only
+ --rw rw packages only
+ --keep-db keep current database
+ -h [ --help ] display this help message
+ --recover-db register pkg db only
+)";
bool IsGlobalUser(uid_t uid) {
return uid == kRootUserUid || uid == kGlobalUserUid;
}
+void PrintHelp() {
+ std::cerr << kHelpMessage;
+}
+
} // namespace
bool OptionChecker::Init(int argc, char* argv[]) {
- try {
- options_.add_options()
- ("uid,u", bpo::value<int>()->default_value(kRootUserUid), "user id")
- ("partial-rw", "rw-partition only")
- ("ro", "readonly packages only")
- ("rw", "rw packages only")
- ("keep-db", "keep current database")
- ("help,h", "display this help message")
- ("recover-db", "register pkg db only");
- bpo::store(bpo::parse_command_line(argc, argv, options_), opt_map_);
- if (opt_map_.count("help")) {
- std::cerr << options_ << std::endl;
- return false;
+ uid_ = kRootUserUid;
+ while (true) {
+ int opt = getopt_long(argc, argv, "uh", long_opts, nullptr);
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case 'u':
+ if (!optarg) {
+ std::cerr << "The required argument for option '--uid' is missing\n";
+ return false;
+ }
+ uid_ = std::stoi(optarg);
+ break;
+ case 'p':
+ partial_rw_ = true;
+ break;
+ case 'o':
+ ro_only_ = true;
+ break;
+ case 'w':
+ rw_only_ = true;
+ break;
+ case 'k':
+ keep_db_ = true;
+ break;
+ case 'h':
+ PrintHelp();
+ break;
+ case 'r':
+ recover_db_ = true;
+ break;
+ default:
+ std::cerr << "Unrecognised option";
+ PrintHelp();
+ return false;
}
- if (opt_map_.count("partial-rw"))
- partial_rw_ = true;
- if (opt_map_.count("ro"))
- ro_only_ = true;
- if (opt_map_.count("rw"))
- rw_only_ = true;
- if (opt_map_.count("keep-db"))
- keep_db_ = true;
- if (opt_map_.count("recover-db"))
- recover_db_ = true;
- bpo::notify(opt_map_);
- uid_ = opt_map_["uid"].as<int>();
- } catch (...) {
- std::cerr << "Exception occurred: "
- << boost::current_exception_diagnostic_information()
- << std::endl;
- return false;
}
return ValidateOptions();
}
diff --git a/src/pkg_initdb/option_checker.h b/src/pkg_initdb/option_checker.h
index 37d64fdf..dc35e962 100644
--- a/src/pkg_initdb/option_checker.h
+++ b/src/pkg_initdb/option_checker.h
@@ -5,23 +5,14 @@
#ifndef PKG_INITDB_OPTION_CHECKER_H_
#define PKG_INITDB_OPTION_CHECKER_H_
-#include <boost/exception/diagnostic_information.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
-
#include <string>
#include <iostream>
#include <vector>
-namespace bs = boost::system;
-namespace bpo = boost::program_options;
-
class OptionChecker {
public:
OptionChecker() :
- options_("Allowed options"), partial_rw_(false),
+ partial_rw_(false),
ro_only_(false), rw_only_(false), keep_db_(false),
recover_db_(false), uid_(-1) {}
@@ -39,13 +30,11 @@ class OptionChecker {
private:
bool ValidateOptions();
- bpo::options_description options_;
bool partial_rw_;
bool ro_only_;
bool rw_only_;
bool keep_db_;
bool recover_db_;
- bpo::variables_map opt_map_;
uid_t uid_;
};
diff --git a/src/pkg_recovery/CMakeLists.txt b/src/pkg_recovery/CMakeLists.txt
index 8e3ac2f7..90ca0182 100644
--- a/src/pkg_recovery/CMakeLists.txt
+++ b/src/pkg_recovery/CMakeLists.txt
@@ -10,7 +10,6 @@ TARGET_INCLUDE_DIRECTORIES(${TARGET_PKG_RECOVERY} PUBLIC "${CMAKE_CURRENT_SOURCE
# Target - deps
APPLY_PKG_CONFIG(${TARGET_PKG_RECOVERY} PUBLIC
TZPLATFORM_CONFIG_DEPS
- Boost
)
# Target - in-package deps
diff --git a/src/pkg_recovery/pkg_recovery.cc b/src/pkg_recovery/pkg_recovery.cc
index 266748cc..fb186275 100644
--- a/src/pkg_recovery/pkg_recovery.cc
+++ b/src/pkg_recovery/pkg_recovery.cc
@@ -2,10 +2,6 @@
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
-#include <boost/exception/diagnostic_information.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
#include <glib.h>
#include <common/utils/file_util.h>
#include <common/utils/request.h>
@@ -16,12 +12,14 @@
#include <tzplatform_config.h>
#include <array>
+#include <exception>
+#include <filesystem>
#include <regex>
#include <string>
#include <vector>
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
@@ -55,7 +53,7 @@ std::vector<std::string> ParseRecoveryFile(const char* file) {
break;
}
- if (!boost::filesystem::exists(line_data))
+ if (!std::filesystem::exists(line_data))
continue;
arguments.emplace_back(line_data);
@@ -92,7 +90,7 @@ bool PkgRecoveryService::RunBackend(uid_t uid, const char* type,
if (std::string(type) == "unified") {
auto arguments = ParseRecoveryFile(file);
if (!arguments.size())
- return ci::Remove(bf::path(file));
+ return ci::Remove(fs::path(file));
arguments.emplace(arguments.begin(), "-b");
arguments.emplace_back("-u");
@@ -106,7 +104,7 @@ bool PkgRecoveryService::RunBackend(uid_t uid, const char* type,
if (WIFSIGNALED(status) || WEXITSTATUS(status))
return false;
- ci::Remove(bf::path(file));
+ ci::Remove(fs::path(file));
return true;
}
@@ -130,33 +128,33 @@ void PkgRecoveryService::Run() {
}
void PkgRecoveryService::SearchBackupFiles(uid_t uid) {
- const bf::path recovery_dir = ci::GetRootAppPath(false, uid);
+ const fs::path recovery_dir = ci::GetRootAppPath(false, uid);
try {
- for (bf::directory_iterator iter(recovery_dir);
- iter != bf::directory_iterator();
+ for (fs::directory_iterator iter(recovery_dir);
+ iter != fs::directory_iterator();
++iter) {
std::string file = iter->path().filename().string();
std::regex backup_regex(kBackupFilePattern);
std::smatch match;
if (std::regex_search(file, match, backup_regex)) {
- bf::path orig_file(iter->path().parent_path() / iter->path().stem());
- if (bf::exists(orig_file))
- bf::remove(orig_file);
- bf::rename(iter->path(), orig_file);
+ fs::path orig_file(iter->path().parent_path() / iter->path().stem());
+ if (fs::exists(orig_file))
+ fs::remove(orig_file);
+ fs::rename(iter->path(), orig_file);
}
}
- } catch (...) {
+ } catch (const std::exception& e) {
LOG(WARNING) << "Exception occurred: "
- << boost::current_exception_diagnostic_information();
+ << typeid(e).name() << ", " << e.what();
}
}
std::vector<RecoverEntry> PkgRecoveryService::SearchRecoveryFiles(uid_t uid) {
std::vector<RecoverEntry> list;
- const bf::path recovery_dir = ci::GetRootAppPath(false, uid);
+ const fs::path recovery_dir = ci::GetRootAppPath(false, uid);
LOG(INFO) << "RootAppPath: " << recovery_dir;
- for (bf::directory_iterator iter(recovery_dir);
- iter != bf::directory_iterator();
+ for (fs::directory_iterator iter(recovery_dir);
+ iter != fs::directory_iterator();
++iter) {
try {
std::string file = iter->path().filename().string();
@@ -170,9 +168,9 @@ std::vector<RecoverEntry> PkgRecoveryService::SearchRecoveryFiles(uid_t uid) {
else
list.emplace_back(type, iter->path().string());
}
- } catch (...) {
+ } catch (const std::exception& e) {
LOG(WARNING) << "Exception occurred: "
- << boost::current_exception_diagnostic_information();
+ << typeid(e).name() << ", " << e.what();
continue;
}
}
@@ -186,7 +184,7 @@ void PkgRecoveryService::ProcessRecovery(uid_t uid,
for (const auto& entry : entries) {
const char* type = entry.first.c_str();
const char* file = entry.second.c_str();
- if (!bf::exists(file))
+ if (!fs::exists(file))
continue;
if (!RunBackend(uid, type, file))
diff --git a/test/smoke_tests/CMakeLists.txt b/test/smoke_tests/CMakeLists.txt
index 0c7b3d0b..26bed0a8 100644
--- a/test/smoke_tests/CMakeLists.txt
+++ b/test/smoke_tests/CMakeLists.txt
@@ -25,12 +25,10 @@ ADD_EXECUTABLE(${TARGET_PLUGINS_TEST}
INSTALL(DIRECTORY test_samples/ DESTINATION ${SHAREDIR}/${DESTINATION_DIR}/test_samples)
APPLY_PKG_CONFIG(${TARGET_SIGNATURE_TEST} PUBLIC
- Boost
GMOCK_DEPS
)
APPLY_PKG_CONFIG(${TARGET_PLUGINS_TEST} PUBLIC
- Boost
GMOCK_DEPS
)
diff --git a/test/smoke_tests/common/CMakeLists.txt b/test/smoke_tests/common/CMakeLists.txt
index 08711797..b94197ef 100644
--- a/test/smoke_tests/common/CMakeLists.txt
+++ b/test/smoke_tests/common/CMakeLists.txt
@@ -3,7 +3,6 @@ ADD_LIBRARY(${TARGET_SMOKE_UTILS} SHARED
)
APPLY_PKG_CONFIG(${TARGET_SMOKE_UTILS} PUBLIC
- Boost
GMOCK_DEPS
GUM_DEPS
)
diff --git a/test/smoke_tests/common/smoke_utils.cc b/test/smoke_tests/common/smoke_utils.cc
index eb6eb330..027098c4 100644
--- a/test/smoke_tests/common/smoke_utils.cc
+++ b/test/smoke_tests/common/smoke_utils.cc
@@ -4,15 +4,16 @@
#include "smoke_tests/common/smoke_utils.h"
+#include <getopt.h>
#include <gum/gum-user.h>
#include <gum/gum-user-service.h>
#include <gum/common/gum-user-types.h>
#include <manifest_parser/utils/version_number.h>
#include <sys/smack.h>
+#include <unistd.h>
#include <vconf.h>
#include <vconf-internal-keys.h>
-#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
#include <common/installer/app_installer.h>
@@ -23,16 +24,17 @@
#include "pkgmgr_parser_db.h"
+#include <filesystem>
+#include <fstream>
#include <list>
#include <memory>
#include <sstream>
#include <string>
+#include <system_error>
#include <vector>
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
namespace ci = common_installer;
-namespace bo = boost::program_options;
+namespace fs = std::filesystem;
namespace {
@@ -84,39 +86,59 @@ const char kLegacyExtImageDir[] = "legacy_extimage_dir";
const std::string& kDefaultUserIdStr = std::to_string(kDefaultUserUid);
const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
const uid_t kGlobalUserGid = tzplatform_getgid(TZ_SYS_GLOBALAPP_USER);
-extern const bf::path kSdkDirectory = "/home/owner/share/tmp/sdk_tools";
+extern const fs::path kSdkDirectory = "/home/owner/share/tmp/sdk_tools";
ci::RequestMode ParseRequestMode(int argc, char** argv) {
- bo::options_description desc("Available options");
- desc.add_options()
- ("request-mode", bo::value<std::string>(), "set request mode")
- ("global-request,g", "set request mode to global")
- ("user-request,u", "set request mode to user");
-
- bo::variables_map vm;
- bo::store(bo::command_line_parser(argc, argv).
- options(desc).allow_unregistered().run(), vm);
- bo::notify(vm);
-
- if (vm.count("global-request")) {
+ const struct option long_opts[] = {
+ { "request-mode", required_argument, nullptr, 'r' },
+ { "global-request", no_argument, nullptr, 'g' },
+ { "user-request", no_argument, nullptr, 'u' },
+ { 0, 0, 0, 0 }
+ };
+
+ std::string request_mode;
+ bool is_global_request = false;
+ bool is_user_request = false;
+ while (true) {
+ int opt = getopt_long(argc, argv, "gu", long_opts, nullptr);
+ if (opt == -1)
+ break;
+
+ switch (opt) {
+ case 'r':
+ if (optarg)
+ request_mode = optarg;
+ break;
+ case 'g':
+ is_global_request = true;
+ break;
+ case 'u':
+ is_user_request = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (is_global_request) {
std::cout << "Request mode was set to global." << std::endl;
return ci::RequestMode::GLOBAL;
}
- if (vm.count("user-request")) {
+ if (is_user_request) {
std::cout << "Request mode was set to user." << std::endl;
return ci::RequestMode::USER;
}
- if (vm.count("request-mode")) {
- if (vm["request-mode"].as<std::string>() == "global") {
+ if (!request_mode.empty()) {
+ if (request_mode.compare("global") == 0) {
std::cout << "Request mode was set to global." << std::endl;
return ci::RequestMode::GLOBAL;
}
- if (vm["request-mode"].as<std::string>() == "user") {
+ if (request_mode.compare("user") == 0) {
std::cout << "Request mode was set to user." << std::endl;
return ci::RequestMode::USER;
}
std::cout << "Cannot set request mode to "
- << vm["request-mode"].as<std::string>() << std::endl;
+ << request_mode << std::endl;
}
std::cout << "Request mode was set to global." << std::endl;
return ci::RequestMode::GLOBAL;
@@ -147,10 +169,10 @@ static bool DeleteUser(const char* user_name, bool rem_home_dir) {
bool AddTestUser(User* test_user) {
std::cout << "Adding test user: " << kNormalUserName << std::endl;
AddUser(kNormalUserName);
- if (boost::optional<uid_t> uid = ci::GetUidByUserName(kNormalUserName)) {
+ if (std::optional<uid_t> uid = ci::GetUidByUserName(kNormalUserName)) {
test_user->uid = *uid;
std::cout << "User created properly: uid=" << *uid;
- if (boost::optional<gid_t> gid = ci::GetGidByUid(*uid)) {
+ if (std::optional<gid_t> gid = ci::GetGidByUid(*uid)) {
test_user->gid = *gid;
std::cout << " gid=" << *gid;
}
@@ -164,7 +186,7 @@ bool AddTestUser(User* test_user) {
bool DeleteTestUser() {
std::cout << "Deleting test user: " << kNormalUserName << std::endl;
uid_t test_uid;
- if (boost::optional<uid_t> uid = ci::GetUidByUserName(kNormalUserName))
+ if (std::optional<uid_t> uid = ci::GetUidByUserName(kNormalUserName))
test_uid = *uid;
else
return false;
@@ -178,7 +200,7 @@ bool DeleteTestUser() {
return false;
}
-bool TouchFile(const bf::path& path) {
+bool TouchFile(const fs::path& path) {
FILE* f = fopen(path.c_str(), "w+");
if (!f)
return false;
@@ -187,8 +209,8 @@ bool TouchFile(const bf::path& path) {
}
void AddDataFiles(const std::string& pkgid, uid_t uid,
- std::vector<bf::path>* result) {
- std::vector<bf::path> files;
+ std::vector<fs::path>* result) {
+ std::vector<fs::path> files;
files.clear();
if (uid == kGlobalUserUid) {
ci::UserList list = ci::GetUserList();
@@ -211,33 +233,31 @@ void AddDataFiles(const std::string& pkgid, uid_t uid,
}
void RemoveAllRecoveryFiles(const std::string& prefix, uid_t uid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
- if (!bf::exists(root_path))
+ fs::path root_path = ci::GetRootAppPath(false, uid);
+ if (!fs::exists(root_path))
return;
- for (auto& dir_entry : boost::make_iterator_range(
- bf::directory_iterator(root_path), bf::directory_iterator())) {
- if (bf::is_regular_file(dir_entry)) {
+ for (auto& dir_entry : fs::directory_iterator(root_path)) {
+ if (fs::is_regular_file(dir_entry)) {
if (dir_entry.path().string().find(prefix) != std::string::npos) {
- bs::error_code error;
- bf::remove(dir_entry.path(), error);
+ std::error_code error;
+ fs::remove(dir_entry, error);
if (error)
- LOG(ERROR) << "Failed to remove " << dir_entry.path()
+ LOG(ERROR) << "Failed to remove " << dir_entry
<< ": " << error.message();
}
}
}
}
-bf::path FindRecoveryFile(const std::string& prefix, uid_t uid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
- if (!bf::exists(root_path))
+fs::path FindRecoveryFile(const std::string& prefix, uid_t uid) {
+ fs::path root_path = ci::GetRootAppPath(false, uid);
+ if (!fs::exists(root_path))
return {};
- for (auto& dir_entry : boost::make_iterator_range(
- bf::directory_iterator(root_path), bf::directory_iterator())) {
- if (bf::is_regular_file(dir_entry)) {
+ for (auto& dir_entry : fs::directory_iterator(root_path)) {
+ if (fs::is_regular_file(dir_entry)) {
if (dir_entry.path().string().find(prefix) != std::string::npos) {
- return dir_entry.path();
+ return dir_entry;
}
}
}
@@ -245,12 +265,12 @@ bf::path FindRecoveryFile(const std::string& prefix, uid_t uid) {
}
std::unique_ptr<ci::recovery::RecoveryFile> GetRecoverFileInfo(
- const bf::path& recovery_file_path) {
+ const fs::path& recovery_file_path) {
return ci::recovery::RecoveryFile::OpenRecoveryFile(recovery_file_path);
}
-bf::path GetPackageRoot(const std::string& pkgid, uid_t uid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
+fs::path GetPackageRoot(const std::string& pkgid, uid_t uid) {
+ fs::path root_path = ci::GetRootAppPath(false, uid);
return root_path / pkgid;
}
@@ -258,10 +278,10 @@ bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
const std::string& expected,
const TestParameters& params) {
- bf::path file_path = ci::GetRootAppPath(params.is_readonly,
+ fs::path file_path = ci::GetRootAppPath(params.is_readonly,
params.test_user.uid);
file_path = file_path / pkgid / relative;
- if (!bf::exists(file_path)) {
+ if (!fs::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
return false;
}
@@ -280,23 +300,23 @@ bool ValidateFileContentInPackage(const std::string& pkgid,
}
static bool ValidatePackageRWFS(const std::string& pkgid, uid_t uid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
- bf::path package_path = root_path / pkgid;
- bf::path data_path = package_path / rwDirectories[DATA];
- bf::path cache_path = package_path / rwDirectories[CACHE];
- bf::path shared_data_path = package_path / rwDirectories[SHARED_DATA];
+ fs::path root_path = ci::GetRootAppPath(false, uid);
+ fs::path package_path = root_path / pkgid;
+ fs::path data_path = package_path / rwDirectories[DATA];
+ fs::path cache_path = package_path / rwDirectories[CACHE];
+ fs::path shared_data_path = package_path / rwDirectories[SHARED_DATA];
- EXTENDED_ASSERT_TRUE(bf::exists(data_path));
- EXTENDED_ASSERT_TRUE(bf::exists(cache_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(data_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(cache_path));
struct stat stats;
stat(data_path.c_str(), &stats);
// gid of RW dirs should be system_share
- boost::optional<gid_t> system_share =
+ std::optional<gid_t> system_share =
ci::GetGidByGroupName(kSystemShareGroupName);
EXTENDED_ASSERT_EQ(uid, stats.st_uid);
EXTENDED_ASSERT_EQ(*system_share, stats.st_gid);
- if (bf::exists(shared_data_path)) {
+ if (fs::exists(shared_data_path)) {
stat(shared_data_path.c_str(), &stats);
EXTENDED_ASSERT_EQ(uid, stats.st_uid);
EXTENDED_ASSERT_EQ(*system_share, stats.st_gid);
@@ -310,54 +330,54 @@ static bool ValidatePackageRWFS(const std::string& pkgid, uid_t uid) {
static bool ValidatePackageFS(const std::string& pkgid, const Apps& apps,
const TestParameters& params) {
- bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ fs::path root_path = ci::GetRootAppPath(params.is_readonly,
params.test_user.uid);
- bf::path package_path = root_path / pkgid;
- bf::path shared_path = package_path / "shared";
- EXTENDED_ASSERT_TRUE(bf::exists(root_path));
- EXTENDED_ASSERT_TRUE(bf::exists(package_path));
- EXTENDED_ASSERT_TRUE(bf::exists(shared_path));
-
- bf::path manifest_path =
- bf::path(getUserManifestPath(params.test_user.uid,
+ fs::path package_path = root_path / pkgid;
+ fs::path shared_path = package_path / "shared";
+ EXTENDED_ASSERT_TRUE(fs::exists(root_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(package_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(shared_path));
+
+ fs::path manifest_path =
+ fs::path(getUserManifestPath(params.test_user.uid,
params.is_readonly)) / (pkgid + ".xml");
- EXTENDED_ASSERT_TRUE(bf::exists(manifest_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(manifest_path));
for (auto& app : apps) {
const std::string &exec = app.second;
- bf::path binary_path = package_path / "bin" / exec;
- EXTENDED_ASSERT_TRUE(bf::exists(binary_path));
+ fs::path binary_path = package_path / "bin" / exec;
+ EXTENDED_ASSERT_TRUE(fs::exists(binary_path));
}
if (params.pkg_type == PackageType::WGT ||
params.pkg_type == PackageType::HYBRID) {
- bf::path widget_root_path = package_path / "res" / "wgt";
- bf::path config_path = widget_root_path / "config.xml";
- EXTENDED_ASSERT_TRUE(bf::exists(widget_root_path));
- EXTENDED_ASSERT_TRUE(bf::exists(config_path));
+ fs::path widget_root_path = package_path / "res" / "wgt";
+ fs::path config_path = widget_root_path / "config.xml";
+ EXTENDED_ASSERT_TRUE(fs::exists(widget_root_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(config_path));
- bf::path private_tmp_path = package_path / "tmp";
- EXTENDED_ASSERT_TRUE(bf::exists(private_tmp_path));
+ fs::path private_tmp_path = package_path / "tmp";
+ EXTENDED_ASSERT_TRUE(fs::exists(private_tmp_path));
}
// backups should not exist
- bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
- bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- EXTENDED_ASSERT_FALSE(bf::exists(package_backup));
- EXTENDED_ASSERT_FALSE(bf::exists(manifest_backup));
-
- for (bf::recursive_directory_iterator iter(package_path);
- iter != bf::recursive_directory_iterator(); ++iter) {
- if (bf::is_symlink(symlink_status(iter->path())))
+ fs::path package_backup = ci::GetBackupPathForPackagePath(package_path);
+ fs::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
+ EXTENDED_ASSERT_FALSE(fs::exists(package_backup));
+ EXTENDED_ASSERT_FALSE(fs::exists(manifest_backup));
+
+ for (fs::recursive_directory_iterator iter(package_path);
+ iter != fs::recursive_directory_iterator(); ++iter) {
+ if (fs::is_symlink(symlink_status(iter->path())))
continue;
bool is_rw_dir = false;
for (const auto rw_dir : rwDirectories) {
- bf::path rw_dir_path = rw_dir;
+ fs::path rw_dir_path = rw_dir;
is_rw_dir |= ci::MakeRelativePath(iter->path(), package_path)
== rw_dir_path;
}
if (is_rw_dir || iter->path().filename() == ".mmc") {
- iter.no_push();
+ iter.disable_recursion_pending();
continue;
}
struct stat stats;
@@ -389,13 +409,13 @@ bool ValidateDataFiles(const std::string& pkgid, uid_t uid) {
ci::UserList list = ci::GetUserList();
for (auto l : list) {
auto pkg_path = GetPackageRoot(pkgid, std::get<0>(l));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
+ EXTENDED_ASSERT_TRUE(fs::exists(pkg_path / "data" / "file1.txt"));
+ EXTENDED_ASSERT_TRUE(fs::exists(pkg_path / "data" / "file2.txt"));
}
} else {
auto pkg_path = GetPackageRoot(pkgid, uid);
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
+ EXTENDED_ASSERT_TRUE(fs::exists(pkg_path / "data" / "file1.txt"));
+ EXTENDED_ASSERT_TRUE(fs::exists(pkg_path / "data" / "file2.txt"));
}
return true;
}
@@ -404,12 +424,12 @@ static bool ValidateExternalPackageFS(const std::string& pkgid,
const Apps& apps, const TestParameters& params) {
EXTENDED_ASSERT_EQ(app2ext_usr_enable_external_pkg(pkgid.c_str(),
params.test_user.uid), 0);
- bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
+ fs::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
if (params.pkg_type == PackageType::TPK) {
- EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / ".mmc" / "bin"));
- EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / ".mmc" / "lib"));
+ EXTENDED_ASSERT_TRUE(fs::exists(root_path / pkgid / ".mmc" / "bin"));
+ EXTENDED_ASSERT_TRUE(fs::exists(root_path / pkgid / ".mmc" / "lib"));
}
- EXTENDED_ASSERT_TRUE(bf::exists(root_path / pkgid / ".mmc" / "res"));
+ EXTENDED_ASSERT_TRUE(fs::exists(root_path / pkgid / ".mmc" / "res"));
EXTENDED_ASSERT_TRUE(ValidatePackageFS(pkgid, apps, params));
EXTENDED_ASSERT_EQ(app2ext_usr_disable_external_pkg(pkgid.c_str(),
params.test_user.uid), 0);
@@ -420,8 +440,8 @@ bool ValidateExternalPackage(const std::string& pkgid, const Apps& apps,
const TestParameters& params) {
ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid, true);
std::string storage = pkg_query.StorageForPkgId();
- bf::path ext_mount_path = ci::GetExternalCardPath();
- if (bf::is_empty(ext_mount_path)) {
+ fs::path ext_mount_path = ci::GetExternalCardPath();
+ if (fs::is_empty(ext_mount_path)) {
LOG(INFO) << "Sdcard not exists!";
EXTENDED_ASSERT_EQ(storage, "installed_internal");
} else {
@@ -435,9 +455,9 @@ bool ValidateExtendedPackage(const std::string& pkgid, const Apps& apps,
const TestParameters& params) {
ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid, true);
std::string storage = pkg_query.StorageForPkgId();
- bf::path extended_path =
- bf::path(ci::GetExtendedRootAppPath(params.test_user.uid)) / pkgid;
- if (!bf::exists(extended_path)) {
+ fs::path extended_path =
+ fs::path(ci::GetExtendedRootAppPath(params.test_user.uid)) / pkgid;
+ if (!fs::exists(extended_path)) {
LOG(INFO) << "Extended storage not exists!";
EXTENDED_ASSERT_EQ(storage, "installed_internal");
} else {
@@ -449,20 +469,20 @@ bool ValidateExtendedPackage(const std::string& pkgid, const Apps& apps,
static bool PackageCheckCleanup(const std::string& pkgid,
const TestParameters& params) {
- bf::path root_path = ci::GetRootAppPath(params.is_readonly,
+ fs::path root_path = ci::GetRootAppPath(params.is_readonly,
params.test_user.uid);
- bf::path package_path = root_path / pkgid;
- EXTENDED_ASSERT_FALSE(bf::exists(package_path));
+ fs::path package_path = root_path / pkgid;
+ EXTENDED_ASSERT_FALSE(fs::exists(package_path));
- bf::path manifest_path = bf::path(getUserManifestPath(params.test_user.uid,
+ fs::path manifest_path = fs::path(getUserManifestPath(params.test_user.uid,
params.is_readonly)) / (pkgid + ".xml");
- EXTENDED_ASSERT_FALSE(bf::exists(manifest_path));
+ EXTENDED_ASSERT_FALSE(fs::exists(manifest_path));
// backups should not exist
- bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
- bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- EXTENDED_ASSERT_FALSE(bf::exists(package_backup));
- EXTENDED_ASSERT_FALSE(bf::exists(manifest_backup));
+ fs::path package_backup = ci::GetBackupPathForPackagePath(package_path);
+ fs::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
+ EXTENDED_ASSERT_FALSE(fs::exists(package_backup));
+ EXTENDED_ASSERT_FALSE(fs::exists(manifest_backup));
return true;
}
@@ -473,24 +493,24 @@ bool CheckPackageNonExistance(const std::string& pkgid,
ci::GetRequestMode(params.test_user.uid)));
EXTENDED_ASSERT_TRUE(PackageCheckCleanup(pkgid, params));
if (params.test_user.uid == kGlobalUserUid) {
- bf::path skel_path(kSkelDir);
- EXTENDED_ASSERT_FALSE(bf::exists(skel_path / pkgid));
- EXTENDED_ASSERT_FALSE(bf::exists(skel_path / kShared / pkgid));
- EXTENDED_ASSERT_FALSE(bf::exists(skel_path / kSharedTmp / pkgid));
+ fs::path skel_path(kSkelDir);
+ EXTENDED_ASSERT_FALSE(fs::exists(skel_path / pkgid));
+ EXTENDED_ASSERT_FALSE(fs::exists(skel_path / kShared / pkgid));
+ EXTENDED_ASSERT_FALSE(fs::exists(skel_path / kSharedTmp / pkgid));
ci::UserList list = ci::GetUserList();
for (auto& l : list) {
- bf::path root_path = ci::GetRootAppPath(false, std::get<0>(l));
- EXTENDED_ASSERT_FALSE(bf::exists(root_path / kShared / pkgid));
- EXTENDED_ASSERT_FALSE(bf::exists(root_path / kSharedTmp / pkgid));
- bf::path package_path = root_path / pkgid;
- EXTENDED_ASSERT_FALSE(bf::exists(package_path));
+ fs::path root_path = ci::GetRootAppPath(false, std::get<0>(l));
+ EXTENDED_ASSERT_FALSE(fs::exists(root_path / kShared / pkgid));
+ EXTENDED_ASSERT_FALSE(fs::exists(root_path / kSharedTmp / pkgid));
+ fs::path package_path = root_path / pkgid;
+ EXTENDED_ASSERT_FALSE(fs::exists(package_path));
}
}
return true;
}
bool CheckAvailableExternalPath() {
- bf::path ext_mount_path = ci::GetExternalCardPath();
+ fs::path ext_mount_path = ci::GetExternalCardPath();
LOG(DEBUG) << "ext_mount_path :" << ext_mount_path;
if (ext_mount_path.empty()) {
LOG(ERROR) << "Sdcard not exists!";
@@ -500,10 +520,10 @@ bool CheckAvailableExternalPath() {
}
bool CheckAvailableExtendedPath() {
- bf::path extended_path = bf::path(tzplatform_getenv(TZ_SYS_EXTENDEDSD));
+ fs::path extended_path = fs::path(tzplatform_getenv(TZ_SYS_EXTENDEDSD));
LOG(DEBUG) << "extended_path :" << extended_path;
// TODO(jeremy.jang): It should be checked by libstorage API.
- if (!bf::exists(extended_path)) {
+ if (!fs::exists(extended_path)) {
LOG(ERROR) << "Extended storage not exists!";
return false;
}
@@ -519,24 +539,24 @@ bool CheckPackageReadonlyNonExistance(const std::string& pkgid,
return true;
}
-static bool CheckSharedDataExistanceForPath(const bf::path& apps_rw,
+static bool CheckSharedDataExistanceForPath(const fs::path& apps_rw,
const std::string& pkgid) {
- bf::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
- bf::path shared = apps_rw / kShared / pkgid / kData;
- bf::path shared_tmp = apps_rw / kSharedTmp / pkgid;
- EXTENDED_ASSERT_TRUE(bf::exists(shared_data_path));
- EXTENDED_ASSERT_TRUE(bf::exists(shared));
- EXTENDED_ASSERT_TRUE(bf::exists(shared_tmp));
+ fs::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
+ fs::path shared = apps_rw / kShared / pkgid / kData;
+ fs::path shared_tmp = apps_rw / kSharedTmp / pkgid;
+ EXTENDED_ASSERT_TRUE(fs::exists(shared_data_path));
+ EXTENDED_ASSERT_TRUE(fs::exists(shared));
+ EXTENDED_ASSERT_TRUE(fs::exists(shared_tmp));
return true;
}
-static bool CheckSharedDataPermissions(const bf::path& apps_rw,
+static bool CheckSharedDataPermissions(const fs::path& apps_rw,
const std::string& pkgid, uid_t uid) {
- bf::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
- bf::path shared = apps_rw / kShared / pkgid / kData;
- bf::path shared_tmp = apps_rw / kSharedTmp / pkgid;
+ fs::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
+ fs::path shared = apps_rw / kShared / pkgid / kData;
+ fs::path shared_tmp = apps_rw / kSharedTmp / pkgid;
// gid of RW dirs should be system_share
- boost::optional<gid_t> system_share =
+ std::optional<gid_t> system_share =
ci::GetGidByGroupName(kSystemShareGroupName);
struct stat stats;
stat(shared_data_path.c_str(), &stats);
@@ -554,17 +574,17 @@ static bool CheckSharedDataPermissions(const bf::path& apps_rw,
bool CheckSharedDataExistance(const std::string& pkgid,
const TestParameters& params) {
if (params.test_user.uid == kGlobalUserUid) {
- bf::path skel_path(kSkelDir);
+ fs::path skel_path(kSkelDir);
EXTENDED_ASSERT_TRUE(CheckSharedDataExistanceForPath(kSkelDir, pkgid));
ci::UserList list = ci::GetUserList();
for (auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
EXTENDED_ASSERT_TRUE(CheckSharedDataExistanceForPath(apps_rw, pkgid));
EXTENDED_ASSERT_TRUE(CheckSharedDataPermissions(apps_rw, pkgid, uid));
}
} else {
- bf::path apps_rw = ci::GetRootAppPath(false, params.test_user.uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, params.test_user.uid);
EXTENDED_ASSERT_TRUE(CheckSharedDataExistanceForPath(apps_rw, pkgid));
EXTENDED_ASSERT_TRUE(
CheckSharedDataPermissions(apps_rw, pkgid, params.test_user.uid));
@@ -572,44 +592,44 @@ bool CheckSharedDataExistance(const std::string& pkgid,
return true;
}
-static bool CheckSharedDataNonExistanceForPath(const bf::path& apps_rw,
+static bool CheckSharedDataNonExistanceForPath(const fs::path& apps_rw,
const std::string pkgid) {
- bf::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
- bf::path shared = apps_rw / kShared / pkgid / kData;
- bf::path shared_tmp = apps_rw / kSharedTmp / pkgid;
- EXTENDED_ASSERT_FALSE(bf::exists(shared_data_path));
- EXTENDED_ASSERT_FALSE(bf::exists(shared));
- EXTENDED_ASSERT_FALSE(bf::exists(shared_tmp));
+ fs::path shared_data_path = apps_rw / pkgid / rwDirectories[SHARED_DATA];
+ fs::path shared = apps_rw / kShared / pkgid / kData;
+ fs::path shared_tmp = apps_rw / kSharedTmp / pkgid;
+ EXTENDED_ASSERT_FALSE(fs::exists(shared_data_path));
+ EXTENDED_ASSERT_FALSE(fs::exists(shared));
+ EXTENDED_ASSERT_FALSE(fs::exists(shared_tmp));
return true;
}
bool CheckSharedDataNonExistance(const std::string& pkgid,
const TestParameters& params) {
if (params.test_user.uid == kGlobalUserUid) {
- bf::path skel_path(kSkelDir);
+ fs::path skel_path(kSkelDir);
EXTENDED_ASSERT_TRUE(
CheckSharedDataNonExistanceForPath(skel_path, pkgid));
ci::UserList list = ci::GetUserList();
for (auto& l : list) {
uid_t uid = std::get<0>(l);
- bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, uid);
EXTENDED_ASSERT_TRUE(CheckSharedDataNonExistanceForPath(apps_rw, pkgid));
}
} else {
- bf::path apps_rw = ci::GetRootAppPath(false, params.test_user.uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, params.test_user.uid);
EXTENDED_ASSERT_TRUE(CheckSharedDataNonExistanceForPath(apps_rw, pkgid));
}
return true;
}
-void FileInfoCollector::AddPath(const bf::path& path) {
+void FileInfoCollector::AddPath(const fs::path& path) {
root_paths_.emplace_back(path);
}
bool FileInfoCollector::CollectFileInfoRecursive() {
for (const auto& path : root_paths_) {
- if (!bf::exists(path) && !bf::is_symlink(path))
+ if (!fs::exists(path) && !fs::is_symlink(path))
continue;
if (!GetFileListTraversal(path))
@@ -619,9 +639,9 @@ bool FileInfoCollector::CollectFileInfoRecursive() {
return true;
}
-bool FileInfoCollector::GetFileListTraversal(const bf::path& cur) {
- bs::error_code error;
- bf::file_status file_status = bf::symlink_status(cur, error);
+bool FileInfoCollector::GetFileListTraversal(const fs::path& cur) {
+ std::error_code error;
+ fs::file_status file_status = fs::symlink_status(cur, error);
if (error) {
LOG(ERROR) << "Fail to get symlink_status, " << error.message();
return false;
@@ -650,11 +670,11 @@ bool FileInfoCollector::GetFileListTraversal(const bf::path& cur) {
FileInfos_.emplace_back(cur, file_status.type(),
file_status.permissions(), owner, group, access_label);
- if (!bf::is_directory(cur) || bf::is_symlink(cur))
+ if (!fs::is_directory(cur) || fs::is_symlink(cur))
return true;
- for (bf::directory_iterator file(cur);
- file != bf::directory_iterator();
+ for (fs::directory_iterator file(cur);
+ file != fs::directory_iterator();
++file) {
if (!GetFileListTraversal(file->path())) {
FileInfos_.clear();
@@ -665,7 +685,7 @@ bool FileInfoCollector::GetFileListTraversal(const bf::path& cur) {
return true;
}
-bool FileInfoCollector::FileInfoToFile(const bf::path& path) const {
+bool FileInfoCollector::FileInfoToFile(const fs::path& path) const {
std::ofstream out(path.string());
for (const auto& info : FileInfos_)
@@ -677,8 +697,8 @@ bool FileInfoCollector::FileInfoToFile(const bf::path& path) const {
}
bool FileInfoCollector::Init() {
- bf::path skel_apps_rw = bf::path(kSkelDir);
- bf::path root_path =
+ fs::path skel_apps_rw = fs::path(kSkelDir);
+ fs::path root_path =
ci::GetRootAppPath(params_.is_readonly, params_.test_user.uid);
AddPath(root_path / pkgid_);
@@ -688,7 +708,7 @@ bool FileInfoCollector::Init() {
// per user dir
ci::UserList list = ci::GetUserList();
for (auto l : list) {
- bf::path apps_rw = std::get<2>(l) / "apps_rw";
+ fs::path apps_rw = std::get<2>(l) / "apps_rw";
AddPath(apps_rw / pkgid_);
AddPath(apps_rw / kShared / pkgid_);
AddPath(apps_rw / kSharedTmp / pkgid_);
@@ -709,7 +729,7 @@ bool FileInfoCollector::Init() {
return true;
}
-bool FileInfoCollector::LoadFromFile(const bf::path& path) {
+bool FileInfoCollector::LoadFromFile(const fs::path& path) {
std::ifstream readFile;
readFile.open(path.c_str());
@@ -722,7 +742,7 @@ bool FileInfoCollector::LoadFromFile(const bf::path& path) {
while (std::getline(readFile, line)) {
std::istringstream iss(line);
- bf::path p;
+ fs::path p;
int file_permission;
int file_type;
std::string owner;
@@ -732,8 +752,8 @@ bool FileInfoCollector::LoadFromFile(const bf::path& path) {
iss >> p >> file_type >> std::oct >> file_permission
>> owner >> group >> access_label;
- FileInfos_.emplace_back(p, bf::file_type(file_type),
- bf::perms(file_permission), owner, group, access_label);
+ FileInfos_.emplace_back(p, fs::file_type(file_type),
+ fs::perms(file_permission), owner, group, access_label);
}
readFile.close();
@@ -741,22 +761,65 @@ bool FileInfoCollector::LoadFromFile(const bf::path& path) {
return true;
}
+std::string FileInfoCollector::FileTypeToString(const fs::file_type type) const {
+ switch (type) {
+ case fs::file_type::none:
+ return "none";
+ case fs::file_type::not_found:
+ return "not_found";
+ case fs::file_type::regular:
+ return "regular";
+ case fs::file_type::directory:
+ return "directory";
+ case fs::file_type::symlink:
+ return "symlink";
+ case fs::file_type::block:
+ return "block";
+ case fs::file_type::character:
+ return "character";
+ case fs::file_type::fifo:
+ return "fifo";
+ case fs::file_type::socket:
+ return "socket";
+ case fs::file_type::unknown:
+ return "unknown";
+ default:
+ return "implementation-defined";
+ }
+}
+
+int FileInfoCollector::PermsToInt(const fs::perms p) const {
+ int perm_int = 0;
+
+ perm_int |= fs::perms::none == (p & fs::perms::owner_read) ? 0 : 0400;
+ perm_int |= fs::perms::none == (p & fs::perms::owner_write) ? 0 : 0200;
+ perm_int |= fs::perms::none == (p & fs::perms::owner_exec) ? 0 : 0100;
+ perm_int |= fs::perms::none == (p & fs::perms::group_read) ? 0 : 040;
+ perm_int |= fs::perms::none == (p & fs::perms::group_write) ? 0 : 020;
+ perm_int |= fs::perms::none == (p & fs::perms::group_exec) ? 0 : 010;
+ perm_int |= fs::perms::none == (p & fs::perms::others_read) ? 0 : 04;
+ perm_int |= fs::perms::none == (p & fs::perms::others_write) ? 0 : 02;
+ perm_int |= fs::perms::none == (p & fs::perms::others_exec) ? 0 : 01;
+
+ return perm_int;
+}
+
std::string FileInfoCollector::FileInfoToString(
const FileInfo& file_info) const {
- bf::path p = std::get<0>(file_info);
- bf::file_type file_type = std::get<1>(file_info);
+ fs::path p = std::get<0>(file_info);
+ fs::file_type file_type = std::get<1>(file_info);
std::string file_permission;
std::string owner = std::get<3>(file_info);
std::string group = std::get<4>(file_info);
std::string access_label = std::get<5>(file_info);
std::stringstream ss;
- ss << std::oct << std::get<2>(file_info);
+ ss << std::oct << PermsToInt(std::get<2>(file_info));
ss >> file_permission;
std::string res;
res += p.string();
res += " ";
- res += std::to_string(file_type);
+ res += FileTypeToString(file_type);
res += " ";
res += file_permission;
res += " ";
@@ -770,7 +833,7 @@ std::string FileInfoCollector::FileInfoToString(
}
bool FileInfoCollector::IsEqual(const FileInfoCollector& that,
- const std::vector<bf::path>* exception_list) const {
+ const std::vector<fs::path>* exception_list) const {
auto it_l = FileInfos_.begin();
auto it_r = that.FileInfos_.begin();
bool res = true;
@@ -782,8 +845,8 @@ bool FileInfoCollector::IsEqual(const FileInfoCollector& that,
continue;
}
- bf::path path_l = std::get<0>(*it_l);
- bf::path path_r = std::get<0>(*it_r);
+ fs::path path_l = std::get<0>(*it_l);
+ fs::path path_r = std::get<0>(*it_r);
if (exception_list && path_l == path_r &&
std::find(exception_list->begin(), exception_list->end(), path_r)
!= exception_list->end()) {
@@ -992,12 +1055,12 @@ BackendInterface::CommandResult BackendInterface::CallBackendWithRunner(
}
BackendInterface::CommandResult BackendInterface::Install(
- const std::vector<bf::path>& paths) const {
+ const std::vector<fs::path>& paths) const {
std::vector<const char*> argv;
argv.emplace_back("");
argv.emplace_back("-i");
for (const auto& p : paths)
- argv.emplace_back(p.string().c_str());
+ argv.emplace_back(p.c_str());
return CallBackendWithRunner(argv.size(), argv.data());
}
@@ -1012,7 +1075,7 @@ BackendInterface::CommandResult BackendInterface::Uninstall(
}
BackendInterface::CommandResult BackendInterface::InstallSuccess(
- const std::vector<bf::path>& paths) const {
+ const std::vector<fs::path>& paths) const {
RequestResult tmp_mode = mode_;
RequestResult &original_mode = const_cast<RequestResult&>(mode_);
original_mode = RequestResult::NORMAL;
@@ -1052,19 +1115,19 @@ BackendInterface::CommandResult BackendInterface::CallBackend(int argc,
}
BackendInterface::CommandResult BackendInterface::Install(
- const bf::path& path) const {
+ const fs::path& path) const {
const char* argv[] = {"", "-i", path.c_str(), "-u", uid_str_.c_str()};
return CallBackend(SIZEOFARRAY(argv), argv);
}
BackendInterface::CommandResult BackendInterface::InstallPreload(
- const bf::path& path) const {
+ const fs::path& path) const {
const char* argv[] = {"", "-i", path.c_str(), "--preload"};
return CallBackend(SIZEOFARRAY(argv), argv);
}
BackendInterface::CommandResult BackendInterface::InstallWithStorage(
- const bf::path& path, StorageType type) const {
+ const fs::path& path, StorageType type) const {
int default_storage = 0;
int storage = 0;
switch (type) {
@@ -1106,20 +1169,20 @@ BackendInterface::CommandResult BackendInterface::InstallWithStorage(
BackendInterface::CommandResult BackendInterface::MigrateLegacyExternalImage(
const std::string& pkgid,
- const bf::path& path,
- const bf::path& legacy_path) const {
+ const fs::path& path,
+ const fs::path& legacy_path) const {
if (InstallWithStorage(path, StorageType::EXTERNAL) !=
BackendInterface::CommandResult::OK) {
LOG(ERROR) << "Failed to install application. Cannot perform Migrate";
return BackendInterface::CommandResult::ERROR;
}
- bf::path ext_mount_path = ci::GetExternalCardPath();
- if (bf::is_empty(ext_mount_path)) {
+ fs::path ext_mount_path = ci::GetExternalCardPath();
+ if (fs::is_empty(ext_mount_path)) {
LOG(ERROR) << "Sdcard not exists!";
return BackendInterface::CommandResult::ERROR;
}
- bf::path app2sd_path = ext_mount_path / "app2sd";
+ fs::path app2sd_path = ext_mount_path / "app2sd";
char* image_name = app2ext_usr_getname_image(pkgid.c_str(),
kGlobalUserUid);
@@ -1127,38 +1190,38 @@ BackendInterface::CommandResult BackendInterface::MigrateLegacyExternalImage(
LOG(ERROR) << "Failed to get external image name";
return BackendInterface::CommandResult::ERROR;
}
- bf::path org_image = app2sd_path / image_name;
+ fs::path org_image = app2sd_path / image_name;
free(image_name);
- bs::error_code error;
- bf::remove(org_image, error);
+ std::error_code error;
+ fs::remove(org_image, error);
if (error) {
LOG(ERROR) << "Failed to remove org image";
return BackendInterface::CommandResult::ERROR;
}
- bf::path db_path = tzplatform_getenv(TZ_SYS_DB);
- bf::path app2sd_db = db_path / ".app2sd.db";
- bf::path app2sd_db_journal = db_path / ".app2sd.db-journal";
- bf::remove(app2sd_db, error);
+ fs::path db_path = tzplatform_getenv(TZ_SYS_DB);
+ fs::path app2sd_db = db_path / ".app2sd.db";
+ fs::path app2sd_db_journal = db_path / ".app2sd.db-journal";
+ fs::remove(app2sd_db, error);
if (error) {
LOG(ERROR) << "Failed to remove app2sd db";
return BackendInterface::CommandResult::ERROR;
}
- bf::remove(app2sd_db_journal, error);
+ fs::remove(app2sd_db_journal, error);
if (error) {
LOG(ERROR) << "Failed to remove app2sd journal db";
return BackendInterface::CommandResult::ERROR;
}
- bf::path app2sd_migrate_db = legacy_path / kMigrateTestDBName;
+ fs::path app2sd_migrate_db = legacy_path / kMigrateTestDBName;
if (!ci::CopyFile(app2sd_migrate_db, app2sd_db)) {
LOG(ERROR) << "Failed to copy test db";
return BackendInterface::CommandResult::ERROR;
}
- bf::path legacy_src = legacy_path / pkgid;
- bf::path legacy_dst = app2sd_path / pkgid;
+ fs::path legacy_src = legacy_path / pkgid;
+ fs::path legacy_dst = app2sd_path / pkgid;
if (!ci::CopyFile(legacy_src, legacy_dst)) {
LOG(ERROR) << "Failed to copy test image";
return BackendInterface::CommandResult::ERROR;
@@ -1169,7 +1232,7 @@ BackendInterface::CommandResult BackendInterface::MigrateLegacyExternalImage(
}
BackendInterface::CommandResult BackendInterface::RDSUpdate(
- const bf::path& path,
+ const fs::path& path,
const std::string& pkgid) const {
RequestResult tmp_mode = mode_;
RequestResult &original_mode = const_cast<RequestResult&>(mode_);
@@ -1197,7 +1260,7 @@ BackendInterface::CommandResult BackendInterface::DisablePackage(
}
BackendInterface::CommandResult BackendInterface::Recover(
- const bf::path& recovery_file) const {
+ const fs::path& recovery_file) const {
const char* argv[] = {"", "-b", recovery_file.c_str(), "-u",
uid_str_.c_str()};
return CallBackend(SIZEOFARRAY(argv), argv);
@@ -1223,7 +1286,7 @@ BackendInterface::CommandResult BackendInterface::UninstallPreload(
}
BackendInterface::CommandResult BackendInterface::InstallSuccess(
- const bf::path& path) const {
+ const fs::path& path) const {
RequestResult tmp_mode = mode_;
RequestResult &original_mode = const_cast<RequestResult&>(mode_);
original_mode = RequestResult::NORMAL;
@@ -1236,7 +1299,7 @@ BackendInterface::CommandResult BackendInterface::InstallSuccess(
}
BackendInterface::CommandResult BackendInterface::InstallPreloadSuccess(
- const bf::path& path) const {
+ const fs::path& path) const {
RequestResult tmp_mode = mode_;
RequestResult &original_mode = const_cast<RequestResult&>(mode_);
original_mode = RequestResult::NORMAL;
@@ -1249,13 +1312,13 @@ BackendInterface::CommandResult BackendInterface::InstallPreloadSuccess(
}
BackendInterface::CommandResult BackendInterface::MountInstall(
- const bf::path& path) const {
+ const fs::path& path) const {
const char* argv[] = {"", "-w", path.c_str(), "-u", uid_str_.c_str()};
return CallBackend(SIZEOFARRAY(argv), argv);
}
BackendInterface::CommandResult BackendInterface::MountInstallSuccess(
- const bf::path& path) const {
+ const fs::path& path) const {
RequestResult tmp_mode = mode_;
RequestResult &original_mode = const_cast<RequestResult&>(mode_);
original_mode = RequestResult::NORMAL;
@@ -1267,8 +1330,8 @@ BackendInterface::CommandResult BackendInterface::MountInstallSuccess(
return BackendInterface::CommandResult::OK;
}
-static boost::filesystem::path GetTrashPath(
- const boost::filesystem::path& path) {
+static std::filesystem::path GetTrashPath(
+ const std::filesystem::path& path) {
return path.string() + ".trash";
}
@@ -1309,21 +1372,21 @@ BackendInterface::SubProcessResult BackendInterface::RunSubprocessAndKill(
}
BackendInterface::SubProcessResult BackendInterface::InstallWithSubprocess(
- const bf::path& path) const {
+ const fs::path& path) const {
std::vector<std::string> args =
{ "-i", path.string(), "-u", uid_str_ };
return RunSubprocess(args);
}
BackendInterface::SubProcessResult BackendInterface::MountInstallWithSubprocess(
- const bf::path& path) const {
+ const fs::path& path) const {
std::vector<std::string> args =
{ "-w", path.string(), "-u", uid_str_ };
return RunSubprocess(args);
}
BackendInterface::SubProcessResult BackendInterface::RecoverWithSubprocess(
- const bf::path& path) const {
+ const fs::path& path) const {
std::vector<std::string> args =
{ "-b", path.string(), "-u", uid_str_ };
return RunSubprocess(args);
@@ -1337,14 +1400,14 @@ BackendInterface::SubProcessResult BackendInterface::UninstallWithSubprocess(
BackendInterface::SubProcessResult
BackendInterface::InstallPreloadWithSubprocess(
- const boost::filesystem::path& path) const {
+ const std::filesystem::path& path) const {
std::vector<std::string> args = { "", "-i", path.string(), "--preload" };
return RunSubprocess(args);
}
BackendInterface::SubProcessResult
BackendInterface::InstallWithSubprocessAndKill(
- const bf::path& path, useconds_t delay) const {
+ const fs::path& path, useconds_t delay) const {
std::vector<std::string> args =
{ "-i", path.string(), "-u", uid_str_ };
return RunSubprocessAndKill(args, delay);
@@ -1352,7 +1415,7 @@ BackendInterface::SubProcessResult
BackendInterface::SubProcessResult
BackendInterface::MountInstallWithSubprocessAndKill(
- const bf::path& path, useconds_t delay) const {
+ const fs::path& path, useconds_t delay) const {
std::vector<std::string> args =
{ "-w", path.string(), "-u", uid_str_ };
return RunSubprocessAndKill(args, delay);
@@ -1367,10 +1430,10 @@ BackendInterface::SubProcessResult
}
BackendInterface::SubProcessResult BackendInterface::InstallPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const {
+ const std::vector<fs::path>& paths) const {
std::vector<std::string> args;
args.emplace_back("-i");
- for (const bf::path& p : paths)
+ for (const fs::path& p : paths)
args.emplace_back(p.string());
args.emplace_back("-u");
args.emplace_back(uid_str_);
@@ -1379,10 +1442,10 @@ BackendInterface::SubProcessResult BackendInterface::InstallPkgsWithSubprocess(
BackendInterface::SubProcessResult
BackendInterface::MountInstallPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const {
+ const std::vector<fs::path>& paths) const {
std::vector<std::string> args;
args.emplace_back("-w");
- for (const bf::path& p : paths)
+ for (const fs::path& p : paths)
args.emplace_back(p.string());
args.emplace_back("-u");
args.emplace_back(uid_str_);
@@ -1390,10 +1453,10 @@ BackendInterface::SubProcessResult
}
BackendInterface::SubProcessResult BackendInterface::RecoverPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const {
+ const std::vector<fs::path>& paths) const {
std::vector<std::string> args;
args.emplace_back("-b");
- for (const bf::path& p : paths)
+ for (const fs::path& p : paths)
args.emplace_back(p.string());
args.emplace_back("-u");
args.emplace_back(uid_str_);
@@ -1413,10 +1476,10 @@ BackendInterface::SubProcessResult
BackendInterface::SubProcessResult
BackendInterface::InstallPkgsWithSubprocessAndKill(
- const std::vector<bf::path>& paths, useconds_t delay) const {
+ const std::vector<fs::path>& paths, useconds_t delay) const {
std::vector<std::string> args;
args.emplace_back("-i");
- for (const bf::path& p : paths)
+ for (const fs::path& p : paths)
args.emplace_back(p.string());
args.emplace_back("-u");
args.emplace_back(uid_str_);
@@ -1425,19 +1488,19 @@ BackendInterface::SubProcessResult
BackendInterface::SubProcessResult
BackendInterface::MountInstallPkgsWithSubprocessAndKill(
- const std::vector<bf::path>& paths, useconds_t delay) const {
+ const std::vector<fs::path>& paths, useconds_t delay) const {
std::vector<std::string> args;
args.emplace_back("-w");
- for (const bf::path& p : paths)
+ for (const fs::path& p : paths)
args.emplace_back(p.string());
args.emplace_back("-u");
args.emplace_back(uid_str_);
return RunSubprocessAndKill(args, delay);
}
-bool CopySmackAccess(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
- if (!bf::exists(src) && !bf::is_symlink(src)) {
+bool CopySmackAccess(const std::filesystem::path& src,
+ const std::filesystem::path& dst) {
+ if (!fs::exists(src) && !fs::is_symlink(src)) {
LOG(ERROR) << "Failed to copy smack access label";
return false;
}
@@ -1459,9 +1522,9 @@ bool CopySmackAccess(const boost::filesystem::path& src,
return true;
}
-bool CopySmackExec(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
- if (!bf::exists(src) && !bf::is_symlink(src)) {
+bool CopySmackExec(const std::filesystem::path& src,
+ const std::filesystem::path& dst) {
+ if (!fs::exists(src) && !fs::is_symlink(src)) {
LOG(ERROR) << "Failed to copy smack exec label";
return false;
}
@@ -1483,9 +1546,9 @@ bool CopySmackExec(const boost::filesystem::path& src,
return true;
}
-bool CopySmackMmap(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
- if (!bf::exists(src) && !bf::is_symlink(src)) {
+bool CopySmackMmap(const std::filesystem::path& src,
+ const std::filesystem::path& dst) {
+ if (!fs::exists(src) && !fs::is_symlink(src)) {
LOG(ERROR) << "Failed to copy smack mmap label";
return false;
}
@@ -1507,9 +1570,9 @@ bool CopySmackMmap(const boost::filesystem::path& src,
return true;
}
-bool CopySmackTransmute(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
- if (!bf::exists(src)) {
+bool CopySmackTransmute(const std::filesystem::path& src,
+ const std::filesystem::path& dst) {
+ if (!fs::exists(src)) {
LOG(ERROR) << "Failed to copy smack tranmute label";
return false;
}
@@ -1537,40 +1600,40 @@ bool CopySmackTransmute(const boost::filesystem::path& src,
return true;
}
-bool CopySmackLabels(const boost::filesystem::path& src,
- const boost::filesystem::path& dst) {
+bool CopySmackLabels(const std::filesystem::path& src,
+ const std::filesystem::path& dst) {
if (!CopySmackAccess(src, dst))
return false;
if (!CopySmackExec(src, dst))
return false;
if (!CopySmackMmap(src, dst))
return false;
- if (!bf::is_symlink(src) && bf::is_directory(src)) {
+ if (!fs::is_symlink(src) && fs::is_directory(src)) {
if (!CopySmackTransmute(src, dst))
return false;
}
return true;
}
-bool CopyAndRemoveWithSmack(const bf::path& src, const bf::path& dst) {
- bs::error_code error;
- if (bf::exists(dst)) {
+bool CopyAndRemoveWithSmack(const fs::path& src, const fs::path& dst) {
+ std::error_code error;
+ if (fs::exists(dst)) {
try {
- bf::remove_all(dst, error);
+ fs::remove_all(dst, error);
} catch (...) {
std::cout << "Exception occurred during remove [" << dst.string()
<< "], and skip this file"<< std::endl;
}
if (error) {
- if (!bf::is_directory(dst)) {
+ if (!fs::is_directory(dst)) {
LOG(ERROR) << "remove_all fail";
return false;
}
}
}
try {
- if (bf::is_symlink(src)) {
- bf::copy_symlink(src, dst, error);
+ if (fs::is_symlink(src)) {
+ fs::copy_symlink(src, dst, error);
if (error) {
LOG(ERROR) << "Failed to copy symlink: " << src << ", "
<< error.message();
@@ -1581,9 +1644,9 @@ bool CopyAndRemoveWithSmack(const bf::path& src, const bf::path& dst) {
<< "] to [" << dst.string() << "] fail";
return false;
}
- } else if (bf::is_directory(src)) {
- if (!bf::exists(dst)) {
- bf::create_directories(dst, error);
+ } else if (fs::is_directory(src)) {
+ if (!fs::exists(dst)) {
+ fs::create_directories(dst, error);
if (error) {
LOG(ERROR) << "create directories fail";
return false;
@@ -1596,25 +1659,25 @@ bool CopyAndRemoveWithSmack(const bf::path& src, const bf::path& dst) {
}
}
bool success = true;
- for (bf::directory_iterator file(src);
- file != bf::directory_iterator();
+ for (fs::directory_iterator file(src);
+ file != fs::directory_iterator();
++file) {
- bf::path current(file->path());
- bf::path target = dst / current.filename();
+ fs::path current(file->path());
+ fs::path target = dst / current.filename();
success &= CopyAndRemoveWithSmack(current, target);
}
- bf::remove_all(src);
+ fs::remove_all(src);
if (!success)
return false;
} else {
- bf::copy_file(src, dst);
+ fs::copy_file(src, dst);
ci::CopyOwnershipAndPermissions(src, dst);
if (!CopySmackLabels(src, dst)) {
LOG(ERROR) << "copy smack label from [" << src.string()
<< "] to [" << dst.string() << "] fail";
return false;
}
- bf::remove_all(src);
+ fs::remove_all(src);
}
} catch (...) {
std::cout << "Exception occurred during copy [" << src.string()
@@ -1625,11 +1688,11 @@ bool CopyAndRemoveWithSmack(const bf::path& src, const bf::path& dst) {
return true;
}
-bool BackupPathCopyAndRemove(const bf::path& path) {
- if (!bf::exists(path))
+bool BackupPathCopyAndRemove(const fs::path& path) {
+ if (!fs::exists(path))
return true;
- bf::path backup_path = path.string() + ".bck";
+ fs::path backup_path = path.string() + ".bck";
std::cout << "Backup path: " << path << " to " << backup_path << std::endl;
if (!CopyAndRemoveWithSmack(path, backup_path)) {
LOG(ERROR) << "Failed to setup test environment. Does some previous"
@@ -1640,22 +1703,22 @@ bool BackupPathCopyAndRemove(const bf::path& path) {
return true;
}
-bool BackupPath(const bf::path& path) {
- bf::path trash_path = GetTrashPath(path);
- if (bf::exists(trash_path)) {
+bool BackupPath(const fs::path& path) {
+ fs::path trash_path = GetTrashPath(path);
+ if (fs::exists(trash_path)) {
LOG(ERROR) << trash_path << " exists. Please remove "
<< trash_path << " manually!";
return false;
}
- bf::path backup_path = path.string() + ".bck";
+ fs::path backup_path = path.string() + ".bck";
std::cout << "Backup path: " << path << " to " << backup_path << std::endl;
- bs::error_code error;
- bf::remove_all(backup_path, error);
+ std::error_code error;
+ fs::remove_all(backup_path, error);
if (error)
LOG(ERROR) << "Remove failed: " << backup_path
<< " (" << error.message() << ")";
- if (bf::exists(path)) {
- bf::rename(path, backup_path, error);
+ if (fs::exists(path)) {
+ fs::rename(path, backup_path, error);
if (error) {
LOG(ERROR) << "Failed to setup test environment. Does some previous"
<< " test crashed? Path: "
@@ -1663,8 +1726,8 @@ bool BackupPath(const bf::path& path) {
return false;
}
assert(!error);
- if (bf::is_directory(backup_path))
- bf::create_directory(path);
+ if (fs::is_directory(backup_path))
+ fs::create_directory(path);
}
return true;
}
@@ -1674,9 +1737,9 @@ void CreateDatabase() {
pkgmgr_parser_create_and_initialize_db(getuid());
}
-bool RestorePathCopyAndRemove(const bf::path& path) {
- bf::path backup_path = path.string() + ".bck";
- if (!bf::exists(backup_path))
+bool RestorePathCopyAndRemove(const fs::path& path) {
+ fs::path backup_path = path.string() + ".bck";
+ if (!fs::exists(backup_path))
return true;
std::cout << "Restore path: " << path << " from " << backup_path << std::endl;
@@ -1687,24 +1750,24 @@ bool RestorePathCopyAndRemove(const bf::path& path) {
return true;
}
-bool RestorePath(const bf::path& path) {
- bf::path backup_path = path.string() + ".bck";
+bool RestorePath(const fs::path& path) {
+ fs::path backup_path = path.string() + ".bck";
std::cout << "Restore path: " << path << " from " << backup_path << std::endl;
- bs::error_code error;
- bf::remove_all(path, error);
+ std::error_code error;
+ fs::remove_all(path, error);
if (error) {
- bf::path trash_path = GetTrashPath(path);
+ fs::path trash_path = GetTrashPath(path);
LOG(ERROR) << "Remove failed: " << path << " (" << error.message() << ")";
std::cout << "Moving " << path << " to " << trash_path << std::endl;
- bf::rename(path, trash_path, error);
+ fs::rename(path, trash_path, error);
if (error)
LOG(ERROR) << "Failed to move " << path << " to " << trash_path
<< " (" << error.message() << ")";
else
LOG(ERROR) << trash_path << " should be removed manually!";
}
- if (bf::exists(backup_path)) {
- bf::rename(backup_path, path, error);
+ if (fs::exists(backup_path)) {
+ fs::rename(backup_path, path, error);
if (error) {
LOG(ERROR) << "Failed to restore backup path: " << backup_path
<< " (" << error.message() << ")";
@@ -1714,13 +1777,13 @@ bool RestorePath(const bf::path& path) {
return true;
}
-std::vector<bf::path> SetupBackupDirectories(uid_t test_uid) {
- std::vector<bf::path> entries;
- bf::path db_dir = bf::path(tzplatform_getenv(TZ_SYS_DB));
+std::vector<fs::path> SetupBackupDirectories(uid_t test_uid) {
+ std::vector<fs::path> entries;
+ fs::path db_dir = fs::path(tzplatform_getenv(TZ_SYS_DB));
if (test_uid != kGlobalUserUid)
db_dir = db_dir / "user" / std::to_string(test_uid);
for (auto e : kDBEntries) {
- bf::path path = db_dir / e;
+ fs::path path = db_dir / e;
entries.emplace_back(path);
}
@@ -1735,30 +1798,29 @@ std::vector<bf::path> SetupBackupDirectories(uid_t test_uid) {
entries.emplace_back(kGlobalManifestDir);
ci::UserList list = ci::GetUserList();
for (auto l : list) {
- bf::path apps = std::get<2>(l) / "apps_rw";
+ fs::path apps = std::get<2>(l) / "apps_rw";
entries.emplace_back(apps);
}
} else {
tzplatform_set_user(test_uid);
- bf::path approot = tzplatform_getenv(TZ_USER_APPROOT);
+ fs::path approot = tzplatform_getenv(TZ_USER_APPROOT);
tzplatform_reset_user();
entries.emplace_back(approot);
}
- bf::path apps_rw = ci::GetRootAppPath(false, test_uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, test_uid);
entries.emplace_back(apps_rw);
entries.emplace_back(kSdkDirectory);
return entries;
}
-void UninstallAllAppsInDirectory(bf::path dir, bool is_preload,
+void UninstallAllAppsInDirectory(fs::path dir, bool is_preload,
BackendInterface* backend) {
- if (bf::exists(dir)) {
- for (auto& dir_entry : boost::make_iterator_range(
- bf::directory_iterator(dir), bf::directory_iterator())) {
+ if (fs::exists(dir)) {
+ for (auto& dir_entry : fs::directory_iterator(dir)) {
if (dir_entry.path().string().find("smoke") != std::string::npos &&
- bf::is_directory(dir_entry)) {
+ fs::is_directory(dir_entry)) {
std::string package = dir_entry.path().filename().string();
std::regex pkg_regex("smoke[a-zA-Z0-9]{5,}");
if (std::regex_match(package, pkg_regex)) {
@@ -1783,10 +1845,10 @@ void UninstallAllAppsInDirectory(bf::path dir, bool is_preload,
void UninstallAllSmokeApps(ci::RequestMode request_mode, uid_t test_uid,
BackendInterface *backend) {
std::cout << "Uninstalling all smoke apps" << std::endl;
- bf::path apps_rw = ci::GetRootAppPath(false, test_uid);
+ fs::path apps_rw = ci::GetRootAppPath(false, test_uid);
UninstallAllAppsInDirectory(apps_rw, false, backend);
if (getuid() == 0 && request_mode == ci::RequestMode::GLOBAL) {
- bf::path root_path = kPreloadApps;
+ fs::path root_path = kPreloadApps;
UninstallAllAppsInDirectory(root_path, true, backend);
}
}
@@ -1808,12 +1870,12 @@ int GetAppInstalledTime(const char* appid, uid_t uid) {
}
bool CompareFileInfo(const std::string& pkgid, const TestParameters& params,
- const bf::path& file) {
+ const fs::path& file) {
FileInfoCollector result(pkgid, params);
if (!result.Init())
return false;
- bf::path p = "/tmp";
+ fs::path p = "/tmp";
p /= file.filename();
if (!result.FileInfoToFile(p))
diff --git a/test/smoke_tests/common/smoke_utils.h b/test/smoke_tests/common/smoke_utils.h
index 9e1369b5..10fa019d 100644
--- a/test/smoke_tests/common/smoke_utils.h
+++ b/test/smoke_tests/common/smoke_utils.h
@@ -10,12 +10,6 @@
#include <unistd.h>
#include <tzplatform_config.h>
-#include <boost/filesystem/operations.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/format.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
-
#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
@@ -34,6 +28,7 @@
#include <array>
#include <cstdio>
#include <cstdlib>
+#include <filesystem>
#include <memory>
#include <regex>
#include <string>
@@ -66,8 +61,8 @@
namespace smoke_test {
-extern const bf::path kSmokePackagesDirectory;
-extern const bf::path kSdkDirectory;
+extern const fs::path kSmokePackagesDirectory;
+extern const fs::path kSdkDirectory;
extern const uid_t kGlobalUserUid;
extern const uid_t kGlobalUserGid;
extern const char kLegacyExtImageDir[];
@@ -90,7 +85,7 @@ enum class StorageType {
class ScopedTzipInterface {
public:
explicit ScopedTzipInterface(const std::string& pkgid, uid_t test_user)
- : pkg_path_(boost::filesystem::path(
+ : pkg_path_(std::filesystem::path(
common_installer::GetRootAppPath(false, test_user)) / pkgid),
interface_(common_installer::GetMountLocation(pkg_path_)),
mounted_(true) {
@@ -110,7 +105,7 @@ class ScopedTzipInterface {
}
private:
- boost::filesystem::path pkg_path_;
+ std::filesystem::path pkg_path_;
common_installer::TzipInterface interface_;
bool mounted_;
};
@@ -154,26 +149,28 @@ struct TestParameters {
class FileInfoCollector {
public:
- using FileInfo = std::tuple<bf::path, bf::file_type, bf::perms,
+ using FileInfo = std::tuple<fs::path, fs::file_type, fs::perms,
std::string, std::string, std::string>;
FileInfoCollector(std::string pkgid, TestParameters params) :
pkgid_(pkgid), params_(params) {}
- bool FileInfoToFile(const bf::path& path) const;
+ bool FileInfoToFile(const fs::path& path) const;
bool Init();
bool IsEqual(const FileInfoCollector& collector,
- const std::vector<bf::path>* exception_list = nullptr) const;
- bool LoadFromFile(const bf::path& path);
+ const std::vector<fs::path>* exception_list = nullptr) const;
+ bool LoadFromFile(const fs::path& path);
private:
- void AddPath(const bf::path& path);
+ void AddPath(const fs::path& path);
bool CollectFileInfoRecursive();
- bool GetFileListTraversal(const bf::path& cur);
+ bool GetFileListTraversal(const fs::path& cur);
+ std::string FileTypeToString(fs::file_type type) const;
+ int PermsToInt(fs::perms perms) const;
std::string FileInfoToString(const FileInfo& file_info) const;
std::string pkgid_;
TestParameters params_;
- std::vector<bf::path> root_paths_;
+ std::vector<fs::path> root_paths_;
std::vector<FileInfo> FileInfos_;
};
@@ -203,10 +200,10 @@ struct PackageAttributes {
common_installer::RequestMode ParseRequestMode(int argc, char** argv);
-bool TouchFile(const boost::filesystem::path& path);
+bool TouchFile(const std::filesystem::path& path);
void AddDataFiles(const std::string& pkgid, uid_t uid,
- std::vector<bf::path>* result = nullptr);
+ std::vector<fs::path>* result = nullptr);
bool AddTestUser(User* test_user);
@@ -214,12 +211,12 @@ bool DeleteTestUser();
void RemoveAllRecoveryFiles(const std::string& prefix, uid_t uid);
-boost::filesystem::path FindRecoveryFile(const std::string& prefix, uid_t uid);
+std::filesystem::path FindRecoveryFile(const std::string& prefix, uid_t uid);
-boost::filesystem::path GetPackageRoot(const std::string& pkgid, uid_t uid);
+std::filesystem::path GetPackageRoot(const std::string& pkgid, uid_t uid);
std::unique_ptr<common_installer::recovery::RecoveryFile> GetRecoverFileInfo(
- const bf::path& recovery_file_path);
+ const fs::path& recovery_file_path);
bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
@@ -248,7 +245,7 @@ bool CheckSharedDataExistance(const std::string& pkgid,
bool CheckSharedDataNonExistance(const std::string& pkgid,
const TestParameters& params);
-bool TouchFile(const boost::filesystem::path& path);
+bool TouchFile(const std::filesystem::path& path);
class SmokeInstallerFactory {
public:
@@ -285,15 +282,15 @@ class BackendInterface {
void CrashAfterEachStep(std::vector<std::string>* args,
std::function<bool(int iter)> validator,
PackageType type) const;
- CommandResult Install(const std::vector<bf::path>& paths) const;
- CommandResult InstallSuccess(const std::vector<bf::path>& paths) const;
- CommandResult Install(const boost::filesystem::path& path) const;
- CommandResult InstallPreload(const boost::filesystem::path& path) const;
- CommandResult InstallWithStorage(const boost::filesystem::path& path,
+ CommandResult Install(const std::vector<fs::path>& paths) const;
+ CommandResult InstallSuccess(const std::vector<fs::path>& paths) const;
+ CommandResult Install(const std::filesystem::path& path) const;
+ CommandResult InstallPreload(const std::filesystem::path& path) const;
+ CommandResult InstallWithStorage(const std::filesystem::path& path,
StorageType type = StorageType::INTERNAL) const;
- CommandResult InstallSuccess(const bf::path& path) const;
+ CommandResult InstallSuccess(const fs::path& path) const;
CommandResult InstallPreloadSuccess(
- const boost::filesystem::path& path) const;
+ const std::filesystem::path& path) const;
CommandResult Uninstall(const std::vector<std::string>& pkgids) const;
CommandResult Uninstall(const std::string& pkgid) const;
@@ -302,43 +299,43 @@ class BackendInterface {
CommandResult EnablePackage(const std::string& pkgid) const;
CommandResult DisablePackage(const std::string& pkgid) const;
- CommandResult MountInstall(const boost::filesystem::path& path) const;
- CommandResult MountInstallSuccess(const bf::path& path) const;
+ CommandResult MountInstall(const std::filesystem::path& path) const;
+ CommandResult MountInstallSuccess(const fs::path& path) const;
CommandResult ManifestDirectInstall(const std::string& pkgid) const;
CommandResult MigrateLegacyExternalImage(const std::string& pkgid,
- const boost::filesystem::path& path,
- const boost::filesystem::path& legacy_path) const;
+ const std::filesystem::path& path,
+ const std::filesystem::path& legacy_path) const;
- CommandResult RDSUpdate(const boost::filesystem::path& path,
+ CommandResult RDSUpdate(const std::filesystem::path& path,
const std::string& pkgid) const;
- CommandResult Recover(const boost::filesystem::path& recovery_file) const;
+ CommandResult Recover(const std::filesystem::path& recovery_file) const;
- SubProcessResult InstallWithSubprocess(const bf::path& path) const;
- SubProcessResult MountInstallWithSubprocess(const bf::path& path) const;
- SubProcessResult RecoverWithSubprocess(const bf::path& path) const;
+ SubProcessResult InstallWithSubprocess(const fs::path& path) const;
+ SubProcessResult MountInstallWithSubprocess(const fs::path& path) const;
+ SubProcessResult RecoverWithSubprocess(const fs::path& path) const;
SubProcessResult UninstallWithSubprocess(const std::string& pkgid) const;
SubProcessResult InstallPreloadWithSubprocess(
- const boost::filesystem::path& path) const;
+ const std::filesystem::path& path) const;
SubProcessResult InstallWithSubprocessAndKill(
- const bf::path& path, useconds_t delay) const;
+ const fs::path& path, useconds_t delay) const;
SubProcessResult MountInstallWithSubprocessAndKill(
- const bf::path& path, useconds_t delay) const;
+ const fs::path& path, useconds_t delay) const;
SubProcessResult UninstallWithSubprocessAndKill(
const std::string& pkgid, useconds_t delay) const;
SubProcessResult InstallPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const;
+ const std::vector<fs::path>& paths) const;
SubProcessResult MountInstallPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const;
+ const std::vector<fs::path>& paths) const;
SubProcessResult RecoverPkgsWithSubprocess(
- const std::vector<bf::path>& paths) const;
+ const std::vector<fs::path>& paths) const;
SubProcessResult UninstallPkgsWithSubprocess(
const std::vector<std::string>& pkgids) const;
SubProcessResult InstallPkgsWithSubprocessAndKill(
- const std::vector<bf::path>& paths, useconds_t delay) const;
+ const std::vector<fs::path>& paths, useconds_t delay) const;
SubProcessResult MountInstallPkgsWithSubprocessAndKill(
- const std::vector<bf::path>& paths, useconds_t delay) const;
+ const std::vector<fs::path>& paths, useconds_t delay) const;
protected:
CommandResult CallBackend(int argc, const char* argv[]) const;
@@ -372,19 +369,19 @@ bool CheckAvailableExternalPath();
bool CheckAvailableExtendedPath();
-bool BackupPathCopyAndRemove(const boost::filesystem::path& path);
+bool BackupPathCopyAndRemove(const std::filesystem::path& path);
-bool BackupPath(const boost::filesystem::path& path);
+bool BackupPath(const std::filesystem::path& path);
void CreateDatabase();
-bool RestorePathCopyAndRemove(const boost::filesystem::path& path);
+bool RestorePathCopyAndRemove(const std::filesystem::path& path);
-bool RestorePath(const boost::filesystem::path& path);
+bool RestorePath(const std::filesystem::path& path);
-std::vector<boost::filesystem::path> SetupBackupDirectories(uid_t test_uid);
+std::vector<std::filesystem::path> SetupBackupDirectories(uid_t test_uid);
-void UninstallAllAppsInDirectory(boost::filesystem::path dir, bool is_preload,
+void UninstallAllAppsInDirectory(std::filesystem::path dir, bool is_preload,
BackendInterface* backend);
void UninstallAllSmokeApps(common_installer::RequestMode request_mode,
@@ -429,7 +426,7 @@ class StepCrash : public common_installer::Step {
};
bool CompareFileInfo(const std::string& pkgid, const TestParameters& params,
- const bf::path& file);
+ const fs::path& file);
} // namespace smoke_test
diff --git a/test/smoke_tests/libs/test_assessor.cc b/test/smoke_tests/libs/test_assessor.cc
index cec05246..81723f47 100644
--- a/test/smoke_tests/libs/test_assessor.cc
+++ b/test/smoke_tests/libs/test_assessor.cc
@@ -17,7 +17,7 @@ void TestAssessor::ClearResults() {
}
void TestAssessor::AddResult(const ResultLine& result,
- const boost::optional<std::string>& error) {
+ const std::optional<std::string>& error) {
results.insert(std::make_pair(result, error));
}
diff --git a/test/smoke_tests/libs/test_assessor.h b/test/smoke_tests/libs/test_assessor.h
index 5bf9437c..24fb7968 100644
--- a/test/smoke_tests/libs/test_assessor.h
+++ b/test/smoke_tests/libs/test_assessor.h
@@ -5,9 +5,8 @@
#ifndef TEST_SMOKE_TESTS_LIBS_TEST_ASSESSOR_H_
#define TEST_SMOKE_TESTS_LIBS_TEST_ASSESSOR_H_
-#include <boost/optional/optional.hpp>
-
#include <map>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -28,11 +27,11 @@ class TestAssessor : public common_installer::Singleton<TestAssessor> {
public:
using ResultLine = std::tuple<std::string, Plugin::ActionType,
Plugin::ProcessType>;
- using ResultStore = std::map<ResultLine, boost::optional<std::string>>;
+ using ResultStore = std::map<ResultLine, std::optional<std::string>>;
void ClearResults();
void AddResult(const ResultLine& result,
- const boost::optional<std::string> &error);
+ const std::optional<std::string> &error);
const ResultStore& GetResults() const;
private:
diff --git a/test/smoke_tests/libs/test_category_fail_plugin.cc b/test/smoke_tests/libs/test_category_fail_plugin.cc
index fccc8631..d626481c 100644
--- a/test/smoke_tests/libs/test_category_fail_plugin.cc
+++ b/test/smoke_tests/libs/test_category_fail_plugin.cc
@@ -2,16 +2,10 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
#include <pkgmgr_parser.h>
#include <glib/glist.h>
-#include <cstring>
-#include <string>
-#include <tuple>
-
#include "common/plugins/plugin.h"
#include "common/utils/glist_range.h"
diff --git a/test/smoke_tests/libs/test_category_plugin.cc b/test/smoke_tests/libs/test_category_plugin.cc
index de97b772..b2124fe2 100644
--- a/test/smoke_tests/libs/test_category_plugin.cc
+++ b/test/smoke_tests/libs/test_category_plugin.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
#include <pkgmgr_parser.h>
#include <glib/glist.h>
#include <cstring>
+#include <optional>
#include <string>
#include <tuple>
@@ -20,7 +19,7 @@ namespace ci = common_installer;
namespace {
-boost::optional<std::string> CheckArgs(
+std::optional<std::string> CheckArgs(
const char* pkgid,
const char* appid,
GList* categories) {
diff --git a/test/smoke_tests/libs/test_metadata_fail_plugin.cc b/test/smoke_tests/libs/test_metadata_fail_plugin.cc
index 1e86f295..e554f33d 100644
--- a/test/smoke_tests/libs/test_metadata_fail_plugin.cc
+++ b/test/smoke_tests/libs/test_metadata_fail_plugin.cc
@@ -2,18 +2,7 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
-#include <pkgmgr_parser.h>
-
-#include <glib/glist.h>
-
-#include <cstring>
-#include <string>
-#include <tuple>
-
-#include "common/plugins/plugin.h"
-#include "common/utils/glist_range.h"
+#include <glib.h>
extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(
const char*, const char*, GList*) {
diff --git a/test/smoke_tests/libs/test_metadata_plugin.cc b/test/smoke_tests/libs/test_metadata_plugin.cc
index 1c178d86..edfe4f35 100644
--- a/test/smoke_tests/libs/test_metadata_plugin.cc
+++ b/test/smoke_tests/libs/test_metadata_plugin.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
#include <pkgmgr_parser.h>
#include <glib/glist.h>
#include <cstring>
+#include <optional>
#include <string>
#include <tuple>
@@ -20,7 +19,7 @@ namespace ci = common_installer;
namespace {
-boost::optional<std::string> CheckArgs(
+std::optional<std::string> CheckArgs(
const char* pkgid,
const char* appid,
GList* metadata) {
diff --git a/test/smoke_tests/libs/test_tag_fail_plugin.cc b/test/smoke_tests/libs/test_tag_fail_plugin.cc
index 399a2876..fcfe2086 100644
--- a/test/smoke_tests/libs/test_tag_fail_plugin.cc
+++ b/test/smoke_tests/libs/test_tag_fail_plugin.cc
@@ -2,13 +2,7 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
-#include <cstring>
-#include <string>
-#include <tuple>
-
-#include "common/plugins/plugin.h"
+#include <libxml2/libxml/tree.h>
extern "C" int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char*) {
return 0;
diff --git a/test/smoke_tests/libs/test_tag_plugin.cc b/test/smoke_tests/libs/test_tag_plugin.cc
index 653609b5..43f06ee3 100644
--- a/test/smoke_tests/libs/test_tag_plugin.cc
+++ b/test/smoke_tests/libs/test_tag_plugin.cc
@@ -2,9 +2,8 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/optional/optional.hpp>
-
#include <cstring>
+#include <optional>
#include <string>
#include <tuple>
@@ -15,7 +14,7 @@ namespace ci = common_installer;
namespace {
-boost::optional<std::string> CheckArgs(const char* pkgid) {
+std::optional<std::string> CheckArgs(const char* pkgid) {
if (!pkgid)
return std::string("Package id is null for tag plugin");
if (strcmp(pkgid, ci::kTestPackageId) != 0)
@@ -24,7 +23,7 @@ boost::optional<std::string> CheckArgs(const char* pkgid) {
return {};
}
-boost::optional<std::string> CheckArgs(xmlDocPtr doc, const char* pkgid) {
+std::optional<std::string> CheckArgs(xmlDocPtr doc, const char* pkgid) {
if (!doc)
return std::string("XML doc pointer is null for tag plugin");
return CheckArgs(pkgid);
diff --git a/test/smoke_tests/plugins_smoketest.cc b/test/smoke_tests/plugins_smoketest.cc
index 956baaa7..293d2fb0 100644
--- a/test/smoke_tests/plugins_smoketest.cc
+++ b/test/smoke_tests/plugins_smoketest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
#include <memory>
@@ -17,26 +16,26 @@
#include "common/plugins/plugin_xml_parser.h"
#include "smoke_tests/libs/test_assessor.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
const char kPluginsTestFiles[] =
"/usr/share/app-installers-ut/test_samples/plugins";
-const bf::path kTestTagPlugin =
- bf::path(kPluginsTestFiles) / "libtest-tag-plugin.so";
-const bf::path kTestCategoryPlugin =
- bf::path(kPluginsTestFiles) / "libtest-category-plugin.so";
-const bf::path kTestMetadataPlugin =
- bf::path(kPluginsTestFiles) / "libtest-metadata-plugin.so";
-const bf::path kTestValidPluginsListDir =
- bf::path(kPluginsTestFiles) / "valid-parser-plugins";
-const bf::path kTestValidFailPluginsListDir =
- bf::path(kPluginsTestFiles) / "valid-fail-parser-plugins";
-const bf::path kTestInvalidPluginsListDir =
- bf::path(kPluginsTestFiles) / "invalid-parser-plugins";
+const fs::path kTestTagPlugin =
+ fs::path(kPluginsTestFiles) / "libtest-tag-plugin.so";
+const fs::path kTestCategoryPlugin =
+ fs::path(kPluginsTestFiles) / "libtest-category-plugin.so";
+const fs::path kTestMetadataPlugin =
+ fs::path(kPluginsTestFiles) / "libtest-metadata-plugin.so";
+const fs::path kTestValidPluginsListDir =
+ fs::path(kPluginsTestFiles) / "valid-parser-plugins";
+const fs::path kTestValidFailPluginsListDir =
+ fs::path(kPluginsTestFiles) / "valid-fail-parser-plugins";
+const fs::path kTestInvalidPluginsListDir =
+ fs::path(kPluginsTestFiles) / "invalid-parser-plugins";
void CheckCall(
const ci::TestAssessor::ResultStore& store,
@@ -85,7 +84,7 @@ class PluginTest : public testing::Test {
};
TEST_F(PluginTest, PluginsXmlParser_Valid) {
- bf::path manifest = bf::path(kPluginsTestFiles) / "tizen-manifest.xml";
+ fs::path manifest = fs::path(kPluginsTestFiles) / "tizen-manifest.xml";
PluginsXmlParser parser(manifest);
ASSERT_TRUE(parser.Parse());
ASSERT_NE(parser.doc_ptr(), nullptr);
@@ -107,7 +106,7 @@ TEST_F(PluginTest, PluginsXmlParser_Valid) {
}
TEST_F(PluginTest, PluginsXmlParser_Invalid) {
- bf::path manifest = bf::path(kPluginsTestFiles) / "invalid_manifest.xml";
+ fs::path manifest = fs::path(kPluginsTestFiles) / "invalid_manifest.xml";
PluginsXmlParser parser(manifest);
ASSERT_FALSE(parser.Parse());
}
@@ -166,8 +165,8 @@ TEST_F(PluginTest, PluginFactory_CreatingPlugins) {
TEST_F(PluginTest, PluginManager_CallingPlugins ## NAME) { \
TestAssessor::Instance().ClearResults(); \
\
- bf::path manifest = bf::path(kPluginsTestFiles) / "tizen-manifest.xml"; \
- bf::path list = kTestValidPluginsListDir; \
+ fs::path manifest = fs::path(kPluginsTestFiles) / "tizen-manifest.xml"; \
+ fs::path list = kTestValidPluginsListDir; \
\
InstallerContext context; \
context.unpacked_dir_path.set(manifest.parent_path()); \
@@ -195,9 +194,9 @@ CALLING_PLUGIN_FOR_ACTION_TEST(Uninstall, Plugin::ActionType::Uninstall)
std::string kind_of_plugins[3] = {"category", "metadata", "tag"}; \
for (auto name : kind_of_plugins) { \
std::string manifest_dir = name + "-manifest"; \
- bf::path manifest = \
- bf::path(kPluginsTestFiles) / manifest_dir / "tizen-manifest.xml"; \
- bf::path list = kTestValidFailPluginsListDir; \
+ fs::path manifest = \
+ fs::path(kPluginsTestFiles) / manifest_dir / "tizen-manifest.xml"; \
+ fs::path list = kTestValidFailPluginsListDir; \
\
InstallerContext context; \
context.unpacked_dir_path.set(manifest.parent_path()); \
diff --git a/test/smoke_tests/signature_smoketest.cc b/test/smoke_tests/signature_smoketest.cc
index 0d694ce3..dd004ab7 100644
--- a/test/smoke_tests/signature_smoketest.cc
+++ b/test/smoke_tests/signature_smoketest.cc
@@ -2,26 +2,25 @@
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
#include <memory>
#include "common/certificate_validation.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace security {
class SignatureValidatorTest : public testing::Test {
protected:
- std::unique_ptr<bf::path> signature_file;
+ std::unique_ptr<fs::path> signature_file;
};
// Tests signature verifier with proper signatures
TEST_F(SignatureValidatorTest, HandlesInitializedSignatureDir) {
- signature_file.reset(new bf::path(
+ signature_file.reset(new fs::path(
"/usr/share/app-installers-ut/test_samples/good_signatures"));
PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
common_installer::CertificateInfo cert_info;
@@ -32,7 +31,7 @@ TEST_F(SignatureValidatorTest, HandlesInitializedSignatureDir) {
// Tests signature verifier with signature directory containing bad signatures
TEST_F(SignatureValidatorTest, HandlesBadSignatureDir) {
- signature_file.reset(new bf::path(
+ signature_file.reset(new fs::path(
"/usr/share/app-installers-ut/test_samples/bad_signatures"));
PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
common_installer::CertificateInfo cert_info;