From: SangYoun Kwak Date: Fri, 7 Jun 2024 06:08:29 +0000 (+0900) Subject: Split do_update function into update.c X-Git-Tag: accepted/tizen/unified/20240614.085117~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51816f1b453e3f3f4aa3f948729ee12cef730aa4;p=platform%2Fcore%2Fsystem%2Fupdate-control.git Split do_update function into update.c There are two functionalities in the osu: resize, update. Function for resize is separated into its file so it is easy to find and maintain. On the other hand, update is embeded in the osu.c with main function. To increase readability and maintainability, update function is separated into update.c and update.h. Change-Id: Iaf84325f1ef8edc7236a4a324f1194e1ec9f8b25 Signed-off-by: SangYoun Kwak --- diff --git a/tools/osu/CMakeLists.txt b/tools/osu/CMakeLists.txt index a1e6628..42f2cf2 100644 --- a/tools/osu/CMakeLists.txt +++ b/tools/osu/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT(update-control-tools-${OUTPUT_BIN_NAME} C) INCLUDE_DIRECTORIES(. ${CMAKE_SOURCE_DIR}/include) -FILE(GLOB_RECURSE SRCS osu.c resize.c) +FILE(GLOB_RECURSE SRCS osu.c resize.c update.c) ADD_EXECUTABLE(${OUTPUT_BIN_NAME} ${SRCS}) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") TARGET_LINK_LIBRARIES(${OUTPUT_BIN_NAME} ${REQUIRED_PKGS_LDFLAGS} update-control) diff --git a/tools/osu/osu.c b/tools/osu/osu.c index 744ba47..b08f639 100644 --- a/tools/osu/osu.c +++ b/tools/osu/osu.c @@ -23,8 +23,8 @@ #include #include -#include "update_control.h" #include "resize.h" +#include "update.h" struct arguments { @@ -90,45 +90,6 @@ static void print_help(char *my_name) "By default, without an argument, the OS Upgrade will be triggered.\n\n", my_name); } -static int do_update() -{ - int ret = 0; - ret = update_control_initialize(); - if (ret != UPDATE_CONTROL_ERROR_NONE) { - printf("Failed to initialize: %d\n", ret); - return ret; - } - printf("Succeed to initialize\n"); - - ret = update_control_check_new_version(); - if (ret != UPDATE_CONTROL_ERROR_NONE) { - printf("Failed to check new version: %d\n", ret); - goto cleanup; - } - - ret = update_control_download_package(); - if (ret != UPDATE_CONTROL_ERROR_NONE) { - printf("Failed to download delta: %d\n", ret); - goto cleanup; - } - printf("Succeed to download delta\n"); - - ret = update_control_do_update(); - if (ret != UPDATE_CONTROL_ERROR_NONE) { - printf("Failed to trigger update: %d\n", ret); - goto cleanup; - } - - printf("Succeed to trigger update: %d\n", ret); - -cleanup: - ret = update_control_deinitialize(); - if (ret != UPDATE_CONTROL_ERROR_NONE) - printf("Failed to deinitialize: %d\n", ret); - - return ret; -} - int main(int argc, char **argv) { int ret = 0; diff --git a/tools/osu/update.c b/tools/osu/update.c new file mode 100644 index 0000000..458bb90 --- /dev/null +++ b/tools/osu/update.c @@ -0,0 +1,43 @@ +#include + +#include "update_control.h" +#include "update.h" + +int do_update(void) +{ + int ret = 0; + ret = update_control_initialize(); + if (ret != UPDATE_CONTROL_ERROR_NONE) { + printf("Failed to initialize: %d\n", ret); + return ret; + } + printf("Succeed to initialize\n"); + + ret = update_control_check_new_version(); + if (ret != UPDATE_CONTROL_ERROR_NONE) { + printf("Failed to check new version: %d\n", ret); + goto cleanup; + } + + ret = update_control_download_package(); + if (ret != UPDATE_CONTROL_ERROR_NONE) { + printf("Failed to download delta: %d\n", ret); + goto cleanup; + } + printf("Succeed to download delta\n"); + + ret = update_control_do_update(); + if (ret != UPDATE_CONTROL_ERROR_NONE) { + printf("Failed to trigger update: %d\n", ret); + goto cleanup; + } + + printf("Succeed to trigger update: %d\n", ret); + +cleanup: + ret = update_control_deinitialize(); + if (ret != UPDATE_CONTROL_ERROR_NONE) + printf("Failed to deinitialize: %d\n", ret); + + return ret; +} diff --git a/tools/osu/update.h b/tools/osu/update.h new file mode 100644 index 0000000..5c64bbc --- /dev/null +++ b/tools/osu/update.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 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. + */ + +#pragma once + +int do_update(void);