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")
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)
Source1000: app-installers.manifest
Source1001: app-installers-tests.manifest
-BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: pkgconfig(pkgmgr)
BuildRequires: pkgconfig(pkgmgr-parser)
LIBSYSTEMD_DEPS
TTRACE_DEPS
TRUST_ANCHOR_DEPS
- Boost
)
# Extra
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/
// 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;
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,
}
bool AppQueryInterface::ClearTemporaryFile(
- const boost::filesystem::path& path) const {
+ const fs::path& path) const {
return RemoveAll(path);
}
#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 {
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;
#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>
#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 {
}
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,
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
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);
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) {
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>>{
#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>
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);
#include "common/dependency_checker.h"
-#include <boost/filesystem/path.hpp>
-
#include <pkgmgr-info.h>
#include <manifest_parser/utils/logging.h>
#include <tpk_manifest_handlers/package_handler.h>
#include <tpk_manifest_handlers/tpk_config_parser.h>
+#include <filesystem>
#include <map>
#include <memory>
#include <tuple>
#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 {
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;
}
#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 {
}
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;
}
#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 {
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),
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),
}
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));
}
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) {
}
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));
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;
#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>
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();
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_;
#include "common/feature_validator.h"
-#include <boost/scope_exit.hpp>
-
#include <system_info.h>
+#include <memory>
+#include <string>
+
namespace common_installer {
FeatureValidator::FeatureValidator(
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()") +
#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) ||
}
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())
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 {};
}
bool GlobalRecoveryFile::AppendPath(
- const bf::path& additional_path) {
+ const fs::path& additional_path) {
return AppendString(additional_path.string());
}
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";
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;
#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 {
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_;
};
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()) {
#include <manifest_parser/utils/logging.h>
-#include <boost/bind/bind.hpp>
-
+#include <algorithm>
#include <list>
#include <memory>
#include <string>
* 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 {
/** 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
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));
}
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();
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);
}
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));
}
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));
}
#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>
* \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) {
}
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;
/**
* \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();
}
/**
* \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
* \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
* (${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
#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"
protected:
virtual std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) = 0;
+ const std::filesystem::path& mount_path) = 0;
};
} // namespace common_installer
#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"
#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 {
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));
}
}
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;
}
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.";
// 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()) {
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";
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
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));
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 {
#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"
*
* \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
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_;
#include "common/utils/glist_range.h"
#include "common/utils/manifest_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
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;
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;
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;
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;
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);
#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"
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
*
* \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);
* \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);
#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>
#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)),
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_;
}
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;
}
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)));
}
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";
#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>
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_;
};
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();
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_;
};
#include <pkgmgr-info.h>
-#include <boost/filesystem.hpp>
-
#include <algorithm>
#include <string>
#include <utility>
#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>
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)
#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>
/** 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();
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);
#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 {
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;
}
}
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;
}
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";
}
void RecoveryFile::set_unpacked_dir(
- boost::filesystem::path unpacked_dir) {
+ std::filesystem::path unpacked_dir) {
unpacked_dir_ = std::move(unpacked_dir);
}
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_;
}
}
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;
}
}
- bi::stream<bi::file_descriptor_sink> ofs(path_);
+ std::ofstream ofs(path_);
if (!ofs) {
LOG(ERROR) << "Cannot write recovery file";
return false;
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;
} // namespace recovery
} // namespace common_installer
-
#ifndef COMMON_RECOVERY_FILE_H_
#define COMMON_RECOVERY_FILE_H_
-#include <boost/filesystem/path.hpp>
-
#include <cstdio>
+#include <filesystem>
#include <memory>
#include <string>
* \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
* \return new RecoveryFile object
*/
static std::unique_ptr<RecoveryFile> OpenRecoveryFile(
- const boost::filesystem::path& path);
+ const std::filesystem::path& path);
/** Desctructor */
~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
*
* \return current unpacked_dir
*/
- const boost::filesystem::path& unpacked_dir() const;
+ const std::filesystem::path& unpacked_dir() const;
/**
* getter for pkgid
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_;
#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>
#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 {
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},
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_);
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;
}
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";
}
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;
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,
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";
// 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) {
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();
}
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()) {
}
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()) {
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;
}
#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>
* \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);
/**
* \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
#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>
#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>
#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 {
"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;
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))
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;
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;
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))
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;
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();
}
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();
}
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();
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;
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;
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;
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;
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;
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;
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;
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;
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();
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();
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()),
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";
}
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;
}
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))
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;
}
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;
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))
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,
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;
}
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))
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);
}
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;
}
}
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;
}
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");
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;
}
}
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;
}
}
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;
}
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;
}
}
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;
}
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)
}
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)) {
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;
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 /
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;
}
}
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;
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 /
}
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 /
}
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;
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;
}
}
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;
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 /
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;
}
}
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 /
#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>
*
* \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);
*
* \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
*
* \return true if succeed, false otherwise
*/
-bool DeleteSharedDirectories(const boost::filesystem::path& path,
+bool DeleteSharedDirectories(const std::filesystem::path& path,
const std::string& pkgid);
/**
*
* \return true if succeed, false otherwise
*/
-bool SetPackageDirectoryOwnerAndPermissions(const boost::filesystem::path& path,
+bool SetPackageDirectoryOwnerAndPermissions(const std::filesystem::path& path,
uid_t uid);
/**
#include <tzplatform_config.h>
#include <unistd.h>
+#include <filesystem>
+#include <fstream>
#include <string>
#include <regex>
#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))
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))
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;
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(),
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)");
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;
}
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_;
}
#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 {
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_;
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
#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 {
}
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);
}
}
#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>
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_;
#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;
}
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) ||
}
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;
#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))
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;
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;
// 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)) {
if (context_->external_storage)
context_->external_storage->Abort();
- if (!bf::exists(backup_path_))
+ if (!fs::exists(backup_path_))
return Status::OK;
if (!RollbackApplicationDirectory()) {
}
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;
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());
}
-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;
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";
}
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;
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;
}
// 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";
}
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;
}
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;
#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"
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)
};
#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 {
#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"
#include "common/utils/user_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace configuration {
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);
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);
}
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();
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;
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();
#include "common/step/configuration/step_parse_manifest.h"
-#include <boost/tokenizer.hpp>
-
#include <pkgmgr/pkgmgr_parser.h>
#include <pkgmgr-info.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
#include <memory>
+#include <regex>
#include <set>
#include <type_traits>
#include <string>
#include "common/utils/time_util.h"
namespace app_keys = tpk::application_keys;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
}
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;
}
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;
LOG(DEBUG) << "manifest path: " << manifest;
- if (!boost::filesystem::exists(manifest))
+ if (!std::filesystem::exists(manifest))
return false;
path_ = 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()
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()
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()
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()
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()
}
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(
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()
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");
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(),
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 {
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, {});
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()
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();
#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>
#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>
protected:
bool LocateConfigFile();
- boost::filesystem::path path_;
+ std::filesystem::path path_;
private:
bool FillInstallationInfo(manifest_x* manifest);
#include <pkgmgr-info.h>
#include <unistd.h>
-#include <boost/filesystem.hpp>
-
#include <cstring>
#include <cstdio>
#include <string>
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
namespace common_installer {
#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>
#include "common/utils/user_util.h"
#include "common/utils/request.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
{"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;
}
}
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;
}
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";
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;
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()) {
#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 {
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";
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";
}
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();
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();
<< " 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();
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);
}
#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 {
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
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;
}
}
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;
#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 {
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)
};
#include <cassert>
#include <cstring>
+#include <filesystem>
#include <string>
+#include <system_error>
#include "common/utils/paths.h"
#include "common/utils/file_util.h"
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()) {
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";
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());
// 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;
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);
#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 {
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;
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;
#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>
Status precheck() override { return Status::OK; }
private:
- std::vector<boost::filesystem::path> icons_;
+ std::vector<std::filesystem::path> icons_;
STEP_NAME(CreateIcons)
};
#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))
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))
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;
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;
#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>
#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 {
#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>
#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 {
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)
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;
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;
}
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);
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;
} 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;
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))
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;
}
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;
}
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
#include <string>
#include "common/installer_context.h"
Status precheck() override;
private:
- boost::filesystem::path patch_dir_;
+ std::filesystem::path patch_dir_;
std::string delta_root_;
STEP_NAME(DeltaPatch)
#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 {
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";
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;
}
#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"
#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)) {
}
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;
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);
// 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();
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;
}
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();
} // namespace filesystem
} // namespace common_installer
-
#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"
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)
#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 {
} // namespace filesystem
} // namespace common_installer
-
#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;
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;
}
// 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;
}
}
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());
}
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 "
// 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()
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;
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)) {
return Status::OK;
}
-bool StepRecoverFiles::ClearPath(const bf::path& path) {
+bool StepRecoverFiles::ClearPath(const fs::path& path) {
return RemoveAll(path);
}
#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"
Status Cleanup() override;
protected:
- virtual bool ClearPath(const boost::filesystem::path& path);
+ virtual bool ClearPath(const std::filesystem::path& path);
STEP_NAME(RecoverFiles)
};
#include "common/shared_dirs.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
namespace filesystem {
#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 {
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;
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("");
} // namespace filesystem
} // namespace common_installer
-
#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>
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)
#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 {
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;
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;
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;
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);
#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"
#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 {
}
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);
}
} // namespace filesystem
} // namespace common_installer
-
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/step/recovery/step_recovery.h"
* @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)
#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>
#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"},
}
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");
// 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";
}
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());
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;
}
// 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;
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;
#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 {
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)) {
#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>
// 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"
namespace common_installer {
namespace filesystem {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
Step::Status StepRemoveTemporaryDirectory::RecoveryUpdate() {
return RemoveFiles();
}
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";
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
-
#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 {
Status Cleanup() override;
protected:
- virtual bool ClearPath(const boost::filesystem::path& path);
+ virtual bool ClearPath(const std::filesystem::path& path);
private:
/**
#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
#include "common/step/filesystem/step_remove_user_data.h"
+#include <filesystem>
#include <string>
#include <utility>
#include <vector>
#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 {
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;
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 /
#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>
#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 {
}
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;
}
#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 {
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";
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";
}
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());
}
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;
}
}
- 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;
}
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();
}
#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"
#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>
#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 {
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());
#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"
#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 {
// 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;
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);
}
}
}
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;
#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"
#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 =
#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"
#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 {
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();
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";
}
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";
}
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;
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";
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";
}
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;
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
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);
#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";
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;
}
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";
}
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;
#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"
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)
#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"
#include "common/tzip_interface.h"
#include "common/zip_interface.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
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
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";
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";
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";
}
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;
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
STEP_NAME(MountUnpacked)
};
#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"
#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;
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";
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";
}
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";
}
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;
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)) {
}
// 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";
}
}
- if (bf::exists(backup_path_))
+ if (fs::exists(backup_path_))
RemoveAll(backup_path_);
return Status::OK;
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";
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";
}
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;
#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"
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)
};
#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 {
}
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;
#include <manifest_parser/utils/logging.h>
+#include <filesystem>
+
#include "common/installer_context.h"
#include "common/mount_base.h"
#include "common/step/step.h"
protected:
std::unique_ptr<IZipInterface> CreateZipInterface(
- const boost::filesystem::path& mount_path) override;
+ const std::filesystem::path& mount_path) override;
STEP_NAME(Unmount);
};
#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 {
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(
#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 {
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";
#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 {
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";
#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"
#include "common/step/pkgmgr/step_register_app.h"
-#include <boost/filesystem.hpp>
-
#include <unistd.h>
#include <cassert>
#include <cstring>
#include "common/pkgmgr_registration.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-
namespace common_installer {
namespace pkgmgr {
#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 {
#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();
}
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))
#include "common/step/pkgmgr/step_run_parser_plugins.h"
+#include <filesystem>
#include <string>
#include <vector>
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(
: 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()))
#include <pkgmgrinfo_basic.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <vector>
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_;
#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"
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";
#include <sys/types.h>
#include <unistd.h>
-#include <boost/filesystem.hpp>
#include <vcore/Certificate.h>
#include <cassert>
#include "common/utils/pkgmgr_query.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
-
namespace common_installer {
namespace pkgmgr {
#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) {}
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";
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)) {
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;
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;
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)) {
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;
}
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();
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
#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>
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_;
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;
}
#include <common/step/step.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include <vector>
Status precheck() override;
private:
- boost::filesystem::path rds_file_path_;
+ std::filesystem::path rds_file_path_;
STEP_NAME(RDSParse)
};
#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>
#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";
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;
}
#include "common/step/security/step_privacy_privilege.h"
-#include <boost/scope_exit.hpp>
-
#include <map>
#include <string>
#include <vector>
#include "common/step/security/step_privilege_compatibility.h"
-#include <boost/scope_exit.hpp>
-
#include <pkgmgrinfo_basic.h>
#include <privilege_manager.h>
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 "
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;
} // namespace security
} // namespace common_installer
-
#include "common/step/security/step_recover_security.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/security_registration.h"
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;
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;
}
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;
}
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;
}
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;
}
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;
}
#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;
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;
#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"
Status Cleanup() override;
private:
- virtual boost::filesystem::path GetSignatureRoot() = 0;
+ virtual std::filesystem::path GetSignatureRoot() = 0;
STEP_NAME(RecoverSignature)
};
#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"
#include "common/step/security/step_register_security.h"
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/security_registration.h"
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";
!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;
}
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;
}
#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"
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
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;
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) {
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;
}
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;
}
}
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) {
#include "common/step/security/step_revoke_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
<< 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";
#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"
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
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;
}
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;
}
}
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) {
#include "common/step/security/step_rollback_deinstallation_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
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;
}
#include "common/step/security/step_rollback_installation_security.h"
-#include <boost/filesystem.hpp>
#include <string>
#include "common/security_registration.h"
#include "common/certificate_validation.h"
#include "common/utils/file_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace ci = common_installer;
namespace {
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";
return Step::Status::OK;
}
-boost::filesystem::path StepSignature::GetSignatureRoot() const {
+std::filesystem::path StepSignature::GetSignatureRoot() const {
return context_->unpacked_dir_path.get();
}
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;
}
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;
}
&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;
}
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;
}
#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"
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)
#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";
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) {
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;
}
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;
}
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;
}
#include <pkgmgr_installer_error.h>
-#include <boost/signals2.hpp>
#include <string>
#include "common/installer_context.h"
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) { }
/** 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
#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 {
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()) {
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,
}
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));
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)
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);
}
#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>
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:
#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
#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;
}
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;
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
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;
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;
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;
}
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;
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();
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;
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;
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 << "]";
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,
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);
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;
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();
}
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;
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];
// 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";
}
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;
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;
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
#include <sys/types.h>
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
#include <string>
#include <vector>
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
#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 {
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);
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;
#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);
#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;
}
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);
}
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;
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)
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;
}
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;
#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"
*
* \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)
*
* \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)
*
* \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
*
* \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
*
* @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);
/**
*
* @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
*
* @return path
*/
-boost::filesystem::path GetExternalCardPath();
+std::filesystem::path GetExternalCardPath();
/**
* @brief GetExternalTepPath
*
* @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
*
* @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
*
* @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
#include "common/utils/user_util.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace common_installer {
#ifndef COMMON_UTILS_REQUEST_H_
#define COMMON_UTILS_REQUEST_H_
-#include <boost/filesystem/path.hpp>
-
#include <string>
namespace common_installer {
#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 {
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);
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;
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;
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];
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];
}
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
#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
#ifndef COMMON_ZIP_INTERFACE_H_
#define COMMON_ZIP_INTERFACE_H_
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
namespace common_installer {
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;
};
# 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})
// 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>
#include "common/utils/file_util.h"
#include "common/utils/subprocess.h"
-namespace bf = boost::filesystem;
namespace ci = common_installer;
+namespace fs = std::filesystem;
namespace {
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);
// 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;
#include <string>
#include <tuple>
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
using ManifestInfo = std::tuple<std::string, std::string, std::string>;
std::list<ManifestInfo> LoadManifest();
private:
- bf::path path_;
+ fs::path path_;
};
#endif // PKG_INITDB_MANIFEST_LOADER_H_
// 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>
#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();
}
#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) {}
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_;
};
# Target - deps
APPLY_PKG_CONFIG(${TARGET_PKG_RECOVERY} PUBLIC
TZPLATFORM_CONFIG_DEPS
- Boost
)
# Target - in-package deps
// 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>
#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 {
break;
}
- if (!boost::filesystem::exists(line_data))
+ if (!std::filesystem::exists(line_data))
continue;
arguments.emplace_back(line_data);
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");
if (WIFSIGNALED(status) || WEXITSTATUS(status))
return false;
- ci::Remove(bf::path(file));
+ ci::Remove(fs::path(file));
return true;
}
}
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();
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;
}
}
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))
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
)
)
APPLY_PKG_CONFIG(${TARGET_SMOKE_UTILS} PUBLIC
- Boost
GMOCK_DEPS
GUM_DEPS
)
#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>
#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 {
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;
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;
}
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;
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;
}
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();
}
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;
}
}
}
}
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;
}
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;
}
}
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);
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;
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;
}
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);
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 {
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 {
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;
}
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!";
}
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;
}
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);
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));
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))
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;
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();
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_)
}
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_);
// 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_);
return true;
}
-bool FileInfoCollector::LoadFromFile(const bf::path& path) {
+bool FileInfoCollector::LoadFromFile(const fs::path& path) {
std::ifstream readFile;
readFile.open(path.c_str());
while (std::getline(readFile, line)) {
std::istringstream iss(line);
- bf::path p;
+ fs::path p;
int file_permission;
int file_type;
std::string owner;
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();
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 += " ";
}
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;
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()) {
}
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());
}
}
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;
}
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) {
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);
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;
}
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_);
}
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);
}
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;
}
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;
}
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;
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";
}
}
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);
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);
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);
}
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_);
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_);
}
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_);
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_);
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;
}
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;
}
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;
}
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;
}
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();
<< "] 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;
}
}
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()
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"
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: "
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;
}
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;
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() << ")";
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);
}
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)) {
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);
}
}
}
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))
#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>
#include <array>
#include <cstdio>
#include <cstdlib>
+#include <filesystem>
#include <memory>
#include <regex>
#include <string>
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[];
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) {
}
private:
- boost::filesystem::path pkg_path_;
+ std::filesystem::path pkg_path_;
common_installer::TzipInterface interface_;
bool mounted_;
};
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_;
};
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);
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,
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:
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;
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;
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,
};
bool CompareFileInfo(const std::string& pkgid, const TestParameters& params,
- const bf::path& file);
+ const fs::path& file);
} // namespace smoke_test
}
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));
}
#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>
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:
// 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"
// 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>
namespace {
-boost::optional<std::string> CheckArgs(
+std::optional<std::string> CheckArgs(
const char* pkgid,
const char* appid,
GList* categories) {
// 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*) {
// 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>
namespace {
-boost::optional<std::string> CheckArgs(
+std::optional<std::string> CheckArgs(
const char* pkgid,
const char* appid,
GList* metadata) {
// 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;
// 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>
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)
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);
// 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/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,
};
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);
}
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());
}
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()); \
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()); \
// 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;
// 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;