From f7c4d6ea59341644489dd3379f10d9aedcc8aa25 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Jan 17 2013 21:47:49 +0000 Subject: install a systemd unit file on in-devel releases --- diff --git a/NEWS b/NEWS index c63dcea..c28bf47 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +0.31.3 - Fix use of incorrectly-named facilities in the LSB header in the + init script. + Provide systemd configuration files. 0.31.2 - Notice when we fail to register a name with the message bus. 0.31.1 - Tweak init script exit status when given an unrecognized command. 0.31 - Set permissions on intermediate directories correctly when the diff --git a/configure.ac b/configure.ac index 8432c0d..d0f9a30 100644 --- a/configure.ac +++ b/configure.ac @@ -4,8 +4,9 @@ PACKAGE_NAME_CAPS=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'` AC_DEFINE_UNQUOTED(PACKAGE_NAME_CAPS,"$PACKAGE_NAME_CAPS",[Define to the package name, in caps.]) AC_SUBST(PACKAGE_NAME_CAPS) AM_INIT_AUTOMAKE([foreign]) +AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC -AM_MAINTAINER_MODE +AM_MAINTAINER_MODE([enable]) AC_DEFINE(_GNU_SOURCE,1,[Use GNU libc extensions.]) @@ -70,6 +71,21 @@ DEFAULT_RECONNECT_TIMEOUT=30 AC_DEFINE_UNQUOTED(DEFAULT_RECONNECT_TIMEOUT,$DEFAULT_RECONNECT_TIMEOUT,[Define to the default amount of time which oddjobd will pause between attempts to reconnect to the system message bus after being disconnected for any reason.]) AC_SUBST(DEFAULT_RECONNECT_TIMEOUT) +AC_ARG_ENABLE(systemd, +AS_HELP_STRING([--enable-systemd],[install unit file for systemd]), +SYSTEMD=$enableval, +SYSTEMD=no) + +AC_SUBST(SYSTEMD) +AM_CONDITIONAL(SYSTEMD,test x$SYSTEMD != xno) +if test x$SYSTEMD = xyes ; then + SYSTEMDSYSTEMUNITDIR=`pkg-config --variable=systemdsystemunitdir systemd 2> /dev/null` + AC_MSG_RESULT(will install systemd unit file) +else + AC_MSG_RESULT(will install sysv init script) +fi +AC_SUBST(SYSTEMDSYSTEMUNITDIR) + AC_ARG_ENABLE(sample, AS_HELP_STRING(--enable-sample,[Build and install a sample service.]), sample=$withval, diff --git a/oddjob.spec b/oddjob.spec index 4d40887..be9e1c7 100644 --- a/oddjob.spec +++ b/oddjob.spec @@ -1,10 +1,14 @@ %global build_sample_subpackage 0 %global dbus_send /bin/dbus-send -%if 0%{?fedora} > 17 || 0%{?rhel} > 6 + +%if 0%{?fedora} > 18 || 0%{?rhel} > 6 %global systemd 1 +%global sysvinit 0 %else %global systemd 0 +%global sysvinit 1 %endif + %if 0%{?fedora} > 16 || 0%{?rhel} > 6 %global separate_usr 0 %else @@ -13,7 +17,7 @@ Name: oddjob Version: 0.31.2 -Release: 3%{?dist} +Release: 1%{?dist} Source: http://fedorahosted.org/released/oddjob/oddjob-%{version}.tar.gz Summary: A D-Bus service which runs odd jobs on behalf of client applications License: BSD @@ -40,6 +44,20 @@ Requires(post): psmisc Obsoletes: oddjob-devel < 0.30, oddjob-libs < 0.30, oddjob-python < 0.30 URL: http://www.fedorahosted.org/oddjob +%if %{systemd} +BuildRequires: systemd-units +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units +Requires(post): systemd-sysv +%endif + +%if %{sysvinit} +Requires(post): /sbin/chkconfig, /sbin/service +Requires(preun): /sbin/chkconfig, /sbin/service +%endif + + %description oddjob is a D-Bus service which performs particular tasks for clients which connect to it and issue requests using the system-wide message bus. @@ -167,34 +185,47 @@ if test $1 -eq 1 ; then killall -HUP dbus-daemon 2>&1 > /dev/null fi %if %{systemd} -if test $1 -eq 1 ; then - /bin/systemctl daemon-reload >/dev/null 2>&1 || : -fi -%else +%systemd_post oddjobd.service +%endif +%if %{sysvinit} /sbin/chkconfig --add oddjobd %endif %postun -if [ $1 -gt 0 ] ; then %if %{systemd} - /bin/systemctl daemon-reload >/dev/null 2>&1 || : - /bin/systemctl try-restart oddjobd.service >/dev/null 2>&1 || : -%else - /sbin/service oddjobd condrestart 2>&1 > /dev/null || : +%systemd_postun oddjobd.service %endif +%if %{sysvinit} +if [ $1 -gt 0 ] ; then + /sbin/service oddjobd condrestart 2>&1 > /dev/null || : fi +%endif exit 0 %preun -if [ $1 -eq 0 ] ; then %if %{systemd} - /bin/systemctl --no-reload disable oddjob.service > /dev/null 2>&1 || : - /bin/systemctl stop oddjob.service > /dev/null 2>&1 || : -%else +%systemd_preun oddjobd.service +%endif +%if %{sysvinit} +if [ $1 -eq 0 ] ; then /sbin/service oddjobd stop > /dev/null 2>&1 /sbin/chkconfig --del oddjobd -%endif fi +%endif +exit 0 + +%if %{systemd} +%triggerun -- oddjobd < 0.31.2 +# Save the current service runlevel info, in case the user wants to apply +# the enabled status manually later, by running +# "systemd-sysv-convert --apply oddjobd". +%{_bindir}/systemd-sysv-convert --save oddjobd >/dev/null 2>&1 ||: +# Do this because the old package's %%postun doesn't know we need to do it. +/sbin/chkconfig --del oddjobd >/dev/null 2>&1 || : +# Do this because the old package's %%postun wouldn't have tried. +/bin/systemctl try-restart oddjobd.service >/dev/null 2>&1 || : +exit 0 +%endif %post mkhomedir # Adjust older configuration files that may have been modified so that they @@ -212,6 +243,9 @@ fi exit 0 %changelog +* Thu Jan 17 2013 Nalin Dahyabhai 0.31.3-1 +- use newer systemd macros + * Wed Nov 21 2012 Nalin Dahyabhai 0.31.2-3 - add that dependency to the right subpackage diff --git a/scripts/oddjobd.service.in b/scripts/oddjobd.service.in index ef861e9..7730c20 100644 --- a/scripts/oddjobd.service.in +++ b/scripts/oddjobd.service.in @@ -3,7 +3,6 @@ Description=privileged operations for unprivileged applications After=syslog.target network.target dbus.service [Service] -Type=dbus +Type=simple PIDFile=/var/run/oddjobd.pid -ExecStart=@sbindir@/oddjobd -n -p /var/run/oddjobd.pid -BusName=@NAMESPACE@.@PACKAGE_NAME@ +ExecStart=@sbindir@/oddjobd -n -p /var/run/oddjobd.pid -t 300