File dansguardian.spec of Package dansguardian

#
# spec file for package dansguardian
#
# Copyright (c) 2012 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
# 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/
#


Name:           dansguardian
Version:        2.12.0.0
Release:        1
License:        GPL-2.0+
Summary:        Content filtering web proxy
Url:            http://www.dansguardian.org/
Group:          Productivity/Networking/Web/Proxy
Source:         %{name}-%{version}.tar.bz2
Source1:        %{name}.init
Source3:        %{name}.logrotate
Source4:        %{name}.init-redhat
Source5:        %{name}.init-sysv
Source10:       dansguardian-rpmlintrc
# PATCH-FIX-UPSTREAM -- Fix FTBFS by including cstddef for size_t
Patch0:         dansguardian-ntlm.patch
# PATCH-FIX-UPSTREAM -- Add missing includes
Patch1:         dansguardian-commandlinescan.patch
# PATCH-FIX-openSUSE -- Fix path to clamd socket in example config
Patch3:         dansguardian-clamdsocket.patch
BuildRequires:  curl-devel
BuildRequires:  gcc-c++
BuildRequires:  gmp-devel
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
Requires:       coreutils
Requires:       logrotate
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         dg_user  dansguardian
%define         dg_group dansguardian
#
# openSUSE specials
%if 0%{?suse_version}
PreReq:         %insserv_prereq
PreReq:         pwdutils
Requires:       http_proxy
%define         _initddir %{_sysconfdir}/init.d
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%endif
%endif

%description
DansGuardian is a web filtering engine that checks the content within
the page itself in addition to the more traditional URL filtering.

DansGuardian is a content filtering proxy. It filters using multiple methods,
including URL and domain filtering, content phrase filtering, PICS filtering,
MIME filtering, file extension filtering, POST filtering.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%if 0%{?suse_version}
%patch3 -p1
%endif

%build
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
%configure \
	--enable-pcre \
	--enable-segv-backtrace \
	--enable-fancydm \
	--enable-trickledm \
	--enable-ntlm \
	--enable-email \
	--enable-lfs \
	--enable-clamd \
	--enable-icap \
	--enable-commandline \
	--with-piddir="/var/run/" \
	--with-logdir="/var/log/%{name}/" \
	--with-proxyuser="%{dg_user}" \
	--with-proxygroup="%{dg_group}"

%{__perl} -pi.orig -e '
        s|^(CHKCONFIG) =.*$|$1 = :|;
        s|^\tchown|#\tchown|;
        s|/usr/lib|%{_libdir}|g;
        ' Makefile
%{__make} %{?_smp_mflags}

%install
%makeinstall
%{__install} -d %{buildroot}%{_localstatedir}/log/%{name}/

%if 0%{?suse_version}
# SUSE version
%{__install} -D -m0755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
# Only create rc shortcut on SUSE
%{__ln_s} /etc/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%if 0%{?suse_version} > 1020
# save some space, link identical files
%fdupes -s %{buildroot}%{_datadir}/%{name}/languages/
%endif
%else
%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora}
# Red Hat version
%{__install} -D -m0755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}
%else
# Generic SYSV version
%{__install} -D -m0755 %{SOURCE5} %{buildroot}%{_initddir}/%{name}
%endif
%endif

%{__install} -D -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# remove obsolete scripts
%{__rm} -rf %{buildroot}%{_datadir}/%{name}/scripts
# fix execute rights
chmod +x %{buildroot}%{_datadir}/%{name}/%{name}.pl

%pre
getent group %{dg_group} >/dev/null || groupadd -r %{dg_group}
getent passwd %{dg_user} >/dev/null || useradd -r -g %{dg_group} -d %{_localstatedir}/log/%{name} -s /sbin/nologin -c "User for %{name}" %{dg_user}

%if 0%{?suse_version}
%preun
%stop_on_removal %{name}

%postun
%restart_on_update %{name}
%insserv_cleanup %{name}
%endif

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

%files
%defattr(-, root, root, 0755)
%doc AUTHORS ChangeLog COPYING NEWS README UPGRADING
%doc %{_mandir}/man?/*
%doc %{_datadir}/doc/%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_datadir}/%{name}/
%{_sbindir}/%{name}
%{_initddir}/%{name}
%if 0%{?suse_version}
# Only create rc shortcut on SUSE
%{_sbindir}/rc%{name}
%endif
%attr(0755, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/log/%{name}

%changelog
openSUSE Build Service is sponsored by