From 685ac61a04fed608c83176930bf922f6a7b146ac Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 20 Mar 2017 00:30:16 +0900 Subject: [PATCH] Add build & packaging script of context-agent context-agent will be a user-level assistant service of the main context-service daemon. Change-Id: I74db377718ecd9883c3cb75bef556f32d02cc4d3 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 32 +--------------- packaging/context-service.spec | 38 ++++++++++++++++--- packaging/contextd-agent.service | 9 +++++ ...ntext-service.service => contextd.service} | 2 +- packaging/org.tizen.contextagent.conf | 15 ++++++++ packaging/org.tizen.contextagent.service | 7 ++++ src/agent/AgentMain.cpp | 22 +++++++++++ src/agent/CMakeLists.txt | 21 ++++++++++ src/{ => server}/ActiveUserMonitor.cpp | 0 src/{ => server}/ActiveUserMonitor.h | 0 src/{ => server}/AlarmInitializer.cpp | 0 src/{ => server}/AlarmInitializer.h | 0 src/server/CMakeLists.txt | 32 ++++++++++++++++ src/{ => server}/DBusConnector.cpp | 0 src/{ => server}/DBusConnector.h | 0 src/{Main.cpp => server/ServerMain.cpp} | 0 src/{ => server}/ServiceLoader.cpp | 0 src/{ => server}/ServiceLoader.h | 0 18 files changed, 142 insertions(+), 36 deletions(-) create mode 100644 packaging/contextd-agent.service rename packaging/{context-service.service => contextd.service} (76%) create mode 100644 packaging/org.tizen.contextagent.conf create mode 100644 packaging/org.tizen.contextagent.service create mode 100644 src/agent/AgentMain.cpp create mode 100644 src/agent/CMakeLists.txt rename src/{ => server}/ActiveUserMonitor.cpp (100%) rename src/{ => server}/ActiveUserMonitor.h (100%) rename src/{ => server}/AlarmInitializer.cpp (100%) rename src/{ => server}/AlarmInitializer.h (100%) create mode 100644 src/server/CMakeLists.txt rename src/{ => server}/DBusConnector.cpp (100%) rename src/{ => server}/DBusConnector.h (100%) rename src/{Main.cpp => server/ServerMain.cpp} (100%) rename src/{ => server}/ServiceLoader.cpp (100%) rename src/{ => server}/ServiceLoader.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04c4f5a..ff2c8a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,36 +2,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(context-service) INCLUDE(GNUInstallDirs) -SET(target "contextd") - -SET(DEPS "libsystemd-login glib-2.0 gio-2.0 dlog capi-base-common alarm-service") -SET(DEPS "${DEPS} context-common-server") -SET(DEPS "${DEPS} context-app-history-server") -SET(DEPS "${DEPS} context-sensor-recorder-server") -SET(DEPS "${DEPS} context-store-server") -SET(DEPS "${DEPS} context-job-scheduler-server") - -SET(INCDIR "${CMAKE_INSTALL_INCLUDEDIR}/context-service") - -INCLUDE_DIRECTORIES( - ${CMAKE_INSTALL_PREFIX}/${INCDIR}/private -) - -FILE(GLOB_RECURSE SRCS src/*.cpp) -MESSAGE("Sources: ${SRCS}") - ADD_DEFINITIONS(-O2 -Wall -fPIC -fPIE -fdata-sections -ffunction-sections -fvisibility=hidden) -ADD_DEFINITIONS(-DLOG_TAG="CONTEXT") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -pie -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") -INCLUDE(FindPkgConfig) -pkg_check_modules(DEPS_PKG REQUIRED ${DEPS}) - -FOREACH(flag ${DEPS_PKG_CFLAGS}) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") -ENDFOREACH(flag) - -ADD_EXECUTABLE(${target} ${SRCS}) -TARGET_LINK_LIBRARIES(${target} ${DEPS_PKG_LDFLAGS}) - -INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR}) +ADD_SUBDIRECTORY(src/server) +ADD_SUBDIRECTORY(src/agent) diff --git a/packaging/context-service.spec b/packaging/context-service.spec index 2b90a72..5df292d 100644 --- a/packaging/context-service.spec +++ b/packaging/context-service.spec @@ -5,8 +5,11 @@ Release: 1 Group: Service/Context License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -Source1: context-service.service +Source1: contextd.service Source2: org.tizen.context.conf +Source3: contextd-agent.service +Source4: org.tizen.contextagent.conf +Source5: org.tizen.contextagent.service BuildRequires: cmake BuildRequires: pkgconfig(libsystemd-login) @@ -25,6 +28,14 @@ BuildRequires: pkgconfig(context-job-scheduler-server) %description This is a systemd service that contains all features provided by the Tizen Contextual Service Framework. + +%package -n context-agent +Summary: User-level agent service of the Tizen Contextual Service Framework + +%description -n context-agent +This is a systemd service that runs in the user session to assist the main service daemon of the Contextual Service Framework. + + %prep %setup -q @@ -42,15 +53,32 @@ make %{?_smp_mflags} mkdir -p %{buildroot}%{_unitdir}/default.target.wants install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir} -ln -s ../context-service.service %{buildroot}%{_unitdir}/default.target.wants/context-service.service +ln -s ../contextd.service %{buildroot}%{_unitdir}/default.target.wants/contextd.service mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/system.d/ +mkdir -p %{buildroot}%{_unitdir_user} +install -m 0644 %{SOURCE3} %{buildroot}%{_unitdir_user} + +mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/session.d +install -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/dbus-1/session.d/ + +mkdir -p %{buildroot}/usr/share/dbus-1/services +install -m 0644 %{SOURCE5} %{buildroot}/usr/share/dbus-1/services/ + %files %manifest packaging/%{name}.manifest %config %{_sysconfdir}/dbus-1/system.d/* -%{_bindir}/* -%{_unitdir}/context-service.service -%{_unitdir}/*/context-service.service +%{_bindir}/contextd +%{_unitdir}/contextd.service +%{_unitdir}/*/contextd.service +%license LICENSE + +%files -n context-agent +%manifest packaging/%{name}.manifest +%config %{_sysconfdir}/dbus-1/session.d/* +%{_bindir}/contextd-agent +%{_unitdir_user}/contextd-agent.service +/usr/share/dbus-1/services/* %license LICENSE diff --git a/packaging/contextd-agent.service b/packaging/contextd-agent.service new file mode 100644 index 0000000..e6e36b3 --- /dev/null +++ b/packaging/contextd-agent.service @@ -0,0 +1,9 @@ +[Unit] +Description=Contextual Service Framework User-Level Agent Daemon + +[Service] +Type=dbus +BusName=org.tizen.contextagent +ExecStart=/usr/bin/contextd-agent +Restart=on-failure +RestartSec=1 diff --git a/packaging/context-service.service b/packaging/contextd.service similarity index 76% rename from packaging/context-service.service rename to packaging/contextd.service index e5f2f31..0fb5d90 100644 --- a/packaging/context-service.service +++ b/packaging/contextd.service @@ -1,5 +1,5 @@ [Unit] -Description=Contextual Service Framework Daemon +Description=Contextual Service Framework Server Daemon [Service] User=service_fw diff --git a/packaging/org.tizen.contextagent.conf b/packaging/org.tizen.contextagent.conf new file mode 100644 index 0000000..3683fc7 --- /dev/null +++ b/packaging/org.tizen.contextagent.conf @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/packaging/org.tizen.contextagent.service b/packaging/org.tizen.contextagent.service new file mode 100644 index 0000000..198b7d1 --- /dev/null +++ b/packaging/org.tizen.contextagent.service @@ -0,0 +1,7 @@ +[Unit] +Description=Contextual Service Framework User-Level Agent D-Bus + +[D-BUS Service] +Name=org.tizen.contextagent +Exec=/bin/false +SystemdService=contextd-agent.service diff --git a/src/agent/AgentMain.cpp b/src/agent/AgentMain.cpp new file mode 100644 index 0000000..fc1dc8d --- /dev/null +++ b/src/agent/AgentMain.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 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 + +int main(int argc, char* argv[]) +{ + return EXIT_SUCCESS; +} diff --git a/src/agent/CMakeLists.txt b/src/agent/CMakeLists.txt new file mode 100644 index 0000000..114362f --- /dev/null +++ b/src/agent/CMakeLists.txt @@ -0,0 +1,21 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(target "contextd-agent") + +SET(DEPS glib-2.0 gio-2.0 dlog capi-base-common) + +FILE(GLOB_RECURSE SRCS *.cpp) +MESSAGE("Sources: ${SRCS}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(DEPS_AGENT_PKG REQUIRED ${DEPS}) + +FOREACH(flag ${DEPS_AGENT_PKG_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_EXECUTABLE(${target} ${SRCS}) +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-AGENT\"") +TARGET_LINK_LIBRARIES(${target} ${DEPS_AGENT_PKG_LDFLAGS}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/ActiveUserMonitor.cpp b/src/server/ActiveUserMonitor.cpp similarity index 100% rename from src/ActiveUserMonitor.cpp rename to src/server/ActiveUserMonitor.cpp diff --git a/src/ActiveUserMonitor.h b/src/server/ActiveUserMonitor.h similarity index 100% rename from src/ActiveUserMonitor.h rename to src/server/ActiveUserMonitor.h diff --git a/src/AlarmInitializer.cpp b/src/server/AlarmInitializer.cpp similarity index 100% rename from src/AlarmInitializer.cpp rename to src/server/AlarmInitializer.cpp diff --git a/src/AlarmInitializer.h b/src/server/AlarmInitializer.h similarity index 100% rename from src/AlarmInitializer.h rename to src/server/AlarmInitializer.h diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt new file mode 100644 index 0000000..170e43e --- /dev/null +++ b/src/server/CMakeLists.txt @@ -0,0 +1,32 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(target "contextd") + +SET(DEPS libsystemd-login glib-2.0 gio-2.0 dlog capi-base-common alarm-service) +SET(DEPS ${DEPS} context-common-server) +SET(DEPS ${DEPS} context-app-history-server) +SET(DEPS ${DEPS} context-sensor-recorder-server) +SET(DEPS ${DEPS} context-store-server) +SET(DEPS ${DEPS} context-job-scheduler-server) + +SET(INCDIR "${CMAKE_INSTALL_INCLUDEDIR}/context-service") + +INCLUDE_DIRECTORIES( + ${CMAKE_INSTALL_PREFIX}/${INCDIR}/private +) + +FILE(GLOB_RECURSE SRCS *.cpp) +MESSAGE("Sources: ${SRCS}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(DEPS_SERVER_PKG REQUIRED ${DEPS}) + +FOREACH(flag ${DEPS_SERVER_PKG_CFLAGS}) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_EXECUTABLE(${target} ${SRCS}) +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT\"") +TARGET_LINK_LIBRARIES(${target} ${DEPS_SERVER_PKG_LDFLAGS}) + +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/DBusConnector.cpp b/src/server/DBusConnector.cpp similarity index 100% rename from src/DBusConnector.cpp rename to src/server/DBusConnector.cpp diff --git a/src/DBusConnector.h b/src/server/DBusConnector.h similarity index 100% rename from src/DBusConnector.h rename to src/server/DBusConnector.h diff --git a/src/Main.cpp b/src/server/ServerMain.cpp similarity index 100% rename from src/Main.cpp rename to src/server/ServerMain.cpp diff --git a/src/ServiceLoader.cpp b/src/server/ServiceLoader.cpp similarity index 100% rename from src/ServiceLoader.cpp rename to src/server/ServiceLoader.cpp diff --git a/src/ServiceLoader.h b/src/server/ServiceLoader.h similarity index 100% rename from src/ServiceLoader.h rename to src/server/ServiceLoader.h -- 2.34.1