[openct] install systemd service unit instead of SysV initscript

Tomáš Mráz tmraz at fedoraproject.org
Fri Jul 27 19:59:20 UTC 2012


commit 033fb1fcba57903d1c1faa9967ad2071cef2e111
Author: Tomas Mraz <tmraz at fedoraproject.org>
Date:   Fri Jul 27 21:59:08 2012 +0200

    install systemd service unit instead of SysV initscript
    
    - fix placement of tmpfiles.d default configuration

 openct.init    |  113 --------------------------------------------------------
 openct.service |   13 ++++++
 openct.spec    |   56 ++++++++++++++++++++--------
 3 files changed, 53 insertions(+), 129 deletions(-)
---
diff --git a/openct.service b/openct.service
new file mode 100644
index 0000000..c9ec497
--- /dev/null
+++ b/openct.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Openct Middleware framework for smart card terminals
+After=syslog.target network.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/openct
+ExecStart=/usr/sbin/openct-control $OPENCT_OPTIONS init 
+ExecStop=/usr/sbin/openct-control $OPENCT_OPTIONS shutdown
+RemainAfterExit=yes
+KillMode=none
+
+[Install]
+WantedBy=multi-user.target
diff --git a/openct.spec b/openct.spec
index 23d092f..08c11ee 100644
--- a/openct.spec
+++ b/openct.spec
@@ -2,14 +2,14 @@
 
 Name:           openct
 Version:        0.6.20
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Middleware framework for smart card terminals
 
 Group:          System Environment/Libraries
 License:        LGPLv2+
 URL:            http://www.opensc-project.org/openct/
 Source0:        http://www.opensc-project.org/files/openct/%{name}-%{version}.tar.gz
-Source1:        %{name}.init
+Source1:        %{name}.service
 Source2:        %{name}.sysconfig
 Source3:        %{name}tmp.conf
 Patch1:         %{name}-0.6.19-nosleep.patch
@@ -20,13 +20,16 @@ BuildRequires:  pcsc-lite-devel >= 1.3.0
 BuildRequires:  libusb-devel
 BuildRequires:  libtool-ltdl-devel
 BuildRequires:  doxygen
+BuildRequires:  systemd-units
 Requires:       ctapi-common%{?_isa}
 # 098 for some keywords in shipped rules, see etc/openct.udev for more info
 Requires:       udev >= 098
-Requires(post): /sbin/chkconfig /sbin/service
+Requires(post): systemd-sysv
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
 Requires(post): /sbin/ldconfig
-Requires(preun): /sbin/chkconfig /sbin/service
-Requires(postun): /sbin/ldconfig /sbin/service
+Requires(postun): /sbin/ldconfig
 
 %description
 OpenCT implements drivers for several smart card readers.  It comes as
@@ -97,7 +100,7 @@ install -Dpm 644 etc/openct.udev \
 
 install -pm 644 etc/openct.conf $RPM_BUILD_ROOT%{_sysconfdir}/openct.conf
 
-install -Dpm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initddir}/openct
+install -Dpm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/openct.service
 
 install -Dpm 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/openct
 
@@ -110,7 +113,7 @@ install -dm 755 $RPM_BUILD_ROOT%{_localstatedir}/run/openct
 touch $RPM_BUILD_ROOT%{_localstatedir}/run/openct/status
 chmod 644 $RPM_BUILD_ROOT%{_localstatedir}/run/openct/status
 
-install -Dpm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/tmpfiles.d/opencttmp.conf
+install -Dpm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_prefix}/lib/tmpfiles.d/openct.conf
 
 rm -f $RPM_BUILD_ROOT%{_libdir}/{*.la,openct-ifd.so}
 
@@ -124,28 +127,45 @@ rm -rf $RPM_BUILD_ROOT
 
 %post
 /sbin/ldconfig
-/sbin/chkconfig --add openct
+if [ $1 -eq 1 ] ; then
+    # Initial installation
+    /bin/systemctl enable openct.service >/dev/null 2>&1 || :
+fi
 
 %preun
 if [ $1 -eq 0 ] ; then
-    /sbin/service openct stop >/dev/null 2>&1 || :
-    /sbin/chkconfig --del openct
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable openct.service > /dev/null 2>&1 || :
+    /bin/systemctl stop openct.service > /dev/null 2>&1 || :
 fi
 
 %postun
 /sbin/ldconfig
-if [ $1 -gt 0 ] ; then
-    /sbin/service openct try-restart >/dev/null || :
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart openct.service >/dev/null 2>&1 || :
 fi
 
 %post -n pcsc-lite-%{name}
 if [ $1 -eq 1 ] ; then
-    /sbin/service pcscd try-restart >/dev/null 2>&1 || :
+    /bin/systemctl try-restart pcscd.service >/dev/null 2>&1 || :
 fi
 
 %postun -n pcsc-lite-%{name}
-/sbin/service pcscd try-restart >/dev/null 2>&1 || :
+/bin/systemctl try-restart pcscd.service >/dev/null 2>&1 || :
+
+%triggerun -- openct < 0.6.20-5
+# Save the current service runlevel info
+# User must manually run systemd-sysv-convert --apply openct
+# to migrate them to systemd targets
+/usr/bin/systemd-sysv-convert --save openct >/dev/null 2>&1 ||:
 
+/bin/systemctl --no-reload enable openct.service >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del openct >/dev/null 2>&1 || :
+/bin/systemctl try-restart openct.service >/dev/null 2>&1 || :
 
 %files
 %defattr(-,root,root,-)
@@ -154,8 +174,8 @@ fi
 %config(noreplace) %{_sysconfdir}/openct.conf
 %config(noreplace) %{_sysconfdir}/sysconfig/openct
 %config(noreplace) %{_sysconfdir}/udev/rules.d/*openct.rules
-%config(noreplace) %{_sysconfdir}/tmpfiles.d/opencttmp.conf
-%{_initddir}/openct
+%{_prefix}/lib/tmpfiles.d/openct.conf
+%{_unitdir}/openct.service
 %{_bindir}/openct-tool
 %{_sbindir}/ifdhandler
 %{_sbindir}/ifdproxy
@@ -183,6 +203,10 @@ fi
 
 
 %changelog
+* Fri Jul 27 2012 Tomas Mraz <tmraz at redhat.com> - 0.6.20-5
+- install systemd service unit instead of SysV initscript
+- fix placement of tmpfiles.d default configuration
+
 * Fri Jul 20 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.6.20-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
 


More information about the scm-commits mailing list