File dansguardian.spec of Package dansguardian
#
# spec file for package dansguardian
#
# Copyright (c) 2015 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/
#
%define dg_user dansguardian
%define dg_group vscan
#
# openSUSE specials
%if 0%{?suse_version}
%define _initddir %{_sysconfdir}/init.d
Requires: http_proxy
Requires(pre): %insserv_prereq
Requires(pre): pwdutils
Buildrequires: fdupes
%endif
Name: dansguardian
Version: 2.12.0.3
Release: 0
Summary: Content filtering web proxy
License: GPL-2.0+
Group: Productivity/Networking/Web/Proxy
Url: http://www.dansguardian.org/
Source0: http://sourceforge.net/projects/dansguardian/files/%{name}-%{version}.tar.bz2
Source1: %{name}.init
Source3: %{name}.logrotate
Source4: %{name}.init-redhat
Source5: %{name}.init-sysv
Source10: dansguardian-rpmlintrc
Source11: gpl-2.0.txt
# PATCH-FIX-openSUSE -- Fix path to clamd socket in example config
Patch3: dansguardian-clamdsocket.patch
# PATCH-fix-upstream -- fix undeclared max_upload_size
# http://sourceforge.net/p/dansguardian/patches/12/attachment/dg.maxuploadsize.patch
# rebased and renamed
Patch4: %{name}-maxuploadsize.patch
BuildRequires: curl-devel
BuildRequires: gcc-c++
BuildRequires: gmp-devel
BuildRequires: pcre-devel
BuildRequires: pkg-config
BuildRequires: zlib-devel
Requires: coreutils
Recommends: logrotate
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%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
cp %{SOURCE11} ./COPYING
%if 0%{?suse_version}
%patch3
%endif
%patch4
%build
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
%configure \
--enable-pcre \
--enable-segv-backtrace \
--enable-fancydm \
--enable-trickledm \
--enable-ntlm \
--enable-email \
--enable-lfs \
--enable-orig-ip \
--enable-clamd \
--enable-avastd \
--enable-icap \
--enable-kavd \
--enable-commandline \
--with-piddir="%{_localstatedir}/run/" \
--with-logdir="%{_localstatedir}/log/%{name}/" \
--with-proxyuser="%{dg_user}" \
--with-proxygroup="%{dg_group}"
perl -pi.orig -e '
s|^(CHKCONFIG) =.*$|$1 = :|;
s|^\tchown|#\tchown|;
s|%{_prefix}/lib|%{_libdir}|g;
' Makefile
make %{?_smp_mflags}
%install
install -d %{buildroot}%{_localstatedir}/cache/%{name}/
install -d %{buildroot}%{_localstatedir}/log/%{name}/
make DESTDIR=%{buildroot} install %{?_smp_mflags}
%if 0%{?suse_version}
# SUSE version
install -D -m0755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
# save some space, link identical files
%fdupes -s %{buildroot}%{_datadir}/%{name}/languages/
# Only create rc shortcut on SUSE
ln -s %{_initddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
%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
%files
%defattr(-, root, root, 0755)
%doc AUTHORS ChangeLog COPYING NEWS README UPGRADING
%{_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(0640, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/cache/%{name}
%attr(0640, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/log/%{name}
%changelog