%define webroot /var/www/lighttpd

Summary: Lightning fast webserver with light system requirements
Summary(ja): 少ないシステムリソースで動く超高速なウェブサーバ
Name: lighttpd
Version: 1.4.22
Release: 1%{?_dist_release}
License: BSD
Group: System Environment/Daemons
URL: http://www.lighttpd.net/
Source0: http://www.lighttpd.net/download/lighttpd-%{version}.tar.bz2
Source1: lighttpd.logrotate
Source2: php.d-lighttpd.ini
Source3: lighttpd.init
Source10: index.html
Source11: http://www.lighttpd.net/favicon.ico
Source13: http://www.lighttpd.net/light_button.png
Source14: http://www.lighttpd.net/light_logo.png
Patch0: lighttpd-1.4.20-defaultconf.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires(pre): shadow-utils
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(postun): chkconfig
BuildRequires: openssl-devel, pcre-devel, bzip2-devel, zlib-devel, gcc-c++
%{?_with_ldap:BuildRequires: openldap-devel}
BuildRequires: gamin-devel
BuildRequires: gdbm-devel
BuildRequires: lua-devel

%description
Secure, fast, compliant and very flexible web-server which has been optimized
for high-performance environments. It has a very low memory footprint compared
to other webservers and takes care of cpu-load. Its advanced feature-set
(FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more) make
it the perfect webserver-software for every server that is suffering load
problems.

Available rpmbuild rebuild options :
--with : memcache webdavprops ldap
--without: lua

%package mod_mysql_vhost
Summary: Virtual host module for lighttpd that uses a MySQL database
Group: System Environment/Daemons
Requires: %{name} = %{version}
BuildRequires: mysql-devel

%description mod_mysql_vhost
Virtual host module for lighttpd that uses a MySQL database.


%package fastcgi
Summary: FastCGI module and spawning helper for lighttpd and PHP configuration
Group: System Environment/Daemons
Requires: %{name} = %{version}

%description fastcgi
This package contains the spawn-fcgi helper for lighttpd's automatic spawning
of local FastCGI programs. Included is also a PHP .ini file to change a few
defaults needed for correct FastCGI behavior.
Note that for FastCGI to work with PHP, you will most likely need to find a
tweaked PHP package (--enable-fastcgi and --enable-discard-path added) or
recompile PHP yourself.


%prep
%setup -q
%patch0 -p1 -b .defaultconf


%build
%configure \
    --libdir="%{_libdir}/lighttpd" \
    --with-mysql \
    %{?_with_ldap:--with-ldap} \
    --with-openssl \
    --with-fam \
    --with-gdbm \
    %{?_with_memcache:--with-memcache} \
    %{?_with_webdavprops:--with-webdav-props} \
    %{?_with_webdavlocks:--with-webdav-locks} \
    %{?!_without_lua:--with-lua}
%{__make}


%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}

# Install included init script and sysconfig entry
%{__install} -D -p -m 0755 doc/rc.lighttpd.redhat \
    %{buildroot}%{_sysconfdir}/rc.d/init.d/lighttpd
%{__install} -D -p -m 0644 doc/sysconfig.lighttpd \
    %{buildroot}%{_sysconfdir}/sysconfig/lighttpd

# Install (*patched above*) sample config file
%{__install} -D -p -m 0640 doc/lighttpd.conf \
    %{buildroot}%{_sysconfdir}/lighttpd/lighttpd.conf

# Install our own logrotate entry
%{__install} -D -p -m 0644 %{SOURCE1} \
    %{buildroot}%{_sysconfdir}/logrotate.d/lighttpd

# Install our own php.d ini file
%{__install} -D -p -m 0644 %{SOURCE2} \
    %{buildroot}%{_sysconfdir}/php.d/lighttpd.ini

# Install our own init script
%{__install} -D -p -m 0755 %{SOURCE3} \
    %{buildroot}%{_sysconfdir}/rc.d/init.d/lighttpd

# Install our own default web page and images
%{__mkdir_p} %{buildroot}%{webroot}
%{__install} -p -m 0644 %{SOURCE10} %{SOURCE11} %{SOURCE13} \
    %{SOURCE14} \
    %{buildroot}%{webroot}/

# Install empty log directory to include
%{__mkdir_p} %{buildroot}%{_var}/log/lighttpd

# Install empty run directory to include (for the example fastcgi socket)
%{__mkdir_p} %{buildroot}%{_var}/run/lighttpd


%clean
%{__rm} -rf %{buildroot}


%pre
/usr/sbin/useradd -s /sbin/nologin -M -r -d %{webroot} \
    -c "lighttpd web server" lighttpd &>/dev/null || :

%post
/sbin/chkconfig --add lighttpd

%preun
if [ $1 -eq 0 ]; then
  /sbin/service lighttpd stop &>/dev/null || :
  /sbin/chkconfig --del lighttpd
fi

%postun
if [ $1 -ge 1 ]; then
    /sbin/service lighttpd condrestart &>/dev/null || :
fi


%files
%defattr(-, root, root, 0755)
%doc AUTHORS ChangeLog COPYING README
%doc doc/*.txt doc/lighttpd.conf doc/lighttpd.user
%dir %{_sysconfdir}/lighttpd/
%config(noreplace) %{_sysconfdir}/lighttpd/lighttpd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/lighttpd
%config(noreplace) %{_sysconfdir}/sysconfig/lighttpd
%{_sysconfdir}/rc.d/init.d/lighttpd
%{_sbindir}/lighttpd
%{_sbindir}/lighttpd-angel
%{_libdir}/lighttpd/
%exclude %{_libdir}/lighttpd/*.la
%exclude %{_libdir}/lighttpd/mod_fastcgi.so
%exclude %{_libdir}/lighttpd/mod_mysql_vhost.so
%{_mandir}/man1/lighttpd.1*
%attr(0750, lighttpd, lighttpd) %{_var}/log/lighttpd/
%{webroot}/

%files mod_mysql_vhost
%defattr(-, root, root, 0755)
%doc doc/mysqlvhost.txt
%dir %{_libdir}/lighttpd/
%{_libdir}/lighttpd/mod_mysql_vhost.so

%files fastcgi
%defattr(-, root, root, 0755)
%doc doc/fastcgi*.txt
%config(noreplace) %{_sysconfdir}/php.d/lighttpd.ini
%{_bindir}/spawn-fcgi
%dir %{_libdir}/lighttpd/
%{_libdir}/lighttpd/mod_fastcgi.so
%{_mandir}/man1/spawn-fcgi.1*


%changelog
* Fri Jun 05 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.22-1
- new upstream release
- build with lua, add BR: lua-devel
- update init script

* Fri May 22 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.20-2
- rebuilt with MySQL-5.1.34.

* Wed Oct 08 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 1.4.20-1
- updated to 1.4.20 release with many bug/security fixes, including:
  - CVE-2008-4298: fix memory leak in request header handling
  - CVE-2008-4360: fix mod_userdir information disclosure
  - CVE-2008-4359: fix bypassing rewrite/redirect rules with encoded urls
  - CVE-2008-1531: fix DoS of ssl connections
- modified Patch0 for version 1.4.20
- add %{_sbindir}/lighttpd-angel to the filelist

* Fri Oct 03 2008 Shu KONNO <owa@bg.wakwak.com> 1.4.16-1vl5
- applied new versioning policy, spec in utf-8

* Tue Jul 31 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.16-0vl1
- new upstream release

* Fri Nov 03 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.13-0vl1
- initial build for Vine Linux

* Wed Oct 11 2006 Matthias Saou <http://freshrpms.net/> 1.4.13-1
- Update to 1.4.13, which contains the previous fix.

* Tue Oct  3 2006 Matthias Saou <http://freshrpms.net/> 1.4.12-3
- Include fix for segfaults (lighttpd bug #876, changeset 1352).

* Mon Sep 25 2006 Matthias Saou <http://freshrpms.net/> 1.4.12-1
- Update to 1.4.12 final.

* Fri Sep 22 2006 Matthias Saou <http://freshrpms.net/> 1.4.12-0.1.r1332
- Update to latest 1.4.12 pre-release, fixes SSL issues and other bugs.
- Update powered_by_fedora.png to the new logo.

* Mon Aug 28 2006 Matthias Saou <http://freshrpms.net/> 1.4.11-2
- FC6 rebuild.

* Thu Mar  9 2006 Matthias Saou <http://freshrpms.net/> 1.4.11-1
- Update to 1.4.11.

* Mon Mar  6 2006 Matthias Saou <http://freshrpms.net/> 1.4.10-2
- FC5 rebuild.

* Wed Feb  8 2006 Matthias Saou <http://freshrpms.net/> 1.4.10-1
- Update to 1.4.10.
- Remove now included fix.

* Wed Jan 25 2006 Matthias Saou <http://freshrpms.net/> 1.4.9-2
- Add mod_fastcgi-fix patch to fix crash on backend overload.

* Mon Jan 16 2006 Matthias Saou <http://freshrpms.net/> 1.4.9-1
- Update to 1.4.9.

* Wed Nov 23 2005 Matthias Saou <http://freshrpms.net/> 1.4.8-1
- Update to 1.4.8.

* Fri Nov  4 2005 Matthias Saou <http://freshrpms.net/> 1.4.7-1
- Update to 1.4.7.

* Wed Oct 12 2005 Matthias Saou <http://freshrpms.net/> 1.4.6-1
- Update to 1.4.6.

* Mon Oct  3 2005 Matthias Saou <http://freshrpms.net/> 1.4.5-1
- Update to 1.4.5.
- Disable gamin/fam support for now, it does not work.

* Tue Sep 27 2005 Matthias Saou <http://freshrpms.net/> 1.4.4-3
- Update to current SVN to check if it fixes the remaining load problems.

* Wed Sep 21 2005 Matthias Saou <http://freshrpms.net/> 1.4.4-2
- Patch to SVN 722 revision : Fixes a crash in mod_mysql_vhost and a problem
  with keepalive and certain browsers.

* Mon Sep 19 2005 Matthias Saou <http://freshrpms.net/> 1.4.4-1
- Update to 1.4.4 final.
- Enable ldap auth, gdbm and gamin/fam support by default.

* Thu Sep 15 2005 Matthias Saou <http://freshrpms.net/> 1.4.4-0
- Update to 1.4.4 pre-release (fixes another fastcgi memleak).
- Enable lua (cml module) by default.
- Add --with-webdav-props conditional option.

* Tue Sep 13 2005 Matthias Saou <http://freshrpms.net/> 1.4.3-2
- Include lighttpd-1.4.3-stat_cache.patch to fix memleak.

* Fri Sep  2 2005 Matthias Saou <http://freshrpms.net/> 1.4.3-1.1
- Rearrange the included index.html to include the new logo, button and
  favicon from lighttpd.net.

* Fri Sep  2 2005 Matthias Saou <http://freshrpms.net/> 1.4.3-1
- Update to 1.4.3.
- No longer override libdir at make install stage, use DESTDIR instead, as
  the resulting binary would now have referenced to %%{buildroot} :-(

* Tue Aug 30 2005 Matthias Saou <http://freshrpms.net/> 1.4.2-1
- Update to 1.4.2.

* Mon Aug 22 2005 Matthias Saou <http://freshrpms.net/> 1.4.1-1
- Update to 1.4.1.

* Sun Aug 21 2005 Matthias Saou <http://freshrpms.net/> 1.4.0-1
- Update to 1.4.0.
- Add conditional of gamin, gdbm, memcache and lua options.

* Mon Aug  1 2005 Matthias Saou <http://freshrpms.net/> 1.3.16-2
- Update to 1.3.16, rebuild.

* Mon Jul 18 2005 Matthias Saou <http://freshrpms.net/> 1.3.15-1
- Update to 1.3.15.

* Mon Jun 20 2005 Matthias Saou <http://freshrpms.net/> 1.3.14-1
- Update to 1.3.14.

* Sun May 22 2005 Jeremy Katz <katzj@redhat.com> - 1.3.13-5
- rebuild on all arches

* Mon Apr  4 2005 Matthias Saou <http://freshrpms.net/> 1.3.13-4
- Change signal sent from the logrotate script from USR1 to HUP, as that's the
  correct one.

* Fri Apr  1 2005 Michael Schwendt <mschwendt[AT]users.sf.net> 1.3.13-2
- Include /etc/lighttpd directory.

* Sun Mar  6 2005 Matthias Saou <http://freshrpms.net/> 1.3.13-1
- Update to 1.3.13.

* Wed Mar  2 2005 Matthias Saou <http://freshrpms.net/> 1.3.12-1
- Update to 1.3.12.
- Remove obsolete empty_cgi_handler patch.

* Tue Mar  1 2005 Matthias Saou <http://freshrpms.net/> 1.3.11-2
- Add missing defattr to sub-packages (#150018).

* Mon Feb 21 2005 Matthias Saou <http://freshrpms.net/> 1.3.11-0
- Update to 1.3.11.
- Remove cleanconf and init.d patches (merged upstream).
- Add empty_cgi_handler patch.

* Fri Feb 18 2005 Matthias Saou <http://freshrpms.net/> 1.3.10-0
- Split off -fastcgi sub-package.
- Include php.d entry to set sane FastCGI defaults.

* Wed Feb 16 2005 Matthias Saou <http://freshrpms.net/> 1.3.10-0
- Spec file cleanup for freshrpms.net/Extras.
- Compile OpenSSL support unconditionally.
- Put modules in a subdirectory of libdir.
- Don't include all of libdir's content to avoid debuginfo content.
- Add optional LDAP support.
- Add patch to change the default configuration.
- Add dedicated lighttpd user/group creation.
- Add logrotate entry.
- Include a nice little default page for the default setup.
- Split off mod_mysql_vhost sub-package, get dep only there.
- Use webroot in /srv by default.
- Exclude .la files, I doubt anyone will need them.

* Thu Sep 30 2004 <jan@kneschke.de> 1.3.1
- upgraded to 1.3.1

* Tue Jun 29 2004 <jan@kneschke.de> 1.2.3
- rpmlint'ed the package
- added URL
- added (noreplace) to start-script
- change group to Networking/Daemon (like apache)

* Sun Feb 23 2003 <jan@kneschke.de>
- initial version