From 9a8a4c8e26f4769fc43f75fb8519a7bfd43264a8 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Wed, 13 Jan 2021 10:21:36 +0900 Subject: [PATCH] Cleanup pkgmgr-info - 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 --- CMakeLists.txt | 9 +- packaging/pkgmgr-info.spec | 1 - parser/include/pkgmgr_parser.h | 3 - parser/src/pkgmgr_parser_deprecated.c | 111 ++------------------- parser_path.conf.in | 6 -- plugin_list/CMakeLists.txt | 7 ++ .../category_parser_list.txt.in | 0 .../mdparser_list.txt.in | 0 .../metadata_parser_list.txt.in | 0 .../tag_parser_list.txt.in | 0 10 files changed, 16 insertions(+), 121 deletions(-) delete mode 100644 parser_path.conf.in create mode 100644 plugin_list/CMakeLists.txt rename category_parser_list.txt.in => plugin_list/category_parser_list.txt.in (100%) rename mdparser_list.txt.in => plugin_list/mdparser_list.txt.in (100%) rename metadata_parser_list.txt.in => plugin_list/metadata_parser_list.txt.in (100%) rename tag_parser_list.txt.in => plugin_list/tag_parser_list.txt.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a43be7b..d119ce8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/) diff --git a/packaging/pkgmgr-info.spec b/packaging/pkgmgr-info.spec index c0aa9fe..c2f10b8 100644 --- a/packaging/pkgmgr-info.spec +++ b/packaging/pkgmgr-info.spec @@ -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 diff --git a/parser/include/pkgmgr_parser.h b/parser/include/pkgmgr_parser.h index 980d440..98945dd 100644 --- a/parser/include/pkgmgr_parser.h +++ b/parser/include/pkgmgr_parser.h @@ -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) diff --git a/parser/src/pkgmgr_parser_deprecated.c b/parser/src/pkgmgr_parser_deprecated.c index 16c2507..442d329 100644 --- a/parser/src/pkgmgr_parser_deprecated.c +++ b/parser/src/pkgmgr_parser_deprecated.c @@ -42,13 +42,10 @@ #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 index 34453a9..0000000 --- a/parser_path.conf.in +++ /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 index 0000000..61d0578 --- /dev/null +++ b/plugin_list/CMakeLists.txt @@ -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) diff --git a/category_parser_list.txt.in b/plugin_list/category_parser_list.txt.in similarity index 100% rename from category_parser_list.txt.in rename to plugin_list/category_parser_list.txt.in diff --git a/mdparser_list.txt.in b/plugin_list/mdparser_list.txt.in similarity index 100% rename from mdparser_list.txt.in rename to plugin_list/mdparser_list.txt.in diff --git a/metadata_parser_list.txt.in b/plugin_list/metadata_parser_list.txt.in similarity index 100% rename from metadata_parser_list.txt.in rename to plugin_list/metadata_parser_list.txt.in diff --git a/tag_parser_list.txt.in b/plugin_list/tag_parser_list.txt.in similarity index 100% rename from tag_parser_list.txt.in rename to plugin_list/tag_parser_list.txt.in -- 2.7.4