From: Woongsuk Cho Date: Mon, 5 Feb 2024 01:08:27 +0000 (+0900) Subject: Change implementation of regeneratePkgNI X-Git-Tag: accepted/tizen/unified/20240220.115648~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fdotnet%2Flauncher.git;a=commitdiff_plain;h=291f923faa896e766655c9913775d50188380b99 Change implementation of regeneratePkgNI --- diff --git a/NativeLauncher/inc/utils.h b/NativeLauncher/inc/utils.h index 7a3f33b..dca091f 100644 --- a/NativeLauncher/inc/utils.h +++ b/NativeLauncher/inc/utils.h @@ -341,7 +341,7 @@ std::string getResourcePaths(const std::string& rootPath); /** * @brief check the package is rpk type * @param[in] pkgId package ID - * @return bool + * @return return true when package is rpk type */ bool isRPK(const std::string& pkgId); diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc index bfe3afb..739d2b4 100644 --- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc @@ -62,8 +62,8 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app if (strcmp(AOT_METADATA_KEY, md->key) == 0) { if (strcmp(METADATA_VALUE_TRUE, md->value) == 0) { doAOT = true; - break; } + break; } iter = g_list_next(iter); } diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index d6515e8..6ab3e10 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -822,10 +822,9 @@ static ni_error_e removeAndCreateNI(const char* pkgId, NIOption* pOptions) if (createNIUnderPkgRoot(pkgId, pOptions) != NI_ERROR_NONE) { _SERR("Failed to generate NI file [%s]", pkgId); return NI_ERROR_UNKNOWN; - } else { - _SOUT("Complete make native image for pkg (%s)", pkgId); } + _SOUT("Complete make native image for pkg (%s)", pkgId); return NI_ERROR_NONE; } @@ -851,42 +850,7 @@ static bool isReadOnlyPkg(std::string pkgId) pkgmgrinfo_pkginfo_destroy_pkginfo(handle); return readonly; } -#if 0 -// callback function of "pkgmgrinfo_appinfo_metadata_filter_foreach" -static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData) -{ - char *pkgId = NULL; - int ret = 0; - ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId); - if (ret != PMINFO_R_OK) { - _SERR("Failed to get pkgid"); - return -1; - } - - NIOption **pOptions = (NIOption**)userData; - if (isReadOnlyPkg(pkgId) && (*pOptions)->flags & NI_FLAGS_SKIP_RO_APP) { - return 0; - } - - return removeAndCreateNI(pkgId, *pOptions); -} - -// callback function of "pkgmgrinfo_pkginfo_metadata_filter_foreach" -static int pkgAotCb(pkgmgrinfo_pkginfo_h handle, void *userData) -{ - char *pkgId = NULL; - int ret = 0; - NIOption **pOptions = (NIOption**)userData; - - ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgId); - if (ret != PMINFO_R_OK) { - _SERR("Failed to get pkgid"); - return -1; - } - return removeAndCreateNI(pkgId, *pOptions); -} -#endif // callback function of "pkgmgrinfo_appinfo_metadata_filter_foreach" static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData) { @@ -1106,8 +1070,6 @@ ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt) ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) { - ni_error_e ret; - if (!isR2RImage(concatPath(__pm->getRuntimePath(), "System.Private.CoreLib.dll"))) { _SERR("The native image of System.Private.CoreLib does not exist.\n" "Run the command to create the native image\n" @@ -1127,15 +1089,15 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) splitPath(extraDllPaths, opt->extraRefPath); } + std::string targetDirs; if (isRPK(pkgId)) { opt->flags &= ~NI_FLAGS_APPNI; std::string paths = getResourcePaths(rootPath); - if (!paths.empty()) { - ret = createNIUnderDirs(paths, opt); - } else { + if (paths.empty()) { _SERR("Failed to get rpk paths from [%s]", pkgId.c_str()); - ret = NI_ERROR_UNKNOWN; + return NI_ERROR_UNKNOWN; } + targetDirs = paths; } else { __pm->setAppRootPath(rootPath); @@ -1149,12 +1111,10 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) opt->flags &= ~NI_FLAGS_APP_UNDER_RO_AREA; } - // create native image under bin and lib directory - // tac directory is skipped in the createNIUnderDirs. - ret = createNIUnderDirs(__pm->getAppPaths(), opt); + targetDirs = __pm->getAppPaths(); } - return ret; + return createNIUnderDirs(targetDirs, opt); } void removeNIPlatform() diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index f91ca65..a60b53c 100644 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -837,9 +837,15 @@ int pkgmgrPkgMDFilterForeach(pkgmgrinfo_pkginfo_metadata_filter_h handle, pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data) { + uid_t uid = 0; int ret = 0; - ret = pkgmgrinfo_pkginfo_metadata_filter_foreach(handle, pkg_cb, user_data); + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + _ERR("Failed to get UID"); + return -1; + } + + ret = pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(handle, pkg_cb, user_data, uid); if (ret != PMINFO_R_OK) { _ERR("Failed to execute the metadata filter query (%d)", ret); return -1;