From: Kichan Kwon Date: Tue, 15 May 2018 08:05:28 +0000 (+0900) Subject: Make some macros consistent X-Git-Tag: submit/tizen/20180515.082614~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ac5b82f1b3e25e7ed9cbee278614e08abc0df21;p=platform%2Fcore%2Fapi%2Fsystem-info.git Make some macros consistent - Related with model-config and DB Change-Id: I12b8b9629d7993a7d11a55bfcbd21342c278d570 Signed-off-by: Kichan Kwon --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c6695c0..2a74d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,12 +27,12 @@ IF("${ARCH}" STREQUAL "arm") ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DCONFIG_FILE_PATH=\"${CONFIG_FILE_PATH}\"") +ADD_DEFINITIONS("-DMODEL_CONFIG_RO_PATH=\"${MODEL_CONFIG_RO_PATH}\"") ADD_DEFINITIONS("-DINFO_FILE_PATH=\"${INFO_FILE_PATH}\"") ADD_DEFINITIONS("-DTIZEN_ID_PATH=\"${TIZEN_ID_PATH}\"") ADD_DEFINITIONS("-DLIBPATH=\"${LIB_INSTALL_DIR}\"") -ADD_DEFINITIONS("-DSYSTEM_INFO_DB_PATH=\"${DB_PATH}\"") -ADD_DEFINITIONS("-DSYSTEM_INFO_DB_RUNTIME_PATH=\"${DB_RUNTIME_PATH}\"") +ADD_DEFINITIONS("-DSYSTEM_INFO_DB_RO_PATH=\"${DB_RO_PATH}\"") +ADD_DEFINITIONS("-DSYSTEM_INFO_DB_RW_PATH=\"${DB_RW_PATH}\"") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") diff --git a/packaging/capi-system-info.spec b/packaging/capi-system-info.spec index 1f5d784..d3e316e 100644 --- a/packaging/capi-system-info.spec +++ b/packaging/capi-system-info.spec @@ -1,5 +1,3 @@ -%define config_file_path %{_sysconfdir}/config/model-config.xml - Name: capi-system-info Version: 0.5 Release: 1 @@ -37,20 +35,22 @@ cp %{SOURCE1001} . %define info_file_path /etc/info.ini %define sysinfo_shared_path %{TZ_SYS_ETC}/sysinfo %define tizen_id_path %{sysinfo_shared_path}/tizenid -%define db_path %{TZ_SYS_RO_ETC}/system_info_db -%define model_config_path /opt/system/model-config -%define db_runtime_path %{model_config_path}/system_info_db + +%define model_config_ro_path %{_sysconfdir}/config/model-config.xml +%define db_ro_path %{TZ_SYS_RO_ETC}/system_info_db +%define model_config_rw_dir /opt/system/model-config +%define db_rw_path %{model_config_rw_dir}/system_info_db %build MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DCONFIG_FILE_PATH=%{config_file_path} \ +%cmake . -DMODEL_CONFIG_RO_PATH=%{model_config_ro_path} \ -DINFO_FILE_PATH=%{info_file_path} \ -DMAJORVER=${MAJORVER} \ -DFULLVER=%{version} \ -DTIZEN_ID_PATH=%{tizen_id_path} \ - -DDB_PATH=%{db_path} \ - -DDB_RUNTIME_PATH=%{db_runtime_path} + -DDB_RO_PATH=%{db_ro_path} \ + -DDB_RW_PATH=%{db_rw_path} %__make %{?_smp_mflags} @@ -62,11 +62,11 @@ cp -f script/make_info_file.sh %{buildroot}/etc/make_info_file.sh %install_service sysinit.target.wants tizenid.service mkdir -p %{buildroot}/%{sysinfo_shared_path} -mkdir -p %{buildroot}/%{model_config_path} +mkdir -p %{buildroot}/%{model_config_rw_dir} %posttrans /usr/bin/chsmack -a "System::Shared" -t %{sysinfo_shared_path} -/usr/bin/chsmack -a "System::Shared" -t %{model_config_path} +/usr/bin/chsmack -a "System::Shared" -t %{model_config_rw_dir} /usr/bin/system_info_init_db /sbin/ldconfig @@ -79,7 +79,7 @@ mkdir -p %{buildroot}/%{model_config_path} %attr(0744,root,-) /etc/make_info_file.sh %{_bindir}/system_info_init_db -%attr(0775,root,system_share) %dir %{model_config_path} +%attr(0775,root,system_share) %dir %{model_config_rw_dir} #tizenid %attr(0775,root,system_share) %dir %{sysinfo_shared_path} %{_bindir}/tizen_id diff --git a/src/init_db/system_info_db_init.c b/src/init_db/system_info_db_init.c index 1137a9c..911c997 100644 --- a/src/init_db/system_info_db_init.c +++ b/src/init_db/system_info_db_init.c @@ -299,10 +299,10 @@ static int system_info_create_db(const char *conf_path, char *db_path) GDBM_FILE db; if (conf_path == NULL) - conf_path = CONFIG_FILE_PATH; + conf_path = MODEL_CONFIG_RO_PATH; if (db_path == NULL) - db_path = SYSTEM_INFO_DB_PATH; + db_path = SYSTEM_INFO_DB_RO_PATH; db = gdbm_open(db_path, 0, GDBM_WRCREAT, S_IRUSR | S_IRGRP | S_IROTH, NULL); if (!db) { @@ -450,7 +450,7 @@ static int system_info_update_db(int argc, char *argv[]) * If flags is set to ‘GDBM_WRITER’, * the user wants both read and write access to the database * and requires exclusive access */ - db = gdbm_open(SYSTEM_INFO_DB_PATH, 0, GDBM_WRITER, S_IRUSR | S_IRGRP | S_IROTH, NULL); + db = gdbm_open(SYSTEM_INFO_DB_RO_PATH, 0, GDBM_WRITER, S_IRUSR | S_IRGRP | S_IROTH, NULL); if (!db) { _E("Failed to open db (%d, %s)", gdbm_errno, gdbm_strerror(gdbm_errno)); return -ENOENT; diff --git a/src/system_info.c b/src/system_info.c index cb90d1c..030a795 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -121,10 +121,10 @@ static int db_get_value(enum tag_type tag, const char *key, } } - if (access(SYSTEM_INFO_DB_RUNTIME_PATH, R_OK) == 0) - db_path = SYSTEM_INFO_DB_RUNTIME_PATH; + if (access(SYSTEM_INFO_DB_RW_PATH, R_OK) == 0) + db_path = SYSTEM_INFO_DB_RW_PATH; else - db_path = SYSTEM_INFO_DB_PATH; + db_path = SYSTEM_INFO_DB_RO_PATH; db = gdbm_open(db_path, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL); if (!db) { @@ -223,10 +223,10 @@ static int system_info_get_type(enum tag_type tag, const char *key, } if (!system_info_db_path) { - if (access(SYSTEM_INFO_DB_RUNTIME_PATH, R_OK) == 0) - system_info_db_path = SYSTEM_INFO_DB_RUNTIME_PATH; + if (access(SYSTEM_INFO_DB_RW_PATH, R_OK) == 0) + system_info_db_path = SYSTEM_INFO_DB_RW_PATH; else - system_info_db_path = SYSTEM_INFO_DB_PATH; + system_info_db_path = SYSTEM_INFO_DB_RO_PATH; } db = gdbm_open(system_info_db_path, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL);