Added logic to recover when db file is corrupted.
authorj-h.choi <j-h.choi@samsung.com>
Thu, 26 Sep 2019 01:01:20 +0000 (10:01 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Wed, 9 Oct 2019 22:37:39 +0000 (07:37 +0900)
13 files changed:
NativeLauncher/CMakeLists.txt
NativeLauncher/inc/db_manager.h
NativeLauncher/inc/ni_common.h
NativeLauncher/inc/tac_common.h
NativeLauncher/inc/utils.h
NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc
NativeLauncher/tool/dotnettool.cc
NativeLauncher/tool/ni_common.cc
NativeLauncher/tool/tac_common.cc
NativeLauncher/tool/tpatool.cc
NativeLauncher/util/db_manager.cc
NativeLauncher/util/utils.cc
packaging/dotnet-launcher.spec

index 4474d51dd38ac14db589fb1b13162e308a1be3b4..97d8eff37bcdc0e3072f85855b3d2d14bfc12202 100644 (file)
@@ -90,7 +90,6 @@ SET(${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES
     util/plugin_manager.cc
     util/path_manager.cc
     util/log_manager.cc
-    util/db_manager.cc
 )
 ADD_LIBRARY(${DOTNET_LAUNCHER_UTIL} SHARED ${${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER_UTIL} PROPERTIES COMPILE_FLAGS "-fPIC")
@@ -111,14 +110,22 @@ SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER}
     PROPERTIES SKIP_BUILD_RPATH TRUE
 ) # remove rpath option that is automatically generated by cmake.
 
+SET(TAC_COMMON "tac_common")
+SET(${TAC_COMMON}_SOURCE_FILES
+    tool/tac_common.cc
+    util/db_manager.cc
+)
+ADD_LIBRARY(${TAC_COMMON} SHARED ${${TAC_COMMON}_SOURCE_FILES})
+SET_TARGET_PROPERTIES(${TAC_COMMON} PROPERTIES COMPILE_FLAGS "-fPIC")
+TARGET_LINK_LIBRARIES(${TAC_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL})
+
 SET(NI_COMMON "ni_common")
 SET(${NI_COMMON}_SOURCE_FILES
     tool/ni_common.cc
-    tool/tac_common.cc
 )
 ADD_LIBRARY(${NI_COMMON} SHARED ${${NI_COMMON}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${NI_COMMON} PROPERTIES COMPILE_FLAGS "-fPIC")
-TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL})
+TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON})
 
 SET(NITOOL "nitool")
 SET(${NITOOL}_SOURCE_FILES
@@ -158,12 +165,13 @@ SET(${PREFER_NUGET_CACHE_PLUGIN}_SOURCE_FILES
 )
 ADD_LIBRARY(${PREFER_NUGET_CACHE_PLUGIN} SHARED ${${PREFER_NUGET_CACHE_PLUGIN}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${PREFER_NUGET_CACHE_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC")
-TARGET_LINK_LIBRARIES(${PREFER_NUGET_CACHE_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL})
+TARGET_LINK_LIBRARIES(${PREFER_NUGET_CACHE_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON})
 
 CONFIGURE_FILE(dotnet-launcher.pc.in dotnet-launcher.pc @ONLY)
 
 INSTALL(TARGETS ${DOTNET_LAUNCHER_UTIL} DESTINATION ${LIBDIR})
 INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR})
+INSTALL(TARGETS ${TAC_COMMON} DESTINATION ${LIBDIR})
 INSTALL(TARGETS ${NI_COMMON} DESTINATION ${LIBDIR})
 INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR})
 INSTALL(TARGETS ${TPATOOL} DESTINATION ${BINDIR})
index 59c23d51236d658329459fa7a80ae86db0c6ff0f..afae883fac26f81cc6f4e29e1f67409c8eb15661 100644 (file)
@@ -30,7 +30,7 @@
 #define QUERY_MAX_LEN  4096
 
 sqlite3* dbCreate(std::string path);
-bool dbOpen(sqlite3 *tac_db, std::string path);
+sqlite3* dbOpen(std::string path);
 void dbClose(sqlite3 *tac_db);
 void dbRollback(sqlite3 *tac_db);
 bool dbUpdate(sqlite3 *tac_db, std::string path, std::string query);
index ed882827637e6410c6579662aae5abdbc7df46d8..31a679a850f54fa8be7e6585cea47afc0953599f 100644 (file)
@@ -88,6 +88,13 @@ ni_error_e createNiDll(const std::string& dllPath, DWORD flags);
  */
 void createNiUnderTAC(const std::string rootPaths[], int count, DWORD flags);
 
+/**
+ * @brief creates a symbolic link file, the native image of TAC for specific package.
+ * @param[i] pkgId package ID
+ * @return ni_error_e
+ */
+ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags);
+
 /**
  * @brief create native images for all DLLs under directories
  * @param[i] rootPaths paths to directories
@@ -138,4 +145,10 @@ ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
  */
 ni_error_e regenerateAppNI(DWORD flags);
 
+/**
+ * @brief regenerate native image of TAC for all shared assembly.
+ * @return ni_error_e
+ */
+ni_error_e regenerateTACNI(DWORD flags);
+
 #endif /* __NI_COMMON_H__ */
index 26e3edfe3172d7f66726d62f9ace634441a2ecad..88d4bd5fce3bf017bb9faf452b15445d983564b0 100644 (file)
 
 #include <functional>
 
+#ifndef DWORD
+#define DWORD uint32_t
+#endif
+
 typedef enum {
        TAC_ERROR_NONE = 0,
        TAC_ERROR_INVALID_PARAMETER = -1,
@@ -42,19 +46,6 @@ tac_error_e restoreTACDB();
  */
 tac_error_e resetTACPackage(const std::string& pkgId);
 
-/**
- * @brief creates a symbolic link file, the native image of TAC for specific package.
- * @param[i] pkgId package ID
- * @return tac_error_e
- */
-tac_error_e createTACPackage(const std::string& pkgId, DWORD flags);
-
-/**
- * @brief regenerate native image of TAC for all shared assembly.
- * @return tac_error_e
- */
-tac_error_e regenerateTAC(DWORD flags);
-
 /**
  * @brief disable tac feature.
  * @param[i] pkgId package ID
@@ -69,4 +60,13 @@ tac_error_e disableTACPackage(const std::string& pkgId);
  */
 tac_error_e enableTACPackage(const std::string& pkgId);
 
+/**
+ * @brief .deps.json file parser
+ * @param[in] root path
+ * @param[in] exec name
+ * @param[in] tpa list
+ * @return std::vector<std::string> parser data
+ */
+std::vector<std::string> depsJsonParser(std::string rootPath, std::string execName, std::string tpaList);
+
 #endif /* __TAC_COMMON_H__ */
index 40db9d80befaf8dc5f17ee530f02b81922c0f6b9..c894c45647a4226653ef4982e8a7008aece8500d 100644 (file)
@@ -216,13 +216,4 @@ bool removeFile(const bf::path& path);
  */
 bool removeAll(const bf::path& path);
 
-/**
- * @brief .deps.json file parser
- * @param[in] root path
- * @param[in] exec name
- * @param[in] tpa list
- * return std::vector<std::string> parser data
- */
-std::vector<std::string> depsJsonParser(std::string rootPath, std::string execName, std::string tpaList);
-
 #endif /* __UTILS_H__ */
index 433766f01608d2babe2b5a4a98a137c7885e67fa..9e6c06b63a2bbcba1d520411208f8dd4c72bdd9c 100644 (file)
@@ -19,6 +19,7 @@
 #include "db_manager.h"
 #include "path_manager.h"
 #include "plugin_manager.h"
+#include "tac_common.h"
 
 #include <cstring>
 #include <fstream>
@@ -55,7 +56,6 @@ std::string status = "";
 std::string rootPath;
 std::string execName;
 std::string binPath;
-bool isCreateDirectory = false;
 static sqlite3 *tac_db = NULL;
 
 bool metadataCheck(GList *list)
@@ -149,7 +149,7 @@ void SHA256(std::string path, char outputBuffer[65])
        free(buffer);
 }
 
-int createSymlink(std::string tac_version_dir, std::string np)
+int copyNCreateSymlink(std::string tac_version_dir, std::string np, bool is_create_tac_dir)
 {
        uid_t uid = 0;
        if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
@@ -169,7 +169,7 @@ int createSymlink(std::string tac_version_dir, std::string np)
                std::string assembly = nuget_package_assembly.substr(nuget_package_assembly.rfind(':') + 1);
                if (!strcmp(nuget_package.c_str(), np.c_str())) {
                        if (bf::exists(concatPath(binPath, assembly))) {
-                               if (isCreateDirectory) {
+                               if (is_create_tac_dir) {
                                        if (!copyFile(concatPath(binPath, assembly), concatPath(tac_version_dir, assembly))) {
                                                _ERR("Failed to copy of %s", assembly.c_str());
                                                return -1;
@@ -227,12 +227,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
 
        status = "install";
        tac_db = dbCreate(TAC_APP_LIST_DB);
-       if (tac_db) {
-               if (!dbOpen(tac_db, TAC_APP_LIST_DB)) {
-                       _ERR("Sqlite open error");
-                       return 0;
-               }
-       } else {
+       if (!tac_db) {
                _ERR("Sqlite create error");
                return 0;
        }
@@ -250,14 +245,12 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
 
                std::string tac_version_dir = concatPath(__TAC_DIR, np);
                std::string sha256_info = concatPath(tac_version_dir, TAC_SHA_256_INFO);
-               isCreateDirectory = false;
                if (!bf::exists(tac_version_dir)) {
                        _INFO("Create tac_version_dir [%s]", tac_version_dir.c_str());
                        if (!createDir(tac_version_dir)) {
                                _ERR("Cannot create directory: %s", tac_version_dir.c_str());
                                return 0;
                        }
-                       isCreateDirectory = true;
                        createDirectories.push_back(tac_version_dir);
                        std::ofstream ofs(sha256_info, std::ios::app);
                        int assembly_count = 0;
@@ -274,7 +267,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
                        ofs << assembly_count << std::endl;
                        ofs.close();
 
-                       if (createSymlink(tac_version_dir, np) < 0) {
+                       if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
                                _ERR("Failed to create symlink");
                                return -1;
                        }
@@ -309,7 +302,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
                        if (!strcmp(std::to_string(assembly_count).c_str(), std::to_string(compare_count).c_str()) &&
                                !strcmp(std::to_string(assembly_count).c_str(), sha256_count.c_str())) {
                                _INFO("Same nuget : %s", np.c_str());
-                               if (createSymlink(tac_version_dir, np) < 0) {
+                               if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
                                        _ERR("Failed to create symlink");
                                        return -1;
                                }
@@ -339,15 +332,6 @@ int updateTacDB(const char *pkgId)
 {
        for (auto& unp : updateTac) {
                int count = -1;
-               if (tac_db) {
-                       if (!dbOpen(tac_db, TAC_APP_LIST_DB)) {
-                               _ERR("Sqlite open error");
-                               return -1;
-                       }
-               } else {
-                       _ERR("Sqlite create error");
-                       return -1;
-               }
                std::string sql = "SELECT COUNT(NUGET) FROM TAC WHERE NUGET = '" + unp + "';";
                int ret = sqlite3_exec(tac_db, sql.c_str(), sqliteCb, &count, NULL);
                if (ret != SQLITE_OK) {
@@ -397,26 +381,21 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
 
        status = "update";
        tac_db = dbCreate(TAC_APP_LIST_DB);
-       if (tac_db) {
-               if (!dbOpen(tac_db, TAC_APP_LIST_DB)) {
-                       _ERR("Sqlite open error");
-                       return 0;
-               }
-       } else {
-               _ERR("Sqlite create error");
+       if (!tac_db) {
+               _ERR("Sqlite open error");
                return 0;
        }
 
-       std::string sql = "SELECT * FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
-       updateTac = dbSelect(tac_db, TAC_APP_LIST_DB, sql);
-
        if (tacDB.empty()) {
-               sql = "DELETE FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+               std::string sql = "DELETE FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
                dbDelete(tac_db, TAC_APP_LIST_DB, sql);
                if (updateTacDB(pkgId) < 0) {
                        return -1;
                }
        } else {
+               std::string sql = "SELECT * FROM TAC WHERE PKGID = '" + std::string(pkgId) + "';";
+               updateTac = dbSelect(tac_db, TAC_APP_LIST_DB, sql);
+
                for (auto& np : tacDB) {
                        std::string tac_name = np.substr(0, np.find('/'));
                        std::string tac_version = np.substr(np.rfind('/') + 1);
@@ -425,14 +404,12 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
 
                        std::string tac_version_dir = concatPath(__TAC_DIR, np);
                        std::string sha256_info = concatPath(tac_version_dir, TAC_SHA_256_INFO);
-                       isCreateDirectory = false;
                        if (!bf::exists(tac_version_dir)) {
                                _INFO("Create tac_version_dir [%s]", tac_version_dir.c_str());
                                if (!createDir(tac_version_dir)) {
                                        _ERR("Cannot create directory: %s", tac_version_dir.c_str());
                                        return 0;
                                }
-                               isCreateDirectory = true;
                                createDirectories.push_back(tac_version_dir);
                                std::ofstream ofs(sha256_info, std::ios::app);
                                int assembly_count = 0;
@@ -448,7 +425,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
                                }
                                ofs << assembly_count << std::endl;
                                ofs.close();
-                               if (createSymlink(tac_version_dir, np) < 0) {
+                               if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
                                        _ERR("Failed to create symlink");
                                        return -1;
                                }
@@ -497,7 +474,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app
                                if (!strcmp(std::to_string(assembly_count).c_str(), std::to_string(compare_count).c_str()) &&
                                        !strcmp(std::to_string(assembly_count).c_str(), sha256_count.c_str())) {
                                        _INFO("Same nuget : %s", np.c_str());
-                                       if (createSymlink(tac_version_dir, np) < 0) {
+                                       if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
                                                _ERR("Failed to create symlink");
                                                return -1;
                                        }
@@ -553,14 +530,9 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgId, const char *a
        _INFO("PackageID : %s", pkgId);
 
        status = "uninstall";
-       tac_db = dbCreate(TAC_APP_LIST_DB);
-       if (tac_db) {
-               if (!dbOpen(tac_db, TAC_APP_LIST_DB)) {
-                       _ERR("Sqlite open error");
-                       return 0;
-               }
-       } else {
-               _ERR("Sqlite create error");
+       tac_db = dbOpen(TAC_APP_LIST_DB);
+       if (!tac_db) {
+               _ERR("Sqlite open error");
                return 0;
        }
 
index 5c3f6e84a0baef21d4c8882356a3d4f24ff5fc6b..3699372fd92cd480334a816029d67ed563b17463 100644 (file)
@@ -138,7 +138,7 @@ int main(int argc, char* argv[])
                regenerateAppNI(flags);
                return 0;
        } else if (cmdOptionExists(argv, argv+argc, "--tac-regen-all")) {
-               regenerateTAC(flags);
+               regenerateTACNI(flags);
                return 0;
        } else if (cmdOptionExists(argv, argv+argc, "--tac-restore-db")) {
                restoreTACDB();
@@ -181,7 +181,7 @@ int main(int argc, char* argv[])
                                fprintf(stderr, "Failed to generate NI file [%s]\n", pkg.c_str());
                                return -1;
                        }
-                       ret = createTACPackage(pkg, flags);
+                       ret = createTACPkgRoot(pkg, flags);
                        if (ret == TAC_ERROR_INVALID_PACKAGE) {
                                fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
                                return -1;
index ffe7b48628028c40deb4d0a1c81b58c13331ed40..d31e7d14bcbc549c9d4cc317204da2de9f4173bc 100644 (file)
@@ -363,7 +363,7 @@ static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
                fprintf(stderr, "Complete make application to native image\n");
        }
 
-       if (createTACPackage(pkgId, *pFlags) != TAC_ERROR_NONE) {
+       if (createTACPkgRoot(pkgId, *pFlags) != NI_ERROR_NONE) {
                fprintf(stderr, "Failed to generate symbolic link file [%s]\n", pkgId);
                return -1;
        }else {
@@ -483,11 +483,58 @@ void createNiUnderTAC(const std::string rootPaths[], int count, DWORD flags)
                        scanFilesInDir(rootPaths[i], convert, -1);
                }
        } catch (const bf::filesystem_error& error) {
-               fprintf(stderr, "Failed to recursive directory: %s", error.what());
+               fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
                return;
        }
 }
 
+ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags)
+{
+       std::string pkgRoot;
+       if (getRootPath(pkgId, pkgRoot) < 0) {
+               return NI_ERROR_INVALID_PACKAGE;
+       }
+
+       std::string binDir = concatPath(pkgRoot, "bin");
+       std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
+       std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
+       if (bf::exists(tacDir)) {
+               try {
+                       for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
+                               std::string symPath = symlinkAssembly.path().string();
+                               if (bf::is_symlink(symPath)) {
+                                       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, flags) != NI_ERROR_NONE) {
+                                                               fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
+                                                               return NI_ERROR_UNKNOWN;
+                                                       }
+                                               }
+                                               std::string symNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
+                                               if (!bf::exists(symNIPath)) {
+                                                       bf::create_symlink(originNiPath, symNIPath);
+                                                       fprintf(stderr, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
+                                                       updateAssemblyInfo(tacDir.c_str(), symNIPath.c_str(), true);
+
+                                                       std::string NIFileName = symNIPath.substr(symNIPath.rfind('/') + 1);
+                                                       if (!removeFile(concatPath(binNIDir, NIFileName))) {
+                                                               fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, NIFileName).c_str());
+                                                               return NI_ERROR_UNKNOWN;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } catch (const bf::filesystem_error& error) {
+                       fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
+                       return NI_ERROR_UNKNOWN;
+               }
+       }
+       return NI_ERROR_NONE;
+}
+
 void createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags)
 {
        createCoreLibNI(flags);
@@ -705,3 +752,11 @@ ni_error_e regenerateAppNI(DWORD flags)
        pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
        return NI_ERROR_NONE;
 }
+
+ni_error_e regenerateTACNI(DWORD flags)
+{
+       const std::string tacDir[] = {__TAC_DIR};
+       removeNiUnderDirs(tacDir, 1);
+       createNiUnderTAC(tacDir, 1, flags);
+       return NI_ERROR_NONE;
+}
index 1614e77b872595cb15ce90dd654a21052e47890c..19250e783f41b698062f1d59274e723a75cb37de 100644 (file)
  */
 
 #include <fstream>
+#include <json/json.h>
 #include <pkgmgr-info.h>
 #include <pkgmgr_installer_info.h>
 
 #include "log.h"
 #include "utils.h"
-#include "ni_common.h"
 #include "tac_common.h"
 #include "db_manager.h"
 #include "path_manager.h"
@@ -37,20 +37,21 @@ static const char* __TAC_DIR = __STR(TAC_DIR);
 #undef __XSTR
 
 static sqlite3 *tac_db = NULL;
-std::vector<std::string> restoreNuget;
+std::vector<std::string> restore_nuget;
 
-void cleanupDirectory()
+static void cleanupDirectory()
 {
        std::vector<std::string> removeNuget;
        try {
                for (auto& nuget : bf::recursive_directory_iterator(__TAC_DIR)) {
                        bool isExist = false;
                        std::string nugetPath = nuget.path().string();
-                       for (auto& restore : restoreNuget) {
+                       for (auto& restore : restore_nuget) {
                                if (!bf::is_directory(nugetPath)) {
                                        isExist = true;
                                }
-                               if (strstr(nugetPath.c_str(), restore.c_str()) != NULL) {
+                               if (!strcmp(nugetPath.c_str(), restore.c_str()) ||
+                                       !strcmp(nugetPath.c_str(), restore.substr(0, restore.rfind('/')).c_str())) {
                                        isExist = true;
                                        break;
                                }
@@ -62,12 +63,12 @@ void cleanupDirectory()
 
                for (auto& rm : removeNuget) {
                        if (!removeAll(rm)) {
-                               _ERR("Failed to remove of %s", rm.c_str());
+                               fprintf(stderr, "Failed to remove of %s\n", rm.c_str());
                        }
                }
                removeNuget.clear();
        } catch (const bf::filesystem_error& error) {
-               _ERR("Failed to recursive directory: %s", error.what());
+               fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
                return;
        }
 }
@@ -116,7 +117,7 @@ static int restoreDBCb(pkgmgrinfo_appinfo_h handle, void *userData)
                        std::string sql = "INSERT INTO TAC (PKGID, NUGET, NAME, VERSION) " \
                                                "VALUES ('" + std::string(pkgId) + "', '" + nuget + "', '" + name + "', '" + version + "');";
                        dbInsert(tac_db, TAC_APP_LIST_RESTORE_DB, sql);
-                       restoreNuget.push_back(concatPath(__TAC_DIR, name));
+                       restore_nuget.push_back(concatPath(__TAC_DIR, nuget));
                }
        }
        parserData.clear();
@@ -126,27 +127,24 @@ static int restoreDBCb(pkgmgrinfo_appinfo_h handle, void *userData)
 tac_error_e restoreTACDB()
 {
        if (!removeFile(TAC_APP_LIST_RESTORE_DB)) {
-               fprintf(stderr, "Failed to remove of %s", TAC_APP_LIST_RESTORE_DB);
+               fprintf(stderr, "Failed to remove of %s\n", TAC_APP_LIST_RESTORE_DB);
                return TAC_ERROR_UNKNOWN;
        }
 
        std::string dbRestoreJournal = TAC_APP_LIST_RESTORE_DB + std::string("-journal");
        if (!removeFile(dbRestoreJournal)) {
-               fprintf(stderr, "Failed to remove of %s", dbRestoreJournal.c_str());
+               fprintf(stderr, "Failed to remove of %s\n", dbRestoreJournal.c_str());
                return TAC_ERROR_UNKNOWN;
        }
 
        if (initializePathManager(std::string(), std::string(), std::string())) {
-               fprintf(stderr, "Fail to initialize PathManger");
+               fprintf(stderr, "Fail to initialize PathManger\n");
                return TAC_ERROR_UNKNOWN;
        }
 
        tac_db = dbCreate(TAC_APP_LIST_RESTORE_DB);
-       if (tac_db) {
-               if (!dbOpen(tac_db, TAC_APP_LIST_RESTORE_DB)) {
-                       return TAC_ERROR_UNKNOWN;
-               }
-       } else {
+       if (!tac_db) {
+               fprintf(stderr, "Sqlite create error\n");
                return TAC_ERROR_UNKNOWN;
        }
 
@@ -178,21 +176,21 @@ tac_error_e restoreTACDB()
        }
 
        if (!copyFile(TAC_APP_LIST_RESTORE_DB, TAC_APP_LIST_DB)) {
-               fprintf(stderr, "Failed to copy of %s", TAC_APP_LIST_DB);
+               fprintf(stderr, "Failed to copy of %s\n", TAC_APP_LIST_DB);
                return TAC_ERROR_UNKNOWN;
        }
        if (!removeFile(TAC_APP_LIST_RESTORE_DB)) {
-               fprintf(stderr, "Failed to remove of %s", TAC_APP_LIST_RESTORE_DB);
+               fprintf(stderr, "Failed to remove of %s\n", TAC_APP_LIST_RESTORE_DB);
                return TAC_ERROR_UNKNOWN;
        }
 
        std::string dbJournal = TAC_APP_LIST_DB + std::string("-journal");
        if (!copyFile(dbRestoreJournal, dbJournal)) {
-               fprintf(stderr, "Failed to copy of %s", dbJournal.c_str());
+               fprintf(stderr, "Failed to copy of %s\n", dbJournal.c_str());
                return TAC_ERROR_UNKNOWN;
        }
        if (!removeFile(dbRestoreJournal)) {
-               fprintf(stderr, "Failed to remove of %s", dbRestoreJournal.c_str());
+               fprintf(stderr, "Failed to remove of %s\n", dbRestoreJournal.c_str());
                return TAC_ERROR_UNKNOWN;
        }
 
@@ -222,74 +220,19 @@ tac_error_e resetTACPackage(const std::string& pkgId)
                        }
                        for (auto& path : tacNativeImage) {
                                if (!removeFile(path)) {
-                                       fprintf(stderr, "Failed to remove of %s", path.c_str());
+                                       fprintf(stderr, "Failed to remove of %s\n", path.c_str());
                                        return TAC_ERROR_UNKNOWN;
                                }
                        }
                        tacNativeImage.clear();
                } catch (const bf::filesystem_error& error) {
-                       _ERR("Failed to recursive directory: %s", error.what());
+                       fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
                        return TAC_ERROR_UNKNOWN;
                }
        }
        return TAC_ERROR_NONE;
 }
 
-tac_error_e createTACPackage(const std::string& pkgId, DWORD flags)
-{
-       std::string pkgRoot;
-       if (getRootPath(pkgId, pkgRoot) < 0) {
-               return TAC_ERROR_INVALID_PACKAGE;
-       }
-
-       std::string binDir = concatPath(pkgRoot, "bin");
-       std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
-       std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
-       if (bf::exists(tacDir)) {
-               try {
-                       for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
-                               std::string symPath = symlinkAssembly.path().string();
-                               if (bf::is_symlink(symPath)) {
-                                       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, flags) != NI_ERROR_NONE) {
-                                                               fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
-                                                               return TAC_ERROR_UNKNOWN;
-                                                       }
-                                               }
-                                               std::string symNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
-                                               if (!bf::exists(symNIPath)) {
-                                                       bf::create_symlink(originNiPath, symNIPath);
-                                                       fprintf(stderr, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
-                                                       updateAssemblyInfo(tacDir.c_str(), symNIPath.c_str(), true);
-
-                                                       std::string NIFileName = symNIPath.substr(symNIPath.rfind('/') + 1);
-                                                       if (!removeFile(concatPath(binNIDir, NIFileName))) {
-                                                               fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, NIFileName).c_str());
-                                                               return TAC_ERROR_UNKNOWN;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               } catch (const bf::filesystem_error& error) {
-                       _ERR("Failed to recursive directory: %s", error.what());
-                       return TAC_ERROR_UNKNOWN;
-               }
-       }
-       return TAC_ERROR_NONE;
-}
-
-tac_error_e regenerateTAC(DWORD flags)
-{
-       const std::string tacDir[] = {__TAC_DIR};
-       removeNiUnderDirs(tacDir, 1);
-       createNiUnderTAC(tacDir, 1, flags);
-       return TAC_ERROR_NONE;
-}
-
 tac_error_e disableTACPackage(const std::string& pkgId)
 {
        std::string pkgRoot;
@@ -329,7 +272,7 @@ tac_error_e disableTACPackage(const std::string& pkgId)
                                return TAC_ERROR_UNKNOWN;
                        }
                } catch (const bf::filesystem_error& error) {
-                       _ERR("Failed to recursive directory: %s", error.what());
+                       fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
                        return TAC_ERROR_UNKNOWN;
                }
        }
@@ -354,7 +297,7 @@ tac_error_e enableTACPackage(const std::string& pkgId)
        }
 
        if (initializePathManager(std::string(), std::string(), std::string())) {
-               fprintf(stderr, "Fail to initialize PathManger");
+               fprintf(stderr, "Fail to initialize PathManger\n");
                return TAC_ERROR_UNKNOWN;
        }
 
@@ -411,7 +354,7 @@ tac_error_e enableTACPackage(const std::string& pkgId)
                        }
                        if (enableNuget.empty()) {
                                if (!removeAll(tacDir)) {
-                                       _ERR("Failed to remove of %s", tacDir.c_str());
+                                       fprintf(stderr, "Failed to remove of %s\n", tacDir.c_str());
                                }
                        }
                        enableNuget.clear();
@@ -421,3 +364,101 @@ tac_error_e enableTACPackage(const std::string& pkgId)
        }
        return TAC_ERROR_NONE;
 }
+
+//Parser the .deps.json file to get nuget information.
+std::vector<std::string> depsJsonParser(std::string rootPath, std::string execName, std::string tpaList)
+{
+       std::vector<std::string> tpaAssemblies;
+       splitPath(tpaList, tpaAssemblies);
+
+       std::vector<std::string> parserData;
+       std::string depsJsonName = execName.substr(0, execName.rfind(".dll")) + ".deps.json";
+       std::string depsJsonPath = concatPath(rootPath, depsJsonName);
+       try {
+               if (bf::exists(depsJsonPath)) {
+                       std::ifstream ifs(depsJsonPath);
+                       Json::CharReaderBuilder reader;
+                       Json::Value root;
+                       std::string error;
+                       if (ifs.is_open()) {
+                               if (!Json::parseFromStream(reader, ifs, &root, &error)) {
+                                       _ERR("Failed to parse of deps.json");
+                                       ifs.close();
+                                       tpaAssemblies.clear();
+                                       return parserData;
+                               }
+                               const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
+                               const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
+                               std::vector<std::string> appDependencies;
+                               for (auto& nuget : nugetPackages.getMemberNames()) {
+                                       if (strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) != NULL ||
+                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) != NULL) {
+                                               const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
+                                               if (assemblies != Json::nullValue) {
+                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
+                                                       for (auto& dependency : dependencies.getMemberNames()) {
+                                                               appDependencies.push_back(dependency);
+                                                       }
+                                               }
+                                       }
+                               }
+                               for (auto& nuget : nugetPackages.getMemberNames()) {
+                                       //Skip the nuget package related to Tizen
+                                       if (strstr(nuget.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
+                                               strstr(nuget.c_str(), TIZEN_DOTNET_SDK_NUGET) == NULL &&
+                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) == NULL &&
+                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) == NULL) {
+                                               const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
+                                               if (assemblies != Json::nullValue) {
+                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
+                                                       bool hasDependency = false;
+                                                       for (auto& dependency : dependencies.getMemberNames()) {
+                                                               //Skip the nugget package that is dependent on another nuget package
+                                                               if (strstr(dependency.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
+                                                                       strstr(dependency.c_str(), NET_STANDARD_LIBRARY_NUGET) == NULL) {
+                                                                       hasDependency = true;
+                                                                       for (auto& ad : appDependencies) {
+                                                                               if (!strcmp(ad.c_str(), dependency.c_str())) {
+                                                                                       hasDependency = true;
+                                                                                       break;
+                                                                               } else {
+                                                                                       hasDependency = false;
+                                                                               }
+                                                                       }
+                                                                       if (hasDependency) break;
+                                                               }
+                                                       }
+                                                       if (!hasDependency) {
+                                                               bool isExistTpaAssembly = false;
+                                                               for (auto& assembly : assemblies.getMemberNames()) {
+                                                                       std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
+                                                                       //Skip the assembly present in the TPA list
+                                                                       for (auto& tpa : tpaAssemblies) {
+                                                                               if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
+                                                                                       isExistTpaAssembly = true;
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                                       if (isExistTpaAssembly) break;
+                                                               }
+                                                               if (!isExistTpaAssembly) {
+                                                                       for (auto& assembly : assemblies.getMemberNames()) {
+                                                                               std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
+                                                                               parserData.push_back(nuget + ":" + assemblyName);
+                                                                               _INFO("Nuget : [%s] / Assembly : [%s]", nuget.c_str(), assemblyName.c_str());
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               appDependencies.clear();
+                               ifs.close();
+                       }
+               }
+       } catch (const Json::LogicError& error) {
+               _ERR("Failed to parse Json: %s", error.what());
+       }
+       tpaAssemblies.clear();
+       return parserData;
+}
index 195bfa4c9cc4bc86ba0a5de66a63caf811c943af..e450207d4ec400d76575b7af2b3f5e6a6a806783 100644 (file)
@@ -24,7 +24,7 @@
 int main(int argc, char* argv[])
 {
        if (initializePathManager(std::string(), std::string(), std::string())) {
-               fprintf(stderr, "Fail to initialize PathManager");
+               fprintf(stderr, "Fail to initialize PathManager\n");
                return -1;
        }
 
index 1a479bd656305a0c5c9cb2f6b13189bb8d72184a..6c1c6d141b03967f077b4ae95670c27acdfdad9f 100644 (file)
  * limitations under the License.
  */
 
+#include <algorithm>
+
 #include "db_manager.h"
 #include "log.h"
+#include "tac_common.h"
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
 #endif
 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
 
+static int dbIntegrityCheckCb(void *user_data, int argc, char **argv, char **not_used)
+{
+       bool* is_db_corrupted = static_cast<bool*>(user_data);
+       std::string result_DB_check = argv[0];
+       std::transform(result_DB_check.begin(), result_DB_check.end(), result_DB_check.begin(), ::tolower);
+       if(result_DB_check != "ok") {
+               *is_db_corrupted = true;
+               _ERR("DB integrity check failed");
+               return -1;
+       }
+       _INFO("DB integrity result : %s", argv[0]);
+       return 0;
+}
+
 sqlite3* dbCreate(std::string path)
 {
        sqlite3 *sqlite = NULL;
+       bool is_db_corrupted = false;
        int ret = sqlite3_open(path.c_str(), &sqlite);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d] : path [%s]", ret, path.c_str());
-               return NULL;
+               _INFO("DB file is corrupted, start to recover corrupted db");
+               if (restoreTACDB() != TAC_ERROR_NONE) {
+                       _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+                       return NULL;
+               }
+               return dbCreate(path);
        }
        ret = sqlite3_exec(sqlite, "PRAGMA journal_mode = PERSIST", NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d]", ret);
-               return NULL;
+               _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+               sqlite3_close(sqlite);
+               sqlite = NULL;
+               return sqlite;
        }
        ret = sqlite3_exec(sqlite, CREATE_TAC_DB_TABLE, NULL, NULL, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d] : path [%s]", ret, path.c_str());
-               return NULL;
+               _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+               sqlite3_close(sqlite);
+               sqlite = NULL;
+               return sqlite;
+       }
+       ret = sqlite3_exec(sqlite, "PRAGMA integrity_check", dbIntegrityCheckCb, &is_db_corrupted, NULL);
+       if (ret == SQLITE_CORRUPT || is_db_corrupted) {
+               _INFO("DB file is corrupted, start to recover corrupted db");
+               if (restoreTACDB() != TAC_ERROR_NONE) {
+                       _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+                       sqlite3_close(sqlite);
+                       sqlite = NULL;
+                       return sqlite;
+               }
+               return dbCreate(path);
        }
        return sqlite;
 }
 
-bool dbOpen(sqlite3 *tac_db, std::string path)
+sqlite3* dbOpen(std::string path)
 {
-       if (!tac_db) {
-               int ret = sqlite3_open(path.c_str(), &tac_db);
-               if (ret != SQLITE_OK) {
-                       _ERR("Sqlite error : [%d] : path [%s]", ret, path.c_str());
-                       return false;
+       sqlite3 *sqlite = NULL;
+       bool is_db_corrupted = false;
+       int ret = sqlite3_open(path.c_str(), &sqlite);
+       if (ret != SQLITE_OK) {
+               _INFO("DB file is corrupted, start to recover corrupted db");
+               if (restoreTACDB() != TAC_ERROR_NONE) {
+                       _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+                       return NULL;
+               }
+               return dbOpen(path);
+       }
+       ret = sqlite3_exec(sqlite, "PRAGMA integrity_check", dbIntegrityCheckCb, &is_db_corrupted, NULL);
+       if (ret == SQLITE_CORRUPT || is_db_corrupted) {
+               _INFO("DB file is corrupted, start to recover corrupted db");
+               if (restoreTACDB() != TAC_ERROR_NONE) {
+                       _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
+                       sqlite3_close(sqlite);
+                       sqlite = NULL;
+                       return sqlite;
                }
+               return dbOpen(path);
        }
-       return true;
+       return sqlite;
 }
 
 void dbFinalize(sqlite3_stmt *stmt)
@@ -84,19 +136,16 @@ void dbRollback(sqlite3 *tac_db)
 bool dbUpdate(sqlite3 *tac_db, std::string path, std::string query)
 {
        sqlite3_stmt *stmt = NULL;
-       if (!dbOpen(tac_db, path)) {
-               return false;
-       }
        int ret = sqlite3_exec(tac_db, "BEGIN;", NULL, NULL, NULL);
        ret = sqlite3_prepare(tac_db, query.c_str(), QUERY_MAX_LEN , &stmt, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%s, %s]", query.c_str(), sqlite3_errmsg(tac_db));
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbClose(tac_db);
                return false;
        }
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_DONE && ret != SQLITE_ROW && ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d]", ret);
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbFinalize(stmt);
                dbClose(tac_db);
                return false;
@@ -108,19 +157,16 @@ bool dbUpdate(sqlite3 *tac_db, std::string path, std::string query)
 bool dbInsert(sqlite3 *tac_db, std::string path, std::string query)
 {
        sqlite3_stmt *stmt = NULL;
-       if (!dbOpen(tac_db, path)) {
-               return false;
-       }
        int ret = sqlite3_exec(tac_db, "BEGIN;", NULL, NULL, NULL);
        ret = sqlite3_prepare(tac_db, query.c_str(), QUERY_MAX_LEN , &stmt, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%s, %s]", query.c_str(), sqlite3_errmsg(tac_db));
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbClose(tac_db);
                return false;
        }
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_DONE && ret != SQLITE_ROW && ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d]", ret);
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbFinalize(stmt);
                dbClose(tac_db);
                return false;
@@ -134,12 +180,9 @@ std::vector<std::string> dbSelect(sqlite3 *tac_db, std::string path, std::string
        std::vector<std::string> updateDB;
        sqlite3_stmt* stmt = NULL;
        const char* str = NULL;
-       if (!dbOpen(tac_db, path)) {
-               return updateDB;
-       }
        int ret = sqlite3_prepare_v2(tac_db, query.c_str(), strlen(query.c_str()), &stmt, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%s, %s]", query.c_str(), sqlite3_errmsg(tac_db));
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbClose(tac_db);
                return updateDB;
        }
@@ -154,19 +197,16 @@ std::vector<std::string> dbSelect(sqlite3 *tac_db, std::string path, std::string
 bool dbDelete(sqlite3 *tac_db, std::string path, std::string query)
 {
        sqlite3_stmt *stmt = NULL;
-       if (!dbOpen(tac_db, path)) {
-               return false;
-       }
        int ret = sqlite3_exec(tac_db, "BEGIN;", NULL, NULL, NULL);
        ret = sqlite3_prepare(tac_db, query.c_str(), QUERY_MAX_LEN , &stmt, NULL);
        if (ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%s, %s]", query.c_str(), sqlite3_errmsg(tac_db));
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbClose(tac_db);
                return false;
        }
        ret = sqlite3_step(stmt);
        if (ret != SQLITE_DONE && ret != SQLITE_ROW && ret != SQLITE_OK) {
-               _ERR("Sqlite error : [%d]", ret);
+               _ERR("Sqlite error : [%d, %s]", ret, sqlite3_errmsg(tac_db));
                dbFinalize(stmt);
                dbClose(tac_db);
                return false;
index e2cd5bdc1d06ef73620c212fca4bfc0fc4246056..c4df8b08eaa9580402321264d3ea4cdb9570ce51 100644 (file)
@@ -23,7 +23,6 @@
 #include <pkgmgr-info.h>
 #include <pkgmgr_installer_info.h>
 #include <sys/smack.h>
-#include <json/json.h>
 
 #include <cstdlib>
 #include <cstring>
@@ -595,101 +594,3 @@ bool removeAll(const bf::path& path) {
        }
        return true;
 }
-
-//Parser the .deps.json file to get nuget information.
-std::vector<std::string> depsJsonParser(std::string rootPath, std::string execName, std::string tpaList)
-{
-       std::vector<std::string> tpaAssemblies;
-       splitPath(tpaList, tpaAssemblies);
-
-       std::vector<std::string> parserData;
-       std::string depsJsonName = execName.substr(0, execName.rfind(".dll")) + ".deps.json";
-       std::string depsJsonPath = concatPath(rootPath, depsJsonName);
-       try {
-               if (bf::exists(depsJsonPath)) {
-                       std::ifstream ifs(depsJsonPath);
-                       Json::CharReaderBuilder reader;
-                       Json::Value root;
-                       std::string error;
-                       if (ifs.is_open()) {
-                               if (!Json::parseFromStream(reader, ifs, &root, &error)) {
-                                       _ERR("Failed to parse of deps.json");
-                                       ifs.close();
-                                       tpaAssemblies.clear();
-                                       return parserData;
-                               }
-                               const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
-                               const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
-                               std::vector<std::string> appDependencies;
-                               for (auto& nuget : nugetPackages.getMemberNames()) {
-                                       if (strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) != NULL ||
-                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) != NULL) {
-                                               const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
-                                               if (assemblies != Json::nullValue) {
-                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
-                                                       for (auto& dependency : dependencies.getMemberNames()) {
-                                                               appDependencies.push_back(dependency);
-                                                       }
-                                               }
-                                       }
-                               }
-                               for (auto& nuget : nugetPackages.getMemberNames()) {
-                                       //Skip the nuget package related to Tizen
-                                       if (strstr(nuget.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
-                                               strstr(nuget.c_str(), TIZEN_DOTNET_SDK_NUGET) == NULL &&
-                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) == NULL &&
-                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) == NULL) {
-                                               const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
-                                               if (assemblies != Json::nullValue) {
-                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
-                                                       bool hasDependency = false;
-                                                       for (auto& dependency : dependencies.getMemberNames()) {
-                                                               //Skip the nugget package that is dependent on another nuget package
-                                                               if (strstr(dependency.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
-                                                                       strstr(dependency.c_str(), NET_STANDARD_LIBRARY_NUGET) == NULL) {
-                                                                       hasDependency = true;
-                                                                       for (auto& ad : appDependencies) {
-                                                                               if (!strcmp(ad.c_str(), dependency.c_str())) {
-                                                                                       hasDependency = true;
-                                                                                       break;
-                                                                               } else {
-                                                                                       hasDependency = false;
-                                                                               }
-                                                                       }
-                                                                       if (hasDependency) break;
-                                                               }
-                                                       }
-                                                       if (!hasDependency) {
-                                                               bool isExistTpaAssembly = false;
-                                                               for (auto& assembly : assemblies.getMemberNames()) {
-                                                                       std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
-                                                                       //Skip the assembly present in the TPA list
-                                                                       for (auto& tpa : tpaAssemblies) {
-                                                                               if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
-                                                                                       isExistTpaAssembly = true;
-                                                                                       break;
-                                                                               }
-                                                                       }
-                                                                       if (isExistTpaAssembly) break;
-                                                               }
-                                                               if (!isExistTpaAssembly) {
-                                                                       for (auto& assembly : assemblies.getMemberNames()) {
-                                                                               std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
-                                                                               parserData.push_back(nuget + ":" + assemblyName);
-                                                                               _INFO("Nuget : [%s] / Assembly : [%s]", nuget.c_str(), assemblyName.c_str());
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                               appDependencies.clear();
-                               ifs.close();
-                       }
-               }
-       } catch (const Json::LogicError& error) {
-               _ERR("Failed to parse Json: %s", error.what());
-       }
-       tpaAssemblies.clear();
-       return parserData;
-}
\ No newline at end of file
index 72abee7a1694a905fcc492550f9e9501cef01f61..97334a5e52e51cde88eba58435fbaac7d8933c7f 100644 (file)
@@ -158,6 +158,7 @@ chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet
 %{_bindir}/dotnet-launcher
 %{_libdir}/libdotnet_launcher_util.so
 %{_libdir}/libni_common.so
+%{_libdir}/libtac_common.so
 /etc/tmpfiles.d/%{name}.conf
 /usr/share/parser-plugins/dotnet-launcher.info
 %{_framework_dir}/Tizen.Init.dll
@@ -173,4 +174,5 @@ chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet
 %{_includedir}/coreclr_host.h
 %{_libdir}/libdotnet_launcher_util.so
 %{_libdir}/libni_common.so
+%{_libdir}/libtac_common.so
 %{_libdir}/pkgconfig/dotnet-launcher.pc