X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=NativeLauncher%2Finstaller-plugin%2Fprefer_dotnet_aot_plugin.cc;h=91928a7fa9a55ee777626cae7bef8337de19ff01;hb=546f3a3947b7e7c205a4799156bcd41bc5ae3c2e;hp=9e09ad105e1350cd57e49db03860bca0b08e819c;hpb=9c2a1ac81c620fb58024a88f0075bcf446da6623;p=platform%2Fcore%2Fdotnet%2Flauncher.git diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc index 9e09ad1..91928a7 100644 --- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc @@ -20,7 +20,8 @@ #include #include -#include + +#include #include #include @@ -29,12 +30,8 @@ #endif #define LOG_TAG "DOTNET_INSTALLER_PLUGIN" -typedef struct Metadata { - const char *key; - const char *value; -} Metadata; - bool aotPluginInstalled = false; +bool aotPluginFinished = false; extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list) { @@ -53,76 +50,32 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app } } - GList *tag = NULL; - bool mdValue = false; - Metadata *mdInfo = NULL; - tag = g_list_first(list); - while (tag) { - mdInfo = (Metadata*)tag->data; - if (strcmp(mdInfo->key, AOT_METADATA_KEY) == 0 && strcmp(mdInfo->value, METADATA_VALUE) == 0) { - _DBG("Prefer dotnet application AOT set TRUE"); - mdValue = true; - } - tag = g_list_next(tag); + std::string metaValue = getMetadataValue(std::string(pkgId), AOT_METADATA_KEY); + if (metaValue.empty()) { + _ERR("Failed to get metadata from [%s]", pkgId); + return -1; } - if (mdValue) { - NiCommonOption option = {std::string(), std::string(), std::string()}; - if (initNICommon(&option) < 0) { + if (metaValue == METADATA_VALUE_TRUE) { + _DBG("Prefer dotnet application AOT set TRUE"); + + if (initNICommon() != NI_ERROR_NONE) { _ERR("Fail to initialize NI Common"); return -1; } - if (createNiUnderPkgRoot(pkgId, 0) != NI_ERROR_NONE) { - _ERR("Failed to get root path from [%s]", pkgId); + NIOption* opt = getNIOption(); + if (opt == nullptr) { + _ERR("Fail to create option structure."); return -1; - } else { - _INFO("Complete make application to native image"); } - std::string pkgRoot; - if (getRootPath(pkgId, pkgRoot) < 0) { - _ERR("Failed to get root path from [%s]", pkgId); - return 0; + if (createNIUnderPkgRoot(pkgId, opt) != NI_ERROR_NONE) { + _ERR("Failed to generate application to native image [%s]", pkgId); + return -1; } - std::string binDir = concatPath(pkgRoot, "bin"); - std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR); - if (bf::exists(tacDir)) { - 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; - } - try { - for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) { - std::string symPath = symlinkAssembly.path().string(); - if (!isNativeImage(symPath)) { - std::string originPath = bf::read_symlink(symPath).string(); - std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll"; - if (!bf::exists(originNiPath)) { - if(createNiDllUnderPkgRoot(pkgId, originPath, 0) != NI_ERROR_NONE) { - _ERR("Failed to create NI file [%s]", originPath.c_str()); - return -1; - } - } - std::string setNiPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll"; - if (!bf::exists(setNiPath)) { - bf::create_symlink(originNiPath, setNiPath); - _INFO("%s symbolic link file generated successfully.", setNiPath.c_str()); - if (lchown(setNiPath.c_str(), g_uid, g_gid)) { - _ERR("Failed to change owner of: %s", setNiPath.c_str()); - return -1; - } - } - } - } - } catch (const bf::filesystem_error& error) { - _ERR("File system error while interating files: %s", error.what()); - return -1; - } - } + _INFO("Complete make application to native image"); } return 0; } @@ -144,10 +97,26 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_REMOVED(const char *pkgId, const char *app extern "C" int PKGMGR_MDPARSER_PLUGIN_CLEAN(const char *pkgId, const char *appId, GList *list) { + // Can be multiple apps in one package + if (aotPluginFinished) { + _INFO("AOT plugin already finished(CLEAN)"); + return 0; + } + aotPluginFinished = true; + + finalizeNICommon(); return 0; } extern "C" int PKGMGR_MDPARSER_PLUGIN_UNDO(const char *pkgId, const char *appId, GList *list) { + // Can be multiple apps in one package + if (aotPluginFinished) { + _INFO("AOT plugin already finished(UNDO)"); + return 0; + } + aotPluginFinished = true; + + finalizeNICommon(); return 0; }