From: Kichan Kwon Date: Thu, 10 Aug 2017 01:54:56 +0000 (+0900) Subject: update_db : remove system_info_update_db X-Git-Tag: submit/tizen/20170811.083904~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F143428%2F2;p=platform%2Fcore%2Fapi%2Fsystem-info.git update_db : remove system_info_update_db - It is for emulator to chroot before system_info_init_db - But, with using busybox, we can use chroot in the initramfs - To apply with emulator, the prerun patch should be applied first - https://review.tizen.org/gerrit/#/c/143420/ Change-Id: I49f12420005ef8860fbb65efb45c57179eadfc0d Signed-off-by: Kichan Kwon --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 68bb0c2..75bcf8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,12 +81,6 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/system_info_intf.h DESTINATION ADD_SUBDIRECTORY(src/tizenid) ADD_SUBDIRECTORY(src/init_db) -OPTION(BUILD_UPDATE_DB "Build update_db tool" ON) - -IF(BUILD_UPDATE_DB) -ADD_SUBDIRECTORY(src/update_db) -ENDIF(BUILD_UPDATE_DB) - #Upgrade script CONFIGURE_FILE( script/500.system_info_upgrade.sh.in diff --git a/packaging/capi-system-info.spec b/packaging/capi-system-info.spec index ae07376..4e946df 100644 --- a/packaging/capi-system-info.spec +++ b/packaging/capi-system-info.spec @@ -1,5 +1,3 @@ -%bcond_with emulator - %define config_file_path %{_sysconfdir}/config/model-config.xml Name: capi-system-info @@ -24,14 +22,6 @@ Requires: security-config %description -%ifarch %{ix86} x86_64 -%package extension-emulator -Summary: A System Information library in Core API for emulator -Requires: %{name} = %{version}-%{release} -%description extension-emulator -A System Information library in Core API for emulator -%endif // ifarch %{ix86} x86_64 - %package devel Summary: A System Information library in Core API (Development) Group: Development/System @@ -51,40 +41,21 @@ cp %{SOURCE1001} . %define upgrade_script_path %{TZ_SYS_RO_SHARE}/upgrade/scripts %build -%{?asan: %define sanitizer 1} -%{?ubsan: %define sanitizer 1} - MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -CMAKE_OPTS="-DCONFIG_FILE_PATH=%{config_file_path} \ - -DINFO_FILE_PATH=%{info_file_path} \ - -DMAJORVER=${MAJORVER} \ - -DFULLVER=%{version} \ - -DSHARED_PATH=%{sysinfo_shared_path} \ - -DTIZEN_ID_PATH=%{tizen_id_path} \ - -DDB_PATH=%{db_path} \ - -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} \ - %{?sanitizer:-DBUILD_UPDATE_DB=OFF}" - -mkdir build && cd build -%cmake .. ${CMAKE_OPTS} - -# Address Sanitizer can't be applied to static binaries, so update_db should be -# excluded from ASan build. So the update_db is rebuilt without forced ASan -# options after the rest of package is ready -%__make %{?_smp_mflags} -%{?sanitizer: -mkdir -p %{_builddir}/update_db && pushd %{_builddir}/update_db -/usr/bin/gcc-unforce-options -%cmake %{_builddir}/%{name}-%{version} ${CMAKE_OPTS} -DBUILD_UPDATE_DB=ON + +%cmake . -DCONFIG_FILE_PATH=%{config_file_path} \ + -DINFO_FILE_PATH=%{info_file_path} \ + -DMAJORVER=${MAJORVER} \ + -DFULLVER=%{version} \ + -DSHARED_PATH=%{sysinfo_shared_path} \ + -DTIZEN_ID_PATH=%{tizen_id_path} \ + -DDB_PATH=%{db_path} \ + -DUPGRADE_SCRIPT_PATH=%{upgrade_script_path} + %__make %{?_smp_mflags} -popd -} %install -pushd build %make_install -popd -%{?sanitizer:pushd %{_builddir}/update_db/src/update_db && %make_install && popd} mkdir -p %{buildroot}/etc cp -f script/make_info_file.sh %{buildroot}/etc/make_info_file.sh @@ -92,10 +63,6 @@ cp -f script/make_info_file.sh %{buildroot}/etc/make_info_file.sh mkdir -p %{buildroot}/%{sysinfo_shared_path} -%ifnarch %{ix86} x86_64 -rm %{buildroot}/%{_bindir}/system_info_update_db -%endif - %posttrans /usr/bin/chsmack -a "System::Shared" -t %{sysinfo_shared_path} /usr/bin/system_info_init_db @@ -120,11 +87,6 @@ rm %{buildroot}/%{_bindir}/system_info_update_db #upgrade script %{upgrade_script_path}/500.system_info_upgrade.sh -%ifarch %{ix86} x86_64 -%files extension-emulator -%{_bindir}/system_info_update_db -%endif // ifarch %{ix86} x86_64 - %files devel %manifest %{name}.manifest %{_includedir}/system/system_info.h diff --git a/src/update_db/CMakeLists.txt b/src/update_db/CMakeLists.txt deleted file mode 100755 index c80cd30..0000000 --- a/src/update_db/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(UPDATE_DB "system_info_update_db") - -SET(SRCS ${CMAKE_SOURCE_DIR}/src/update_db/system_info_db_update.c) -INCLUDE_DIRECTORIES(include) - -SET(BUILD_SHARED_LIBRARIES OFF) -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -static") - -ADD_EXECUTABLE(${UPDATE_DB} ${SRCS}) -TARGET_LINK_LIBRARIES(${UPDATE_DB}) -INSTALL(TARGETS ${UPDATE_DB} DESTINATION bin) diff --git a/src/update_db/system_info_db_update.c b/src/update_db/system_info_db_update.c deleted file mode 100644 index f61f53a..0000000 --- a/src/update_db/system_info_db_update.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define KEY_MAX 256 - -static const char *db_update_arg[] = { - "/usr/bin/system_info_init_db", - "-k", NULL, - "-t", NULL, - "-g", NULL, - "-v", NULL, - NULL, -}; - -static void show_help(void) -{ - printf("system_info_update_db [OPTIONS]\n"); - printf(" -h --help Show this help\n"); - printf(" -r --root=ROOT Root path for chroot operation\n"); - printf(" -k --key=KEY System info key to update\n"); - printf(" -t --type=TYPE System info type to update (int/bool/double/string)\n"); - printf(" -g --tag=TAGE System info tag to update (platform/custom)\n"); - printf(" -v --value=VALUE System info value to update\n"); -} - -int main(int argc, char *argv[]) -{ - pid_t pid; - int status, ret; - int opt; - bool failed; - char root[KEY_MAX] = { 0, }; - char key[KEY_MAX] = { 0, }; - char type[KEY_MAX] = { 0, }; - char tag[KEY_MAX] = { 0, }; - char value[KEY_MAX] = { 0, }; - struct option long_options[] = { - { "root", required_argument, 0, 0 }, - { "key", required_argument, 0, 0 }, - { "type", required_argument, 0, 0 }, - { "tag", required_argument, 0, 0 }, - { "value", required_argument, 0, 0 }, - { "help", no_argument, 0, 0 }, - { 0, 0, 0, 0 }, - }; - - while (1) { - opt = getopt_long(argc, argv, "r:k:t:g:v:h", - long_options, NULL); - if (opt < 0) - break; - switch (opt) { - case 'r': - snprintf(root, sizeof(root), "%s", optarg); - break; - case 'k': - snprintf(key, sizeof(key), "%s", optarg); - break; - case 't': - snprintf(type, sizeof(type), "%s", optarg); - break; - case 'g': - snprintf(tag, sizeof(tag), "%s", optarg); - break; - case 'v': - snprintf(value, sizeof(value), "%s", optarg); - break; - case 'h': - default: - show_help(); - return 0; - } - } - - failed = false; - if (root[0] == '\0') { - printf("Invalid Parameter: no root path\n"); - failed = true; - } - if (key[0] == '\0') { - printf("Invalid Parameter: no key\n"); - failed = true; - } - if (type[0] == '\0') { - printf("Invalid Parameter: no type\n"); - failed = true; - } - if (tag[0] == '\0') { - printf("Invalid Parameter: no tag\n"); - failed = true; - } - if (value[0] == '\0') { - printf("Invalid Parameter: no value\n"); - failed = true; - } - - if (failed) - return -EINVAL; - - printf("Root Path(%s)\n", root); - printf("Request to update: key(%s), type(%s), tag(%s), value(%s)\n", - key, type, tag, value); - - db_update_arg[2] = key; - db_update_arg[4] = type; - db_update_arg[6] = tag; - db_update_arg[8] = value; - - ret = chroot(root); - if (ret < 0) { - printf("Failed to change root dir (%s, errno:%d)\n", root, errno); - return -errno; - } - ret = chdir("/"); - if (ret < 0) { - printf("Failed to go to root directory : %d", errno); - return -errno; - } - - pid = fork(); - if (pid < 0) { - printf("Failed to update db (%d)\n", errno); - return -errno; - } else if (pid == 0) { - ret = execv(db_update_arg[0], (char **)db_update_arg); - if (ret < 0) - exit(EXIT_FAILURE); - return ret; - } else { - ret = waitpid(pid, &status, 0); - if (ret == -1) { - printf("%d waitpid() failed : %d\n", pid, errno); - return -EAGAIN; - } - - if (WIFEXITED(status)) { - printf("%d terminated by exit(%d)\n", pid, WEXITSTATUS(status)); - return WEXITSTATUS(status); - } - - if (WIFSIGNALED(status)) - printf("%d terminated by signal %d\n", pid, WTERMSIG(status)); - else if (WIFSTOPPED(status)) - printf("%d stopped by signal %d\n", pid, WSTOPSIG(status)); - return -EAGAIN; - } -}