#undef __STR
#undef __XSTR
-typedef struct Metadata {
- const char *key;
- const char *value;
-} Metadata;
-
std::vector<std::string> nugetPackagesAssembliesSha;
std::vector<std::string> tacDB;
std::vector<std::string> createDirectories;
std::vector<std::string> updateTac;
std::string status = "";
-std::string rootPath;
-std::string execName;
-std::string binPath;
static sqlite3 *tac_db = NULL;
bool tacPluginInstalled = false;
bool tacPluginFinished = false;
-bool metadataCheck(GList *list)
-{
- GList *tag = NULL;
- Metadata *mdInfo = NULL;
- tag = g_list_first(list);
- mdInfo = (Metadata*)tag->data;
- if (strcmp(mdInfo->key, TAC_METADATA_KEY) == 0 && strcmp(mdInfo->value, METADATA_VALUE) == 0) {
- _DBG("Prefer nuget cache set TRUE");
- if (initializePluginManager("normal")) {
- _ERR("Fail to initialize PluginManager");
- return false;
- }
- if (initializePathManager(std::string(), std::string(), std::string())) {
- _ERR("Fail to initialize PathManger");
- return false;
- }
- return true;
- }
- return false;
-}
-
-bool appTypeCheck(std::string pkgId)
-{
- uid_t uid = 0;
- if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
- _ERR("Failed to get UID");
- return false;
- }
-
- 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 false;
- }
-
- bool isDotnetAppType = false;
- auto dotnetAppCounter = [] (pkgmgrinfo_appinfo_h handle, void *userData) -> int {
- char* type = nullptr;
- bool* dotnet = static_cast<bool*>(userData);
- if (pkgmgrinfo_appinfo_get_apptype(handle, &type) != PMINFO_R_OK) {
- _ERR("Failed to get app type : %s", type);
- return -1;
- }
- if (strcmp(type, "dotnet") == 0) {
- *dotnet = true;
- }
- return 0;
- };
-
- 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());
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return false;
- }
-
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return isDotnetAppType;
-}
-
-void SHA256(std::string path, char outputBuffer[65])
+static void SHA256(std::string path, char outputBuffer[65])
{
FILE *file = fopen(path.c_str(), "rb");
if (!file) {
free(buffer);
}
-void createSHA256Info(std::string sha256Info, std::string nugetPackage)
+static void createSHA256Info(std::string sha256Info, std::string nugetPackage)
{
std::ofstream ofs(sha256Info, std::ios::app);
int assembly_count = 0;
ofs.close();
}
-int compareSHA256Info(std::string sha256Info, std::string nugetPackage)
+static int compareSHA256Info(std::string sha256Info, std::string nugetPackage)
{
int compare_count = 0;
int assembly_count = 0;
return 0;
}
-int copyNCreateSymlink(std::string tacVersionDir, std::string nugetPackage, bool isCreateTacDir)
+static int copyNCreateSymlink(std::string binPath, std::string tacVersionDir, std::string nugetPackage, bool isCreateTacDir)
{
uid_t g_uid = 0;
gid_t g_gid = 0;
return 0;
}
-void depsJsonCheck() {
+static void depsJsonCheck(std::string rootPath, std::string binPath, std::string execName)
+{
for (auto& npAssembly : depsJsonParser(rootPath, execName, getTPA())) {
std::string nuget_package = npAssembly.substr(0, npAssembly.rfind(':'));
std::string assembly_name = npAssembly.substr(npAssembly.rfind(':') + 1);
}
tacPluginInstalled = true;
- if (!appTypeCheck(std::string(pkgId))) {
- _INFO("App type is not dotnet");
+ if (initializePathManager(std::string(), std::string(), std::string())) {
+ _ERR("Fail to initialize PathManger");
+ return 0;
+ }
+
+ std::string appType = getAppType(std::string(pkgId));
+ if (strstr(appType.c_str(), "dotnet") == NULL) {
+ _ERR("App type is not dotnet");
return 0;
}
- if (getExecName(std::string(pkgId), execName) < 0) {
+ std::string execName = getExecName(std::string(pkgId));
+ std::string rootPath = getRootPath(std::string(pkgId));
+ if (execName.empty() || rootPath.empty()) {
return 0;
}
- if (getRootPath(std::string(pkgId), rootPath) < 0) {
+ std::string binPath = concatPath(rootPath, "bin");
+ std::string metaValue = getMetadataValue(std::string(pkgId), TAC_METADATA_KEY);
+ if (metaValue.empty()) {
return 0;
- } else {
- binPath = concatPath(rootPath, "bin");
}
- if (metadataCheck(list)) {
- depsJsonCheck();
+ if (metaValue == METADATA_VALUE) {
+ depsJsonCheck(rootPath, binPath, execName);
}
status = "install";
return -1;
}
- if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
+ if (copyNCreateSymlink(binPath, tac_version_dir, np, true) < 0) {
_ERR("Failed to create symlink");
return -1;
}
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
if (!bf::is_symlink(sha256_info)) {
if (compareSHA256Info(sha256_info, np)) {
- if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
+ if (copyNCreateSymlink(binPath, tac_version_dir, np, false) < 0) {
_ERR("Failed to create symlink");
return -1;
}
}
}
if (!bf::exists(sha256_info)) {
- if(!removeAll(tac_version_dir)) {
+ if (!removeAll(tac_version_dir)) {
_ERR("Failed to remove of %s", tac_version_dir.c_str());
}
}
return 0;
}
-static int sqliteCb(void *count, int argc, char **argv, char **colName) {
+static int sqliteCb(void *count, int argc, char **argv, char **colName)
+{
int *c = (int*)count;
*c = atoi(argv[0]);
return 0;
}
-int updateTacDB(sqlite3 *sqlite)
+static int updateTacDB(sqlite3 *sqlite)
{
for (auto& unp : updateTac) {
int count = -1;
}
tacPluginInstalled = true;
- if (!appTypeCheck(std::string(pkgId))) {
- _INFO("App type is not dotnet");
+ if (initializePathManager(std::string(), std::string(), std::string())) {
+ _ERR("Fail to initialize PathManger");
return 0;
}
- if (getExecName(std::string(pkgId), execName) < 0) {
+
+ std::string appType = getAppType(std::string(pkgId));
+ if (strstr(appType.c_str(), "dotnet") == NULL) {
+ _ERR("App type is not dotnet");
return 0;
}
- if (getRootPath(std::string(pkgId), rootPath) < 0) {
+ std::string execName = getExecName(std::string(pkgId));
+ std::string rootPath = getRootPath(std::string(pkgId));
+ if (execName.empty() || rootPath.empty()) {
return 0;
- } else {
- binPath = concatPath(rootPath, "bin");
}
+ std::string binPath = concatPath(rootPath, "bin");
+
if (!strcmp("removed", status.c_str())) {
_INFO("Skipped to parse of deps.json");
} else {
- if (metadataCheck(list)) {
- depsJsonCheck();
+ std::string metaValue = getMetadataValue(std::string(pkgId), TAC_METADATA_KEY);
+ if (metaValue.empty()) {
+ return 0;
+ }
+ if (metaValue == METADATA_VALUE) {
+ depsJsonCheck(rootPath, binPath, execName);
}
}
return -1;
}
- if (copyNCreateSymlink(tac_version_dir, np, true) < 0) {
+ if (copyNCreateSymlink(binPath, tac_version_dir, np, true) < 0) {
_ERR("Failed to create symlink");
return -1;
}
_INFO("Exists tac_version_dir [%s]", tac_version_dir.c_str());
if (!bf::is_symlink(sha256_info)) {
if (compareSHA256Info(sha256_info, np)) {
- if (copyNCreateSymlink(tac_version_dir, np, false) < 0) {
+ if (copyNCreateSymlink(binPath, tac_version_dir, np, false) < 0) {
_ERR("Failed to create symlink");
return -1;
}
}
}
if (!bf::exists(sha256_info)) {
- if(!removeAll(tac_version_dir)) {
+ if (!removeAll(tac_version_dir)) {
_ERR("Failed to remove of %s", tac_version_dir.c_str());
}
}