From 98340494af435f334e87fffdf9a526df09e7e6dbcca1a1a9e72afa0ce6daa2ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20=C4=8C=C3=AD=C5=BEek?= Date: Mon, 21 Jul 2014 13:48:59 +0000 Subject: [PATCH] Accepting request 241561 from home:posophe:branches:server:http Use systemd instead of sysvinit in openSUSE > 12.2 OBS-URL: https://build.opensuse.org/request/show/241561 OBS-URL: https://build.opensuse.org/package/show/server:http/thttpd?expand=0&rev=22 --- thttpd.changes | 5 +++++ thttpd.service | 10 +++++++++ thttpd.spec | 59 ++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 thttpd.service diff --git a/thttpd.changes b/thttpd.changes index 9725b49..dcc1e27 100644 --- a/thttpd.changes +++ b/thttpd.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Jul 18 16:40:22 UTC 2014 - p.drouand@gmail.com + +- Use systemd instead of sysvinit in openSUSE > 12.2 + ------------------------------------------------------------------- Tue Dec 3 14:31:18 UTC 2013 - vcizek@suse.com diff --git a/thttpd.service b/thttpd.service new file mode 100644 index 0000000..a080d3e --- /dev/null +++ b/thttpd.service @@ -0,0 +1,10 @@ +[Unit] +Description=Tiny HTTP Daemon + +[Service] +PIDFile=/run/thttpd.pid +ExecStart=/usr/bin/thttpd -D -C /etc/thttpd.conf +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/thttpd.spec b/thttpd.spec index 52108bf..a5d842c 100644 --- a/thttpd.spec +++ b/thttpd.spec @@ -1,7 +1,7 @@ # # spec file for package thttpd # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,14 +15,26 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # +%if 0%{?suse_version} > 1220 +%define with_systemd 1 +%else +%define with_systemd 0 +%endif Name: thttpd Provides: http_daemon -PreReq: %fillup_prereq %insserv_prereq permissions +%if %{with_systemd} +BuildRequires: systemd +%{?systemd_requires} +%else +PreReq: %fillup_prereq %insserv_prereq +%endif +PreReq: permissions Version: 2.25b Release: 0 Source: %{name}-%{version}.tar.bz2 Source1: %{name}-SuSE.tar.bz2 +Source2: %{name}.service Patch0: %{name}-%{version}-configure.patch Patch1: %{name}-%{version}-dirs.patch Patch2: %{name}-%{version}-time_h.patch @@ -55,12 +67,6 @@ in memory use. Basic support for cgi scripts, authentication, and ssi is provided for. Advanced features include the ability to throttle traffic. - - -Authors: --------- - jef@acme.com - %define serverroot /srv/www %prep @@ -96,11 +102,7 @@ libtoolize --force aclocal --force autoconf -f V_CCOPT="$RPM_OPT_FLAGS -Wall" \ -./configure \ - --mandir=%{_mandir} \ - --prefix=%{_prefix} \ - --infodir=%{_infodir} \ - --sysconfdir=%{_sysconfdir} +%configure %ifarch s390 s390x make F_PIE="-fPIE" %else @@ -116,9 +118,25 @@ install -d %{buildroot}/usr/bin \ make DESTDIR=%{buildroot} install cp -a SuSE/* %{buildroot} rm -f %{buildroot}%{serverroot}/htdocs/index.html +%if %{with_systemd} +rm -rf %{buildroot}/etc/init.d +rm %{buildroot}%{_sbindir}/rc%{name} +mkdir -p %{buildroot}%{_unitdir} +install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name} +%endif + +%if %{with_systemd} +%pre +%service_add_pre %{name}.service +%endif %post +%if %{with_systemd} +%service_add_post %{name}.service +%else %{fillup_and_insserv thttpd} +%endif %if 0%{?suse_version} <= 1130 %run_permissions %else @@ -129,14 +147,19 @@ rm -f %{buildroot}%{serverroot}/htdocs/index.html %verify_permissions -e /usr/bin/makeweb %preun +%if %{with_systemd} +%service_del_preun %{name}.service +%else %stop_on_removal thttpd +%endif %postun +%if %{with_systemd} +%service_del_postun %{name}.service +%else %restart_on_update thttpd %{insserv_cleanup} - -%clean -rm -rf "%{buildroot}" +%endif %files %defattr(-, root, root) @@ -147,7 +170,11 @@ rm -rf "%{buildroot}" /usr/bin/htpasswd /usr/sbin/* /usr/share/man/*/* +%if %{with_systemd} +%{_unitdir}/%{name}.service +%else %config /etc/init.d/thttpd +%endif %config(noreplace) /etc/thttpd.conf %changelog