From a0662b55b7a4433b399ae8d5a3c7c6927781660f Mon Sep 17 00:00:00 2001 From: Jeon Sang-Heon Date: Mon, 1 Jun 2020 14:06:59 +0900 Subject: [PATCH] Remove update-helper - Remove update-helper - Give permission to system_fw of tota_dir - Version up : 1.2.8 Change-Id: I888d52279f754fd004273d71c022dd666639e5f4 Signed-off-by: Jeon Sang-Heon --- CMakeLists.txt | 2 - packaging/tota-ua.spec | 24 +-- update-helper/CMakeLists.txt | 28 --- update-helper/org.tizen.system.update.service | 4 - update-helper/update-helper.c | 274 -------------------------- update-helper/update-helper.conf | 24 --- update-helper/update-helper.path | 5 - update-helper/update-helper.service | 8 - update-helper/update-helper.sh | 26 --- 9 files changed, 2 insertions(+), 393 deletions(-) delete mode 100755 update-helper/CMakeLists.txt delete mode 100644 update-helper/org.tizen.system.update.service delete mode 100644 update-helper/update-helper.c delete mode 100644 update-helper/update-helper.conf delete mode 100644 update-helper/update-helper.path delete mode 100644 update-helper/update-helper.service delete mode 100755 update-helper/update-helper.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c8e781..0243c93 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,5 +65,3 @@ ADD_EXECUTABLE(${FOTA_GUI_TEST} src/fota_gui_test.c) INSTALL(TARGETS ${EXECNAME} DESTINATION ${BINDIR}) INSTALL(TARGETS ${FOTA_GUI_TEST} DESTINATION ${BINDIR}) - -ADD_SUBDIRECTORY(update-helper) diff --git a/packaging/tota-ua.spec b/packaging/tota-ua.spec index 04c8316..7d63fe9 100755 --- a/packaging/tota-ua.spec +++ b/packaging/tota-ua.spec @@ -1,7 +1,7 @@ Name: tota-ua Summary: fota update agent ExclusiveArch: %{arm} -Version: 1.2.7 +Version: 1.2.8 Release: 0 Group: System License: Apache-2.0 @@ -20,12 +20,6 @@ Requires: gzip %description Fota update agent which update firmware using delta files -%package -n update-helper-service -Summary: Update Helper Package for update-agent -Requires: %{name} = %{version}-%{release} -%description -n update-helper-service -Update helper service and script package for update-agent - %prep %setup -q @@ -53,29 +47,15 @@ install -m 755 scripts/upgrade-trigger.sh %{buildroot}%{_bindir} %define fota_dir /opt/usr/data/fota mkdir -p %{buildroot}%{fota_dir} -# update-helper-service -%define update_dir %{_datadir}/upgrade -mkdir -p %{buildroot}%{update_dir} -mkdir -p %{buildroot}%{_unitdir}/basic.target.wants -install -m 755 update-helper/update-helper.sh %{buildroot}%{update_dir} -install -m 644 update-helper/update-helper.service %{buildroot}%{_unitdir} - %post %files %license LICENSE %manifest tota-ua.manifest %doc README -%{fota_dir} +%attr(755, root, system_fw) %{fota_dir} %defattr(-,root,root,-) %{_bindir}/delta.ua %{_bindir}/upgrade-trigger.sh %attr(700,-,-) %{_datadir}/initrd-recovery/initrd.list.d/40-tota-ua.list %{_bindir}/fota_gui_test - -%files -n update-helper-service -%{_bindir}/update-helper -%{update_dir}/update-helper.sh -%{_unitdir}/update-helper.service -%{system_bus_services_dir}/org.tizen.system.update.service -%{systemd_dbus_conf_dir}/update-helper.conf diff --git a/update-helper/CMakeLists.txt b/update-helper/CMakeLists.txt deleted file mode 100755 index 72a2022..0000000 --- a/update-helper/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(update-helper C) - -SET(SRCS update-helper.c) - -INCLUDE(FindPkgConfig) -pkg_check_modules(requires REQUIRED - dlog - gio-2.0 - libtzplatform-config -) - -FOREACH(flag ${requires_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") - -SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie") - -ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${requires_LDFLAGS}) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) - -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.system.update.service - DESTINATION ${SYSTEM_BUS_SERVICES_DIR}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/update-helper.conf - DESTINATION ${SYSTEMD_DBUS_CONF_DIR}) diff --git a/update-helper/org.tizen.system.update.service b/update-helper/org.tizen.system.update.service deleted file mode 100644 index f672b5e..0000000 --- a/update-helper/org.tizen.system.update.service +++ /dev/null @@ -1,4 +0,0 @@ -[D-BUS Service] -Name=org.tizen.system.update -Exec=/bin/false -SystemdService=update-helper.service diff --git a/update-helper/update-helper.c b/update-helper/update-helper.c deleted file mode 100644 index 70d8758..0000000 --- a/update-helper/update-helper.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. - * - * 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 - -#define UPDATE_BUS_NAME "org.tizen.system.update" -#define UPDATE_OBJECT_PATH "/Org/Tizen/System/Update" - -#define UPDATE_HELPER_PATH "/usr/share/upgrade/update-helper.sh" -#define UPDATE_RESULT_PATH "/opt/data/update/result" - -#define TIMEOUT_INTERVAL 30 - -#undef LOG_TAG -#define LOG_TAG "UPDATE_HELPER" -#define _D(fmt, args...) SLOGD(fmt, ##args) -#define _E(fmt, args...) SLOGE(fmt, ##args) -#define _I(fmt, args...) SLOGI(fmt, ##args) - -static GMainLoop *loop; -static GMutex timeout_mutex; -static guint timeout_id; -static GDBusNodeInfo *introspection_data; -static const gchar introspection_xml[] = -"" -" " -" " -" " -" " -" " -" " -" " -" " -" " -""; - -static int system_command(char *command) -{ - int pid = 0; - int status = 0; - const char *environ[] = { NULL }; - - if (command == NULL) - return -1; - - pid = fork(); - if (pid == -1) - return -1; - if (pid == 0) { - char *argv[4]; - argv[0] = "sh"; - argv[1] = "-c"; - argv[2] = (char *)command; - argv[3] = 0; - execve("/bin/sh", argv, (char **)environ); - exit(127); - } - if (pid < 0) - return -1; - - do { - if (waitpid(pid, &status, 0) == -1) { - if (errno != EINTR) - return -1; - } else { - if (WIFEXITED(status)) - return WEXITSTATUS(status); - else if (WIFSIGNALED(status)) - return WTERMSIG(status); - else if (WIFSTOPPED(status)) - return WSTOPSIG(status); - } - } while (!WIFEXITED(status) && !WIFSIGNALED(status)); - - return 0; -} - -static void exec_update_helper(const char *pkg_path) -{ - int ret; - char command[PATH_MAX]; - - ret = snprintf(command, sizeof(command), "%s %s", - UPDATE_HELPER_PATH, pkg_path); - if (ret < 0) { - _E("Failed to execute update helper"); - return; - } - system_command(command); -} - -static int read_result(void) -{ - int result = -1; - FILE *fp = NULL; - - if (access(UPDATE_RESULT_PATH, F_OK) || !(fp = fopen(UPDATE_RESULT_PATH, "r"))) { - _E("Fail to open result file: %s", UPDATE_RESULT_PATH); - return -1; - } - - if (fscanf(fp, "%x", (unsigned int *)&result) == -1) { - _E("Fail to fscanf"); - fclose(fp); - return -1; - } - - fclose(fp); - return result; -} - -static int timeout_cb(gpointer data) -{ - _I("Time out!"); - g_main_loop_quit((GMainLoop *)data); - - return 0; -} - -static void add_timeout(void) -{ - g_mutex_lock(&timeout_mutex); - - if (timeout_id) - g_source_remove(timeout_id); - timeout_id = g_timeout_add_seconds(TIMEOUT_INTERVAL, timeout_cb, loop); - - g_mutex_unlock(&timeout_mutex); - _I("Add loop timeout (%d)", TIMEOUT_INTERVAL); -} - -static void remove_timeout(void) -{ - g_mutex_lock(&timeout_mutex); - - if (timeout_id) { - g_source_remove(timeout_id); - timeout_id = 0; - } - - g_mutex_unlock(&timeout_mutex); - _I("Remove loop timeout"); -} - -static void method_call_handler(GDBusConnection *conn, - const gchar *sender, - const gchar *object_path, - const gchar *iface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - int ret = 0; - const gchar *arg; - - remove_timeout(); - - if (g_strcmp0(method_name, "do_update") == 0) { - g_variant_get(parameters, "(&s)", &arg); - _D("Update package path: %s", arg); - exec_update_helper(arg); - } else if (g_strcmp0(method_name, "get_result") == 0) { - if ((ret = read_result()) < 0) - _E("Failed to read_result"); - } - - g_dbus_method_invocation_return_value(invocation, - g_variant_new("(i)", ret)); - - add_timeout(); -} - -static const GDBusInterfaceVTable interface_vtable = { - method_call_handler, - NULL, - NULL -}; - -static void on_bus_acquired(GDBusConnection *conn, - const gchar *name, - gpointer user_data) -{ - guint registration_id; - - registration_id = g_dbus_connection_register_object(conn, - UPDATE_OBJECT_PATH, introspection_data->interfaces[0], - &interface_vtable, NULL, NULL, NULL); - if (registration_id == 0) - _E("Failed to g_dbus_connection_register_object"); -} - -static void on_name_acquired(GDBusConnection *conn, - const gchar *name, - gpointer user_data) -{ - _D("Acquired the name %s on the system bus", name); -} - -static void on_name_lost(GDBusConnection *conn, - const gchar *name, - gpointer user_data) -{ - _D("Lost the name %s on the system bus", name); -} - -static void dbus_init(void) -{ - GDBusConnection *conn = NULL; - GError *error = NULL; - - introspection_data = - g_dbus_node_info_new_for_xml(introspection_xml, NULL); - if (introspection_data == NULL) { - _E("Failed to init g_dbus_info_new_for_xml"); - return; - } - - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); - if (!conn) { - _E("Failed to get dbus"); - return; - } - - if (error) { - _E("Failed to get dbus: %s", error->message); - g_error_free(error); - return; - } - - g_bus_own_name(G_BUS_TYPE_SYSTEM, UPDATE_BUS_NAME, - G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, - on_name_acquired, on_name_lost, NULL, NULL); -} - -int main(int argc, char **argv) -{ - loop = g_main_loop_new(NULL, false); - - dbus_init(); - - g_mutex_init(&timeout_mutex); - add_timeout(); - - _I("update_helper activated"); - g_main_loop_run(loop); - - if (introspection_data) - g_dbus_node_info_unref(introspection_data); - g_mutex_clear(&timeout_mutex); - g_main_loop_unref(loop); - - return 0; -} diff --git a/update-helper/update-helper.conf b/update-helper/update-helper.conf deleted file mode 100644 index d1d4b95..0000000 --- a/update-helper/update-helper.conf +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/update-helper/update-helper.path b/update-helper/update-helper.path deleted file mode 100644 index 815a54d..0000000 --- a/update-helper/update-helper.path +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -Description=Path activator of update-helper - -[Path] -PathExists=/tmp/.update_start diff --git a/update-helper/update-helper.service b/update-helper/update-helper.service deleted file mode 100644 index 53036fe..0000000 --- a/update-helper/update-helper.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Update helper service for update-agent -DefaultDependencies=no - -[Service] -Type=oneshot -SmackProcessLabel=System::Privileged -ExecStart=/usr/bin/update-helper diff --git a/update-helper/update-helper.sh b/update-helper/update-helper.sh deleted file mode 100755 index 97c79db..0000000 --- a/update-helper/update-helper.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# update-helper.sh -# - -UPDATE_PACKAGE=$1 -PACKAGE_DIR=$(dirname ${UPDATE_PACKAGE}) - -if [ ! -d "${PACKAGE_DIR}" ]; then - echo "Error: Invalid update package directory: ${PACKAGE_DIR}" -fi - -if [ ! -e "${UPDATE_PACKAGE}" ]; then - echo "Error: The update package does not exist: ${UPDATE_PACKAGE}" -fi - -# Decompress update package (delta.tar.gz -> delta.tar) -echo "Decompress update package" -gzip -d ${UPDATE_PACKAGE} -UPDATE_PACKAGE=${UPDATE_PACKAGE%.*} - -echo "Pass the update package to trigger" -echo "update package: ${UPDATE_PACKAGE}" - -tar xvfp ${UPDATE_PACKAGE} -C ${PACKAGE_DIR} upgrade-trigger.sh -exec ${PACKAGE_DIR}/upgrade-trigger.sh ${UPDATE_PACKAGE} -- 2.7.4