From 4d7c677b9c96c491a6bf1e36938d71c593077f4c Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Wed, 15 Nov 2017 14:31:03 +0100 Subject: [PATCH] Replace pkg_path with GetPkgPath() method in InstallerContext pkg_path is always equal to root_application_path + pkgid. Storing this information in separate variable is problematic, because it requires to remember to update pkg_path after root_application_path or pkgid is changed. Submit with: - https://review.tizen.org/gerrit/#/c/154196/ - https://review.tizen.org/gerrit/#/c/154904/ Change-Id: I403ef165c458091bc71ca9c80175ea7666ba2254 Signed-off-by: Damian Pietruchowski --- .../step/filesystem/step_check_pkg_directory_path.cc | 8 ++++---- src/tpk/step/filesystem/step_create_symbolic_link.cc | 2 +- src/tpk/step/filesystem/step_tpk_patch_icons.cc | 2 +- .../filesystem/step_tpk_prepare_package_directory.cc | 18 +++++++++--------- .../filesystem/step_tpk_update_package_directory.cc | 10 +++++----- src/tpk/step/pkgmgr/step_convert_xml.cc | 2 +- src/tpk/step/security/step_tpk_recover_signature.cc | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/tpk/step/filesystem/step_check_pkg_directory_path.cc b/src/tpk/step/filesystem/step_check_pkg_directory_path.cc index ac22541..04b564d 100644 --- a/src/tpk/step/filesystem/step_check_pkg_directory_path.cc +++ b/src/tpk/step/filesystem/step_check_pkg_directory_path.cc @@ -14,16 +14,16 @@ namespace bf = boost::filesystem; namespace bs = boost::system; common_installer::Step::Status StepCheckPkgDirPath::process() { - if (!bf::exists(context_->pkg_path.get())) { + if (!bf::exists(context_->GetPkgPath())) { LOG(INFO) << "Create pkg_path(" - << context_->pkg_path.get() + << context_->GetPkgPath() << ") for package(" << context_->pkgid.get() << ")"; bs::error_code error; - bf::create_directories(context_->pkg_path.get(), error); + bf::create_directories(context_->GetPkgPath(), error); if (error) { LOG(ERROR) << "Cannot create directory: " - << context_->pkg_path.get().string(); + << context_->GetPkgPath().string(); return Step::Status::APP_DIR_ERROR; } } diff --git a/src/tpk/step/filesystem/step_create_symbolic_link.cc b/src/tpk/step/filesystem/step_create_symbolic_link.cc index 4a2f6b0..8afacd0 100644 --- a/src/tpk/step/filesystem/step_create_symbolic_link.cc +++ b/src/tpk/step/filesystem/step_create_symbolic_link.cc @@ -26,7 +26,7 @@ typedef common_installer::Step::Status Status; bool CreateSymLink(application_x* app, InstallerContext* context) { boost::system::error_code boost_error; - bf::path bindir = context->pkg_path.get() / + bf::path bindir = context->GetPkgPath() / bf::path("bin"); LOG(DEBUG) << "Creating dir: " << bindir; if (!bf::is_symlink(symlink_status(bindir)) && diff --git a/src/tpk/step/filesystem/step_tpk_patch_icons.cc b/src/tpk/step/filesystem/step_tpk_patch_icons.cc index 17dcef3..74d8f20 100644 --- a/src/tpk/step/filesystem/step_tpk_patch_icons.cc +++ b/src/tpk/step/filesystem/step_tpk_patch_icons.cc @@ -86,7 +86,7 @@ common_installer::Step::Status StepTpkPatchIcons::FixIconLocation( } common_installer::Step::Status StepTpkPatchIcons::process() { - bf::path common_icon_location = context_->pkg_path.get() / "shared" / "res"; + bf::path common_icon_location = context_->GetPkgPath() / "shared" / "res"; bs::error_code error; bf::create_directories(common_icon_location, error); for (application_x* app : diff --git a/src/tpk/step/filesystem/step_tpk_prepare_package_directory.cc b/src/tpk/step/filesystem/step_tpk_prepare_package_directory.cc index 55bd00b..be25880 100644 --- a/src/tpk/step/filesystem/step_tpk_prepare_package_directory.cc +++ b/src/tpk/step/filesystem/step_tpk_prepare_package_directory.cc @@ -21,9 +21,9 @@ namespace filesystem { ci::Step::Status StepTpkPreparePackageDirectory::BackupDirectory( const std::string& entry, const bf::path& backup_path) { - if (!bf::exists(context_->pkg_path.get() / entry)) + if (!bf::exists(context_->GetPkgPath() / entry)) return Status::OK; - if (!ci::MoveDir(context_->pkg_path.get() / entry, backup_path / entry, + if (!ci::MoveDir(context_->GetPkgPath() / entry, backup_path / entry, ci::FSFlag::FS_MERGE_OVERWRITE | ci::FSFlag::FS_COMMIT_COPY_FILE | ci::FSFlag::FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS)) { @@ -43,7 +43,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::PrepareDirectory( // simple string filter so we append slash character here std::string filter = entry + '/'; if (!ci::ExtractToTmpDir(context_->file_path.get().c_str(), - context_->pkg_path.get(), entry)) { + context_->GetPkgPath(), entry)) { LOG(ERROR) << "Failed to extract from zip files in: " << filter; return Status::UNZIP_ERROR; } @@ -55,7 +55,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::PrepareLink( bs::error_code error; bf::path mount_point_entry = mount_point / entry; if (bf::exists(mount_point_entry)) { - bf::path destination = context_->pkg_path.get() / entry; + bf::path destination = context_->GetPkgPath() / entry; if (bf::exists(destination)) { if (!bf::is_symlink(symlink_status(destination))) { LOG(ERROR) << "Cannot proceed. " @@ -81,7 +81,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::PrepareLink( ci::Step::Status StepTpkPreparePackageDirectory::ExtractEntries() { LOG(DEBUG) << "Extracting entries from zip package..."; bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); if (context_->request_type.get() == ci::RequestType::MountUpdate && context_->recovery_info.get().recovery_file) { context_->recovery_info.get().recovery_file->set_unpacked_dir(backup_path); @@ -101,7 +101,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::ExtractEntries() { } ci::Step::Status StepTpkPreparePackageDirectory::PrepareLinks() { - bf::path mount_point = ci::GetMountLocation(context_->pkg_path.get()); + bf::path mount_point = ci::GetMountLocation(context_->GetPkgPath()); LOG(DEBUG) << "Creating symlinks to zip package..."; for (auto& link_entry : tpk::GetSymlinkEntries()) { LOG(DEBUG) << "Symlink: " << link_entry; @@ -120,7 +120,7 @@ ci::Step::Status StepTpkPreparePackageDirectory::process() { } ci::Step::Status StepTpkPreparePackageDirectory::precheck() { - if (context_->pkg_path.get().empty()) { + if (context_->GetPkgPath().empty()) { LOG(ERROR) << "Package installation path is not set"; return Status::INVALID_VALUE; } @@ -139,10 +139,10 @@ ci::Step::Status StepTpkPreparePackageDirectory::undo() { return Status::OK; for (auto& entry : tpk::GetExtractEntries()) { - ci::RemoveAll(context_->pkg_path.get() / entry); + ci::RemoveAll(context_->GetPkgPath() / entry); if (!bf::exists(backupPath_ / entry)) continue; - ci::MoveDir(backupPath_ / entry, context_->pkg_path.get() / entry, + ci::MoveDir(backupPath_ / entry, context_->GetPkgPath() / entry, ci::FSFlag::FS_MERGE_OVERWRITE | ci::FSFlag::FS_COMMIT_COPY_FILE | ci::FSFlag::FS_PRESERVE_OWNERSHIP_AND_PERMISSIONS); diff --git a/src/tpk/step/filesystem/step_tpk_update_package_directory.cc b/src/tpk/step/filesystem/step_tpk_update_package_directory.cc index 601828c..3ec0205 100644 --- a/src/tpk/step/filesystem/step_tpk_update_package_directory.cc +++ b/src/tpk/step/filesystem/step_tpk_update_package_directory.cc @@ -44,7 +44,7 @@ namespace filesystem { ci::Step::Status StepTpkUpdatePackageDirectory::BackupDirectory( const std::string& entry, const boost::filesystem::path& backup_path) { - bf::path source = context_->pkg_path.get() / entry; + bf::path source = context_->GetPkgPath() / entry; if (bf::exists(source)) { bf::path destination = backup_path / entry; if (!ReplacePaths(source, destination)) @@ -58,7 +58,7 @@ ci::Step::Status StepTpkUpdatePackageDirectory::RestoreDirectory( // restore backup if directory exists if (bf::exists(backup_path / entry)) { bf::path source = backup_path / entry; - bf::path destination = context_->pkg_path.get() / entry; + bf::path destination = context_->GetPkgPath() / entry; if (bf::exists(destination)) { bs::error_code error; bf::remove_all(destination, error); @@ -83,7 +83,7 @@ ci::Step::Status StepTpkUpdatePackageDirectory::RemoveDirectory( ci::Step::Status StepTpkUpdatePackageDirectory::BackupEntries() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); for (auto& entry : tpk::GetExtractEntries()) { auto status = BackupDirectory(entry, backup_path); if (status != Status::OK) @@ -104,13 +104,13 @@ ci::Step::Status StepTpkUpdatePackageDirectory::process() { ci::Step::Status StepTpkUpdatePackageDirectory::clean() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); return RemoveDirectory(backup_path); } ci::Step::Status StepTpkUpdatePackageDirectory::undo() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); for (auto& entry : tpk::GetExtractEntries()) { auto status = RestoreDirectory(entry, backup_path); diff --git a/src/tpk/step/pkgmgr/step_convert_xml.cc b/src/tpk/step/pkgmgr/step_convert_xml.cc index f7877e6..f62e71c 100644 --- a/src/tpk/step/pkgmgr/step_convert_xml.cc +++ b/src/tpk/step/pkgmgr/step_convert_xml.cc @@ -37,7 +37,7 @@ namespace tpk { namespace pkgmgr { common_installer::Step::Status StepConvertXml::precheck() { - bf::path xml_path = context_->pkg_path.get(); + bf::path xml_path = context_->GetPkgPath(); xml_path /= "tizen-manifest.xml"; if (bf::exists(xml_path)) { diff --git a/src/tpk/step/security/step_tpk_recover_signature.cc b/src/tpk/step/security/step_tpk_recover_signature.cc index 6a8623e..b14754f 100644 --- a/src/tpk/step/security/step_tpk_recover_signature.cc +++ b/src/tpk/step/security/step_tpk_recover_signature.cc @@ -10,7 +10,7 @@ namespace tpk { namespace security { bf::path StepTpkRecoverSignature::GetSignatureRoot() { - return context_->pkg_path.get(); + return context_->GetPkgPath(); } } // namespace security -- 2.7.4