Divide controller to each files 64/239964/17
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 31 Jul 2020 14:05:05 +0000 (14:05 +0000)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Fri, 7 Aug 2020 17:26:21 +0000 (17:26 +0000)
- Divide controller to each files
- If constants uses by only one files, move from header to file
- Minor clean up log tag and message

Change-Id: Ie6ffd4bdbfffb943bb4dde1d92f3d0992af5571f
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
16 files changed:
update-manager/dbus-manager.c
update-manager/fota-controller.c [deleted file]
update-manager/fota/fota-client-controller.c
update-manager/fota/fota-client-info-checker.c
update-manager/fota/fota-delta-verifier.c
update-manager/fota/fota-info-checker.c
update-manager/fota/fota-installer.c [new file with mode: 0644]
update-manager/fota/fota-manager.h
update-manager/fota/fota-result-sender.c [new file with mode: 0644]
update-manager/fota/fota-status-checker.c
update-manager/fota/fota-storage-checker.c
update-manager/recovery/recovery-client-controller.c
update-manager/recovery/recovery-client-info-checker.c
update-manager/recovery/recovery-manager.h
update-manager/update-manager.h
update-manager/util.c

index 9d4c059507ad89d70e11182e4ffa12e9923f7a5d..cea865a9cae1165d2aa795753a26eb1992f124c9 100644 (file)
@@ -1,4 +1,6 @@
+#include "fota/fota-manager.h"
 #include "update-manager.h"
+#include "update-manager-dbus.h"
 
 static guint owner_id;
 
@@ -7,7 +9,7 @@ gboolean dbus_manager_result(OrgTizenUpdateManager *skeleton, GDBusMethodInvocat
        int ret = 0;
 
        _D("Dbus status : result called");
-       ret = fota_controller_result();
+       ret = fota_result_sender_execute();
        if (ret < 0)
                _W("Failed to fetch result with fota : %d", ret);
        org_tizen_update_manager_complete_result(skeleton, invocation, ret);
@@ -20,7 +22,7 @@ gboolean dbus_manager_install(OrgTizenUpdateManager *skeleton, GDBusMethodInvoca
        int ret = 0;
 
        _D("Dbus status : install called");
-       ret = fota_controller_install();
+       ret = fota_installer_execute();
        if (ret < 0)
                _W("Failed to install delta with fota : %d", ret);
        org_tizen_update_manager_complete_install(skeleton, invocation, ret);
diff --git a/update-manager/fota-controller.c b/update-manager/fota-controller.c
deleted file mode 100644 (file)
index ef81437..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-#include "fota/fota-manager.h"
-#include "update-manager.h"
-
-int fota_controller_setup_delta()
-{
-       int ret = 0, status = 0;
-       char *appid = NULL, *build_string = NULL;
-       gchar *shared_path = NULL;
-
-       ret = util_file_mkdir(FOTA_DIR);
-       if (ret < 0) {
-               status = -1;
-               goto delta_destroy;
-       }
-
-       appid = fota_client_info_get_appid();
-       if (appid == NULL) {
-               _I("Failed to get client app id");
-               status = -1;
-               goto delta_destroy;
-       }
-
-       build_string = fota_info_get_build_string();
-       if (build_string == NULL) {
-               _E("Failed to get build string");
-               status = -1;
-               goto delta_destroy;
-       }
-
-       ret = remove(FOTA_DELTA_PATH);
-       if (ret < 0 && errno != ENOENT)
-               _W("Failed to remove exist link : %m");
-
-       shared_path = g_strjoin("/", SHARED_DIR, appid, SHARED_DATA_DIR, FOTA_DELTA_FILE, NULL);
-       ret = fota_delta_verify(shared_path, build_string, NULL);
-       if (ret != 0) {
-               _E("Failed to verify delta : %d", ret);
-               status = -1;
-               goto delta_destroy;
-       }
-
-       ret = symlink(shared_path, FOTA_DELTA_PATH);
-       if (ret < 0) {
-               _E("Failed to link delta : %m");
-               status = -1;
-               goto delta_destroy;
-       }
-
-       ret = util_file_untar(FOTA_DELTA_PATH, FOTA_DIR, FOTA_DELTA_UA_FILE);
-       if (ret < 0) {
-               _E("Failed to fetch delta.ua from delta : %d", ret);
-               status = -1;
-               goto delta_destroy;
-       }
-
-       _I("Success to setup delta to %s", FOTA_DIR);
-
-delta_destroy:
-       g_free(shared_path);
-
-       return status;
-}
-
-int fota_controller_setup_status()
-{
-       int ret = 0;
-
-       ret = util_file_mkdir(STATUS_DIR);
-       if (ret < 0)
-               return -1;
-
-       ret = util_file_write_line(STATUS_FLAG_PATH, "");
-       if (ret < 0)
-               return -1;
-
-       ret = util_file_write_line(STATUS_FOTA_PATH, FOTA_DIR);
-       if (ret < 0)
-               return -1;
-
-       _I("Success to setup fota status to %s", STATUS_DIR);
-
-       return 0;
-}
-
-int fota_controller_write_platform_version()
-{
-       int ret = 0, status = 0;
-       char *platform_version = NULL;
-       gchar *formatted_version = NULL;
-
-       platform_version = fota_info_get_platform_version();
-       if (platform_version == NULL) {
-               _E("Failed to get platform version");
-               status = -1;
-               goto version_destroy;
-       }
-
-       formatted_version = g_strconcat("OLD_VER=", platform_version, ".0.0\n", NULL);
-       ret = util_file_write_line(PLATFORM_VERSION_PATH, formatted_version);
-       if (ret < 0) {
-               status = -1;
-               goto version_destroy;
-       }
-
-       _I("Success to write version to %s : %s", PLATFORM_VERSION_PATH, formatted_version);
-
-version_destroy:
-       g_free(formatted_version);
-
-       return status;
-}
-
-int fota_controller_install()
-{
-       int ret = 0;
-
-       ret = fota_controller_setup_delta();
-       if (ret < 0) {
-               _E("Failed to setup delta.tar : %d", ret);
-               return -1;
-       }
-
-       ret = fota_controller_write_platform_version();
-       if (ret < 0) {
-               _E("Failed to write platform version : %d", ret);
-               return -1;
-       }
-
-       ret = fota_controller_setup_status();
-       if (ret < 0) {
-               _E("Failed to setup fota update status : %d", ret);
-               return -1;
-       }
-
-       ret = device_power_reboot(FOTA_REBOOT_REASON);
-       if (ret != DEVICE_ERROR_NONE) {
-               _E("Failed to request reboot with reason : %s", FOTA_REBOOT_REASON);
-               return -1;
-       }
-
-       _I("Success to request fota, device will reboot");
-       return 0;
-}
-
-int fota_controller_result()
-{
-       char *fota_result = NULL;
-       int len = 0;
-
-       fota_result = fota_status_get_result();
-       if (fota_result == NULL) {
-               _I("Fota result : Not exist");
-               return 4;
-       }
-
-       len = strlen(fota_result);
-       _I("Fota result length : %d", len);
-
-       if (len > 2 && fota_result[0] == 'F') {
-               if (fota_result[1] == 'D') {
-                       _I("Fota result : RO failed, %s", fota_result);
-                       return 3;
-               }
-               else if (fota_result[1] == 'A') {
-                       _I("Fota result : RW failed, %s", fota_result);
-                       return 2;
-               }
-       }
-
-       if (len > 1 && fota_result[1] != '0') {
-               _I("Fota result : RO only success, %s", fota_result);
-               return 1;
-       }
-
-       if (len > 1 && fota_result[0] == '0' && fota_result[1] == '0') {
-               _I("Fota result : RO/RW success, %s", fota_result);
-               return 0;
-       }
-
-       _E("Unexpected result : %s", fota_result);
-       return -1;
-}
index 6207a4bda74326bcabe64a094d2ba22891391b2f..72c86f192435971457b98146eff9d7bea07e7434 100644 (file)
@@ -1,6 +1,10 @@
 #include "../update-manager.h"
 #include "fota-manager.h"
 
+#define FOTA_CLIENT_APP_CTRL_PLUG_KEY "fota-plug"
+#define FOTA_CLIENT_APP_CTRL_UNPLUG_KEY "fota-unplug"
+#define FOTA_CLIENT_APP_CTRL_REBOOT_KEY "fota-reboot"
+
 static const char* fota_event_keys[FOTA_EVENT_SIZE] = {
        FOTA_CLIENT_APP_CTRL_PLUG_KEY,
        FOTA_CLIENT_APP_CTRL_UNPLUG_KEY,
index 1f657d585a5aaad91b0fc1a6f44158ec3d3e9d36..8c14d71b7d22a1742d460d95fedb213b5a18adbc 100644 (file)
@@ -1,6 +1,9 @@
 #include "../update-manager.h"
 #include "fota-manager.h"
 
+#define FOTA_CLIENT_METADATA_KEY "tizen-fota-manager"
+#define FOTA_CLIENT_METADATA_VALUE "client"
+
 static char *fota_client_app_id = NULL;
 
 char *fota_client_info_get_appid()
index a02af04f42d8b783a14004c7d8c40bc27ef6bfdb..6a7b221d20468ff3bbc4a374e7bd074a819ba6b2 100644 (file)
@@ -9,20 +9,19 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
 
        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                _FLOGI("Not found delta in %s", path);
-               status = 1;
+               status = -2;
                goto verify_destroy;
        }
 
        if (old_build_string == NULL) {
                _FLOGE("Failed to try verify, old build string must be passed");
-               status = -1;
+               status = -3;
                goto verify_destroy;
        }
 
        _FLOGI("Found delta in %s, start process to verify", path);
        ret = util_file_untar(path, BUILD_ID_DIR, BUILD_ID_FILE);
        if (ret < 0) {
-               _FLOGE("Failed to fetch %s from delta : %d", BUILD_ID_FILE, ret);
                status = -1;
                goto verify_destroy;
        }
@@ -42,7 +41,7 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
 
        if (g_strrstr(buf, old_build_string) == NULL) {
                _FLOGI("Unmatched occur, old_build_string : %s, delta : %s", old_build_string, buf);
-               status = 2;
+               status = -4;
                goto verify_destroy;
        }
 
@@ -55,7 +54,7 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
 
                if (g_strrstr(buf, new_build_string) == NULL) {
                        _FLOGI("Unmatched occur, new_build_string : %s, delta : %s", new_build_string, buf);
-                       status = 3;
+                       status = -4;
                        goto verify_destroy;
                }
        }
@@ -63,9 +62,7 @@ int fota_delta_verify(const char *path, const char *old_build_string, const char
        _FLOGI("Success to verify %s, old : %s, new : %s", path, old_build_string, new_build_string);
 
 verify_destroy:
-       ret = remove(BUILD_ID_PATH);
-       if (ret < 0)
-               _FLOGW("Failed to remove %s : %m", BUILD_ID_PATH);
+       util_file_remove(BUILD_ID_PATH);
 
        if (!fp)
                fclose(fp);
index 380fddfc232295ff340f2b0a1a64eee4416dfa30..da78460e5fe9d32f6c07321b556094c2c30b1f06 100644 (file)
@@ -1,6 +1,9 @@
 #include "fota-manager.h"
 #include "../update-manager.h"
 
+#define SYSTEM_INFO_BUILD_STRING "tizen.org/system/build.string"
+#define SYSTEM_INFO_PLATFORM_VERSION "tizen.org/feature/platform.version"
+
 static char *build_string = NULL;
 static char *platform_version = NULL;
 
diff --git a/update-manager/fota/fota-installer.c b/update-manager/fota/fota-installer.c
new file mode 100644 (file)
index 0000000..63f4366
--- /dev/null
@@ -0,0 +1,142 @@
+#include "fota-manager.h"
+#include "../update-manager.h"
+
+int fota_installer_setup_delta()
+{
+       int ret = 0;
+       char *appid = NULL, *build_string = NULL;
+       gchar *shared_path = NULL;
+
+       ret = util_file_mkdir(FOTA_DIR);
+       if (ret < 0)
+               return -1;
+
+       appid = fota_client_info_get_appid();
+       if (appid == NULL) {
+               _FLOGE("Failed to get client app id");
+               return -1;
+       }
+
+       build_string = fota_info_get_build_string();
+       if (build_string == NULL) {
+               _FLOGE("Failed to get build string");
+               return -1;
+       }
+
+       shared_path = g_strjoin("/", SHARED_DIR, appid, SHARED_DATA_DIR, FOTA_DELTA_FILE, NULL);
+       ret = fota_delta_verify(shared_path, build_string, NULL);
+       if (ret < 0) {
+               _FLOGE("Failed to verify delta : %d, path : %s, old_build_string : %s",
+                               ret, shared_path, build_string);
+               g_free(shared_path);
+               return -1;
+       }
+
+       ret = util_file_symlink(shared_path, FOTA_DELTA_PATH);
+       if (ret < 0) {
+               g_free(shared_path);
+               return -1;
+       }
+       g_free(shared_path);
+
+       ret = util_file_untar(FOTA_DELTA_PATH, FOTA_DIR, FOTA_DELTA_UA_FILE);
+       if (ret < 0)
+               return -1;
+
+       _FLOGI("Success to setup delta to %s", FOTA_DIR);
+       return 0;
+}
+
+int fota_installer_setup_platform_version()
+{
+       int ret = 0;
+       char *platform_version = NULL;
+       gchar *formatted_version = NULL;
+
+       platform_version = fota_info_get_platform_version();
+       if (platform_version == NULL) {
+               _FLOGE("Failed to get platform version");
+               return -1;
+       }
+
+       switch(strlen(platform_version)) {
+       case 1:
+               formatted_version = g_strconcat("OLD_VER=", platform_version, ".0.0.0\n", NULL);
+               break;
+       case 3:
+               formatted_version = g_strconcat("OLD_VER=", platform_version, ".0.0\n", NULL);
+               break;
+       case 5:
+               formatted_version = g_strconcat("OLD_VER=", platform_version, ".0\n", NULL);
+               break;
+       case 7:
+               formatted_version = g_strconcat("OLD_VER=", platform_version, "\n", NULL);
+               break;
+       default:
+               _FLOGE("Unexpected version string : %s", platform_version);
+               return -1;
+       }
+       
+       ret = util_file_write_line(FOTA_INSTALL_PLATFORM_VERSION_PATH, formatted_version);
+       if (ret < 0) {
+               g_free(formatted_version);
+               return -1;
+       }
+
+       _FLOGI("Success to setup version to %s : %s", FOTA_INSTALL_PLATFORM_VERSION_PATH, formatted_version);
+       g_free(formatted_version);
+
+       return 0;
+}
+
+int fota_installer_setup_status()
+{
+       int ret = 0;
+
+       ret = util_file_mkdir(STATUS_DIR);
+       if (ret < 0)
+               return -1;
+
+       ret = util_file_write_line(STATUS_FLAG_PATH, NULL);
+       if (ret < 0)
+               return -1;
+
+       ret = util_file_write_line(STATUS_FOTA_PATH, FOTA_DIR);
+       if (ret < 0)
+               return -1;
+
+       _FLOGI("Success to setup fota status");
+       return 0;
+}
+
+int fota_installer_execute()
+{
+       int ret = 0;
+
+       ret = fota_installer_setup_delta();
+       if (ret < 0) {
+               _FLOGE("Failed to setup delta.tar : %d", ret);
+               return -1;
+       }
+
+       ret = fota_installer_setup_platform_version();
+       if (ret < 0) {
+               _FLOGE("Failed to setup platform version : %d", ret);
+               return -1;
+       }
+
+       ret = fota_installer_setup_status();
+       if (ret < 0) {
+               _FLOGE("Failed to setup fota status : %d", ret);
+               return -1;
+       }
+
+       ret = device_power_reboot(FOTA_INSTALL_REBOOT_REASON);
+       if (ret != DEVICE_ERROR_NONE) {
+               _FLOGE("Failed to reboot with %s", FOTA_INSTALL_REBOOT_REASON);
+               return -1;
+       }
+
+       _FLOGI("Success to reboot with %s, device will reboot", FOTA_INSTALL_REBOOT_REASON);
+       return 0;
+}
index 2940c3e36ddf15578bae071c364ec59b7c34ce30..374374baf5ef840af02b9837ea15c69ce71e7ecc 100644 (file)
 #define _FLOGE(fmt, arg...) SLOG(LOG_ERROR, FOTA_LOG_TAG, fmt, ##arg)
 
 /* Constant */
-#define FOTA_CLIENT_METADATA_KEY "tizen-fota-manager"
-#define FOTA_CLIENT_METADATA_VALUE "client"
-#define FOTA_CLIENT_APP_CTRL_PLUG_KEY "fota-plug"
-#define FOTA_CLIENT_APP_CTRL_UNPLUG_KEY "fota-unplug"
-#define FOTA_CLIENT_APP_CTRL_REBOOT_KEY "fota-reboot"
 
-#define SYSTEM_INFO_BUILD_STRING "tizen.org/system/build.string"
-#define SYSTEM_INFO_PLATFORM_VERSION "tizen.org/feature/platform.version"
 
-#define FOTA_EVENT_SIZE 3
+#define FOTA_INSTALL_PLATFORM_VERSION_PATH "/opt/etc/version"
+#define FOTA_INSTALL_REBOOT_REASON "fota"
 
-#define FOTA_LOCAL_FOLDER_TOKEN "@"
+#define FOTA_EVENT_SIZE 3
 
 /* Enum */
 typedef enum {
@@ -48,6 +42,10 @@ int fota_info_checker_fini(void);
 char *fota_info_get_build_string(void);
 char *fota_info_get_platform_version(void);
 
+int fota_installer_execute(void);
+
+int fota_result_sender_execute(void);
+
 int fota_status_checker_init(void);
 int fota_status_checker_fini(void);
 char *fota_status_get_result(void);
diff --git a/update-manager/fota/fota-result-sender.c b/update-manager/fota/fota-result-sender.c
new file mode 100644 (file)
index 0000000..767b573
--- /dev/null
@@ -0,0 +1,41 @@
+#include "fota-manager.h"
+#include "../update-manager.h"
+
+int fota_result_sender_execute()
+{
+       char *fota_result = NULL;
+       int len = 0;
+
+       fota_result = fota_status_get_result();
+       if (fota_result == NULL) {
+               _FLOGI("Fota result : Not exist");
+               return 4;
+       }
+
+       len = strlen(fota_result);
+       _FLOGD("Fota result length : %d", len);
+
+       if (len > 2 && fota_result[0] == 'F') {
+               if (fota_result[1] == 'D') {
+                       _FLOGI("Fota result : RO failed, %s", fota_result);
+                       return 3;
+               }
+               else if (fota_result[1] == 'A') {
+                       _FLOGI("Fota result : RW failed, %s", fota_result);
+                       return 2;
+               }
+       }
+
+       if (len > 1 && fota_result[1] != '0') {
+               _FLOGI("Fota result : RO only success, %s", fota_result);
+               return 1;
+       }
+
+       if (len > 1 && fota_result[0] == '0' && fota_result[1] == '0') {
+               _FLOGI("Fota result : RO/RW success, %s", fota_result);
+               return 0;
+       }
+
+       _FLOGW("Unexpected result : %s", fota_result);
+       return -1;
+}
index a23af6d3588da0275153a5ca962c8bbda954d26c..0cc10550b62351ebbf3524a6f577d297a9f9b62d 100644 (file)
@@ -19,10 +19,8 @@ int fota_status_checker_init()
        }
 
        ret = util_file_read_single_line(STATUS_RESULT_PATH, buf);
-       if (ret < 0) {
-               _FLOGE("Failed to read fota result : %d", ret);
+       if (ret < 0)
                return -1;
-       }
 
        fota_result = strndup(buf, strlen(buf));
        if (fota_result == NULL) {
@@ -43,11 +41,9 @@ int fota_status_checker_init()
                return -1;
        }
 
-       ret = remove(STATUS_FLAG_PATH);
-       if (ret != 0) {
-               _FLOGE("Failed to remove fota flag : %d, %m", ret);
+       ret = util_file_remove(STATUS_FLAG_PATH);
+       if (ret < 0)
                return -1;
-       }
 
        return 0;
 }
index 529337ea40c2eda862fa12c7980b125c19b54879..3593015f9f3357483dbb7a4f4f5f12ffda4702c0 100644 (file)
@@ -1,6 +1,8 @@
 #include "../update-manager.h"
 #include "fota-manager.h"
 
+#define FOTA_STORAGE_FOLDER_TOKEN "@"
+
 static int fota_storage_id = -1;
 
 int fota_storage_verify_delta(const char* mount_path, const char *folder_name, gchar **delta_path)
@@ -12,36 +14,35 @@ int fota_storage_verify_delta(const char* mount_path, const char *folder_name, g
        old_build_string = fota_info_get_build_string();
        if (old_build_string == NULL) {
                _FLOGE("Failed to get build string");
-               status = -1;
-               goto verify_destroy;
+               return -1;
        }
 
        if (g_str_has_prefix(folder_name, old_build_string) != TRUE) {
                _FLOGI("Folder %s is not start with %s, pass", folder_name, old_build_string);
-               goto verify_destroy;
+               return -1;
        }
 
-       new_build_string = strstr(folder_name, FOTA_LOCAL_FOLDER_TOKEN);
+       new_build_string = strstr(folder_name, FOTA_STORAGE_FOLDER_TOKEN);
        if (new_build_string == NULL) {
-               _FLOGI("Folder %s doesn't have token : %s", folder_name, FOTA_LOCAL_FOLDER_TOKEN);
-               goto verify_destroy;
+               _FLOGI("Folder %s doesn't have token : %s", folder_name, FOTA_STORAGE_FOLDER_TOKEN);
+               return -1;
        }
        new_build_string = new_build_string + 1;
 
        path = g_strjoin("/", mount_path, folder_name, FOTA_DELTA_FILE, NULL);
        if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
                _FLOGI("Folder %s doesn't have delta.tar", folder_name);
+               status = -1;
                goto verify_destroy;
        }
 
        ret = fota_delta_verify(path, old_build_string, new_build_string);
        if (ret < 0) {
+               _FLOGE("Failed to verify delta : %d, path : %s, old_build_string : %s, new_build_string : %s",
+                               ret, path, old_build_string, new_build_string);
                status = -1;
                goto verify_destroy;
        }
-       else if (ret > 0) {
-               goto verify_destroy;
-       }
 
        *delta_path = path;
 
@@ -80,12 +81,21 @@ int fota_storage_search_delta_path(const char *mount_path, gchar **delta_path)
                folder_name = g_file_info_get_name(info);
                ret = fota_storage_verify_delta(mount_path, folder_name, delta_path);
                if (ret < 0) {
-                       _FLOGE("Failed to verify delta : %d, folder : %s", ret, folder_name);
+                       _FLOGE("Failed to verify storage delta : %d", ret);
                        status = -1;
+                       g_object_unref(info);
+                       continue;
+               }
+
+               if (*delta_path != NULL) {
+                       _FLOGI("Success to find verified delta in %s", *delta_path);
+                       status = 0;
+                       goto search_destroy;
                }
 
                g_object_unref(info);
        }
+       status = -1;
 
 search_destroy:
        if (enumerator)
@@ -107,12 +117,7 @@ void fota_storage_checker_plug(int storage_id, const char *mount_path)
        _FLOGI("Storage mounted with %s, start process to check local delta", mount_path);
        ret = fota_storage_search_delta_path(mount_path, &delta_path);
        if (ret < 0) {
-               _FLOGE("Failed to find delta path : %d", ret);
-               goto plug_destroy;
-       }
-
-       if (delta_path == NULL) {
-               _FLOGI("Not found matched delta in %s", mount_path);
+               _FLOGE("Failed to search delta path : %d", ret);
                goto plug_destroy;
        }
 
index 669220279e0671f6aa4d9ae10c3dcd5fe7c5f39b..51e19dc5b2b2700e8950309162dfa6136e7caaba 100644 (file)
@@ -1,6 +1,9 @@
 #include "recovery-manager.h"
 #include "../update-manager.h"
 
+#define RECOVERY_CLIENT_APP_CTRL_PLUG_KEY "recovery-plug"
+#define RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY "recovery-unplug"
+
 static const char* recovery_event_keys[RECOVERY_EVENT_SIZE] = {
        RECOVERY_CLIENT_APP_CTRL_PLUG_KEY,
        RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY,
index ad205410bf51362bca3459ef3d5fbb71e781faf6..8bdfc4dd3f8390846f2e31f77a0d728be1608cca 100644 (file)
@@ -1,6 +1,9 @@
 #include "recovery-manager.h"
 #include "../update-manager.h"
 
+#define RECOVERY_CLIENT_METADATA_KEY "tizen-recovery-manager"
+#define RECOVERY_CLIENT_METADATA_VALUE "client"
+
 static char *recovery_client_app_id = NULL;
 
 char *recovery_client_info_get_appid()
index 8ba8ac39eddf5c27b8f04d54219dadf721c365fd..50884696ff838f770f44578ce815c0f9d429919b 100644 (file)
 #define _RLOGE(fmt, arg...) SLOG(LOG_ERROR, RECOVERY_LOG_TAG, fmt, ##arg)
 
 /* Constant */
-#define RECOVERY_CLIENT_METADATA_KEY "tizen-recovery-manager"
-#define RECOVERY_CLIENT_METADATA_VALUE "client"
-#define RECOVERY_CLIENT_APP_CTRL_PLUG_KEY "recovery-plug"
-#define RECOVERY_CLIENT_APP_CTRL_UNPLUG_KEY "recovery-unplug"
-
 #define RECOVERY_IMAGE_FILE "tizen-recovery.img"
 
 #define RECOVERY_EVENT_SIZE 2
index 3ad5cc7927379b629f799afc78b8467b48aabe97..23fa4bca02be3e1af0dcf33bb8e98d56bd6cd12c 100644 (file)
@@ -17,8 +17,6 @@
 #include <unistd.h>
 #include <vconf.h>
 
-#include "update-manager-dbus.h"
-
 /* Log */
 #undef LOG_TAG
 #define LOG_TAG "UPDATE_MANAGER"
 #define NODE_NAME                   "/org/tizen/update/manager"
 
 /* Update */
-#define PLATFORM_VERSION_DIR        "/opt/etc"
-#define PLATFORM_VERSION_FILE       "version"
-#define PLATFORM_VERSION_PATH       PLATFORM_VERSION_DIR "/" PLATFORM_VERSION_FILE
 
 #define BUILD_ID_DIR                "/tmp"
 #define BUILD_ID_FILE               "build_id.txt"
 #define BUILD_ID_PATH               BUILD_ID_DIR "/" BUILD_ID_FILE
 
-#define FOTA_REBOOT_REASON          "fota"
 #define FOTA_DIR                    "/opt/usr/data/fota"
 #define FOTA_DELTA_FILE             "delta.tar"
 #define FOTA_DELTA_PATH             FOTA_DIR "/" FOTA_DELTA_FILE
@@ -78,10 +72,9 @@ int common_client_info_checker_filter(const char*, const char*, pkgmgrinfo_app_l
 int dbus_manager_init(void);
 int dbus_manager_fini(void);
 
-int fota_controller_install(void);
-int fota_controller_result(void);
-
 int util_file_mkdir(const char *);
+int util_file_remove(const char *);
+int util_file_symlink(const char *, const char *);
 int util_file_read_single_line(const char *, char []);
 int util_file_write_line(const char *, const char *);
 int util_file_untar(const char *, const char *, const char *);
index 7667b10fd1b26a72066fa246a0417736a67ee791..30ad998fc61ed3f368bdf3224e64a9dcc4bc1146 100644 (file)
@@ -17,6 +17,47 @@ int util_file_mkdir(const char *path)
        return 0;
 }
 
+int util_file_remove(const char *path)
+{
+       int ret = 0;
+       gboolean exist = FALSE;
+
+       exist = g_file_test(path, G_FILE_TEST_EXISTS);
+       if (exist) {
+               ret = remove(path);
+               if (ret < 0) {
+                       _E("Failed to remove %s : %m", path);
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+int util_file_symlink(const char *target_path, const char *link_path)
+{
+       int ret = 0;
+       gboolean exist = FALSE;
+
+       exist = g_file_test(target_path, G_FILE_TEST_EXISTS);
+       if (!exist) {
+               _E("Failed to find %s", target_path);
+               return -1;
+       }
+
+       ret = util_file_remove(link_path);
+       if (ret < 0)
+               return -1;
+
+       ret = symlink(target_path, link_path);
+       if (ret < 0) {
+               _E("Failed to symlink from %s to %s : %m", target_path, link_path);
+               return -1;
+       }
+
+       return 0;
+}
+
 int util_file_read_single_line(const char *path, char buf[])
 {
        int status = 0;
@@ -68,7 +109,7 @@ int util_file_untar(const char *tar_path, const char *dest_path, const char *ext
 
        ret = system(command);
        if (ret < 0) {
-               _E("Failed to execute untar command : %m");
+               _E("Failed to execute untar command %s : %m", command);
                status = -1;
        } else if (ret > 0) {
                _E("Failed to untar : %d", ret);