File e2guardian.spec of Package e2guardian

#
# spec file for package e2guardian
#
# 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/
#


%define         dg_user  e2guardian
%define         dg_group vscan
Name:           e2guardian
Version:        4.1.4+git1.g68c75c9
Release:        0
Summary:        Content filtering web proxy
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Web/Proxy
URL:            http://e2guardian.org/cms/index.php
Source0:        %{name}-%{version}.tar.xz
Source3:        %{name}.logrotate
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  curl-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  gmp-devel
BuildRequires:  pkgconfig
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(zlib)
Requires:       coreutils
Requires:       http_proxy
Requires(pre):  pwdutils
Recommends:     logrotate
%{?systemd_requires}

%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

%build
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
chmod a-x AUTHORS COPYING NEWS ChangeLog UPGRADING
ln -s README.md README
autoreconf -fiv
%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_install

install -D -m0644 data/scripts/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
# save some space, link identical files
%fdupes -s %{buildroot}%{_datadir}/%{name}/languages/

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}
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service

%postun
%service_del_postun %{name}.service

%files
%doc AUTHORS ChangeLog NEWS README UPGRADING
%license COPYING
%{_mandir}/man?/*
%doc %{_datadir}/doc/%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_datadir}/%{name}/
%{_sbindir}/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%attr(0640, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/cache/%{name}
%attr(0755, %{dg_user}, %{dg_group}) %dir %{_localstatedir}/log/%{name}

%changelog
openSUSE Build Service is sponsored by