Modified loading syspopup info 39/204039/4
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 18 Apr 2019 23:11:14 +0000 (08:11 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 18 Apr 2019 23:20:33 +0000 (08:20 +0900)
The sp_initdb tool parses the xml data from
'/usr/share/syspopup/default' directory first.
And then, the tool parses '/usr/share/syspopup/<profile>/' directory.

Change-Id: I95b4f8c1800703291fa829756afcc7582664f7fb
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/syspopup.spec
tool/sp_initdb/CMakeLists.txt
tool/sp_initdb/src/sp_initdb.c
tool/sp_initdb/src/syspopup_parser.c

index 527d453..6da49ad 100644 (file)
@@ -93,51 +93,51 @@ cp -f scripts/502.syspopup_upgrade.sh %{buildroot}%{upgrade_script_path}
 %postun caller -p /sbin/ldconfig
 
 %posttrans
-/usr/bin/sp_initdb
-
 if [ -e %{_sysconfdir}/config/model-config.xml ]; then
        PROFILE=`grep "feature\/profile" %{_sysconfdir}/config/model-config.xml`
        if [[ "${PROFILE}" == *"mobile"* ]]; then
-               rm -rf %{_datarootdir}/syspopup/wearable
-               rm -rf %{_datarootdir}/syspopup/tv
-               rm -rf %{_datarootdir}/syspopup/common
-               rm -rf %{_datarootdir}/syspopup/ivi
+               rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+               rm -rf %{_datarootdir}/syspopup/default/tv.xml
+               rm -rf %{_datarootdir}/syspopup/default/common.xml
+               rm -rf %{_datarootdir}/syspopup/default/ivi.xml
        elif [[ "${PROFILE}" == *"wearable"* ]]; then
-               rm -rf %{_datarootdir}/syspopup/mobile
-               rm -rf %{_datarootdir}/syspopup/tv
-               rm -rf %{_datarootdir}/syspopup/common
-               rm -rf %{_datarootdir}/syspopup/ivi
+               rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+               rm -rf %{_datarootdir}/syspopup/default/tv.xml
+               rm -rf %{_datarootdir}/syspopup/default/common.xml
+               rm -rf %{_datarootdir}/syspopup/default/ivi.xml
        elif [[ "${PROFILE}" == *"tv"* ]]; then
-               rm -rf %{_datarootdir}/syspopup/mobile
-               rm -rf %{_datarootdir}/syspopup/wearable
-               rm -rf %{_datarootdir}/syspopup/common
-               rm -rf %{_datarootdir}/syspopup/ivi
+               rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+               rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+               rm -rf %{_datarootdir}/syspopup/default/common.xml
+               rm -rf %{_datarootdir}/syspopup/default/ivi.xml
        elif [[ "${PROFILE}" == *"common"* ]]; then
-               rm -rf %{_datarootdir}/syspopup/mobile
-               rm -rf %{_datarootdir}/syspopup/wearable
-               rm -rf %{_datarootdir}/syspopup/tv
-               rm -rf %{_datarootdir}/syspopup/ivi
+               rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+               rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+               rm -rf %{_datarootdir}/syspopup/default/tv.xml
+               rm -rf %{_datarootdir}/syspopup/default/ivi.xml
        elif [[ "${PROFILE}" == *"ivi"* ]]; then
-               rm -rf %{_datarootdir}/syspopup/mobile
-               rm -rf %{_datarootdir}/syspopup/wearable
-               rm -rf %{_datarootdir}/syspopup/tv
-               rm -rf %{_datarootdir}/syspopup/common
+               rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+               rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+               rm -rf %{_datarootdir}/syspopup/default/tv.xml
+               rm -rf %{_datarootdir}/syspopup/default/common.xml
        else
-               rm -rf %{_datarootdir}/syspopup/mobile
-               rm -rf %{_datarootdir}/syspopup/wearable
-               rm -rf %{_datarootdir}/syspopup/tv
-               rm -rf %{_datarootdir}/syspopup/common
-               rm -rf %{_datarootdir}/syspopup/ivi
+               rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+               rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+               rm -rf %{_datarootdir}/syspopup/default/tv.xml
+               rm -rf %{_datarootdir}/syspopup/default/common.xml
+               rm -rf %{_datarootdir}/syspopup/default/ivi.xml
 
        fi
 else
-       rm -rf %{_datarootdir}/syspopup/mobile
-       rm -rf %{_datarootdir}/syspopup/wearable
-       rm -rf %{_datarootdir}/syspopup/tv
-       rm -rf %{_datarootdir}/syspopup/common
-       rm -rf %{_datarootdir}/syspopup/ivi
+       rm -rf %{_datarootdir}/syspopup/default/mobile.xml
+       rm -rf %{_datarootdir}/syspopup/default/wearable.xml
+       rm -rf %{_datarootdir}/syspopup/default/tv.xml
+       rm -rf %{_datarootdir}/syspopup/default/common.xml
+       rm -rf %{_datarootdir}/syspopup/default/ivi.xml
 fi
 
+/usr/bin/sp_initdb
+
 %files
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
index a953ffa..983a2e9 100644 (file)
@@ -44,8 +44,8 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/data/ivi.xml.in ivi.xml @ONLY)
 INSTALL(TARGETS sp_initdb DESTINATION bin)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.xsd DESTINATION ${SYSCONFDIR}/syspopup/preload/)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml.xsd DESTINATION ${SYSCONFDIR}/syspopup/preload/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mobile.xml DESTINATION share/syspopup/mobile)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wearable.xml DESTINATION share/syspopup/wearable)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tv.xml DESTINATION share/syspopup/tv)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/common.xml DESTINATION share/syspopup/common)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ivi.xml DESTINATION share/syspopup/ivi)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mobile.xml DESTINATION share/syspopup/default)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wearable.xml DESTINATION share/syspopup/default)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tv.xml DESTINATION share/syspopup/default)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/common.xml DESTINATION share/syspopup/default)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/ivi.xml DESTINATION share/syspopup/default)
index 2eb519e..205f6f5 100644 (file)
@@ -74,14 +74,11 @@ static const char *__get_syspopup_path(void)
        static char path[PATH_MAX];
        char *profile = NULL;
 
-       if (access(PATH_SYSPOPUP_DEFAULT, F_OK) == 0)
-               return PATH_SYSPOPUP_DEFAULT;
-
        system_info_get_platform_string("http://tizen.org/feature/profile",
                        &profile);
        if (profile == NULL) {
                printf("Failed to get profile info\n");
-               snprintf(path, sizeof(path), "%s/mobile", PATH_SYSPOPUP);
+               snprintf(path, sizeof(path), "%s/wearable", PATH_SYSPOPUP);
                return path;
        }
 
@@ -96,9 +93,10 @@ static int __init_db(void)
        GList *list = NULL;
        int ret;
 
-       ret = __load_syspopup_info(__get_syspopup_path(), &list);
-       if (ret < 0)
-               goto end;
+       __load_syspopup_info(PATH_SYSPOPUP_DEFAULT, &list);
+       __load_syspopup_info(__get_syspopup_path(), &list);
+       if (!list)
+               return -1;
 
        ret = syspopup_parser_db_open();
        if (ret < 0)
index 55f6b48..b1aa096 100644 (file)
@@ -337,7 +337,6 @@ static int __parse_syspopup(xmlNodePtr node, syspopup_t **syspopup)
 
 int syspopup_parser_parse(const char *manifest, GList **syspopup_list)
 {
-       GList *list = NULL;
        xmlDocPtr doc;
        xmlNodePtr root;
        xmlNodePtr node;
@@ -381,10 +380,9 @@ int syspopup_parser_parse(const char *manifest, GList **syspopup_list)
                        continue;
                }
 
-               list = g_list_append(list, info);
+               *syspopup_list = g_list_append(*syspopup_list, info);
        }
 
-       *syspopup_list = list;
        xmlFreeDoc(doc);
 
        return 0;