Add flags to the install plugin to avoid duplicate execution
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / prefer_dotnet_aot_plugin.cc
index 3801a84..9e09ad1 100644 (file)
@@ -34,8 +34,25 @@ typedef struct Metadata {
        const char *value;
 } Metadata;
 
+bool aotPluginInstalled = false;
+
 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
 {
+       // Can be multiple apps in one package
+       if (aotPluginInstalled) {
+               _INFO("AOT plugin already installed");
+               return 0;
+       }
+       aotPluginInstalled = true;
+
+       int skipOpt = false;
+       if (!pkgmgr_installer_info_get_skip_optimization(&skipOpt)) {
+               if (skipOpt) {
+                       _DBG("Skip dotnet AOT");
+                       return 0;
+               }
+       }
+
        GList *tag = NULL;
        bool mdValue = false;
        Metadata *mdInfo = NULL;
@@ -72,8 +89,9 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
                std::string binDir = concatPath(pkgRoot, "bin");
                std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
                if (bf::exists(tacDir)) {
-                       uid_t uid = 0;
-                       if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
+                       uid_t g_uid = 0;
+                       gid_t g_gid = 0;
+                       if (pkgmgr_installer_info_get_target_uid(&g_uid) < 0) {
                                _ERR("Failed to get UID");
                                return 0;
                        }
@@ -93,7 +111,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
                                                if (!bf::exists(setNiPath)) {
                                                        bf::create_symlink(originNiPath, setNiPath);
                                                        _INFO("%s symbolic link file generated successfully.", setNiPath.c_str());
-                                                       if (lchown(setNiPath.c_str(), uid, 0)) {
+                                                       if (lchown(setNiPath.c_str(), g_uid, g_gid)) {
                                                                _ERR("Failed to change owner of: %s", setNiPath.c_str());
                                                                return -1;
                                                        }