summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCho Woong Suk <ws77.cho@samsung.com>2017-06-15 16:00:25 +0900
committerCho Woong Suk <ws77.cho@samsung.com>2017-06-15 16:00:25 +0900
commit05e74b0f439327ff661ebce1208deb8b5aa43889 (patch)
tree0e254373b6903233358b55acfa3de2d8270e0ec0
parentcfef9f11cffb8b2a8e8963042b783776c38edac1 (diff)
downloadlauncher-05e74b0f439327ff661ebce1208deb8b5aa43889.tar.gz
launcher-05e74b0f439327ff661ebce1208deb8b5aa43889.tar.bz2
launcher-05e74b0f439327ff661ebce1208deb8b5aa43889.zip
Change-Id: I441626207f77e1de9e6e376668de7bedf064f978
-rw-r--r--NativeLauncher/installer-plugin/common.cc111
1 files changed, 69 insertions, 42 deletions
diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc
index fe89609..8ba2a09 100644
--- a/NativeLauncher/installer-plugin/common.cc
+++ b/NativeLauncher/installer-plugin/common.cc
@@ -33,6 +33,7 @@
#include <grp.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <string.h>
#include "common.h"
@@ -62,10 +63,8 @@ static const char* __JIT_PATH = __STR(RUNTIME_DIR)"/libclrjit.so";
#undef __STR
#undef __XSTR
-static void crossgen(const char* dllPath, const char* appPath);
-static void smack_(const char* dllPath, const char* label);
-std::string replace(std::string &str, const std::string& from, const std::string& to)
+static std::string replace(std::string &str, const std::string& from, const std::string& to)
{
size_t startPos = 0;
while ((startPos = str.find(from, startPos)) != std::string::npos) {
@@ -75,45 +74,6 @@ std::string replace(std::string &str, const std::string& from, const std::string
return str;
}
-void createNiPlatform()
-{
- std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
- std::string niCoreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.ni.dll");
-
- if (fileNotExist(niCoreLib)) {
- crossgen(coreLib.c_str(), nullptr);
- smack_(niCoreLib.c_str(), "_");
- }
-
- const char* platformDirs[] = {__RUNTIME_DIR, __DEVICE_API_DIR, "/usr/bin"};
- const char* ignores[] = {coreLib.c_str()};
-
- createNiUnderDirs(platformDirs, 3, ignores, 1, [](const char* ni) {
- smack_(ni, "_");
- });
-}
-
-void createNiSelect(const char* dllPath)
-{
- std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
- std::string niCoreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.ni.dll");
-
- if (fileNotExist(niCoreLib)) {
- crossgen(coreLib.c_str(), nullptr);
- smack_(niCoreLib.c_str(), "_");
- }
-
- if (!fileNotExist(dllPath)) {
- std::string strPath = dllPath;
- std::string niPath = replace(strPath, std::string(".dll"), std::string(".ni.dll"));
- if (fileNotExist(niPath))
- crossgen(dllPath, nullptr);
- else
- printf("Already [%s] file is exist\n", niPath.c_str());
- smack_(niPath.c_str(), "_");
- }
-}
-
static void smack_(const char* dllPath, const char* label)
{
static const char* chsmack = "/usr/bin/chsmack";
@@ -236,6 +196,17 @@ static int getRootPath(const char *pkgId, std::string& rootPath)
static bool niExist(const std::string& path, std::string& ni)
{
+ // native image of System.Private.CoreLib.dll should have to overwrite
+ // original file to support new coreclr
+ if (path.find("System.Private.CoreLib.dll") != std::string::npos) {
+ std::string coreLibBackup = path + ".Backup";
+ if (!fileNotExist(coreLibBackup)) {
+ ni = path;
+ return true;
+ }
+ return false;
+ }
+
static const char* possibleExts[] = {
".ni.dll", ".NI.dll", ".NI.DLL", ".ni.DLL",
".ni.exe", ".NI.exe", ".NI.EXE", ".ni.EXE"
@@ -255,6 +226,62 @@ static bool niExist(const std::string& path, std::string& ni)
return false;
}
+static void createCoreLibNI()
+{
+ std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
+ std::string niCoreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.ni.dll");
+ std::string coreLibBackup = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll.Backup");
+
+ if (!niExist(coreLib, niCoreLib)) {
+ crossgen(coreLib.c_str(), nullptr);
+ if (!fileNotExist(niCoreLib)) {
+ // change owner and groups for generated ni file.
+ struct stat info;
+ if (!stat(coreLib.c_str(), &info)) {
+ if (chown(niCoreLib.c_str(), info.st_uid, info.st_gid) == -1)
+ _ERR("Failed to change owner and group name");
+ }
+ smack_(niCoreLib.c_str(), "_");
+ rename(coreLib.c_str(), coreLibBackup.c_str());
+ rename(niCoreLib.c_str(), coreLib.c_str());
+ }
+ }
+}
+
+void createNiPlatform()
+{
+ createCoreLibNI();
+
+ const char* platformDirs[] = {__RUNTIME_DIR, __DEVICE_API_DIR, "/usr/bin"};
+
+ createNiUnderDirs(platformDirs, 3, [](const char* ni) {
+ smack_(ni, "_");
+ });
+}
+
+void createNiSelect(const char* dllPath)
+{
+ createCoreLibNI();
+
+ std::string niPath;
+ if (!fileNotExist(dllPath)) {
+ if (!niExist(dllPath, niPath)) {
+ crossgen(dllPath, nullptr);
+ if (niExist(dllPath, niPath)) {
+ // change owner and groups for generated ni file.
+ struct stat info;
+ if (!stat(dllPath, &info)) {
+ if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
+ _ERR("Failed to change owner and group name");
+ }
+ smack_(niPath.c_str(), "_");
+ }
+ }
+ else
+ printf("Already [%s] file is exist\n", niPath.c_str());
+ }
+}
+
void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb)
{
std::string appPaths;