[iodine] Introduce systemd support. Move legacy sysvinit part into subpackages (bz#789697).
Pavel Alexeev
hubbitus at fedoraproject.org
Sun Apr 22 12:41:56 UTC 2012
commit 904d3afc753227589d6c276f7aaba559905be9b8
Author: Pavel Alexeev (aka Pahan-Hubbitus) <pahan at hubbitus.info>
Date: Sun Apr 22 16:41:51 2012 +0400
Introduce systemd support. Move legacy sysvinit part into subpackages (bz#789697).
iodine-client.service | 11 ++++
iodine-server.service | 11 ++++
iodine.spec | 133 ++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 143 insertions(+), 12 deletions(-)
---
diff --git a/iodine-client.service b/iodine-client.service
new file mode 100644
index 0000000..308cf8e
--- /dev/null
+++ b/iodine-client.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Iodine Client
+After=local-fs.target network.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/iodine-client
+ExecStart=/usr/sbin/iodine $OPTIONS
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/iodine-server.service b/iodine-server.service
new file mode 100644
index 0000000..2d8a502
--- /dev/null
+++ b/iodine-server.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Iodine Server
+After=local-fs.target network.target
+
+[Service]
+EnvironmentFile=-/etc/sysconfig/iodine-server
+ExecStart=/usr/sbin/iodined $OPTIONS
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target
diff --git a/iodine.spec b/iodine.spec
index a071d80..97b3fed 100644
--- a/iodine.spec
+++ b/iodine.spec
@@ -2,7 +2,7 @@
Name: iodine
Version: 0.6.0
-Release: 0.rc1.8%{?dist}
+Release: 0.rc1.9%{?dist}
Summary: Solution to tunnel IPv4 data through a DNS server
Summary(ru): Решение для туннелирования IPv4 трафика через DNS сервер
Group: System Environment/Daemons
@@ -19,6 +19,9 @@ Source4: %{name}-server.init
Source5: %{name}.logrotate.client
Source6: %{name}.logrotate.server
+Source7: %{name}-client.service
+Source8: %{name}-server.service
+
# It still needed for EPEL5
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# http://dev.kryo.se/iodine/ticket/87
@@ -31,6 +34,8 @@ Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
+BuildRequires: systemd-units
+
Requires: %{name}-client
Requires: %{name}-server
@@ -61,29 +66,63 @@ Iodine работает на Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD и Window
%package client
Summary: Client part of solution to tunnel IPv4 data through a DNS server
Summary(ru): Клиент для туннелирования IPv4 трафика через DNS сервер
-Requires(post): chkconfig
-Requires(preun): chkconfig, initscripts
-Requires(postun): initscripts
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# This is actually needed for the %%triggerun script but Requires(triggerun)
+# is not valid. We can use %%post because this particular %%triggerun script
+# should fire just after this package is installed.
+Requires(post): systemd-sysv
%description client
This is the client part of iodine sulution.
%description client -l ru
-Это пакет клиентской части
+Это пакет клиентской части.
-%package server
-Summary: Server part of solution to tunnel IPv4 data through a DNS server
-Summary(ru): Сервер для туннелирования IPv4 трафика через DNS сервер
+%package client-sysvinit
+Summary: Legacy sysvinit scripts for cleint daemon
+Summary(ru): Устаревшие скрипты инициализации клиента в стиле sysvinit
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
Requires(postun): initscripts
+%description client-sysvinit
+May be needed f.e. on CentOS.
+
+%description client-sysvinit -l ru
+Могут понадобиться например на CentOS.
+
+%package server
+Summary: Server part of solution to tunnel IPv4 data through a DNS server
+Summary(ru): Сервер для туннелирования IPv4 трафика через DNS сервер
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+# This is actually needed for the %%triggerun script but Requires(triggerun)
+# is not valid. We can use %%post because this particular %%triggerun script
+# should fire just after this package is installed.
+Requires(post): systemd-sysv
+
%description server
This is the server part of iodine solution.
%description server -l ru
Это пакет серверной части
+%package server-sysvinit
+Summary: Legacy sysvinit scripts for server daemon
+Summary(ru): Устаревшие скрипты инициализации сервера в стиле sysvinit
+Requires(post): chkconfig
+Requires(preun): chkconfig, initscripts
+Requires(postun): initscripts
+
+%description server-sysvinit
+May be needed f.e. on CentOS.
+
+%description client-sysvinit -l ru
+Могут понадобиться например на CentOS.
+
%prep
%setup -q -n %{name}-%{version}%{prerel}
%patch0 -p0 -b .prefix
@@ -106,37 +145,102 @@ install -Dp -m 0755 %{SOURCE4} %{buildroot}/%{_initrddir}/%{name}-server
install -Dp -m 0644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}-client
install -Dp -m 0644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name}-server
+install -Dp -m 0644 %{SOURCE7} %{buildroot}/%{_unitdir}/%{name}-client.service
+install -Dp -m 0644 %{SOURCE8} %{buildroot}/%{_unitdir}/%{name}-server.service
+
%clean
rm -rf %{buildroot}
%post client
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
+%preun client
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable %{name}-client.service > /dev/null 2>&1 || :
+ /bin/systemctl stop %{name}-client.service > /dev/null 2>&1 || :
+fi
+
+%postun client
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart %{name}-client.service >/dev/null 2>&1 || :
+fi
+
+%post client-sysvinit
/sbin/chkconfig --add %{name}-client
-%post server
+%post server-sysvinit
/sbin/chkconfig --add %{name}-server
-%preun client
+%preun client-sysvinit
if [ $1 = 0 ] ; then
/sbin/service %{name}-client stop >/dev/null 2>&1
/sbin/chkconfig --del %{name}-client
fi
+%post server
+if [ $1 -eq 1 ] ; then
+ # Initial installation
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
%preun server
+if [ $1 -eq 0 ] ; then
+ # Package removal, not upgrade
+ /bin/systemctl --no-reload disable %{name}-server.service > /dev/null 2>&1 || :
+ /bin/systemctl stop %{name}-server.service > /dev/null 2>&1 || :
+fi
+
+%postun server
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+ # Package upgrade, not uninstall
+ /bin/systemctl try-restart %{name}-server.service >/dev/null 2>&1 || :
+fi
+
+%preun server-sysvinit
if [ $1 = 0 ] ; then
/sbin/service %{name}-server stop >/dev/null 2>&1
/sbin/chkconfig --del %{name}-server
fi
-%postun client
+%postun client-sysvinit
if [ "$1" -ge "1" ] ; then
/sbin/service %{name}-client condrestart >/dev/null 2>&1 || :
fi
-%postun server
+%postun server-sysvinit
if [ "$1" -ge "1" ] ; then
/sbin/service %{name}-server condrestart >/dev/null 2>&1 || :
fi
+# https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd
+%triggerun -- %{name}-client < 0.6.0-0.rc1.9
+/usr/bin/systemd-sysv-convert --save %{name}-client >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del %{name}-client >/dev/null 2>&1 || :
+/bin/systemctl try-restart %{name}-client.service >/dev/null 2>&1 || :
+
+%triggerun -- %{name}-server < 0.6.0-0.rc1.9
+/usr/bin/systemd-sysv-convert --save %{name}-server >/dev/null 2>&1 ||:
+
+# Run these because the SysV package being removed won't do them
+/sbin/chkconfig --del %{name}-client >/dev/null 2>&1 || :
+/bin/systemctl try-restart %{name}-server.service >/dev/null 2>&1 || :
+
+# https://fedoraproject.org/wiki/Packaging:SysVInitScript#Initscripts_in_addition_to_systemd_unit_files
+%triggerpostun -n %{name}-client-sysvinit -- %{name}-client < 0.6.0-0.rc1.9
+/sbin/chkconfig --add %{name}-client >/dev/null 2>&1 || :
+
+%triggerpostun -n %{name}-server-sysvinit -- %{name}-server < 0.6.0-0.rc1.9
+/sbin/chkconfig --add %{name}-server >/dev/null 2>&1 || :
+
%files
%defattr(-,root,root,-)
%doc CHANGELOG README TODO
@@ -148,6 +252,7 @@ fi
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}-client
%{_initrddir}/%{name}-client
%{_mandir}/man8/%{name}.8.gz
+%{_unitdir}/%{name}-client.service
%files server
%defattr(-,root,root,-)
@@ -156,8 +261,12 @@ fi
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}-server
%{_initrddir}/%{name}-server
%{_mandir}/man8/%{name}d.8.gz
+%{_unitdir}/%{name}-server.service
%changelog
+* Thu Feb 23 2012 Pavel Alexeev <Pahan at Hubbitus.info> - 0.6.0-0.rc1.9
+- Introduce systemd support. Move legacy sysvinit part into subpackages (bz#789697).
+
* Sun Jan 8 2012 Pavel Alexeev <Pahan at Hubbitus.info> - 0.6.0-0.rc1.8
- Split man pages also.
More information about the scm-commits
mailing list