[dmapd] First attempt at using systemd Signed-off-by: W. Michael Petullo <mike at flyn.org>

mikep mikep at fedoraproject.org
Mon Jul 11 18:24:02 UTC 2011


commit 701f5995b1f71f4c6fed3ddcfa942a9875e640c9
Author: W. Michael Petullo <mike at flyn.org>
Date:   Mon Jul 11 13:23:10 2011 -0500

    First attempt at using systemd
    Signed-off-by: W. Michael Petullo <mike at flyn.org>

 .gitignore |    1 +
 dmapd.spec |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 sources    |    1 +
 3 files changed, 60 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 7768c7d..70e8478 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ dmapd-0.0.25.tar.gz
 /dmapd-0.0.33.tar.gz
 /dmapd-0.0.34.tar.gz
 /dmapd-0.0.37.tar.gz
+/dmapd-systemd.patch
diff --git a/dmapd.spec b/dmapd.spec
index 6c10380..0d89e02 100644
--- a/dmapd.spec
+++ b/dmapd.spec
@@ -7,13 +7,22 @@ Group: Applications/Multimedia
 License: GPLv2+
 URL: http://www.flyn.org/projects/dmapd/
 Source0: http://www.flyn.org/projects/%name/%{name}-%{version}.tar.gz
+# FIXME: Remove once upgraded to 0.0.43.
+Patch0: dmapd-systemd.patch
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: libdmapsharing-devel >= 2.1.2, vips-devel, gstreamer-devel
 Requires(pre): shadow-utils
+# FIXME: Remove conditionals once Fedora 14 EOL'ed.
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+Requires(post): systemd-units systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else
 Requires(post): chkconfig
 Requires(preun): chkconfig, initscripts
 Requires(postun): initscripts
+%endif
 
 %description 
 The dmapd project provides a GObject-based, Open Source implementation 
@@ -41,9 +50,17 @@ files.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
-%configure --disable-static
+# FIXME: Remove use of auto* once upgraded to 0.0.43.
+aclocal && autoconf && autoheader && libtoolize --force && automake -a
+%configure                                      \
+       --disable-static                         \
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+	--with-systemdsystemunitdir=%{_unitdir} \
+%endif
+
 make %{?_smp_mflags}
 
 %install
@@ -52,10 +69,13 @@ make install DESTDIR=%{buildroot} INSTALL="install -p"
 rm -f %{buildroot}%{_libdir}/libdmapd.la
 rm -f %{buildroot}%{_libdir}/dmapd/%{version}/modules/*.la
 rm -f %{buildroot}%{_sbindir}/dmapd-test
-rm -f %{buildroot}/lib/systemd/system/dmapd.service
 mkdir -p %{buildroot}%{_localstatedir}/cache/dmapd
 mkdir -p %{buildroot}%{_localstatedir}/run/dmapd
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+# NOOP: dmapd.service is universal so "make install" installs it.
+%else
 install -D -m 755 distro/dmapd.fedora %{buildroot}%{_initddir}/dmapd
+%endif
 install -D -m 644 distro/dmapd.conf %{buildroot}%{_sysconfdir}/dmapd.conf
 
 %clean
@@ -67,11 +87,15 @@ rm -rf %{buildroot}
 %{_libdir}/*.so.%{version}
 %{_libdir}/dmapd
 %{_sbindir}/dmapd
-%{_initddir}/dmapd
 %config(noreplace) %{_sysconfdir}/dmapd.conf
 %attr(0700,dmapd,root) %{_localstatedir}/cache/dmapd
 %attr(0700,dmapd,root) %{_localstatedir}/run/dmapd
 %{_mandir}/*/*
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+%{_unitdir}/dmapd.service
+%else
+%{_initddir}/dmapd
+%endif
 %doc AUTHORS COPYING ChangeLog INSTALL NEWS README FAQ 
 
 %pre
@@ -81,14 +105,42 @@ exit 0
 
 %post
 /sbin/ldconfig
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+if [ $1 -eq 1 ] ; then 
+       /bin/systemctl enable dmapd.service >/dev/null 2>&1 || :
+fi
+%else
 /sbin/chkconfig --add dmapd
+%endif
 
 %preun
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+if [ $1 -eq 0 ] ; then
+       /bin/systemctl --no-reload disable dmapd.service > /dev/null 2>&1 || :
+       /bin/systemctl stop dmapd.service > /dev/null 2>&1 || :
+fi
+%else
 if [ $1 = 0 ]; then /sbin/service dmapd stop >/dev/null 2>&1; /sbin/chkconfig --del dmapd; fi
+%endif
 
 %postun
 /sbin/ldconfig
+%if %{?fedora}0 > 150 || %{?rhel}0 > 60
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+       /bin/systemctl try-restart dmapd.service >/dev/null 2>&1 || :
+fi
+%else
 if [ "$1" -ge "1" ]; then /sbin/service dmapd condrestart >/dev/null 2>&1 || :; fi
+%endif
+
+# FIXME: Remove once Fedora 15 EOL'ed.
+# See http://fedoraproject.org/wiki/Packaging:ScriptletSnippets
+%triggerun -- dmapd < 0.0.37-2
+%{_bindir}/systemd-sysv-convert --save dmapd >/dev/null 2>&1 || :
+/bin/systemctl --no-reload enable dmapd.service >/dev/null 2>&1 || :
+/sbin/chkconfig --del dmapd >/dev/null 2>&1 || :
+/bin/systemctl try-restart dmapd.service >/dev/null 2>&1 || :
 
 %package devel
 Summary: Files needed to develop modules using dmapd's libraries
@@ -108,6 +160,9 @@ resources needed for developing modules using dmapd's API.
 %ghost %attr(0600,root,root) %{_localstatedir}/lock/subsys/dmapd
 
 %changelog
+* Mon Jul 11 2011 W. Michael Petullo <mike[@]flyn.org> - 0.0.37-2
+- Use systemd on Fedora > 15
+
 * Fri Feb 11 2011 W. Michael Petullo <mike[@]flyn.org> - 0.0.37-1
 - New upstream version
 
diff --git a/sources b/sources
index d924aa0..7a31592 100644
--- a/sources
+++ b/sources
@@ -1 +1,2 @@
+d8bf94c178ddaa14edacdc0e2ddebbd0  dmapd-systemd.patch
 9b4da89150d1223d49467e4ddfadb725  dmapd-0.0.37.tar.gz


More information about the scm-commits mailing list