bootstrap: change bootstrap to a tizen service app
authorWonki kim <akanad@gmail.com>
Sun, 12 Apr 2020 15:01:45 +0000 (08:01 -0700)
committerJongmin Lee <jm105.lee@samsung.com>
Fri, 17 Apr 2020 23:06:48 +0000 (08:06 +0900)
to make user able to run/kill bootstrap server,
this patch change bootstrap to a tizen service app.

Change-Id: Id604c2fbeabae0fd44536367151f306a181a1167

64 files changed:
bootstrap/meson.build [deleted file]
bootstrap/server/aurum-bootstrap.service [deleted file]
bootstrap/server/src/BootstrapServer.cc [deleted file]
meson.build
meson_options.txt
org.tizen.aurum-bootstrap/inc/AurumServiceImpl.h [moved from bootstrap/server/inc/AurumServiceImpl.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/ClearCommand.h [moved from bootstrap/server/inc/Commands/ClearCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/ClickCommand.h [moved from bootstrap/server/inc/Commands/ClickCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/CloseAppCommand.h [moved from bootstrap/server/inc/Commands/CloseAppCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/Command.h [moved from bootstrap/server/inc/Commands/Command.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/Commands.h [moved from bootstrap/server/inc/Commands/Commands.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/FindElementCommand.h [moved from bootstrap/server/inc/Commands/FindElementCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/FlickCommand.h [moved from bootstrap/server/inc/Commands/FlickCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetAppInfoCommand.h [moved from bootstrap/server/inc/Commands/GetAppInfoCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetAttributeCommand.h [moved from bootstrap/server/inc/Commands/GetAttributeCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetDeviceTimeCommand.h [moved from bootstrap/server/inc/Commands/GetDeviceTimeCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetLocationCommand.h [moved from bootstrap/server/inc/Commands/GetLocationCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetSizeCommand.h [moved from bootstrap/server/inc/Commands/GetSizeCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/GetValueCommand.h [moved from bootstrap/server/inc/Commands/GetValueCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/InstallAppCommand.h [moved from bootstrap/server/inc/Commands/InstallAppCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/KillServerCommand.h [moved from bootstrap/server/inc/Commands/KillServerCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/LaunchAppCommand.h [moved from bootstrap/server/inc/Commands/LaunchAppCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/LongClickCommand.h [moved from bootstrap/server/inc/Commands/LongClickCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/PostCommand.h [moved from bootstrap/server/inc/Commands/PostCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/PreCommand.h [moved from bootstrap/server/inc/Commands/PreCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/RemoveAppCommand.h [moved from bootstrap/server/inc/Commands/RemoveAppCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/SendKeyCommand.h [moved from bootstrap/server/inc/Commands/SendKeyCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/SetValueCommand.h [moved from bootstrap/server/inc/Commands/SetValueCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/SyncCommand.h [moved from bootstrap/server/inc/Commands/SyncCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/TouchDownCommand.h [moved from bootstrap/server/inc/Commands/TouchDownCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/TouchMoveCommand.h [moved from bootstrap/server/inc/Commands/TouchMoveCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/Commands/TouchUpCommand.h [moved from bootstrap/server/inc/Commands/TouchUpCommand.h with 100% similarity]
org.tizen.aurum-bootstrap/inc/ObjectMapper.h [moved from bootstrap/server/inc/ObjectMapper.h with 100% similarity]
org.tizen.aurum-bootstrap/meson.build [moved from bootstrap/server/meson.build with 87% similarity]
org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml [new file with mode: 0644]
org.tizen.aurum-bootstrap/src/AurumServiceImpl.cc [moved from bootstrap/server/src/AurumServiceImpl.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/BootstrapServer.cc [new file with mode: 0644]
org.tizen.aurum-bootstrap/src/Commands/ClearCommand.cc [moved from bootstrap/server/src/Commands/ClearCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/ClickCommand.cc [moved from bootstrap/server/src/Commands/ClickCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/CloseAppCommand.cc [moved from bootstrap/server/src/Commands/CloseAppCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/Command.cc [moved from bootstrap/server/src/Commands/Command.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/FindElementCommand.cc [moved from bootstrap/server/src/Commands/FindElementCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/FlickCommand.cc [moved from bootstrap/server/src/Commands/FlickCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetAppInfoCommand.cc [moved from bootstrap/server/src/Commands/GetAppInfoCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetAttributeCommand.cc [moved from bootstrap/server/src/Commands/GetAttributeCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetDeviceTimeCommand.cc [moved from bootstrap/server/src/Commands/GetDeviceTimeCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetLocationCommand.cc [moved from bootstrap/server/src/Commands/GetLocationCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetSizeCommand.cc [moved from bootstrap/server/src/Commands/GetSizeCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/GetValueCommand.cc [moved from bootstrap/server/src/Commands/GetValueCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/InstallAppCommand.cc [moved from bootstrap/server/src/Commands/InstallAppCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/KillServerCommand.cc [moved from bootstrap/server/src/Commands/KillServerCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/LaunchAppCommand.cc [moved from bootstrap/server/src/Commands/LaunchAppCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/LongClickCommand.cc [moved from bootstrap/server/src/Commands/LongClickCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/PostCommand.cc [moved from bootstrap/server/src/Commands/PostCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/PreCommand.cc [moved from bootstrap/server/src/Commands/PreCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/RemoveAppCommand.cc [moved from bootstrap/server/src/Commands/RemoveAppCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/SendKeyCommand.cc [moved from bootstrap/server/src/Commands/SendKeyCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/SetValueCommand.cc [moved from bootstrap/server/src/Commands/SetValueCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/SyncCommand.cc [moved from bootstrap/server/src/Commands/SyncCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/TouchDownCommand.cc [moved from bootstrap/server/src/Commands/TouchDownCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/TouchMoveCommand.cc [moved from bootstrap/server/src/Commands/TouchMoveCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/Commands/TouchUpCommand.cc [moved from bootstrap/server/src/Commands/TouchUpCommand.cc with 100% similarity]
org.tizen.aurum-bootstrap/src/ObjectMapper.cc [moved from bootstrap/server/src/ObjectMapper.cc with 100% similarity]
packaging/aurum.spec

diff --git a/bootstrap/meson.build b/bootstrap/meson.build
deleted file mode 100644 (file)
index 874ed25..0000000
+++ /dev/null
@@ -1 +0,0 @@
-subdir('server')
diff --git a/bootstrap/server/aurum-bootstrap.service b/bootstrap/server/aurum-bootstrap.service
deleted file mode 100644 (file)
index eafa1b2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Unit]
-Description=Server for testing UI testing
-
-[Service]
-Type=simple
-ExecStart=/usr/bin/aurum_bootstrap
-EnvironmentFile=-/run/tizen-system-env
diff --git a/bootstrap/server/src/BootstrapServer.cc b/bootstrap/server/src/BootstrapServer.cc
deleted file mode 100644 (file)
index e053a49..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <iostream>
-#include <glib.h>
-
-#include <gio/gio.h>
-#include <grpcpp/grpcpp.h>
-#include "aurum.grpc.pb.h"
-
-#include "AurumServiceImpl.h"
-#include "config.h"
-#include "loguru.hpp"
-
-using namespace grpc;
-
-static gpointer
-_grpc_thread_func (gpointer data __attribute__((unused)))
-{
-    std::string binding("0.0.0.0:50051");
-    aurumServiceImpl service;
-    ServerBuilder builder;
-
-    LOG_F(INFO, "[T] Server Listening on %s", binding.c_str());
-    builder.AddListeningPort(binding, grpc::InsecureServerCredentials());
-    builder.RegisterService(&service);
-    std::unique_ptr<Server> server(builder.BuildAndStart());
-    server->Wait();
-
-    return NULL;
-}
-
-int main(int argc, char **argv)
-{
-    const char *logPath = "/tmp/ua.log";
-    GMainLoop *loop;
-
-    loguru::init(argc, argv);
-    loguru::g_preamble = false;
-    loguru::add_file(logPath, loguru::Append, loguru::Verbosity_MAX);
-    LOG_SCOPE_F(INFO, "Log : %s", logPath);
-
-    loop = g_main_loop_new ( NULL , FALSE );
-    g_thread_new("grpc_thread", _grpc_thread_func, loop);
-
-    g_main_loop_run (loop);
-    g_main_loop_unref(loop);
-
-    return 0;
-}
index 748dd5e..ed0f20f 100644 (file)
@@ -18,7 +18,7 @@ root_inc = include_directories('./')
 subdir('protocol')
 subdir('libloguru')
 subdir('libaurum')
-subdir('bootstrap')
+subdir('org.tizen.aurum-bootstrap')
 subdir('tests')
 
 configure_file(
index 1bcc370..7f6e0a0 100644 (file)
@@ -3,5 +3,13 @@ option('tizen',
   value: false,
   description: 'enable tizen specific dependancy'
 )
-
-
+option('tzapp_path',
+  type: 'string',
+  value: '/usr/apps/',
+  description: 'installation path for tizen app binary'
+)
+option('tzpackage_path',
+  type: 'string',
+  value: '/usr/share/packages/',
+  description: 'installation path for registering tizen service app'
+)
similarity index 87%
rename from bootstrap/server/meson.build
rename to org.tizen.aurum-bootstrap/meson.build
index f51672e..aeb2413 100644 (file)
@@ -51,25 +51,19 @@ bootstrap_svr_dep += [
    dependency('capi-appfw-app-control'),
    dependency('capi-appfw-app-manager'),
    dependency('capi-appfw-package-manager'),
+   dependency('capi-appfw-service-application'),
 ]
 endif
 
 bootstrap_svr_bin = executable(
-   'aurum_bootstrap',
+   'aurum-bootstrap',
    [bootstrap_svr_src, grpc_src, grpc_pb_src],
    dependencies: bootstrap_svr_dep,
    include_directories: bootstrap_svr_inc,
    link_with: libloguru,
    install:true,
+   install_dir:  join_paths(get_option('tzapp_path'), 'org.tizen.aurum-bootstrap', 'bin'),
    pie:true,
 )
 
-system_unit_dir = ''
-user_unit_dir = ''
-
-systemd = dependency('systemd', required: false)
-if systemd.found()
-   user_unit_dir = systemd.get_pkgconfig_variable('systemduserunitdir')
-endif
-
-install_data('aurum-bootstrap.service', install_dir:user_unit_dir)
+install_data('org.tizen.aurum-bootstrap.xml', install_dir: get_option('tzpackage_path'))
diff --git a/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml b/org.tizen.aurum-bootstrap/org.tizen.aurum-bootstrap.xml
new file mode 100644 (file)
index 0000000..50f0f21
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="5.5" package="org.tizen.aurum-bootstrap" version="0.1.0">
+       <label>aurum-bootstrap</label>
+       <author email="wonki_.kim@samsung.com" href="www.samsung.com">Wonki Kim</author>
+       <description>autofilld</description>
+       <service-application appid="org.tizen.aurum-bootstrap" exec="aurum-bootstrap" multiple="false" nodisplay="true" taskmanage="false" type="capp">
+               <label>aurum bootstrap daemon</label>
+               <background-category value="system"/>
+       </service-application>
+       <privileges>
+               <privilege>http://tizen.org/privilege/datasharing</privilege>
+               <privilege>http://tizen.org/privilege/externalstroage</privilege>
+               <privilege>http://tizen.org/privilege/mediastorage</privilege>
+               <privilege>http://tizen.org/privilege/message.read</privilege>
+               <privilege>http://tizen.org/privilege/application.info</privilege>
+               <privilege>http://tizen.org/privilege/application.launch</privilege>
+       </privileges>
+       <feature name="http://tizen.org/feature/network.ethernet">true</feature>
+</manifest>
diff --git a/org.tizen.aurum-bootstrap/src/BootstrapServer.cc b/org.tizen.aurum-bootstrap/src/BootstrapServer.cc
new file mode 100644 (file)
index 0000000..ad1db18
--- /dev/null
@@ -0,0 +1,79 @@
+#include <iostream>
+#include <glib.h>
+
+#include <service_app.h>
+
+#include <gio/gio.h>
+#include <grpcpp/grpcpp.h>
+#include "aurum.grpc.pb.h"
+
+#include "AurumServiceImpl.h"
+#include "config.h"
+#include "loguru.hpp"
+
+using namespace grpc;
+
+typedef struct _ServiceContext {
+    GMainLoop *loop;
+    GThread   *thread;
+    std::unique_ptr<Server> server;
+} ServiceContext;
+
+static gpointer
+_grpc_thread_func (gpointer data)
+{
+    ServiceContext *ctx = (ServiceContext*)data;
+    std::string binding("0.0.0.0:50051");
+    aurumServiceImpl service;
+    ServerBuilder builder;
+
+    LOG_F(INFO, "[T] Server Listening on %s", binding.c_str());
+    builder.AddListeningPort(binding, grpc::InsecureServerCredentials());
+    builder.RegisterService(&service);
+    //std::unique_ptr<Server> server(builder.BuildAndStart());
+    ctx->server = std::move(builder.BuildAndStart());
+    ctx->server->Wait();
+
+    return NULL;
+}
+
+bool service_app_create(void *data)
+{
+    ServiceContext *ctx = (ServiceContext*)data;
+    const char *logPath = "/tmp/ua.log";
+
+    loguru::g_preamble = false;
+    loguru::add_file(logPath, loguru::Append, loguru::Verbosity_MAX);
+    LOG_SCOPE_F(INFO, "Log : %s", logPath);
+
+    ctx->loop = g_main_loop_new ( NULL , FALSE );
+    ctx->thread = g_thread_new("grpc_thread", _grpc_thread_func, ctx);
+
+    return true;
+}
+
+void service_app_terminate(void *data)
+{
+    ServiceContext *ctx = (ServiceContext*)data;
+    ctx->server->Shutdown();
+    g_main_loop_unref(ctx->loop);
+    g_thread_join(ctx->thread);
+}
+
+void service_app_control(app_control_h app_control, void *data) 
+{
+    ServiceContext *ctx = (ServiceContext*)data;
+}
+
+int main(int argc, char **argv)
+{
+    service_app_lifecycle_callback_s event_callback;  
+    app_event_handler_h handlers[5] = {NULL, };
+    ServiceContext ctx = {0,};    
+                                                  
+    event_callback.create = service_app_create;       
+    event_callback.terminate = service_app_terminate; 
+    event_callback.app_control = service_app_control; 
+
+    return service_app_main(argc, argv, &event_callback, &ctx);
+}
index 9c70332..60f5072 100644 (file)
@@ -23,6 +23,21 @@ BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(capi-appfw-package-manager)
 BuildRequires: pkgconfig(capi-appfw-app-control)
 BuildRequires: pkgconfig(capi-appfw-app-manager)
+BuildRequires: pkgconfig(capi-appfw-service-application)
+BuildRequires: pkgconfig(libtzplatform-config)
+
+%if "%{?profile}" == "tv"
+  %define __hash_signing 0
+%else
+  %define __hash_signing 1
+%endif
+
+%if 0%{?__hash_signing}
+BuildRequires:  hash-signer
+%if 0%{?sec_product_feature_profile_wearable}
+Requires(post): signing-client
+%endif
+%endif
 
 %description
 aurum is a project for testing ui.
@@ -54,6 +69,8 @@ meson \
     --libdir %{_libdir} \
     -Dcpp_std=c++17 \
     -Dtizen=true \
+    -Dtzapp_path=%{TZ_SYS_RO_APP} \
+    -Dtzpackage_path=%{TZ_SYS_RO_PACKAGES} \
     gbsbuild 2>&1 | sed \
         -e 's%^.*: error: .*$%\x1b[37;41m&\x1b[m%' \
         -e 's%^.*: warning: .*$%\x1b[30;43m&\x1b[m%'
@@ -84,6 +101,14 @@ ninja \
 export DESTDIR=%{buildroot}
 ninja -C gbsbuild install
 
+%if 0%{?__hash_signing}
+%define tizen_sign 1
+%define tizen_sign_base /usr/apps/org.tizen.aurum-bootstrap
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
+%endif
+
 %post
 sbin/ldconfig
 
@@ -91,12 +116,16 @@ sbin/ldconfig
 sbin/ldconfig
 
 %post bootstrap
-chsmack -e "User" %{_bindir}/aurum_bootstrap
-
+%if 0%{?sec_product_feature_profile_wearable}
+echo "signing %{TZ_SYS_RO_APP}/org.tizen.aurum-bootstrap"
+/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{TZ_SYS_RO_APP}/org.tizen.aurum-bootstrap
+%endif
+#chsmack -e "User" %{_bindir}/aurum_bootstrap
 
 %postun bootstrap
 /sbin/ldconfig
 
+
 %files
 %manifest %{name}.manifest
 %defattr(-,root,root)
@@ -113,5 +142,8 @@ chsmack -e "User" %{_bindir}/aurum_bootstrap
 %manifest %{name}.manifest
 %defattr(-,root,root)
 %license COPYING
-%{_bindir}/aurum_bootstrap
-%{_unitdir_user}/aurum-bootstrap.service
+#%{_bindir}/aurum_bootstrap
+#%{_unitdir_user}/aurum-bootstrap.service
+%{TZ_SYS_RO_PACKAGES}/org.tizen.aurum-bootstrap.xml
+%{TZ_SYS_RO_APP}/org.tizen.aurum-bootstrap/*
+