From: Damian Pietruchowski Date: Wed, 11 Oct 2017 11:07:12 +0000 (+0200) Subject: Replace pkg_path with GetPkgPath() method in InstallerContext X-Git-Tag: accepted/tizen/unified/20171128.150354~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=643ec67a2b474ef1bf50897b7fd46816d3abcb3b;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git 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/160353/ Change-Id: I3a1a3ddccb041e93f2aa633b19174f1c67a4ff96 Signed-off-by: Damian Pietruchowski --- diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.cc b/src/hybrid/step/pkgmgr/step_generate_xml.cc index 89772c2..6e85efb 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.cc +++ b/src/hybrid/step/pkgmgr/step_generate_xml.cc @@ -124,7 +124,7 @@ void StepGenerateXml::SetXmlNodeAttribute(xmlNodePtr node, ci::Step::Status StepGenerateXml::process() { bf::path wgt_xml_path = context_->xml_path.get(); - bf::path tpk_xml_path = context_->pkg_path.get() / "tizen-manifest.xml"; + bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml"; if (!LoadXmlDocument(wgt_xml_path, tpk_xml_path)) return Step::Status::MANIFEST_ERROR; @@ -179,7 +179,7 @@ ci::Step::Status StepGenerateXml::precheck() { return Step::Status::MANIFEST_ERROR; } - bf::path tpk_xml_path = context_->pkg_path.get() / "tizen-manifest.xml"; + bf::path tpk_xml_path = context_->GetPkgPath() / "tizen-manifest.xml"; if (!bf::exists(tpk_xml_path)) { LOG(ERROR) << "Native manifest file not found: " << tpk_xml_path; return Step::Status::MANIFEST_ERROR; diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 353cf28..b04e52d 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -843,15 +843,12 @@ bool StepParse::LocateConfigFile() { case ConfigLocation::PACKAGE: return StepParse::Check(context_->unpacked_dir_path.get()); case ConfigLocation::INSTALLED: - return StepParse::Check(context_->pkg_path.get() / kResWgt); + return StepParse::Check(context_->GetPkgPath() / kResWgt); case ConfigLocation::RECOVERY: if (StepParse::Check(common_installer::GetBackupPathForPackagePath( - context_->root_application_path.get() - / context_->pkgid.get()) / kResWgt)) + context_->GetPkgPath()) / kResWgt)) return true; - if (StepParse::Check( - context_->root_application_path.get() - / context_->pkgid.get() / kResWgt)) + if (StepParse::Check(context_->GetPkgPath() / kResWgt)) return true; return false; case ConfigLocation::RESOURCE_WGT: diff --git a/src/wgt/step/configuration/step_parse_recovery.cc b/src/wgt/step/configuration/step_parse_recovery.cc index 36b472c..728a19e 100644 --- a/src/wgt/step/configuration/step_parse_recovery.cc +++ b/src/wgt/step/configuration/step_parse_recovery.cc @@ -23,8 +23,6 @@ StepParseRecovery::StepParseRecovery( common_installer::Step::Status StepParseRecovery::process() { (void) StepParse::process(); - context_->pkg_path.set( - context_->root_application_path.get() / context_->pkgid.get()); return Status::OK; } diff --git a/src/wgt/step/filesystem/step_copy_preview_icons.cc b/src/wgt/step/filesystem/step_copy_preview_icons.cc index 88fc004..95710f8 100644 --- a/src/wgt/step/filesystem/step_copy_preview_icons.cc +++ b/src/wgt/step/filesystem/step_copy_preview_icons.cc @@ -31,12 +31,12 @@ ci::Step::Status StepCopyPreviewIcons::process() { for (auto& size : appwidget.content_size) { if (!size.preview.empty()) { bf::path icon_path = - context_->pkg_path.get() / kResWgt / size.preview; + context_->GetPkgPath() / kResWgt / size.preview; std::string type = wgt::parse::AppWidgetSizeTypeToString(size.type); std::string icon_name = appwidget.id + "." + type + "." + "preview" + bf::path(size.preview).extension().string(); bf::path preview_icon = - context_->pkg_path.get() / kSharedRes / icon_name; + context_->GetPkgPath() / kSharedRes / icon_name; if (!ci::CopyFile(icon_path, preview_icon)) { LOG(ERROR) << "Cannot create preview icon: " << preview_icon; return Status::ICON_ERROR; diff --git a/src/wgt/step/filesystem/step_create_symbolic_link.cc b/src/wgt/step/filesystem/step_create_symbolic_link.cc index e593350..c1091d0 100644 --- a/src/wgt/step/filesystem/step_create_symbolic_link.cc +++ b/src/wgt/step/filesystem/step_create_symbolic_link.cc @@ -39,7 +39,7 @@ bool StepCreateSymbolicLink::CreateSymlinksForApps() { if (strcmp("webapp", app->type) != 0) continue; // binary is a symbolic link named and is located in / - bf::path exec_path = context_->pkg_path.get() / bf::path("bin"); + bf::path exec_path = context_->GetPkgPath() / bf::path("bin"); common_installer::CreateDir(exec_path); exec_path /= bf::path(app->appid); @@ -76,7 +76,7 @@ common_installer::Step::Status StepCreateSymbolicLink::process() { common_installer::Step::Status StepCreateSymbolicLink::undo() { for (application_x* app : GListRange(context_->manifest_data.get()->application)) { - bf::path exec_path = context_->pkg_path.get() / "bin" / app->appid; + bf::path exec_path = context_->GetPkgPath() / "bin" / app->appid; common_installer::RemoveAll(exec_path); } return Status::OK; diff --git a/src/wgt/step/filesystem/step_wgt_patch_icons.cc b/src/wgt/step/filesystem/step_wgt_patch_icons.cc index 89e6fff..e0a1be0 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_icons.cc +++ b/src/wgt/step/filesystem/step_wgt_patch_icons.cc @@ -50,7 +50,7 @@ namespace wgt { namespace filesystem { common_installer::Step::Status StepWgtPatchIcons::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); if (error) { diff --git a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc index dae2b53..ddcb9a5 100644 --- a/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc +++ b/src/wgt/step/filesystem/step_wgt_patch_storage_directories.cc @@ -34,7 +34,7 @@ common_installer::Step::Status StepWgtPatchStorageDirectories::process() { if (version >= 3) { LOG(DEBUG) << "Moving and linking widget's shared/res directory content in " - << context_->pkg_path.get(); + << context_->GetPkgPath(); if (!ShareDirFor3x()) return Status::APP_DIR_ERROR; } @@ -45,11 +45,11 @@ common_installer::Step::Status StepWgtPatchStorageDirectories::process() { bool StepWgtPatchStorageDirectories::ShareDirFor3x() { // check if ${pkg_path}/res/wgt/shared/res exists bf::path wgt_shared_res_dir = - context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation; + context_->GetPkgPath() / kResWgtSubPath / kSharedResLocation; if (!bf::exists(wgt_shared_res_dir)) return true; // create ${pkg_path}/shared/res - bf::path shared_dir = context_->pkg_path.get() / kSharedLocation; + bf::path shared_dir = context_->GetPkgPath() / kSharedLocation; if (!bf::exists(shared_dir)) { bs::error_code error; bf::create_directory(shared_dir, error); @@ -58,7 +58,7 @@ bool StepWgtPatchStorageDirectories::ShareDirFor3x() { return false; } } - bf::path shared_res_dir = context_->pkg_path.get() / kSharedResLocation; + bf::path shared_res_dir = context_->GetPkgPath() / kSharedResLocation; if (!bf::exists(shared_res_dir)) { bs::error_code error; bf::create_directory(shared_res_dir, error); @@ -96,7 +96,7 @@ bool StepWgtPatchStorageDirectories::ShareDirFor3x() { } bool StepWgtPatchStorageDirectories::CreatePrivateTmpDir() { - bf::path tmp_path = context_->pkg_path.get() / kTemporaryData; + bf::path tmp_path = context_->GetPkgPath() / kTemporaryData; if (bf::exists(tmp_path) && bf::is_directory(tmp_path)) { return true; } diff --git a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc index f4a1e6d..d3f53b1 100644 --- a/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_prepare_package_directory.cc @@ -26,8 +26,8 @@ namespace filesystem { ci::Step::Status StepWgtPreparePackageDirectory::CreateSymlinkToMountPoint() { bs::error_code error; - bf::path mount_point = ci::GetMountLocation(context_->pkg_path.get()); - bf::path res_wgt_link = context_->pkg_path.get() / kResWgtDirectory; + bf::path mount_point = ci::GetMountLocation(context_->GetPkgPath()); + bf::path res_wgt_link = context_->GetPkgPath() / kResWgtDirectory; if (bf::exists(res_wgt_link)) { if (!bf::is_symlink(symlink_status(res_wgt_link))) { LOG(ERROR) << res_wgt_link << " is not symlink. Cannot proceed"; @@ -63,7 +63,7 @@ ci::Step::Status StepWgtPreparePackageDirectory::process() { } ci::Step::Status StepWgtPreparePackageDirectory::precheck() { - if (context_->pkg_path.get().empty()) { + if (context_->GetPkgPath().empty()) { LOG(ERROR) << "Package installation path is not set"; return Status::INVALID_VALUE; } diff --git a/src/wgt/step/filesystem/step_wgt_undo_patch_storage_directories.cc b/src/wgt/step/filesystem/step_wgt_undo_patch_storage_directories.cc index 4909a6a..4795137 100644 --- a/src/wgt/step/filesystem/step_wgt_undo_patch_storage_directories.cc +++ b/src/wgt/step/filesystem/step_wgt_undo_patch_storage_directories.cc @@ -30,7 +30,7 @@ ci::Step::Status StepWgtUndoPatchStorageDirectories::process() { if (version >= 3) { LOG(DEBUG) << "Unlinking and moving widget's shared/res directory content back in " - << context_->pkg_path.get(); + << context_->GetPkgPath(); if (!UndoShareDirFor3x()) return Status::APP_DIR_ERROR; } @@ -49,7 +49,7 @@ ci::Step::Status StepWgtUndoPatchStorageDirectories::undo() { LOG(DEBUG) << "Restore res/wgt/shared/res from backup dir"; // restore link bf::path wgt_shared_res_dir = - context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation; + context_->GetPkgPath() / kResWgtSubPath / kSharedResLocation; bf::path backup_wgt_shared_res = backup_dir_ / "wgt_shared_res"; if (!backup_wgt_shared_res.empty()) { if (!ci::RemoveAll(wgt_shared_res_dir)) { @@ -63,7 +63,7 @@ ci::Step::Status StepWgtUndoPatchStorageDirectories::undo() { } } // restore original contents - bf::path shared_res_dir = context_->pkg_path.get() / kSharedResLocation; + bf::path shared_res_dir = context_->GetPkgPath() / kSharedResLocation; bf::path backup_shared_res = backup_dir_ / "shared_res"; if (!backup_shared_res.empty()) { if (!ci::CopyDir(backup_dir_, shared_res_dir, @@ -78,11 +78,11 @@ ci::Step::Status StepWgtUndoPatchStorageDirectories::undo() { bool StepWgtUndoPatchStorageDirectories::UndoShareDirFor3x() { // check if ${pkg_path}/shared/res exists - bf::path shared_res_dir = context_->pkg_path.get() / kSharedResLocation; + bf::path shared_res_dir = context_->GetPkgPath() / kSharedResLocation; if (!bf::exists(shared_res_dir)) return true; bf::path wgt_shared_res_dir = - context_->pkg_path.get() / kResWgtSubPath / kSharedResLocation; + context_->GetPkgPath() / kResWgtSubPath / kSharedResLocation; if (!bf::exists(wgt_shared_res_dir)) return true; diff --git a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc index c762dc4..76396db 100644 --- a/src/wgt/step/filesystem/step_wgt_update_package_directory.cc +++ b/src/wgt/step/filesystem/step_wgt_update_package_directory.cc @@ -46,9 +46,9 @@ namespace filesystem { ci::Step::Status StepWgtUpdatePackageDirectory::CreateBackupOfDirectories() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); for (auto& entry : kBackupEntries) { - bf::path directory = context_->pkg_path.get() / entry; + bf::path directory = context_->GetPkgPath() / entry; if (!bf::exists(directory)) continue; LOG(DEBUG) << "Backup directory entry: " << entry; @@ -65,14 +65,14 @@ StepWgtUpdatePackageDirectory::CreateBackupOfDirectories() { ci::Step::Status StepWgtUpdatePackageDirectory::RecoverBackupOfDirectories() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); // skip if there is no backup of directories if (!bf::exists(backup_path)) return Status::OK; for (auto& entry : kBackupEntries) { - bf::path directory = context_->pkg_path.get() / entry; + bf::path directory = context_->GetPkgPath() / entry; bf::path directory_backup = backup_path / entry; if (!bf::exists(directory_backup)) continue; @@ -107,7 +107,7 @@ ci::Step::Status StepWgtUpdatePackageDirectory::process() { ci::Step::Status StepWgtUpdatePackageDirectory::clean() { bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); if (bf::exists(backup_path)) { bs::error_code error; bf::remove_all(backup_path, error); @@ -124,7 +124,7 @@ ci::Step::Status StepWgtUpdatePackageDirectory::undo() { if (status != Status::OK) return status; bf::path backup_path = - ci::GetBackupPathForPackagePath(context_->pkg_path.get()); + ci::GetBackupPathForPackagePath(context_->GetPkgPath()); if (bf::exists(backup_path)) { bs::error_code error; bf::remove_all(backup_path, error); diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 91d9f56..64a2303 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -165,7 +165,7 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid); // binary is a symbolic link named and is located in / - bf::path exec_path = context_->pkg_path.get() + bf::path exec_path = context_->GetPkgPath() / bf::path("bin") / bf::path(app->appid); xmlTextWriterWriteAttribute(writer, BAD_CAST "exec", BAD_CAST exec_path.string().c_str()); @@ -189,7 +189,7 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( if (!WriteWidgetApplicationAttributesAndElements(writer, app, static_cast( context_->backend_data.get())->appwidgets.get(), - context_->pkg_path.get() / "shared" / "res")) + context_->GetPkgPath() / "shared" / "res")) return Status::MANIFEST_ERROR; break; case AppCompType::WATCHAPP: diff --git a/src/wgt/step/security/step_check_extension_privileges.cc b/src/wgt/step/security/step_check_extension_privileges.cc index 78187d2..281c47e 100755 --- a/src/wgt/step/security/step_check_extension_privileges.cc +++ b/src/wgt/step/security/step_check_extension_privileges.cc @@ -109,7 +109,7 @@ common_installer::Step::Status StepCheckExtensionPrivileges::process() { } std::string StepCheckExtensionPrivileges::GetExtensionPath() { - std::string app_ext_config_pattern(context_->pkg_path.get().string()); + std::string app_ext_config_pattern(context_->GetPkgPath().string()); app_ext_config_pattern.append(kPluginsDirectory); struct utsname u; if (0 == uname(&u)) { diff --git a/src/wgt/step/security/step_wgt_recover_signature.cc b/src/wgt/step/security/step_wgt_recover_signature.cc index d18d172..e951b5b 100644 --- a/src/wgt/step/security/step_wgt_recover_signature.cc +++ b/src/wgt/step/security/step_wgt_recover_signature.cc @@ -16,7 +16,7 @@ namespace wgt { namespace security { bf::path StepWgtRecoverSignature::GetSignatureRoot() { - return context_->pkg_path.get() / kResWgt; + return context_->GetPkgPath() / kResWgt; } } // namespace security