From 73a871fa2688a0f74933dad5df0e38df1dcd704d Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Tue, 23 Apr 2019 13:10:19 +0200 Subject: [PATCH] tizen: Add additional unit for "unified" user session The unified user session is about moving user session units, managed by systemd --user, to main systemd, where it's managed as part of newly created user@.target. user@.target will contain same units as previously available in user/, with same UID and environment setup. systemd instance is used for unit to be able to specify UID (inherited from user@.target). The rationale behind this work is following: * VD requirement to remove user session support * boot time optimization requirements, due to: + 'systemd --user' taking 1s its own startup that could be used for unit startup + ability to better rearrange units if these managed by one systemd instance Unit installed by this commit will not be used till user login mechanism will be changed in systemd package (via changing pam_systemd to start user@.target, rather than user@.service). Change-Id: I2e5785094c90dd5860edf8e4f0f077a24edd023f --- packaging/calendar-service.spec | 63 +++++++++++++++++++++------------- packaging/calendar-serviced.service | 2 +- packaging/calendar-serviced.service.tv | 8 ----- packaging/calendar-serviced@.service | 15 ++++++++ packaging/tv.conf | 3 ++ server/CMakeLists.txt | 10 +++--- 6 files changed, 64 insertions(+), 37 deletions(-) delete mode 100644 packaging/calendar-serviced.service.tv create mode 100644 packaging/calendar-serviced@.service create mode 100644 packaging/tv.conf diff --git a/packaging/calendar-service.spec b/packaging/calendar-service.spec index f9b6100..773574b 100644 --- a/packaging/calendar-service.spec +++ b/packaging/calendar-service.spec @@ -7,7 +7,8 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}d.service Source2: org.tizen.CalendarService.dbus.service -Source5: %{name}d.service.tv +Source5: tv.conf +Source6: %{name}d@.service Source1001: %{name}.manifest Source1002: %{name}.conf.in Source2001: ALARM.a%{name}.service @@ -34,7 +35,10 @@ BuildRequires: pkgconfig(contacts-service2) %endif Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig +Requires(post): %{_sbindir}/update-alternatives +Requires(preun): %{_sbindir}/update-alternatives Provides: %{name}-compat = %{version}-%{release} +Requires: %{name}-units %description Calendar Service for using Calendar DB @@ -43,10 +47,10 @@ Calendar Service for using Calendar DB Summary: for TV Provides: %{name}-compat = %{version}-%{release} Conflicts: %{name} +Requires: %{name}-units %description profile_tv for TV - %package -n lib%{name} Summary: client library %if "%{?profile}" != "tv" @@ -58,9 +62,11 @@ Requires: %{name}-profile_tv = %{version}-%{release} %description -n lib%{name} client library for calendar +%package units +Summary: systemd and dbus-daemon units for %{name} - -%define _dbus_interface org.tizen.CalendarService.dbus +%description units +. %package devel Summary: DB library for calendar @@ -86,6 +92,8 @@ cp %SOURCE1001 . %endif %build +%define _dbus_interface org.tizen.CalendarService.dbus + CXXFLAGS="$CXXFLAGS -DU_USING_ICU_NAMESPACE=1" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DBIN_INSTALL_DIR:PATH=%{_bindir} \ @@ -97,9 +105,15 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants +mkdir -p %{buildroot}%{_unitdir_user}/%{name}d.service.d install -m 0644 %SOURCE1 %{buildroot}%{_unitdir_user} -install -m 0644 %SOURCE5 %{buildroot}%{_unitdir_user} +install -m 0644 %SOURCE5 %{buildroot}%{_unitdir_user}/%{name}d.service.d/ + +mkdir -p %{buildroot}%{_unitdir}/user-default@.target.wants +mkdir -p %{buildroot}%{_unitdir}/%{name}d@.service.d/ +install -m 0644 %SOURCE6 %{buildroot}%{_unitdir} +install -m 0644 %SOURCE5 %{buildroot}%{_unitdir}/%{name}d@.service.d/ +ln -s ../calendar-serviced@.service %{buildroot}%{_unitdir}/user-default@.target.wants/calendar-serviced@.service mkdir -p %{buildroot}%{_datadir}/dbus-1/services install -m 0644 %SOURCE2 %{buildroot}%{_datadir}/dbus-1/services @@ -112,41 +126,44 @@ install -m 0644 %SOURCE1002 %{buildroot}%{_sysconfdir}/dbus-1/session.d/%{name}. mkdir -p %{buildroot}%{_datadir}/dbus-1/services install -m 0644 %SOURCE2001 %{buildroot}%{_datadir}/dbus-1/services - %post -n lib%{name} -p /sbin/ldconfig %postun -n lib%{name} -p /sbin/ldconfig -%post profile_tv -mv %{_unitdir_user}/calendar-serviced.service.tv %{_unitdir_user}/calendar-serviced.service +%post +%{_sbindir}/update-alternatives --install %{_bindir}/calendar-serviced %{name} %{_bindir}/calendar-serviced-common 100 +%pre +%{_sbindir}/update-alternatives --remove %{name} %{_bindir}/calendar-serviced-common -%preun profile_tv -mv %{_unitdir_user}/calendar-serviced.service %{_unitdir_user}/calendar-serviced.service.tv +%post profile_tv +%{_sbindir}/update-alternatives --install %{_bindir}/calendar-serviced %{name} %{_bindir}/calendar-serviced-tv 200 +%pre profile_tv +%{_sbindir}/update-alternatives --remove %{name} %{_bindir}/calendar-serviced-tv +%files units +%config %{_sysconfdir}/dbus-1/session.d/%{name}.conf +%{_datadir}/dbus-1/services/%{_dbus_interface}.service +%{_datadir}/dbus-1/services/ALARM.acalendar-service.service +%{_unitdir_user}/%{name}d.service +%{_unitdir}/%{name}d@.service +%{_unitdir}/user-default@.target.wants/calendar-serviced@.service %files -%{_unitdir_user}/%{name}d.service +%manifest %{name}.manifest +%defattr(-,root,root,-) # This is for backward-compatibility. This does not deteriorate 4.0 Configurability # TV profile does not have contacts-service2. # if wearable, ivi, common, mobile ||"undefined" %if "%{?profile}" != "tv" -%manifest %{name}.manifest -%defattr(-,root,root,-) -%{_bindir}/calendar-serviced -%{_datadir}/dbus-1/services/%{_dbus_interface}.service -%config %{_sysconfdir}/dbus-1/session.d/%{name}.conf -%{_datadir}/dbus-1/services/ALARM.acalendar-service.service +%{_bindir}/calendar-serviced-common %license LICENSE.APLv2 %endif - %files profile_tv %manifest %{name}.manifest %defattr(-,root,root,-) %{_bindir}/calendar-serviced-tv -%{_unitdir_user}/%{name}d.service.tv -%{_datadir}/dbus-1/services/%{_dbus_interface}.service -%config %{_sysconfdir}/dbus-1/session.d/%{name}.conf -%{_datadir}/dbus-1/services/ALARM.acalendar-service.service +%{_unitdir_user}/%{name}d.service.d/tv.conf +%{_unitdir}/%{name}d@.service.d/tv.conf %license LICENSE.APLv2 %files -n lib%{name} diff --git a/packaging/calendar-serviced.service b/packaging/calendar-serviced.service index caffb63..53ac6f7 100644 --- a/packaging/calendar-serviced.service +++ b/packaging/calendar-serviced.service @@ -6,5 +6,5 @@ Requires=contacts-service.service [Service] Type=dbus BusName=org.tizen.CalendarService.dbus -Environment="TIMEOUT=90" +Environment=TIMEOUT=90 ExecStart=/usr/bin/calendar-serviced $TIMEOUT diff --git a/packaging/calendar-serviced.service.tv b/packaging/calendar-serviced.service.tv deleted file mode 100644 index 57dfb0d..0000000 --- a/packaging/calendar-serviced.service.tv +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Calendar Service daemon - -[Service] -Type=dbus -BusName=org.tizen.CalendarService.dbus -Environment="TIMEOUT=90" -ExecStart=/usr/bin/calendar-serviced-tv $TIMEOUT diff --git a/packaging/calendar-serviced@.service b/packaging/calendar-serviced@.service new file mode 100644 index 0000000..658160b --- /dev/null +++ b/packaging/calendar-serviced@.service @@ -0,0 +1,15 @@ +[Unit] +PartOf=userlogin@%i.target +Description=Calendar Service daemon +After=contacts-service@%i.service +Requires=contacts-service@%i.service + +[Service] +User=%i +Environment=DBUS_SESSION_BUS_ADDRESS=kernel:path=/sys/fs/kdbus/%i-user/bus;unix:path=/run/user/%i/bus +Environment=XDG_RUNTIME_DIR=/run/user/%i +SmackProcessLabel=User +Type=dbus +BusName=org.tizen.CalendarService.dbus +Environment=TIMEOUT=90 +ExecStart=/usr/bin/calendar-serviced $TIMEOUT diff --git a/packaging/tv.conf b/packaging/tv.conf new file mode 100644 index 0000000..e1477bf --- /dev/null +++ b/packaging/tv.conf @@ -0,0 +1,3 @@ +[Unit] +After= +Requires= diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index abd8e7a..106725e 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -40,10 +40,10 @@ SET(CONTACTS_CFLAGS "${CONTACTS_CFLAGS} -I${INCLUDE_DIR}") ENDFOREACH(INCLUDE_DIR) IF(${TIZEN_PROFILE_TV} EQUAL 0) -ADD_EXECUTABLE(${DAEMON} ${DAEMON_SRCS}) -ADD_DEPENDENCIES(${DAEMON} GENERATED_DBUS_CODE) -SET_TARGET_PROPERTIES(${DAEMON} PROPERTIES COMPILE_FLAGS ${CONTACTS_CFLAGS}) -TARGET_LINK_LIBRARIES(${DAEMON} ${daemon_pkgs_LIBRARIES} ${daemon_contacts_pkgs_LIBRARIES}) +ADD_EXECUTABLE(${DAEMON}-common ${DAEMON_SRCS}) +ADD_DEPENDENCIES(${DAEMON}-common GENERATED_DBUS_CODE) +SET_TARGET_PROPERTIES(${DAEMON}-common PROPERTIES COMPILE_FLAGS ${CONTACTS_CFLAGS}) +TARGET_LINK_LIBRARIES(${DAEMON}-common ${daemon_pkgs_LIBRARIES} ${daemon_contacts_pkgs_LIBRARIES}) ENDIF() @@ -53,6 +53,6 @@ SET_TARGET_PROPERTIES(${DAEMON}-tv PROPERTIES COMPILE_FLAGS "-I${CMAKE_CURRENT_S TARGET_LINK_LIBRARIES(${DAEMON}-tv ${daemon_pkgs_LIBRARIES}) IF(${TIZEN_PROFILE_TV} EQUAL 0) -INSTALL(TARGETS ${DAEMON} DESTINATION ${BIN_INSTALL_DIR}) +INSTALL(TARGETS ${DAEMON}-common DESTINATION ${BIN_INSTALL_DIR}) ENDIF() INSTALL(TARGETS ${DAEMON}-tv DESTINATION ${BIN_INSTALL_DIR}) -- 2.7.4