Cleanup pkgmgr-info 47/251347/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 13 Jan 2021 01:21:36 +0000 (10:21 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 13 Jan 2021 08:13:40 +0000 (17:13 +0900)
- Create directory for storing plugin list files.
- Remove unused definitions
- Remove parser_path.conf which is used by deprecated functions only
  by hard-cord it.

Change-Id: Ifa2ba0eecd0b00b87def402786f6731a5551c85e
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
CMakeLists.txt
packaging/pkgmgr-info.spec
parser/include/pkgmgr_parser.h
parser/src/pkgmgr_parser_deprecated.c
parser_path.conf.in [deleted file]
plugin_list/CMakeLists.txt [new file with mode: 0644]
plugin_list/category_parser_list.txt.in [moved from category_parser_list.txt.in with 100% similarity]
plugin_list/mdparser_list.txt.in [moved from mdparser_list.txt.in with 100% similarity]
plugin_list/metadata_parser_list.txt.in [moved from metadata_parser_list.txt.in with 100% similarity]
plugin_list/tag_parser_list.txt.in [moved from tag_parser_list.txt.in with 100% similarity]

index a43be7b..d119ce8 100644 (file)
@@ -37,6 +37,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 ################## ## build comm libraries
 ADD_SUBDIRECTORY(parser)
 ADD_SUBDIRECTORY(tool)
+ADD_SUBDIRECTORY(plugin_list)
 
 ## build pkgmgr-info library
 AUX_SOURCE_DIRECTORY(src SRCS)
@@ -47,17 +48,9 @@ SET_TARGET_PROPERTIES(pkgmgr-info PROPERTIES VERSION ${FULLVER})
 TARGET_LINK_LIBRARIES(pkgmgr-info pkgmgr_parser ${libpkgs_LDFLAGS})
 
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/pkgmgr-info.pc.in ${CMAKE_BINARY_DIR}/pkgmgr-info.pc @ONLY)
-CONFIGURE_FILE(parser_path.conf.in parser_path.conf @ONLY)
-CONFIGURE_FILE(mdparser_list.txt.in mdparser_list.txt @ONLY)
-CONFIGURE_FILE(category_parser_list.txt.in category_parser_list.txt @ONLY)
-CONFIGURE_FILE(tag_parser_list.txt.in tag_parser_list.txt @ONLY)
 CONFIGURE_FILE(pkg_db_version.txt.in pkg_db_version.txt @ONLY)
 
 INSTALL(TARGETS pkgmgr-info DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-info.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/parser_path.conf DESTINATION ${SYSCONFDIR}/package-manager/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/metadata)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/category_parser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/category)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tag_parser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkg_db_version.txt DESTINATION ${SYSCONFDIR}/package-manager/)
index c0aa9fe..c2f10b8 100644 (file)
@@ -93,7 +93,6 @@ ln -sf ../pkg-db-recovery.service %{buildroot}%{_unitdir}/basic.target.wants/pkg
 %{_libdir}/libpkgmgr_parser.so.*
 %config %{_sysconfdir}/package-manager/preload/manifest.xsd
 %config %{_sysconfdir}/package-manager/preload/xml.xsd
-%config %{_sysconfdir}/package-manager/parser_path.conf
 %config %{_sysconfdir}/package-manager/parserlib/metadata/mdparser_list.txt
 %config %{_sysconfdir}/package-manager/parserlib/category/category_parser_list.txt
 %config %{_sysconfdir}/package-manager/parserlib/tag_parser_list.txt
index 980d440..98945dd 100644 (file)
@@ -57,9 +57,6 @@ extern "C" {
 
 #define DEFAULT_LOCALE         "No Locale"
 
-#define PKG_PARSERLIB  "parserlib:"
-#define PKG_PARSER_CONF_PATH   SYSCONFDIR "/package-manager/parser_path.conf"
-
 #define PKG_STRING_LEN_MAX 1024
 
 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
index 16c2507..442d329 100644 (file)
 #define XMLCHAR(s) (const xmlChar *)s
 
 #define METADATA_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/metadata/mdparser_list.txt"
-#define METADATA_PARSER_NAME "metadataparser:"
-
 #define CATEGORY_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/category/category_parser_list.txt"
-#define CATEGORY_PARSER_NAME "categoryparser:"
-
 #define TAG_PARSER_LIST SYSCONFDIR "/package-manager/parserlib/tag_parser_list.txt"
-#define TAG_PARSER_NAME        "parserlib:"
+
+#define PLUGIN_PATH_PREFIX SYSCONFDIR "/package-manager/parserlib/"
 
 #define OWNER_ROOT 0
 #define BUFSIZE 4096
@@ -1319,10 +1316,7 @@ static void __str_trim(char *input)
 
 static char *__get_parser_plugin(const char *type)
 {
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
        char temp_path[1024] = { 0 };
-       char *path = NULL;
        int ret = -1;
 
        if (type == NULL) {
@@ -1330,35 +1324,8 @@ static char *__get_parser_plugin(const char *type)
                return NULL;
        }
 
-       fp = fopen(PKG_PARSER_CONF_PATH, "r");
-       if (fp == NULL) {
-               _LOGE("no matching backendlib\n");
-               return NULL;
-       }
-
-       while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-               if (buffer[0] == '#')
-                       continue;
-
-               __str_trim(buffer);
-
-               if ((path = strstr(buffer, PKG_PARSERLIB)) != NULL) {
-                       path = path + strlen(PKG_PARSERLIB);
-                       break;
-               }
-
-               memset(buffer, 0x00, 1024);
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       if (path == NULL) {
-               _LOGE("no matching backendlib\n");
-               return NULL;
-       }
-
-       ret = snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
+       ret = snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so",
+                       PLUGIN_PATH_PREFIX, type);
        if (ret < 0 || ret > sizeof(temp_path) -1) {
                _LOGE("snprintf fail");
                return NULL;
@@ -1526,46 +1493,15 @@ static void __metadata_parser_clear_dir_list(GList* dir_list)
 
 static char *__get_metadata_parser_plugin(const char *type)
 {
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
        char temp_path[1024] = { 0 };
-       char *path = NULL;
 
        if (type == NULL) {
                _LOGE("invalid argument\n");
                return NULL;
        }
 
-       fp = fopen(PKG_PARSER_CONF_PATH, "r");
-       if (fp == NULL) {
-               _LOGE("no matching metadata parser\n");
-               return NULL;
-       }
-
-       while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-               if (buffer[0] == '#')
-                       continue;
-
-               __str_trim(buffer);
-
-               if ((path = strstr(buffer, METADATA_PARSER_NAME)) != NULL) {
-                       path = path + strlen(METADATA_PARSER_NAME);
-
-                       break;
-               }
-
-               memset(buffer, 0x00, 1024);
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       if (path == NULL) {
-               _LOGE("no matching [%s] [%s]\n", METADATA_PARSER_NAME, type);
-               return NULL;
-       }
-
-       snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
+       snprintf(temp_path, sizeof(temp_path) - 1, "%smetadata/lib%s.so",
+                       PLUGIN_PATH_PREFIX, type);
 
        return strdup(temp_path);
 }
@@ -1760,46 +1696,15 @@ static void __category_parser_clear_dir_list(GList* dir_list)
 
 static char *__get_category_parser_plugin(const char *type)
 {
-       FILE *fp = NULL;
-       char buffer[1024] = { 0 };
        char temp_path[1024] = { 0 };
-       char *path = NULL;
 
        if (type == NULL) {
                _LOGE("invalid argument\n");
                return NULL;
        }
 
-       fp = fopen(PKG_PARSER_CONF_PATH, "r");
-       if (fp == NULL) {
-               _LOGE("no matching metadata parser\n");
-               return NULL;
-       }
-
-       while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-               if (buffer[0] == '#')
-                       continue;
-
-               __str_trim(buffer);
-
-               if ((path = strstr(buffer, CATEGORY_PARSER_NAME)) != NULL) {
-                       path = path + strlen(CATEGORY_PARSER_NAME);
-
-                       break;
-               }
-
-               memset(buffer, 0x00, 1024);
-       }
-
-       if (fp != NULL)
-               fclose(fp);
-
-       if (path == NULL) {
-               _LOGE("no matching [%s] [%s]\n", CATEGORY_PARSER_NAME, type);
-               return NULL;
-       }
-
-       snprintf(temp_path, sizeof(temp_path) - 1, "%slib%s.so", path, type);
+       snprintf(temp_path, sizeof(temp_path) - 1, "%s/category/lib%s.so",
+                       PLUGIN_PATH_PREFIX, type);
 
        return strdup(temp_path);
 }
diff --git a/parser_path.conf.in b/parser_path.conf.in
deleted file mode 100644 (file)
index 34453a9..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-# usage
-# parserlib:directory_path
-
-parserlib:@SYSCONFDIR@/package-manager/parserlib/
-mdparser:@SYSCONFDIR@/package-manager/parserlib/metadata/
-categoryparser:@SYSCONFDIR@/package-manager/parserlib/category/
diff --git a/plugin_list/CMakeLists.txt b/plugin_list/CMakeLists.txt
new file mode 100644 (file)
index 0000000..61d0578
--- /dev/null
@@ -0,0 +1,7 @@
+CONFIGURE_FILE(mdparser_list.txt.in mdparser_list.txt @ONLY)
+CONFIGURE_FILE(category_parser_list.txt.in category_parser_list.txt @ONLY)
+CONFIGURE_FILE(tag_parser_list.txt.in tag_parser_list.txt @ONLY)
+
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mdparser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/metadata)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/category_parser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib/category)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tag_parser_list.txt DESTINATION ${SYSCONFDIR}/package-manager/parserlib)