{
char *pkgId = NULL;
char *root = NULL;
- char *exec = NULL;
bool *isReadOnly = (bool*)userData;
int ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
}
std::string rootPath = std::string(root);
- ret = pkgmgrinfo_appinfo_get_exec(handle, &exec);
- if (ret != PMINFO_R_OK) {
- _SERR("Failed to get exec name");
- return -1;
- }
- std::string execName = std::string(exec).substr(std::string(exec).rfind('/') + 1);
-
enableTACPackage(std::string(pkgId));
std::vector<std::string> parserData;
std::string binDir = concatPath(rootPath, "bin");
std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
- for (auto& npAssembly : depsJsonParser(rootPath, execName)) {
+ for (auto& npAssembly : depsJsonParser(rootPath)) {
std::string nugetPackage = npAssembly.substr(0, npAssembly.rfind(':'));
std::string assemblyName = npAssembly.substr(npAssembly.rfind(':') + 1);
if (exist(tacDir) && exist(concatPath(tacDir, assemblyName))) {
return TAC_ERROR_NONE;
}
- std::string execName = getExecName(pkgId);
- if (execName.empty()) {
- _SERR("Failed to get exec name from [%s]", pkgId.c_str());
- return TAC_ERROR_INVALID_PACKAGE;
- }
-
std::string metaValue = getMetadataValue(pkgId, TAC_METADATA_KEY);
if (metaValue.empty()) {
_SERR("Failed to get metadata from [%s]", pkgId.c_str());
copySmackAndOwnership(binDir.c_str(), tacDir.c_str());
std::vector<std::string> enableNuget;
- for (auto& npAssembly : depsJsonParser(rootPath, execName)) {
+ for (auto& npAssembly : depsJsonParser(rootPath)) {
std::string nugetPackage = npAssembly.substr(0, npAssembly.rfind(':'));
std::string assemblyName = npAssembly.substr(npAssembly.rfind(':') + 1);
std::string nugetPath = concatPath(tacLocation, nugetPackage);
return TAC_ERROR_NONE;
}
+static bool ends_with(std::string const &source, std::string const &suffix)
+{
+ if (source.size() < suffix.size()) {
+ return false;
+ }
+
+ return (source.compare(source.size() - suffix.size(), suffix.size(), suffix) == 0);
+}
+
+static std::vector<std::string> getDepsJsonPaths(const std::string& rootPath, std::vector<std::string>& names)
+{
+ std::vector<std::string> paths;
+ auto convert = [&paths, &names](const std::string& path, const std::string& filename) {
+ if (ends_with(filename, ".deps.json")) {
+ paths.push_back(path);
+ names.push_back(changeExtension(filename, ".deps.json", ""));
+ }
+ };
+
+ scanFilesInDirectory(rootPath, convert, -1);
+
+ return paths;
+}
+
//Parser the .deps.json file to get nuget information.
-std::vector<std::string> depsJsonParser(const std::string& rootPath, const std::string& execName)
+std::vector<std::string> depsJsonParser(const std::string& rootPath)
{
std::vector<std::string> parserData;
- std::string depsJsonName = changeExtension(execName, ".dll", ".deps.json");
- std::string depsJsonPath = concatPath(rootPath, depsJsonName);
+ std::vector<std::string> appNames;
try {
- if (exist(depsJsonPath)) {
+ for (const auto& depsJsonPath : getDepsJsonPaths(rootPath, appNames)) {
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();
- return parserData;
+ if (!ifs.is_open()) {
+ _ERR("Failed to open of deps.json");
+ continue;
+ }
+
+ if (!Json::parseFromStream(reader, ifs, &root, &error)) {
+ _ERR("Failed to parse of deps.json");
+ ifs.close();
+ return parserData;
+ }
+
+ const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
+ const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
+ for (const 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) {
+ continue;
}
- const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
- const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
- 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) {
- // handle assembly even though that is included in the TPA.
- 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());
- }
+
+ bool isSkip = false;
+ for (const auto& appName : appNames) {
+ if (strstr(nuget.c_str(), appName.c_str()) != NULL ||
+ strstr(nuget.c_str(), (appName.substr(0, appName.find(".Tizen"))).c_str()) != NULL) {
+ isSkip = true;
+ }
+ }
+ if (!isSkip) {
+ const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
+ if (assemblies != Json::nullValue) {
+ // handle assembly even though that is included in the TPA.
+ for (const 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());
}
}
}
- ifs.close();
}
+ ifs.close();
}
+ std::sort(parserData.begin(), parserData.end());
+ parserData.erase(unique(parserData.begin(), parserData.end()), parserData.end());
} catch (const Json::Exception& error) {
_ERR("Failed to parse Json: %s", error.what());
}
}
}
-static void checkDepsJson(std::string rootPath, std::string binPath, std::string execName)
+static void checkDepsJson(std::string rootPath, std::string binPath)
{
- for (auto& npAssembly : depsJsonParser(rootPath, execName)) {
+ for (auto& npAssembly : depsJsonParser(rootPath)) {
std::string nuget_package = npAssembly.substr(0, npAssembly.rfind(':'));
std::string assembly_name = npAssembly.substr(npAssembly.rfind(':') + 1);
tacDB.push_back(nuget_package);
_ERR("App type is not dotnet");
return 0;
}
- std::string execName = getExecName(pkgId);
std::string rootPath = getRootPath(pkgId);
- if (execName.empty() || rootPath.empty()) {
+ if (rootPath.empty()) {
return 0;
}
}
}
if (metaValue == METADATA_VALUE_TRUE || tacForce) {
- checkDepsJson(rootPath, binPath, execName);
+ checkDepsJson(rootPath, binPath);
}
tacState = state;
_ERR("App type is not dotnet");
return 0;
}
- std::string execName = getExecName(pkgId);
std::string rootPath = getRootPath(pkgId);
- if (execName.empty() || rootPath.empty()) {
+ if (rootPath.empty()) {
return 0;
}
}
}
if (metaValue == METADATA_VALUE_TRUE || tacForce) {
- checkDepsJson(rootPath, binPath, execName);
+ checkDepsJson(rootPath, binPath);
}
}
return rootPath;
}
-std::string getExecName(const std::string& pkgId)
-{
- char *exec = NULL;
- char *appId = 0;
- std::string execName;
-
- pkgmgrinfo_pkginfo_h pkg_handle;
- int ret = pkgmgrGetPkgInfo(pkgId, &pkg_handle);
- if (ret != 0) {
- return execName;
- }
-
- ret = pkgmgrinfo_pkginfo_get_mainappid(pkg_handle, &appId);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return execName;
- }
-
- pkgmgrinfo_appinfo_h app_handle;
- ret = pkgmgrGetAppInfo(appId, &app_handle);
- if (ret != 0) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return execName;
- }
-
- ret = pkgmgrinfo_appinfo_get_exec(app_handle, &exec);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return execName;
- }
- execName = std::string(exec).substr(std::string(exec).rfind('/') + 1);
-
- pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
-
- return execName;
-}
-
std::string getAppType(const std::string& pkgId)
{
- char *appId = 0;
char *type = 0;
std::string appType;
- pkgmgrinfo_pkginfo_h pkg_handle;
- int ret = pkgmgrGetPkgInfo(pkgId, &pkg_handle);
- if (ret != 0) {
- return appType;
- }
-
- ret = pkgmgrinfo_pkginfo_get_mainappid(pkg_handle, &appId);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return appType;
- }
+ for (auto& appId : getAppList(pkgId)) {
+ pkgmgrinfo_appinfo_h app_handle;
+ int ret = pkgmgrGetAppInfo(appId, &app_handle);
+ if (ret != 0) {
+ return appType;
+ }
- pkgmgrinfo_appinfo_h app_handle;
- ret = pkgmgrGetAppInfo(appId, &app_handle);
- if (ret != 0) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return appType;
- }
+ ret = pkgmgrinfo_appinfo_get_apptype(app_handle, &type);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
+ return appType;
+ }
- ret = pkgmgrinfo_appinfo_get_apptype(app_handle, &type);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return appType;
+ appType = std::string(type);
+ if (appType.find("dotnet") != std::string::npos) {
+ break;
+ }
}
- appType = type;
-
- pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
return appType;
}
std::string getMetadataValue(const std::string& pkgId, const std::string& key)
{
- char *value = NULL;
- char *appId = 0;
+ char *value = 0;
std::string metadataValue;
- pkgmgrinfo_pkginfo_h pkg_handle;
- int ret = pkgmgrGetPkgInfo(pkgId, &pkg_handle);
- if (ret != 0) {
- return metadataValue;
- }
+ for (auto& appId : getAppList(pkgId)) {
+ pkgmgrinfo_appinfo_h app_handle;
+ int ret = pkgmgrGetAppInfo(appId, &app_handle);
+ if (ret != 0) {
+ return metadataValue;
+ }
- ret = pkgmgrinfo_pkginfo_get_mainappid(pkg_handle, &appId);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return metadataValue;
- }
+ ret = pkgmgrinfo_appinfo_get_metadata_value(app_handle, key.c_str(), &value);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
+ return metadataValue;
+ }
- pkgmgrinfo_appinfo_h app_handle;
- ret = pkgmgrGetAppInfo(appId, &app_handle);
- if (ret != 0) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return metadataValue;
- }
+ metadataValue = std::string(value);
+ if (metadataValue == "true") {
+ break;
+ }
- ret = pkgmgrinfo_appinfo_get_metadata_value(app_handle, key.c_str(), &value);
- if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
- return metadataValue;
}
- metadataValue = std::string(value);
-
- pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
return metadataValue;
}