[lighttpd] Include systemd service, use bcond and other cleanups.
Matthias Saou
thias at fedoraproject.org
Mon Jul 11 18:40:55 UTC 2011
commit e4f747f0a2c53dd0dd1d041390d8afd1e12c23b1
Author: Matthias Saou <thias at marmotte.net>
Date: Mon Jul 11 20:40:12 2011 +0200
Include systemd service, use bcond and other cleanups.
lighttpd-1.4.28-defaultconf.patch | 4 +-
lighttpd.service | 13 +++
lighttpd.spec | 155 +++++++++++++++++++++++++++++--------
3 files changed, 137 insertions(+), 35 deletions(-)
---
diff --git a/lighttpd-1.4.28-defaultconf.patch b/lighttpd-1.4.28-defaultconf.patch
index 12c6470..a7ade51 100644
--- a/lighttpd-1.4.28-defaultconf.patch
+++ b/lighttpd-1.4.28-defaultconf.patch
@@ -1,6 +1,6 @@
diff -Naupr lighttpd-1.4.28.orig/doc/config/lighttpd.conf lighttpd-1.4.28/doc/config/lighttpd.conf
--- lighttpd-1.4.28.orig/doc/config/lighttpd.conf 2010-07-11 19:01:32.000000000 +0200
-+++ lighttpd-1.4.28/doc/config/lighttpd.conf 2011-07-10 23:24:57.316465832 +0200
++++ lighttpd-1.4.28/doc/config/lighttpd.conf 2011-07-11 16:11:38.917867758 +0200
@@ -14,7 +14,7 @@
## chroot example aswell.
##
@@ -25,7 +25,7 @@ diff -Naupr lighttpd-1.4.28.orig/doc/config/lighttpd.conf lighttpd-1.4.28/doc/co
##
-server.max-fds = 2048
+## With SELinux enabled, this is denied by default and needs to be allowed
-+## before it can work.
++## by running the following once : setsebool -P httpd_setrlimit on
+#server.max-fds = 2048
##
diff --git a/lighttpd.service b/lighttpd.service
new file mode 100644
index 0000000..96f5823
--- /dev/null
+++ b/lighttpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Lightning Fast Webserver With Light System Requirements
+After=syslog.target network.target
+
+[Service]
+Type=forking
+PIDFile=/var/run/lighttpd.pid
+EnvironmentFile=-/etc/sysconfig/lighttpd
+ExecStart=/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/lighttpd.spec b/lighttpd.spec
index f345f8a..3496b24 100644
--- a/lighttpd.spec
+++ b/lighttpd.spec
@@ -1,12 +1,61 @@
%define webroot /var/www/lighttpd
-# LUA support requires >= 5.1 but EPEL4 provides only 5.0, so disable
-%{?el4: %define _without_lua 1}
+# RHEL4's rpm doesn't have the bcond macros
+%if 0%{?rhel} <= 4
+%define with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
+%define without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
+%define bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
+%define bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
+%endif
+
+# We have an bunch of --with/--without options to pass, make it easy with bcond
+%define confswitch() %{expand:%%{?with_%{1}:--with-%{1}}%%{!?with_%{1}:--without-%{1}}}
+
+%bcond_without mysql
+%bcond_without ldap
+%bcond_without attr
+%bcond_without openssl
+%bcond_without kerberos5
+%bcond_without pcre
+%bcond_without fam
+# We can't have bcond names with hyphens
+%bcond_with webdavprops
+%bcond_with webdavlocks
+%bcond_without gdbm
+%bcond_with memcache
+
+# No poweredby.png image in EL5 and earlier (it's in Fedora and EL6+)
+%if 0%{?rhel} <= 5
+%bcond_with systemlogos
+%else
+%bcond_without systemlogos
+%endif
+
+# LUA support requires lua >= 5.1 but EPEL4 provides only 5.0, so disable
+%if 0%{?rhel} <= 4
+%bcond_with lua
+%else
+%bcond_without lua
+%endif
+
+# The /var/run/lighttpd directory uses tmpfiles.d when mounted using tmpfs
+%if 0%{?fedora} >= 15
+%bcond_without tmpfiles
+%else
+%bcond_with tmpfiles
+%endif
+
+# Replace sysvinit script with systemd service file for F16+
+%if 0%{?fedora} >= 15
+%bcond_without systemd
+%else
+%bcond_with systemd
+%endif
Summary: Lightning fast webserver with light system requirements
Name: lighttpd
Version: 1.4.28
-Release: 2%{?dist}
+Release: 3%{?dist}
License: BSD
Group: System Environment/Daemons
URL: http://www.lighttpd.net/
@@ -14,6 +63,7 @@ Source0: http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-%{version
Source1: lighttpd.logrotate
Source2: php.d-lighttpd.ini
Source3: lighttpd.init
+Source4: lighttpd.service
Source10: index.html
Source11: http://www.lighttpd.net/favicon.ico
Source12: http://www.lighttpd.net/light_button.png
@@ -26,25 +76,32 @@ Patch1: lighttpd-1.4.29-mod_geoip.patch
#Patch100: lighttpd-1.4.29-mod_geoip.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
# For the target poweredby.png image (skip requirement + provide image on RHEL)
-%if 0%{!?rhel:1}
+%if %{with systemlogos}
Requires: system-logos >= 7.92.1
%endif
Requires(pre): /usr/sbin/useradd
+%if %{with systemd}
+Requires(post): systemd-units
+Requires(post): systemd-sysv
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+%else
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/service, /sbin/chkconfig
Requires(postun): /sbin/service
+%endif
Provides: webserver
BuildRequires: openssl-devel, pcre-devel, bzip2-devel, zlib-devel
BuildRequires: /usr/bin/awk
-%{!?_without_ldap:BuildRequires: openldap-devel}
-%{?_with_gamin:BuildRequires: gamin-devel}
-%{!?_without_gdbm:BuildRequires: gdbm-devel}
-%{!?_without_lua:BuildRequires: lua-devel}
-# On Fedora <= 6 (and RHEL?), we still need this because of the "broken" lua
-%if %{!?fedora:0}%{?fedora} <= 6
-BuildRequires: readline-devel
-%endif
-%if 0%{?rhel} <= 6
+%{?with_ldap:BuildRequires: openldap-devel}
+%{?with_fam:BuildRequires: gamin-devel}
+%{?with_webdavprops:BuildRequires: libxml2-devel}
+%{?with_webdavlocks:BuildRequires: sqlite-devel}
+%{?with_gdbm:BuildRequires: gdbm-devel}
+%{?with_memcache:BuildRequires: memcached-devel}
+%{?with_lua:BuildRequires: lua-devel}
+# On RHEL <= 5 we still need this because of the "broken" lua
+%if 0%{?rhel} <= 5
BuildRequires: readline-devel
%endif
@@ -56,10 +113,6 @@ to other webservers and takes care of cpu-load. Its advanced feature-set
it the perfect webserver-software for every server that is suffering load
problems.
-Available rpmbuild rebuild options :
---with : gamin webdavprops webdavlocks memcache
---without : ldap gdbm lua (cml)
-
%package fastcgi
Summary: FastCGI module and spawning helper for lighttpd and PHP configuration
@@ -104,16 +157,19 @@ install -p -m 0644 %{SOURCE101} mod_geoip.txt
%build
%configure \
- --libdir="%{_libdir}/lighttpd" \
- --with-mysql \
- %{!?_without_ldap:--with-ldap} \
- --with-openssl \
- %{?_with_gamin:--with-fam} \
- %{?_with_webdavprops:--with-webdav-props} \
- %{?_with_webdavlocks:--with-webdav-locks} \
- %{!?_without_gdbm:--with-gdbm} \
- %{?_with_memcache:--with-memcache} \
- %{?!_without_lua:--with-lua}
+ --libdir='%{_libdir}/lighttpd' \
+ %{confswitch mysql} \
+ %{confswitch ldap} \
+ %{confswitch attr} \
+ %{confswitch openssl} \
+ %{confswitch kerberos5} \
+ %{confswitch pcre} \
+ %{confswitch fam} \
+ %{?with_webdavprops:--with-webdav-props} \
+ %{?with_webdavlocks:--with-webdav-locks} \
+ %{confswitch gdbm} \
+ %{confswitch memcache} \
+ %{confswitch lua}
make %{?_smp_mflags}
@@ -129,9 +185,14 @@ install -D -p -m 0644 %{SOURCE1} \
install -D -p -m 0644 %{SOURCE2} \
%{buildroot}%{_sysconfdir}/php.d/lighttpd.ini
-# Install our own init script (the included one is old style)
+# Install our own init script (included one is old style) or systemd service
+%if %{with systemd}
+install -D -p -m 0644 %{SOURCE4} \
+ %{buildroot}%{_unitdir}/lighttpd.service
+%else
install -D -p -m 0755 %{SOURCE3} \
%{buildroot}%{_sysconfdir}/rc.d/init.d/lighttpd
+%endif
# Install our own default web page and images
mkdir -p %{buildroot}%{webroot}
@@ -139,7 +200,7 @@ install -p -m 0644 %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} \
%{buildroot}%{webroot}/
# Symlink for the powered-by-$DISTRO image (install empty image on RHEL)
-%if 0%{!?rhel:1}
+%if %{with systemlogos}
ln -s %{_datadir}/pixmaps/poweredby.png \
%else
install -p -m 0644 %{SOURCE14} \
@@ -162,7 +223,7 @@ mkdir -p %{buildroot}%{_var}/log/lighttpd
# Install empty run directory to include (for the example fastcgi socket)
mkdir -p %{buildroot}%{_var}/run/lighttpd
-%if 0%{?fedora} >= 15
+%if %{with tmpfiles}
# Setup tmpfiles.d config for the above
mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
echo 'D /var/run/lighttpd 0750 lighttpd lighttpd -' > \
@@ -176,21 +237,39 @@ rm -rf %{buildroot}
%pre
/usr/sbin/useradd -s /sbin/nologin -M -r -d %{webroot} \
- -c "lighttpd web server" lighttpd &>/dev/null || :
+ -c 'lighttpd web server' lighttpd &>/dev/null || :
%post
+%if %{with systemd}
+if [ $1 -eq 1 ] ; then
+ /bin/systemctl daemon-reload &>/dev/null || :
+fi
+%else
/sbin/chkconfig --add lighttpd
+%endif
%preun
if [ $1 -eq 0 ]; then
+%if %{with systemd}
+ /bin/systemctl --no-reload disable lighttpd.service &>/dev/null || :
+ /bin/systemctl stop lighttpd.service &>/dev/null || :
+%else
/sbin/service lighttpd stop &>/dev/null || :
/sbin/chkconfig --del lighttpd
+%endif
fi
%postun
+%if %{with systemd}
+/bin/systemctl daemon-reload &>/dev/null || :
+if [ $1 -ge 1 ]; then
+ /bin/systemctl try-restart lighttpd.service &>/dev/null || :
+fi
+%else
if [ $1 -ge 1 ]; then
/sbin/service lighttpd condrestart &>/dev/null || :
fi
+%endif
%files
@@ -205,8 +284,12 @@ fi
%config %{_sysconfdir}/lighttpd/conf.d/mod.template
%config %{_sysconfdir}/lighttpd/vhosts.d/vhosts.template
%config(noreplace) %{_sysconfdir}/logrotate.d/lighttpd
+%if %{with systemd}
+%{_unitdir}/lighttpd.service
+%else
%{_sysconfdir}/rc.d/init.d/lighttpd
-%if 0%{?fedora} >= 15
+%endif
+%if %{with tmpfiles}
%config(noreplace) %{_sysconfdir}/tmpfiles.d/lighttpd.conf
%endif
%{_sbindir}/lighttpd
@@ -218,7 +301,7 @@ fi
%exclude %{_libdir}/lighttpd/mod_mysql_vhost.so
%{_mandir}/man8/lighttpd.8*
%attr(0750, lighttpd, lighttpd) %{_var}/log/lighttpd/
-%if 0%{?fedora} >= 15
+%if %{with tmpfiles}
%ghost %attr(0750, lighttpd, lighttpd) %{_var}/run/lighttpd/
%else
%attr(0750, lighttpd, lighttpd) %{_var}/run/lighttpd/
@@ -250,6 +333,12 @@ fi
%changelog
+* Mon Jul 11 2011 Matthias Saou <http://freshrpms.net/> 1.4.28-3
+- Update the defaultconf patch to hint at selinux change to fix server.max-fds.
+- Start using %%bcond, including quick defines to also support EL4.
+- Include systemd service for F16+, don't add all of the ugly trigger for sysv
+ migration (yet : new versions might be released before F16 final) (#720210).
+
* Sat Jul 9 2011 Matthias Saou <http://freshrpms.net/> 1.4.28-2
- Rebase F15 master to the 1.4.28 update.
- Try to update to 1.4.29 (#625737).
More information about the scm-commits
mailing list