[mt-daapd] convert to systemd

Tom Callaway spot at fedoraproject.org
Thu Sep 8 16:35:35 UTC 2011


commit 3e1c2cd878ee1b40a9f82054af42e9015a81b740
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Thu Sep 8 12:35:23 2011 -0400

    convert to systemd

 mt-daapd.service |   11 +++++++++++
 mt-daapd.spec    |   42 ++++++++++++++++++++++--------------------
 2 files changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/mt-daapd.service b/mt-daapd.service
new file mode 100644
index 0000000..c34cb1e
--- /dev/null
+++ b/mt-daapd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=mt-daapd - multi-threaded DAAP server for iTunes
+ConditionPathExists=/etc/mt-daapd.conf
+Requires=network.target
+
+[Service]
+ExecStart=/usr/sbin/mt-daapd
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mt-daapd.spec b/mt-daapd.spec
index b70fa95..e77bd86 100644
--- a/mt-daapd.spec
+++ b/mt-daapd.spec
@@ -11,23 +11,21 @@ Summary: An iTunes-compatible media server
 Name: mt-daapd
 Epoch: 1
 Version: 0.2.4.2
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: GPLv2+
 Group: Applications/Multimedia
-Source: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
+Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
+Source1: %{name}.service
 Patch0: mt-daapd-0.2.4.2-defaults.patch
 Patch1: mt-daapd-0.2.4.2-fedora.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Url: http://www.fireflymediaserver.org/
 BuildRequires: fedora-usermgmt-devel
 BuildRequires: gdbm-devel, avahi-devel, zlib-devel
 BuildRequires: flac-devel, libogg-devel, libvorbis-devel
 BuildRequires: libid3tag-devel, sqlite-devel
+BuildRequires: systemd-units
 Requires(pre):   /usr/sbin/useradd
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
-Requires(post): /sbin/chkconfig
+Requires(post): systemd-sysv
 Provides: group(%username) = %uid
 Provides: user(%username) = %uid
 
@@ -48,10 +46,11 @@ make %{?_smp_mflags}
 
 %install
 make DESTDIR=%{buildroot} install
-mkdir -p %{buildroot}%{_initrddir}
+mkdir -p %{buildroot}%{_unitdir}
 mkdir -p %{buildroot}%{_localstatedir}/cache/mt-daapd
-install contrib/mt-daapd %{buildroot}%{_sysconfdir}/rc.d/init.d/mt-daapd
-install -m 0640 contrib/mt-daapd.conf %{buildroot}%{_sysconfdir}/mt-daapd.conf
+install %{SOURCE1} %{buildroot}%{_unitdir}/
+mkdir -p %{buildroot}%{_sysconfdir}
+install -m 0640 contrib/mt-daapd.conf %{buildroot}%{_sysconfdir}/
 
 %pre
 %__fe_groupadd %uid -r %username &>/dev/null || :
@@ -63,29 +62,32 @@ if [ $1 = 0 ]; then
 	/sbin/chkconfig --del mt-daapd
 fi
 
-%post
-/sbin/chkconfig --add mt-daapd
-
 %postun
-if [ "$1" -ge "1" ]; then
-        /sbin/service mt-daapd condrestart >/dev/null 2>&1 || :
-fi
 %__fe_userdel  %username &>/dev/null || :
 %__fe_groupdel %username &>/dev/null || :
 
-%clean
-rm -rf %{buildroot}
+%triggerun -- mt-daapd < 0.2.4.2-9
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply mt-daapd
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save mt-daapd >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del mt-daapd >/dev/null 2>&1 || :
+/bin/systemctl try-restart mt-daapd.service >/dev/null 2>&1 || :
 
 %files
-%defattr(-,root,root,-)
 %config(noreplace) %{_sysconfdir}/mt-daapd.conf
 %{_sbindir}/mt-daapd
 %{_datadir}/mt-daapd
-%{_sysconfdir}/rc.d/init.d/mt-daapd
+%{_unitdir}/%{name}.service
 %attr(0700,mt-daapd,root) %{_localstatedir}/cache/mt-daapd
 %doc AUTHORS COPYING CREDITS NEWS README TODO
 
 %changelog
+* Thu Sep 08 2011 Tom Callaway <spot at fedoraproject.org> - 1:0.2.4.2-9
+- convert to systemd
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1:0.2.4.2-8
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list