Add TAC installer
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / tac_common.cc
index 1d69acf..7755565 100644 (file)
@@ -163,7 +163,7 @@ tac_error_e tac_restoreDB()
                return TAC_ERROR_UNKNOWN;
        }
 
-       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, TAC_METADATA_KEY, METADATA_VALUE);
+       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, TAC_METADATA_KEY, METADATA_VALUE_TRUE);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
                return TAC_ERROR_UNKNOWN;
@@ -222,7 +222,7 @@ tac_error_e disableTACPackage(const std::string& pkgId)
                        for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
                                std::string symPath = symlinkAssembly.path().string();
                                std::string fileName = symlinkAssembly.path().filename().string();
-                               if (bf::is_symlink(symPath)) {
+                               if (isSymlinkFile(symPath)) {
                                        std::string originPath = bf::read_symlink(symPath).string();
                                        if (!isNativeImage(symPath)) {
                                                std::string dllPath = concatPath(binDir, fileName);
@@ -273,7 +273,7 @@ tac_error_e enableTACPackage(const std::string& pkgId)
                return TAC_ERROR_INVALID_PACKAGE;
        }
 
-       if (!strcmp(metaValue.c_str(), "true")) {
+       if (!strcmp(metaValue.c_str(), METADATA_VALUE_TRUE)) {
                std::string binDir = concatPath(rootPath, "bin");
                std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
                std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
@@ -297,6 +297,7 @@ tac_error_e enableTACPackage(const std::string& pkgId)
                                }
                        }
 
+                       bs::error_code error;
                        for (auto& originPath : enableNuget) {
                                if (exist(originPath)) {
                                        std::string fileName = originPath.substr(originPath.rfind('/') + 1);
@@ -304,7 +305,11 @@ tac_error_e enableTACPackage(const std::string& pkgId)
                                        if (exist(binNIDir)) {
                                                std::string originNIPath = changeExtension(originPath, "dll", "ni.dll");
                                                if (exist(originNIPath)) {
-                                                       bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName));
+                                                       bf::create_symlink(originNIPath, concatPath(tacDir, NIFileName), error);
+                                                       if (error) {
+                                                               _SERR("Failed to create symlink %s file", concatPath(tacDir, NIFileName).c_str());
+                                                               return TAC_ERROR_UNKNOWN;
+                                                       }
                                                        _SOUT("%s symbolic link file generated successfully.", concatPath(tacDir, NIFileName).c_str());
                                                        copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, NIFileName).c_str(), true);
 
@@ -314,7 +319,11 @@ tac_error_e enableTACPackage(const std::string& pkgId)
                                                        }
                                                }
                                        }
-                                       bf::create_symlink(originPath, concatPath(tacDir, fileName));
+                                       bf::create_symlink(originPath, concatPath(tacDir, fileName), error);
+                                       if (error) {
+                                               _SERR("Failed to create symlink %s file", concatPath(tacDir, fileName).c_str());
+                                               return TAC_ERROR_UNKNOWN;
+                                       }
                                        _SOUT("%s symbolic link file generated successfully.", concatPath(tacDir, fileName).c_str());
                                        copySmackAndOwnership(tacDir.c_str(), concatPath(tacDir, fileName).c_str(), true);
 
@@ -495,7 +504,7 @@ tac_error_e tlc_restoreDB()
                return TAC_ERROR_UNKNOWN;
        }
 
-       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, TAC_METADATA_KEY, METADATA_VALUE);
+       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, TAC_METADATA_KEY, METADATA_VALUE_TRUE);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
                return TAC_ERROR_UNKNOWN;