540c83a
%define haproxy_user    haproxy
540c83a
%define haproxy_group   %{haproxy_user}
540c83a
%define haproxy_home    %{_localstatedir}/lib/haproxy
540c83a
%define haproxy_confdir %{_sysconfdir}/haproxy
540c83a
%define haproxy_datadir %{_datadir}/haproxy
540c83a
540c83a
Name:           haproxy
540c83a
Version:        1.3.12.2
6a590aa
Release:        4%{?dist}
540c83a
Summary:        HA-Proxy is a TCP/HTTP reverse proxy for high availability environments
540c83a
540c83a
Group:          System Environment/Daemons
540c83a
License:        GPLv2+ and MIT
540c83a
540c83a
URL:            http://haproxy.1wt.eu/
540c83a
Source0:        http://haproxy.1wt.eu/download/1.3/src/haproxy-%{version}.tar.gz
540c83a
Source1:        %{name}.init
540c83a
Source2:        %{name}.cfg
540c83a
540c83a
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
540c83a
BuildRequires:  pcre-devel 
540c83a
0511dc8
Requires:           pcre
540c83a
Requires(pre):      %{_sbindir}/useradd
540c83a
Requires(post):     /sbin/chkconfig
540c83a
Requires(preun):    /sbin/chkconfig, /sbin/service
540c83a
Requires(postun):   /sbin/service
540c83a
540c83a
%description
540c83a
HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high
540c83a
availability environments. Indeed, it can:
540c83a
- route HTTP requests depending on statically assigned cookies
540c83a
- spread the load among several servers while assuring server persistence
540c83a
  through the use of HTTP cookies
540c83a
- switch to backup servers in the event a main one fails
540c83a
- accept connections to special ports dedicated to service monitoring
540c83a
- stop accepting connections without breaking existing ones
540c83a
- add/modify/delete HTTP headers both ways
540c83a
- block requests matching a particular pattern
540c83a
540c83a
540c83a
%prep
540c83a
%setup -q
540c83a
540c83a
%build
540c83a
# No configure script is present, it is all done via make flags
6a590aa
# pcre on EL-4 is in /usr/include/pcre not /usr/include
6a590aa
make %{?_smp_mflags} CPU="generic" TARGET="linux26" REGEX="pcre" ADDINC="%{optflags} -I/usr/include/pcre"
540c83a
540c83a
540c83a
%install
540c83a
rm -rf %{buildroot}
540c83a
# there is no install make target, only one file is created during build
540c83a
%{__install} -p -D -m 0755 %{name} %{buildroot}%{_sbindir}/%{name}
540c83a
%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}%{_initrddir}/%{name}
540c83a
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}%{haproxy_confdir}/%{name}.cfg
540c83a
%{__install} -d -m 0755 %{buildroot}%{haproxy_home}
540c83a
%{__install} -d -m 0755 %{buildroot}%{haproxy_datadir}
540c83a
for httpfile in $(find ./examples/errorfiles/ -type f) 
540c83a
do
540c83a
    %{__install} -p -m 0644 $httpfile %{buildroot}%{haproxy_datadir}
540c83a
done
540c83a
540c83a
# convert all text files to utf8
540c83a
for textfile in $(find ./ -type f -name '*.txt')
540c83a
do
540c83a
    mv $textfile $textfile.old
540c83a
    iconv --from-code ISO8859-1 --to-code UTF-8 --output $textfile $textfile.old
540c83a
    rm -f $textfile.old
540c83a
done 
540c83a
540c83a
540c83a
%clean
540c83a
rm -rf %{buildroot}
540c83a
540c83a
540c83a
%pre
540c83a
%{_sbindir}/useradd -c "HAProxy user" -s /bin/false -r -d %{haproxy_home} %{haproxy_user} 2>/dev/null || :
540c83a
540c83a
540c83a
%post
540c83a
/sbin/chkconfig --add %{name}
540c83a
    
540c83a
540c83a
%preun
540c83a
if [ $1 = 0 ]; then
540c83a
    /sbin/service %{name} stop >/dev/null 2>&1
540c83a
    /sbin/chkconfig --del %{name}
540c83a
fi  
540c83a
    
540c83a
540c83a
%postun
540c83a
if [ $1 -ge 1 ]; then
540c83a
/sbin/service %{name} condrestart > /dev/null 2>&1 || :
540c83a
fi  
540c83a
 
540c83a
540c83a
%files
540c83a
%defattr(-,root,root,-)
540c83a
%doc doc/*
540c83a
%doc examples/url-switching.cfg
540c83a
%doc examples/acl-content-sw.cfg
540c83a
%doc examples/content-sw-sample.cfg
540c83a
%doc examples/cttproxy-src.cfg
540c83a
%doc examples/haproxy.cfg
540c83a
%doc examples/tarpit.cfg
540c83a
%doc examples/tcp-splicing-sample.cfg
540c83a
%doc CHANGELOG CONTRIB LICENSE README
540c83a
%dir %{haproxy_datadir}
540c83a
%dir %{haproxy_datadir}/*
540c83a
%dir %{haproxy_confdir}
540c83a
%config(noreplace) %{haproxy_confdir}/%{name}.cfg
540c83a
%{_initrddir}/%{name}
540c83a
%{_sbindir}/%{name}
540c83a
%attr(-,%{haproxy_user},%{haproxy_group}) %dir %{haproxy_home}
540c83a
540c83a
540c83a
%changelog
6a590aa
* Fri Sep 21 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.3.12.2-4
6a590aa
* update compile flags for different location of pcre.h on EL-4
6a590aa
0511dc8
* Fri Sep 21 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.3.12.2-3
0511dc8
- added pcre as Requires dependency
0511dc8
540c83a
* Thu Sep 20 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.3.12.2-2
540c83a
- update License field
540c83a
540c83a
* Thu Sep 20 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.3.12.2-1
540c83a
- update to 1.3.12.2
540c83a
- remove the upstream patch
540c83a
540c83a
* Tue Sep 18 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.3.12.1-1
540c83a
- switch to 1.3.12.1 branch
540c83a
- add patch from upstream with O'Reilly licensing updates.
540c83a
- convert ISO-8859-1 doc files to UTF-8
540c83a
540c83a
* Sat Mar 24 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.2.17-2
540c83a
- addition of haproxy user
540c83a
- add license information
540c83a
540c83a
* Fri Mar 23 2007 Jeremy Hinegardner <jeremy@hinegardner.org> - 1.2.17-1
540c83a
- initial packaging