diff options
author | j-h.choi <j-h.choi@samsung.com> | 2019-06-27 15:12:06 +0900 |
---|---|---|
committer | j-h.choi <j-h.choi@samsung.com> | 2019-07-03 13:51:24 +0900 |
commit | 138cbf1d1c46ffc57113cd3b8a17ff9f27c6fa3f (patch) | |
tree | 0e725c4a62555e00597ca6388fbc79003db78920 /NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc | |
parent | 3fc2c466691432ad97689fb1ee326db222973666 (diff) | |
download | launcher-138cbf1d1c46ffc57113cd3b8a17ff9f27c6fa3f.tar.gz launcher-138cbf1d1c46ffc57113cd3b8a17ff9f27c6fa3f.tar.bz2 launcher-138cbf1d1c46ffc57113cd3b8a17ff9f27c6fa3f.zip |
Add define for TAC in launcher_env.h
Diffstat (limited to 'NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc')
-rw-r--r-- | NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc index ffed938..0ba9d90 100644 --- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc @@ -18,15 +18,16 @@ #include "log.h" #include "utils.h" -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "NETCORE_INSTALLER_PLUGIN" - #include <cstring> #include <vector> #include <sstream> #include <glib.h> +#include <pkgmgr_installer_info.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "DOTNET_INSTALLER_PLUGIN" typedef struct Metadata { const char *key; @@ -41,7 +42,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app tag = g_list_first(list); while (tag) { mdInfo = (Metadata*)tag->data; - if (strcmp(mdInfo->key, AOT_METADATA_KEY) == 0 && strcmp(mdInfo->value, AOT_METADATA_VALUE) == 0) { + if (strcmp(mdInfo->key, AOT_METADATA_KEY) == 0 && strcmp(mdInfo->value, METADATA_VALUE) == 0) { _DBG("Prefer dotnet application AOT set TRUE"); mdValue = true; } @@ -61,6 +62,44 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app } else { _INFO("Complete make application to native image"); } + + std::string pkgRoot; + if (getRootPath(pkgId, pkgRoot) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId); + return -1; + } + + 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) { + _ERR("Failed to get UID"); + return -1; + } + for (auto& symlinkAssembly : bf::recursive_directory_iterator(bf::path(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(createNiDll(originPath, false) != NI_ERROR_NONE) { + _ERR("Failed to create NI file [%s]\n", 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); + fprintf(stderr, "%s symbolic link file generated successfully.\n", setNiPath.c_str()); + if (lchown(setNiPath.c_str(), uid, 0)) { + _ERR("Failed to change owner of: %s", setNiPath.c_str()); + return -1; + } + } + } + } + } } return 0; } |