Change implementation of regeneratePkgNI
authorWoongsuk Cho <ws77.cho@samsung.com>
Mon, 5 Feb 2024 01:08:27 +0000 (10:08 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Mon, 19 Feb 2024 21:27:33 +0000 (06:27 +0900)
NativeLauncher/inc/utils.h
NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
NativeLauncher/tool/ni_common.cc
NativeLauncher/util/utils.cc

index 7a3f33b..dca091f 100644 (file)
@@ -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);
 
index bfe3afb..739d2b4 100644 (file)
@@ -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);
        }
index d6515e8..6ab3e10 100644 (file)
@@ -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()
index f91ca65..a60b53c 100644 (file)
@@ -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;