From 7b35219a85883e48b184cd2bc272418cab9368ad Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 19 Jul 2022 09:53:11 +0900 Subject: [PATCH] init_db: exclude hal-release information from database For fota, platform-release information is only required. However the current system-info have two kinds of release information, platform and hal, and the hal-release information overwrites the platform-release information. Therefore, do not include hal-release information into system-info database so that there is only platform-release information in the database. Change-Id: I5fc381a3de5d2f13095645d880730531de56d1f0 Signed-off-by: Youngjae Cho (cherry picked from commit 0e51498af3301231c7b59aa5c563582a8f9ba4fa) --- script/make_info_file.sh | 2 +- src/init_db/system_info_db_init.c | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/script/make_info_file.sh b/script/make_info_file.sh index c9b47a8..5785294 100644 --- a/script/make_info_file.sh +++ b/script/make_info_file.sh @@ -30,7 +30,7 @@ Variant=$TZ_BUILD_VARIANT; ID=$ID; EOF - /usr/bin/system_info_init_db --input=/hal/etc/config/model-config.xml --release=/hal/etc/hal-info.ini --output=/hal/etc/system_info_db + /usr/bin/system_info_init_db --input=/hal/etc/config/model-config.xml --output=/hal/etc/system_info_db else cat < /etc/info.ini diff --git a/src/init_db/system_info_db_init.c b/src/init_db/system_info_db_init.c index 0874adf..be203f0 100644 --- a/src/init_db/system_info_db_init.c +++ b/src/init_db/system_info_db_init.c @@ -400,14 +400,8 @@ static int system_info_create_db(const char *conf_path, const char *release_path char file_path[PATH_MAX]; FILE *fp = NULL; - if (conf_path == NULL) - conf_path = MODEL_CONFIG_RO_PATH; - - if (release_path == NULL) - release_path = INFO_FILE_PATH; - if (db_path == NULL) - db_path = SYSTEM_INFO_DB_RO_PATH; + return -EINVAL; ret = mkdir(db_path, 0555); if (ret != 0 && errno != EEXIST) { @@ -425,13 +419,17 @@ static int system_info_create_db(const char *conf_path, const char *release_path fclose(fp); } - ret = system_info_get_values_config_xml(db_path, conf_path); - if (ret < 0) - _E("Failed to get keys and values from xml(%d)", ret); + if (conf_path && conf_path[0]) { + ret = system_info_get_values_config_xml(db_path, conf_path); + if (ret < 0) + _E("Failed to get keys and values from xml(%d)", ret); + } - ret = system_info_get_values_ini(db_path, release_path); - if (ret < 0) - _E("Failed to get keys and values from ini(%d)", ret); + if (release_path && release_path[0]) { + ret = system_info_get_values_ini(db_path, release_path); + if (ret < 0) + _E("Failed to get keys and values from ini(%d)", ret); + } return 0; } @@ -527,8 +525,6 @@ static int system_info_update_db(int argc, char *argv[]) } if (conf_path[0] != '\0' && db_path[0] != '\0') { - if (release_path[0] == '\0') /* For backward compatibility: in case which hasn't provided -r option */ - strncpy(release_path, INFO_FILE_PATH, sizeof(release_path)); printf("Make system info db(%s) by %s and %s\n", db_path, conf_path, release_path); return system_info_create_db(conf_path, release_path, db_path); } @@ -585,7 +581,7 @@ int main(int argc, char *argv[]) umask(0222); if (argc == 1) - return system_info_create_db(NULL, NULL, NULL); + return system_info_create_db(MODEL_CONFIG_RO_PATH, INFO_FILE_PATH, SYSTEM_INFO_DB_RO_PATH); return system_info_update_db(argc, argv); } -- 2.7.4