osu: Add ability to set update type 94/314394/3 accepted/tizen_8.0_unified accepted/tizen/8.0/unified/20240715.155227
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 28 Jun 2024 10:28:35 +0000 (12:28 +0200)
committerSangYoun Kwak <sy.kwak@samsung.com>
Thu, 11 Jul 2024 08:07:30 +0000 (17:07 +0900)
To perform an offline update use:

    osu --offline-update

To perform an online update use:

    osu --online-update

Option --update will perform an offline update.

Change-Id: I16232e5025094db0484ad53dc022ab2b93d89319
Signed-off-by: Mateusz Moscicki <m.moscicki2@partner.samsung.com>
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
tools/osu/CMakeLists.txt
tools/osu/osu.c
tools/osu/update.c
tools/osu/update.h

index 42f2cf2423099a6814fd8db34cd573791afc7e8b..da2727c7318cb31bba5e9e53980e4a719a2c66b2 100644 (file)
@@ -2,6 +2,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 SET(OUTPUT_BIN_NAME osu)
 PROJECT(update-control-tools-${OUTPUT_BIN_NAME} C)
 
+SET(PKG_MODULES
+       hal-api-device
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(REQUIRED_PKGS REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${REQUIRED_PKGS_CFLAGS})
+        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
 INCLUDE_DIRECTORIES(. ${CMAKE_SOURCE_DIR}/include)
 
 FILE(GLOB_RECURSE SRCS osu.c resize.c update.c)
index 2f35d7244e4327f173d7a2253805a9a90b7632a0..524dbc3819042dd969957f0934dcc5c824d946f1 100644 (file)
@@ -30,6 +30,7 @@
 struct arguments {
        bool resize;
        bool update;
+       bool online;
 };
 
 static void print_help(char*);
@@ -41,10 +42,13 @@ static int parse_args(int argc, char **argv, struct arguments *args)
 
        args->resize = false;
        args->update = false;
+       args->online = false;
 
        struct option long_options[] = {
                {"resize", no_argument, NULL, 'r'},
                {"update", no_argument, NULL, 'u'},
+               {"offline-update", no_argument, NULL, 'f'},
+               {"online-update", no_argument, NULL, 'n'},
                {"help", no_argument, NULL, 'h'},
                {}
        };
@@ -56,10 +60,16 @@ static int parse_args(int argc, char **argv, struct arguments *args)
                                args->resize = true;
                                return 0;
                        }
-                       case 'u': {
+                       case 'u':
+                       case 'f': {
                                args->update = true;
                                return 0;
                        }
+                       case 'n': {
+                               args->update = true;
+                               args->online = true;
+                               return 0;
+                       }
                        case 'h': {
                                print_help(argv[0]);
                                return 0;
@@ -83,9 +93,11 @@ static void print_help(char *my_name)
        printf("Usage:\n"
                "    %s [--help|--resize|--update]\n\n"
                "Possible arguments:\n"
-               "  --help     Print this help\n"
-               "  --update   Trigger the OS Upgrade\n"
-               "  --resize   Run resize2fs on the rootfs partition.\n"
+               "  --help             Print this help\n"
+               "  --update           Trigger the OS Upgrade (Offline Upgrade)\n"
+               "  --offline-update   Trigger the OS Offline Upgrade\n"
+               "  --online-update    Trigger the OS Online Upgrade\n"
+               "  --resize           Run resize2fs on the rootfs partition.\n"
                "             After that, performing the OS Upgrade will be impossible.\n\n" ,my_name);
 }
 
@@ -101,7 +113,7 @@ int main(int argc, char **argv)
                return do_resize();
 
        if (args.update)
-               return do_update();
+               return do_update(args.online);
 
        print_help(argv[0]);
 
index 3df4c15f96047e2eb9fe232aedb80648e1e45d15..13bd7bd2853d9e6f04577a93c14daeff1a9d32bf 100644 (file)
@@ -2,12 +2,34 @@
 
 #include "update_control.h"
 #include "update.h"
+#include <hal/device/hal-board.h>
 
-int do_update(void)
+
+#define UPDATE_TYPE_ONLINE "online"
+#define UPDATE_TYPE_OFFLINE "offline"
+
+int set_update_type(bool online)
+{
+       char *type;
+       if (online) {
+               type = UPDATE_TYPE_ONLINE;
+       } else {
+               type = UPDATE_TYPE_OFFLINE;
+       }
+       return hal_device_board_set_upgrade_type(type);
+}
+
+int do_update(bool online)
 {
        int ret = 0;
        int ret_deinit = 0;
 
+       ret = set_update_type(online);
+       if (ret != 0) {
+               printf("Failed to set update type\n");
+               return ret;
+       }
+
        ret = update_control_initialize();
        if (ret != UPDATE_CONTROL_ERROR_NONE) {
                printf("Failed to initialize: %d\n", ret);
index 5c64bbcfded4db118d15d821435ab09c6b228782..df95c4559395fb7f60bc17801e59624ff6f01b34 100644 (file)
@@ -15,5 +15,6 @@
  */
 
 #pragma once
+#include <stdbool.h>
 
-int do_update(void);
+int do_update(bool online);