File pound.spec of Package pound

#
# spec file for package pound
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%if 0%{?suse_version} > 1230
%bcond_without systemd
%else
%bcond_with    systemd
%endif

Name:           pound
BuildRequires:  libopenssl-1_0_0-devel
Summary:        Reverse proxy and load balancer
License:        SUSE-GPL-3.0+-with-openssl-exception
Group:          Productivity/Networking/Web/Proxy
Url:            http://www.apsis.ch/pound/
Version:        2.8a
Release:        0
Source0:        http://www.apsis.ch/pound/Pound-%version.tgz
Source1:        pound.cfg
Source2:        init.pound
Source3:        %{name}.service
Patch:          pound.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         pwdutils
%if %{with systemd}
%{?systemd_requires}
BuildRequires:  systemd-rpm-macros
%else
PreReq:         %insserv_prereq
%endif

%description
The Pound program is a reverse proxy, load balancer and HTTPS front-end
for Web server(s). Pound was developed to enable distributing the load
among several web servers and to allow for a convenient SSL wrapper for
those web servers that do not offer it natively.

%package doc
Summary:        Doumentation for pound
Group:          Documentation/Other

%description doc
The Pound program is a reverse proxy, load balancer and HTTPS front-end
for web server(s). Pound was developed to enable distributing the load
among several web servers and to allow for a convenient SSL wrapper for
those web servers that do not offer it natively.

This package contains the documentation for pound.

%prep
%setup -q -n Pound-%version
%patch

%build
%configure \
  --enable-msdav \
  --with-ssl=/usr/include/openssl \
  --with-owner=pound \
  --with-group=pound
make %{?_smp_mflags}

%install
%makeinstall
# Install pound init script
%if %{with systemd}
install -Dm 0644 %SOURCE3 %{buildroot}/%{_unitdir}/pound.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
%else
install -Dm 0744 %SOURCE2 $RPM_BUILD_ROOT/etc/init.d/pound
ln -sf ../../etc/init.d/pound $RPM_BUILD_ROOT/usr/sbin/rcpound
%endif
install -Dm 0644 %SOURCE1 $RPM_BUILD_ROOT/etc/pound.cfg
mkdir -p %buildroot%_defaultdocdir/%name/examples
install -m644 GPL.txt README FAQ %buildroot%_defaultdocdir/%name/
install -m755 z2_2_5_1.py z2_2_6_1.py %buildroot%_defaultdocdir/%name/examples/ 

%pre
# Add the "pound" user and group
getent group pound >/dev/null || %{_sbindir}/groupadd -r pound
getent passwd pound >/dev/null || \
	%{_sbindir}/useradd -c "Pound" -g pound -r -d /var/lib/pound pound
%if %{with systemd}
%service_add_pre %{name}.service
%endif

%post
%if %{with systemd}
%service_add_post %{name}.service
%else
%{fillup_and_insserv -f -n pound pound}
%endif

%postun
%if %{with systemd}
%service_del_postun %{name}.service
%else
%restart_on_update pound
%insserv_cleanup
%endif

%preun
%if %{with systemd}
%service_del_preun %{name}.service
%else
%stop_on_removal pound
%endif

%files
%defattr(-,root,root)
%doc %_defaultdocdir/%name/GPL.txt
%if %{with systemd}
%{_unitdir}/%{name}.service
%else
/etc/init.d/pound
%endif
%attr(555, root, root) /usr/sbin/pound
%attr(555, root, root) /usr/sbin/poundctl
%{_sbindir}/rcpound
%_mandir/man8/pound.8.gz
%_mandir/man8/poundctl.8.gz
%config(noreplace) /etc/pound.cfg

%files doc
%defattr(-,root,root) 
%doc %_defaultdocdir/%name
%exclude %_defaultdocdir/%name/GPL.txt

%changelog
openSUSE Build Service is sponsored by