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

%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
Name:           dansguardian
Release:        0
Summary:        Content filtering web proxy
License:        GPL-2.0+
Group:          Productivity/Networking/Web/Proxy
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
# 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

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.

%setup -q
%if 0%{?suse_version}

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="%{_localstatedir}/run/" \
  --with-logdir="%{_localstatedir}/log/%{name}/" \
  --with-proxyuser="%{dg_user}" \

perl -pi.orig -e '
        s|^(CHKCONFIG) =.*$|$1 = :|;
        ' Makefile
make %{?_smp_mflags}

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}
%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora}
# Red Hat version
install -D -m0755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}
# Generic SYSV version
install -D -m0755 %{SOURCE5} %{buildroot}%{_initddir}/%{name}

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

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}
%stop_on_removal %{name}

%restart_on_update %{name}
%insserv_cleanup %{name}

%defattr(-, root, root, 0755)
%doc %{_datadir}/doc/%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%if 0%{?suse_version}
# Only create rc shortcut on SUSE
%attr(0755, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/cache/%{name}
%attr(0755, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/log/%{name}

openSUSE Build Service is sponsored by