/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
#include <boost/filesystem.hpp>
#include <glib.h>
#include <json/json.h>
-#include <openssl/sha.h>
#include <pkgmgr-info.h>
#include <pkgmgr_installer_info.h>
+#include <openssl/sha.h>
typedef struct Metadata {
const char *key;
const std::string mTizenNET = "Tizen.NET";
const std::string mTizenNETSdk = "Tizen.NET.Sdk";
const std::string mNETStandardLibrary = "NETStandard.Library";
-const std::string mTacRelease = "TAC.Release";
+const std::string mTacRelease = ".TAC.Release";
const std::string mDepsJson = ".deps.json";
const std::string mBackup = ".bck";
const std::string mdValue = "true";
std::vector<std::string> createDirectories;
std::vector<std::string> updateTac;
std::string status = "";
-
-bool isCreateDirectory = false;
-bf::path rootPath;
-bf::path execPath;
+std::string rootPath;
+std::string execName;
bf::path binPath;
-
+bool isCreateDirectory = false;
static sqlite3 *tac_db = NULL;
int metadataCheck(GList *list)
}
}
-int getAppType(std::string pkgId)
+int appTypeCheck(std::string pkgId)
{
uid_t uid = 0;
if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
return 0;
}
- bool dotnetExist = false;
+ bool isDotnetAppType = false;
auto dotnetAppCounter = [] (pkgmgrinfo_appinfo_h handle, void *userData) -> int {
char* type = nullptr;
bool* dotnet = static_cast<bool*>(userData);
_ERR("Failed to get app type : %s", type);
return 0;
}
- _INFO("App type : %s", type);
if (strcmp(type, "dotnet") == 0) {
*dotnet = true;
}
return 0;
};
- if (pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, dotnetAppCounter, &dotnetExist, uid) != PMINFO_R_OK) {
+ if (pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, dotnetAppCounter, &isDotnetAppType, uid) != PMINFO_R_OK) {
_ERR("Failed to get list of app in pkg : %s", pkgId.c_str());
return -1;
}
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return dotnetExist;
+ return isDotnetAppType;
}
-int getExecPath(std::string pkgId)
+int getExecName(std::string pkgId)
{
uid_t uid = 0;
if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
_ERR("Failed to get exec : %s", exec);
return 0;
}
- _INFO("exec : %s", exec);
- execPath = bf::path(exec);
- return 0;
- };
-
- if (pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, dotnetAppCounter, NULL, uid) != PMINFO_R_OK) {
- _ERR("Failed to get list of app in pkg : %s", pkgId.c_str());
- return -1;
- }
-
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return 0;
-}
-
-int getRootPath(std::string pkgId)
-{
- uid_t uid = 0;
- if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
- _ERR("Failed to get UID");
- return 0;
- }
-
- pkgmgrinfo_pkginfo_h handle;
- int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &handle);
- if (ret != PMINFO_R_OK) {
- _ERR("Failed to get pkg info");
- return 0;
- }
-
- auto dotnetAppCounter = [] (pkgmgrinfo_appinfo_h handle, void *userData) -> int {
- char* root = nullptr;
- if (pkgmgrinfo_appinfo_get_root_path(handle, &root) != PMINFO_R_OK) {
- _ERR("Failed to get root path : %s", root);
- return 0;
- }
- _INFO("Root path : %s", root);
- rootPath = bf::path(root);
- binPath = root / bf::path("bin");
- _INFO("Bin path : %s", binPath.c_str());
+ execName = std::string(exec).substr(std::string(exec).rfind('/') + 1);
return 0;
};
int depsJsonParser()
{
- std::string exec_name = execPath.filename().string();
- std::string deps_json_name = exec_name.substr(0, exec_name.rfind(".dll")) + mDepsJson;
- if (bf::exists(rootPath / deps_json_name)) {
- std::string deps_json_path = (rootPath / deps_json_name).string();
+ std::string deps_json_name = execName.substr(0, execName.rfind(".dll")) + mDepsJson;
+ if (bf::exists(rootPath + "/" + deps_json_name)) {
+ std::string deps_json_path = rootPath + "/" + deps_json_name;
std::ifstream ifs(deps_json_path);
Json::CharReaderBuilder reader;
Json::Value root;
for (auto& nuget : nugetPackages.getMemberNames()) {
if (strstr(nuget.c_str(), mTizenNET.c_str()) != NULL ||
strstr(nuget.c_str(), mTizenNETSdk.c_str()) != NULL ||
- strstr(nuget.c_str(), exec_name.c_str()) != NULL ||
- strstr(nuget.c_str(), (exec_name.substr(0, exec_name.find('.'))).c_str()) != 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) {
continue;
} else {
const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
_DBG("[===== PKGMGR_MDPARSER_PLUGIN_INSTALL =====]");
_INFO("PackageID : %s", pkgId);
- if (!getAppType(std::string(pkgId))) {
+ if (!appTypeCheck(std::string(pkgId))) {
_INFO("App type is not dotnet");
return 0;
}
- if (getExecPath(std::string(pkgId))) {
+ if (getExecName(std::string(pkgId)) < 0) {
return 0;
}
- if (getRootPath(std::string(pkgId))) {
+ if (getRootPath(std::string(pkgId), rootPath) < 0) {
return 0;
+ } else {
+ binPath = rootPath / bf::path("bin");
}
if (!metadataCheck(list)) {
if (depsJsonParser()) {
_DBG("[===== PKGMGR_MDPARSER_PLUGIN_UPGRADE =====]");
_INFO("PackageID : %s", pkgId);
- if (!getAppType(std::string(pkgId))) {
+ if (!appTypeCheck(std::string(pkgId))) {
_INFO("App type is not dotnet");
return 0;
}
- if (getExecPath(std::string(pkgId))) {
+ if (getExecName(std::string(pkgId)) < 0) {
return 0;
}
- if (getRootPath(std::string(pkgId))) {
+ if (getRootPath(std::string(pkgId), rootPath) < 0) {
return 0;
+ } else {
+ binPath = rootPath / bf::path("bin");
}
if (!strcmp("removed", status.c_str())) {
_INFO("Skipped to parse of deps.json");