Add new package update-control-tools 65/307365/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 20 Feb 2024 10:30:06 +0000 (19:30 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Thu, 7 Mar 2024 10:21:55 +0000 (19:21 +0900)
update-control-tools is a package that contains tools for invoking
update, testing update etc.

 * Tool 'fota':
   By using update-control apis, it downloads delta file and triggers
   update.

Change-Id: Id556d224e48657b1e6455774932de34e657d50b9
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
CMakeLists.txt
packaging/update-control.spec
tools/CMakeLists.txt [new file with mode: 0644]
tools/fota/CMakeLists.txt [new file with mode: 0644]
tools/fota/main.c [new file with mode: 0644]

index 32b0b071797c4db17b4ca4e1a44116e9e5b00aec..cf19d0ae580bd1cd5dbcfb532a8768474fce563a 100644 (file)
@@ -71,3 +71,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTAL
 ADD_SUBDIRECTORY(src/plugin)
 ADD_SUBDIRECTORY(update-manager)
 ADD_SUBDIRECTORY(delta-verifier)
+ADD_SUBDIRECTORY(tools)
index 055b08c69647d09984b42aacb051b4926738784e..7144463622f7ee658bf148f6928ceb88d4ab50ed 100644 (file)
@@ -58,6 +58,13 @@ Requires: %{name} = %{version}-%{release}
 
 %description plugin
 
+%package tools
+Summary:  Tools for update control
+Group:    System/Utilities
+Requires: %{name} = %{version}-%{release}
+
+%description tools
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -72,7 +79,8 @@ export CFLAGS+=" -Wno-stringop-truncation"
 %cmake . -DMAJORVER=${MAJORVER} \
         -DFULLVER=%{version} \
         -DDEBUG_MODE=on \
-        -DPLUGIN_PATH=%{_libdir}
+        -DPLUGIN_PATH=%{_libdir} \
+        -DBINARY_PATH=%{_bindir}
 
 %__make %{?jobs:-j%jobs}
 
@@ -116,3 +124,8 @@ ln -s ../%{service_file} %{buildroot}/%{_unitdir}/multi-user.target.wants/%{serv
 %license LICENSE
 # path is fixed in src/update_control.c
 %{_libdir}/libupdate-control-plugin.so*
+
+%files tools
+%manifest %{name}.manifest
+%license LICENSE
+%{_bindir}/fota
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6ad7d0a
--- /dev/null
@@ -0,0 +1,4 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(update-control-tools C)
+
+ADD_SUBDIRECTORY(fota)
diff --git a/tools/fota/CMakeLists.txt b/tools/fota/CMakeLists.txt
new file mode 100644 (file)
index 0000000..83984c7
--- /dev/null
@@ -0,0 +1,11 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(OUTPUT_BIN_NAME fota)
+PROJECT(update-control-tools-${OUTPUT_BIN_NAME} C)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+FILE(GLOB_RECURSE SRCS main.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)
+INSTALL(TARGETS ${OUTPUT_BIN_NAME} DESTINATION ${BINARY_PATH})
diff --git a/tools/fota/main.c b/tools/fota/main.c
new file mode 100644 (file)
index 0000000..d4158db
--- /dev/null
@@ -0,0 +1,43 @@
+#include <stdio.h>
+
+#include "update_control.h"
+
+int main(int argc, char **argv)
+{
+       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;
+}