%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
%build
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-DMAJORVER=${MAJORVER} \
-DFULLVER=%{version} \
-DTIZEN_ID_PATH=%{tizen_id_path} \
- -DDB_PATH=%{db_path}
+ -DDB_PATH=%{db_path} \
+ -DDB_RUNTIME_PATH=%{db_runtime_path}
%__make %{?_smp_mflags}
%install_service sysinit.target.wants tizenid.service
mkdir -p %{buildroot}/%{sysinfo_shared_path}
+mkdir -p %{buildroot}/%{model_config_path}
%posttrans
/usr/bin/chsmack -a "System::Shared" -t %{sysinfo_shared_path}
+/usr/bin/chsmack -a "System::Shared" -t %{model_config_path}
/usr/bin/system_info_init_db
/sbin/ldconfig
%attr(0744,root,-) /etc/make_info_file.sh
%{_bindir}/system_info_init_db
+%attr(0664,root,system_share) %dir %{model_config_path}
#tizenid
%attr(0775,root,system_share) %dir %{sysinfo_shared_path}
%{_bindir}/tizen_id
return ret;
}
-static int system_info_get_values_config_xml(GDBM_FILE *db)
+static int system_info_get_values_config_xml(GDBM_FILE *db, const char *path)
{
xmlDocPtr doc;
xmlNodePtr cur;
if (!db || !*db)
return -EINVAL;
- doc = xmlParseFile(CONFIG_FILE_PATH);
+ doc = xmlParseFile(path);
if (!doc) {
- _E("cannot file open %s file!!!", CONFIG_FILE_PATH);
+ _E("cannot file open %s file!!!", path);
return SYSTEM_INFO_ERROR_IO_ERROR;
}
cur = xmlDocGetRootElement(doc);
if (!cur) {
- _E("empty document %s file!!!", CONFIG_FILE_PATH);
+ _E("empty document %s file!!!", path);
ret = -ENOENT;
goto out;
}
return 0;
}
-static int system_info_create_db(void)
+static int system_info_create_db(const char *conf_path, char *db_path)
{
int ret;
GDBM_FILE db;
- db = gdbm_open(SYSTEM_INFO_DB_PATH, 0, GDBM_WRCREAT, S_IRUSR | S_IRGRP | S_IROTH, NULL);
+ if (conf_path == NULL)
+ conf_path = CONFIG_FILE_PATH;
+
+ if (db_path == NULL)
+ db_path = SYSTEM_INFO_DB_PATH;
+
+ db = gdbm_open(db_path, 0, GDBM_WRCREAT, S_IRUSR | S_IRGRP | S_IROTH, NULL);
if (!db) {
_E("Failed to open db (%d, %s)", gdbm_errno, gdbm_strerror(gdbm_errno));
return -ENOENT;
}
- ret = system_info_get_values_config_xml(&db);
+ ret = system_info_get_values_config_xml(&db, conf_path);
if (ret < 0)
_E("Failed to get keys and values from xml(%d)", ret);
printf(" -l --lang=LANG System info specific language target (capi/webapi/csapi)\n");
printf(" -g --tag=TAG System info tag to update (platform/custom)\n");
printf(" -v --value=VALUE System info value to update\n");
+ printf(" -i --input=PATH System info get input argument from several source\n");
+ printf(" -o --output=PATH System info get output argument from several source\n");
}
static int system_info_update_db(int argc, char *argv[])
char tag[KEY_MAX] = {0};
char value[KEY_MAX] = {0};
char value_bool[LANG_MAX] = {0};
+ char conf_path[KEY_MAX] = {0};
+ char db_path[KEY_MAX] = {0};
enum language lang = LANG_MAX;
int rt;
{ "type", required_argument, 0, 0 },
{ "tag", required_argument, 0, 0 },
{ "value", required_argument, 0, 0 },
+ { "input", required_argument, 0, 0 },
+ { "output", required_argument, 0, 0 },
{ "help", no_argument, 0, 0 },
{ 0, 0, 0, 0 },
};
while (1) {
- opt = getopt_long(argc, argv, "k:t:g:v:l:h",
+ opt = getopt_long(argc, argv, "k:t:g:v:l:i:o:h",
long_options, NULL);
if (opt < 0)
break;
case 'v':
snprintf(value, sizeof(value), "%s", optarg);
break;
+ case 'i':
+ snprintf(conf_path, sizeof(conf_path), "%s", optarg);
+ break;
+ case 'o':
+ snprintf(db_path, sizeof(db_path), "%s", optarg);
+ break;
case 'l':
for (rt = 0; rt < LANG_MAX; rt++) {
if (!runtime[rt].xml_prop)
}
}
+ if (conf_path[0] != '\0' && db_path[0] != '\0') {
+ printf("Make system info db(%s) by %s\n", db_path, conf_path);
+ return system_info_create_db(conf_path, db_path);
+ }
+
failed = false;
if (key[0] == '\0') {
printf("Invalid Parameter: no key\n");
int main(int argc, char *argv[])
{
if (argc == 1)
- return system_info_create_db();
+ return system_info_create_db(NULL, NULL);
return system_info_update_db(argc, argv);
}
GHashTable *hashtable = NULL;
static pthread_mutex_t fmutex = PTHREAD_MUTEX_INITIALIZER;
+static char *system_info_db_path;
+
enum tag_type {
TAG_TYPE_PLATFORM,
TAG_TYPE_CUSTOM,
static int db_get_value(enum tag_type tag, const char *key,
const char *type, char *value, size_t len)
{
+ char *db_path;
char key_internal[KEY_MAX];
GDBM_FILE db = NULL;
datum d_key;
}
}
- db = gdbm_open(SYSTEM_INFO_DB_PATH, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL);
+ if (access(SYSTEM_INFO_DB_RUNTIME_PATH, R_OK) == 0)
+ db_path = SYSTEM_INFO_DB_RUNTIME_PATH;
+ else
+ db_path = SYSTEM_INFO_DB_PATH;
+
+ db = gdbm_open(db_path, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL);
if (!db) {
_E("Failed to open db (%d, %s)", gdbm_errno, gdbm_strerror(gdbm_errno)); //LCOV_EXCL_LINE
pthread_mutex_unlock(&fmutex);
}
}
- db = gdbm_open(SYSTEM_INFO_DB_PATH, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL);
+ if (!system_info_db_path) {
+ if (access(SYSTEM_INFO_DB_RUNTIME_PATH, R_OK) == 0)
+ system_info_db_path = SYSTEM_INFO_DB_RUNTIME_PATH;
+ else
+ system_info_db_path = SYSTEM_INFO_DB_PATH;
+ }
+
+ db = gdbm_open(system_info_db_path, 0, GDBM_READER, S_IRUSR | S_IRGRP | S_IROTH, NULL);
if (!db) {
_E("Failed to open db (%d, %s)", gdbm_errno, gdbm_strerror(gdbm_errno)); //LCOV_EXCL_LINE
pthread_mutex_unlock(&fmutex);