Revert "Revert "service: Reimplement per-profile configuration using snippets"" 50/177950/2
authorAdhavan M <adhavan.m@samsung.com>
Fri, 4 May 2018 11:35:51 +0000 (11:35 +0000)
committerManish Rathod <manish.r@samsung.com>
Fri, 4 May 2018 11:35:59 +0000 (11:35 +0000)
This reverts commit 5aa4d053853caf9d74eba1bbcdb6c7dcfef10b32.

Change-Id: Ied7a11835070c98719c07d49032408a1fa7fb897

12 files changed:
packaging/emulator.conf [new file with mode: 0644]
packaging/oom-adj-1000.conf [new file with mode: 0644]
packaging/reset-privs.conf [new file with mode: 0644]
packaging/restart-on-fail.conf [new file with mode: 0644]
packaging/sdbd-env-generator [new file with mode: 0755]
packaging/sdbd.service
packaging/sdbd.spec
packaging/sdbd@.socket [deleted file]
packaging/sdbd_device.service [deleted file]
packaging/sdbd_device_tv.service [deleted file]
packaging/sdbd_emulator.service [deleted file]
packaging/sdbd_emulator_tv.service [deleted file]

diff --git a/packaging/emulator.conf b/packaging/emulator.conf
new file mode 100644 (file)
index 0000000..c2f6bc0
--- /dev/null
@@ -0,0 +1,3 @@
+[Unit]
+After=dbus.service
+Before=sensord.service
diff --git a/packaging/oom-adj-1000.conf b/packaging/oom-adj-1000.conf
new file mode 100644 (file)
index 0000000..bac841b
--- /dev/null
@@ -0,0 +1,2 @@
+[Service]
+OOMScoreAdjust=-1000
diff --git a/packaging/reset-privs.conf b/packaging/reset-privs.conf
new file mode 100644 (file)
index 0000000..c1af7ed
--- /dev/null
@@ -0,0 +1,4 @@
+[Service]
+User=
+Group=
+SmackProcessLabel=
diff --git a/packaging/restart-on-fail.conf b/packaging/restart-on-fail.conf
new file mode 100644 (file)
index 0000000..0e97dcb
--- /dev/null
@@ -0,0 +1,3 @@
+[Service]
+RemainAfterExit=no
+Restart=on-failure
diff --git a/packaging/sdbd-env-generator b/packaging/sdbd-env-generator
new file mode 100755 (executable)
index 0000000..c7f7aa6
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+awk '{match($0, /sdb_port=([0-9]+)/,port_match); match($0, /vm_name=([^, ]*)/,vm_match); print "SDBD_CMDLINE=\"--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 > /run/sdbd-env
index 3ec4efc..e9b1047 100644 (file)
@@ -6,6 +6,7 @@ After=tmp.mount
 User=sdk
 Group=sdk
 SmackProcessLabel=System
+EnvironmentFile=-/run/sdbd-env
 #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"
 Type=simple
@@ -13,6 +14,6 @@ Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i
 SecureBits=keep-caps
 PIDFile=/tmp/.sdbd.pid
 RemainAfterExit=yes
-ExecStart=/usr/sbin/sdbd
+ExecStart=/usr/sbin/sdbd $SDBD_CMDLINE
 USBFunctionDescriptors=/etc/sdbd/descs
 USBFunctionStrings=/etc/sdbd/strs
index a114dd8..baa5f86 100644 (file)
@@ -8,13 +8,15 @@ License:    Apache-2.0
 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
@@ -55,6 +57,7 @@ SDB daemon for emulator
 %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
@@ -68,7 +71,7 @@ SDBD plugin API library
 
 %prep
 %setup -q
-cp %{SOURCE1003} .
+cp %{SOURCE10} .
 
 %build
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pthread"}
@@ -76,22 +79,24 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?asan:-DCMAKE_EXE_LINKER_FLAGS="-pth
 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/
 
@@ -143,36 +148,20 @@ chsmack -e "User::Shell" /sbin/sdbd-user
 %{_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
diff --git a/packaging/sdbd@.socket b/packaging/sdbd@.socket
deleted file mode 100644 (file)
index d53479e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=sdbd Socket for %I
-
-[Socket]
-ListenUSBFunction=%I
-Service=sdbd.service
diff --git a/packaging/sdbd_device.service b/packaging/sdbd_device.service
deleted file mode 100644 (file)
index 080e0ed..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-[Unit]
-Description=sdbd
-Requires=tizen-system-env.service
-After=tmp.mount
-
-[Service]
-User=sdk
-Group=sdk
-Type=simple
-#location of SDBD log file
-#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"
-EnvironmentFile=-/run/tizen-system-env
-PIDFile=/tmp/.sdbd.pid
-Restart=on-failure
-SmackProcessLabel=System
-Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i
-SecureBits=keep-caps
-ExecStart=/usr/sbin/sdbd
-USBFunctionDescriptors=/etc/sdbd/descs
-USBFunctionStrings=/etc/sdbd/strs
-
-[Install]
-WantedBy=multi-user.target
diff --git a/packaging/sdbd_device_tv.service b/packaging/sdbd_device_tv.service
deleted file mode 100644 (file)
index 88d3a08..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-[Unit]
-Description=sdbd
-Requires=tizen-system-env.service
-After=tmp.mount
-
-[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"
-EnvironmentFile=-/run/tizen-system-env
-OOMScoreAdjust=-1000
-PIDFile=/tmp/.sdbd.pid
-Restart=on-failure
-Capabilities=cap_dac_override,cap_setgid,cap_setuid,cap_sys_admin=i
-SecureBits=keep-caps
-ExecStart=/usr/sbin/sdbd
-USBFunctionDescriptors=/etc/sdbd/descs
-USBFunctionStrings=/etc/sdbd/strs
-
-[Install]
-WantedBy=multi-user.target
diff --git a/packaging/sdbd_emulator.service b/packaging/sdbd_emulator.service
deleted file mode 100644 (file)
index 5ace52d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-[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
-
diff --git a/packaging/sdbd_emulator_tv.service b/packaging/sdbd_emulator_tv.service
deleted file mode 100644 (file)
index 8d45fea..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-[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
-