Summary: SDB daemon
Group: System/Utilities
Source0: %{name}-%{version}.tar.gz
-Source1001: sdbd_device.service
-Source1002: sdbd_emulator.service
-Source1003: %{name}.manifest
+Source10: %{name}.manifest
+Source1000: sdbd.service
Source1004: sdbd_tcp.socket
-Source1005: sdbd_device_tv.service
-Source1006: sdbd_emulator_tv.service
Source1007: sdbd.socket
+Source1010: reset-privs.conf
+Source1011: oom-adj-1000.conf
+Source1012: emulator.conf
+Source1013: restart-on-fail.conf
+Source1020: sdbd-env-generator
BuildRequires: capi-system-info-devel >= 0.2.0
BuildRequires: cmake >= 2.8.3
%package extension-tv-emulator
Summary: SDB daemon for tv emulator
Requires: %{name}-profile_tv = %{version}-%{release}
+Requires: %{name}-extension-emulator = %{version}-%{release}
%description extension-tv-emulator
SDB daemon for tv emulator
%endif // ifarch %{ix86} x86_64
%prep
%setup -q
-cp %{SOURCE1003} .
+cp %{SOURCE10} .
%build
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pthread"}
make %{?jobs:-j%jobs}
%install
-mkdir -p %{buildroot}%{_unitdir}
+mkdir -p %{buildroot}%{_unitdir}/sdbd.service.d/
# extension-*-emulator
%ifarch %{ix86} x86_64
-install -m 0644 %SOURCE1006 %{buildroot}%{_unitdir}/sdbd.service.tv.emulator
-install -m 0644 %SOURCE1002 %{buildroot}%{_unitdir}/sdbd.service.emulator
+install -m 0644 %SOURCE1010 %{buildroot}%{_unitdir}/sdbd.service.d/
+install -m 0644 %SOURCE1011 %{buildroot}%{_unitdir}/sdbd.service.d/
+install -m 0644 %SOURCE1012 %{buildroot}%{_unitdir}/sdbd.service.d/
+mkdir -p %{buildroot}%{_prefix}/lib/systemd/system-generators/
+install -m 0755 %SOURCE1020 %{buildroot}%{_prefix}/lib/systemd/system-generators/
mkdir -p %{buildroot}/%{_unitdir}/emulator_preinit.target.wants
ln -s %{_unitdir}/sdbd.service %{buildroot}/%{_unitdir}/emulator_preinit.target.wants/
%endif // ifarch %{ix86} x86_64
%make_install
-install -m 0644 %SOURCE1005 %{buildroot}%{_unitdir}/sdbd.service.tv
-install -m 0644 %SOURCE1001 %{buildroot}%{_unitdir}/sdbd.service
+install -m 0644 %SOURCE1000 %{buildroot}%{_unitdir}/sdbd.service
install -m 0644 %SOURCE1004 %{buildroot}%{_unitdir}/sdbd_tcp.socket
-
+install -m 0644 %SOURCE1013 %{buildroot}%{_unitdir}/sdbd.service.d/restart-on-fail.conf
install -m 0755 -d %{buildroot}%{_unitdir}/sockets.target.wants/
ln -s ../sdbd_tcp.socket %{buildroot}%{_unitdir}/sockets.target.wants/
%{_sysconfdir}/sdbd/strs
%ifarch %{ix86} x86_64
-%post extension-emulator
-mv %{_unitdir}/sdbd.service.emulator %{_unitdir}/sdbd.service
-%preun extension-emulator
-mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.emulator
%files extension-emulator
%manifest sdbd.manifest
-%{_unitdir}/sdbd.service.emulator
+%{_unitdir}/sdbd.service.d/emulator.conf
%{_unitdir}/emulator_preinit.target.wants/sdbd.service
+%{_prefix}/lib/systemd/system-generators/sdbd-env-generator
-%post extension-tv-emulator
-mv %{_unitdir}/sdbd.service.tv.emulator %{_unitdir}/sdbd.service
-%preun extension-tv-emulator
-mv %{_unitdir}/sdbd.service %{_unitdir}/sdbd.service.tv.emulator
%files extension-tv-emulator
%manifest sdbd.manifest
-%{_unitdir}/sdbd.service.tv.emulator
-%{_unitdir}/emulator_preinit.target.wants/sdbd.service
+%{_unitdir}/sdbd.service.d/reset-privs.conf
+%{_unitdir}/sdbd.service.d/oom-adj-1000.conf
%endif // ifarch %{ix86} x86_64
-%post profile_tv
-pushd %{_unitdir}
-mv sdbd.service.tv sdbd.service
-popd
-%preun profile_tv
-pushd %{_unitdir}
-cp sdbd.service sdbd.service.tv
-echo For correct bahavior of %{name} after uninstalling %{name}-profile_tv, you need to reinstall %{name}
-popd
%files profile_tv
-%{_unitdir}/sdbd.service.tv
+%{_unitdir}/sdbd.service.d/restart-on-fail.conf
%files -n sdbd-devel
%{_includedir}/sdb/sdbd_plugin.h
+++ /dev/null
-[Unit]
-Description=sdbd
-Before=sensord.service
-After=tmp.mount dbus.service
-#DefaultDependencies=false
-
-[Service]
-User=sdk
-Group=sdk
-Type=simple
-PIDFile=/tmp/.sdbd.pid
-RemainAfterExit=yes
-#If necessary, Put Environment variable settings in a file like below
-#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf"
-#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel"
-SmackProcessLabel=System
-Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i
-SecureBits=keep-caps
-ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`"
-USBFunctionDescriptors=/etc/sdbd/descs
-USBFunctionStrings=/etc/sdbd/strs
-
-[Install]
-WantedBy=emulator_preinit.target
-
+++ /dev/null
-[Unit]
-Description=sdbd
-Before=sensord.service
-After=tmp.mount dbus.service
-#DefaultDependencies=false
-
-[Service]
-Type=simple
-#location of SDBD log file
-#Environment=SDBD_LOG_PATH=/tmp
-#If necessary, Put Environment variable settings in a file like below
-#ExecStartPre=/bin/bash -c "/bin/echo 'SDB_TRACE=all SDBD_LOG_PATH=/tmp' >> /tmp/.sdbdlog.conf"
-PIDFile=/tmp/.sdbd.pid
-RemainAfterExit=yes
-OOMScoreAdjust=-1000
-Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i
-SecureBits=keep-caps
-#ExecStartPre=/bin/bash -c "/bin/echo '10.0.2.15/32 system::debugging_network' >> /smack/netlabel"
-ExecStart=/bin/sh -c "/usr/sbin/sdbd `/usr/bin/awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print \"--emulator=\" vm_match[1] \":\" port_match[1] \" --connect-to=10.0.2.2:26099\" \" --sensors=10.0.2.2:\"port_match[1]+3 }' /proc/cmdline`"
-
-[Install]
-WantedBy=emulator_preinit.target
-