Add build & packaging script of context-agent 59/119659/2
authorMu-Woong Lee <muwoong.lee@samsung.com>
Sun, 19 Mar 2017 15:30:16 +0000 (00:30 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 27 Mar 2017 04:47:14 +0000 (13:47 +0900)
context-agent will be a user-level assistant service of the main
context-service daemon.

Change-Id: I74db377718ecd9883c3cb75bef556f32d02cc4d3
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
18 files changed:
CMakeLists.txt
packaging/context-service.spec
packaging/contextd-agent.service [new file with mode: 0644]
packaging/contextd.service [moved from packaging/context-service.service with 76% similarity]
packaging/org.tizen.contextagent.conf [new file with mode: 0644]
packaging/org.tizen.contextagent.service [new file with mode: 0644]
src/agent/AgentMain.cpp [new file with mode: 0644]
src/agent/CMakeLists.txt [new file with mode: 0644]
src/server/ActiveUserMonitor.cpp [moved from src/ActiveUserMonitor.cpp with 100% similarity]
src/server/ActiveUserMonitor.h [moved from src/ActiveUserMonitor.h with 100% similarity]
src/server/AlarmInitializer.cpp [moved from src/AlarmInitializer.cpp with 100% similarity]
src/server/AlarmInitializer.h [moved from src/AlarmInitializer.h with 100% similarity]
src/server/CMakeLists.txt [new file with mode: 0644]
src/server/DBusConnector.cpp [moved from src/DBusConnector.cpp with 100% similarity]
src/server/DBusConnector.h [moved from src/DBusConnector.h with 100% similarity]
src/server/ServerMain.cpp [moved from src/Main.cpp with 100% similarity]
src/server/ServiceLoader.cpp [moved from src/ServiceLoader.cpp with 100% similarity]
src/server/ServiceLoader.h [moved from src/ServiceLoader.h with 100% similarity]

index 04c4f5a..ff2c8a0 100644 (file)
@@ -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)
index 2b90a72..5df292d 100644 (file)
@@ -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 (file)
index 0000000..e6e36b3
--- /dev/null
@@ -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
similarity index 76%
rename from packaging/context-service.service
rename to packaging/contextd.service
index e5f2f31..0fb5d90 100644 (file)
@@ -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 (file)
index 0000000..3683fc7
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+       <policy smack="System">
+               <deny own="org.tizen.contextagent"/>
+               <allow send_destination="org.tizen.contextagent"/>
+       </policy>
+       <policy smack="User">
+               <allow own="org.tizen.contextagent"/>
+               <allow send_destination="org.tizen.contextagent"/>
+       </policy>
+       <policy context="default">
+               <allow send_destination="org.tizen.contextagent"/>
+       </policy>
+</busconfig>
diff --git a/packaging/org.tizen.contextagent.service b/packaging/org.tizen.contextagent.service
new file mode 100644 (file)
index 0000000..198b7d1
--- /dev/null
@@ -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 (file)
index 0000000..fc1dc8d
--- /dev/null
@@ -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 <cstdlib>
+
+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 (file)
index 0000000..114362f
--- /dev/null
@@ -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/server/CMakeLists.txt b/src/server/CMakeLists.txt
new file mode 100644 (file)
index 0000000..170e43e
--- /dev/null
@@ -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})
similarity index 100%
rename from src/Main.cpp
rename to src/server/ServerMain.cpp