File squidGuard.spec of Package squidGuard

#
# spec file for package squidGuard (Version 1.4)
#
# Copyright (c) 2010 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/
#

# norootforbuild

%define sg_dbhome /var/lib/squidGuard/db
%define sg_logdir /var/log/squidGuard
%define sg_config /etc/squidguard.conf
%define cgidir    /srv/www/cgi-bin
%define imgdir    /srv/www/htdocs/images

Name:           squidGuard
Summary:        Filter plugin for squid
Version:        1.4
Release:        10
License:        GPL-2.0+
Group:          Productivity/Networking/Web/Proxy
Url:            http://www.squidguard.org/
Source0:        %{name}-%{version}.tar.bz2
Source1:        README.SuSE
Source2:        squidGuard.logrotate
Source3:        blocked.gif
Patch0:         squidGuard-Makefile.patch
Patch1:         squidGuard-1.4-mysql.patch
Patch2:         squidGuard-config.patch
Patch3:         squidGuard-trailing_dot.patch
Patch4:         squidGuard-unusual_url_end.patch
Patch5:         squidGuard-CVE-2009-3700.patch
Patch6:         squidGuard-CVE-2009-3826.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         http_proxy
BuildRequires:  bison db-devel flex openldap2-devel
BuildRequires:  libmysqlclient-devel
BuildRequires:  gettext grep libtool
BuildRequires:  lynx
Requires:       http_proxy
%if 0%{?suse_version} >= 1010
Recommends:     logrotate lynx
%else
Requires:       logrotate lynx
%endif

%description
SquidGuard is a free (GPL), flexible and ultra-fast filter, redirector,
and access controller plugin for squid.  It lets you define multiple
access rules with different restrictions for different user groups on a
squid cache.  SquidGuard uses squid's standard redirector interface.



Authors:
--------
    Pål Baltzersen <pal.baltzersen@ost.eltele.no>
    Lars Erik Håland <leh@nimrod.no>

%package doc
Summary:        Additional documentation and examples for %name
Group:          Documentation/Other
License:        GPL-2.0+

%description doc
SquidGuard is a free (GPL), flexible and ultra-fast filter, redirector,
and access controller plugin for squid.  It lets you define multiple
access rules with different restrictions for different user groups on a
squid cache.  SquidGuard uses squid's standard redirector interface.

This package contains additional scripts and documentation.


Authors:
--------
    Pål Baltzersen <pal.baltzersen@ost.eltele.no>
    Lars Erik Håland <leh@nimrod.no>


%prep
%setup -q 
%patch0 -p0
%patch1 -p1
%patch2 -p0
%patch3 -p0
%patch4 -p0
%patch5 -p1
%patch6 -p1
find -type d | xargs chmod 755
cp %{SOURCE1} .
# patch the test configs
pushd test 1>/dev/null
for i in test*.conf.in; do
	sed "s|logdir @TESTDIR@|logdir %{sg_logdir}|; \
		 s|dbhome @TESTDIR@|dbhome %{sg_dbhome}|" $i > $i.tmp
	mv -v $i.tmp $i
done

%build
gettextize
export CFLAGS="%optflags" 
./configure \
	--bindir=%{_sbindir} \
	--sbindir=%{_sbindir} \
	--with-squiduser=squid \
	--with-mysql \
	--with-nolog=yes \
	--with-db-inc=%{_includedir}/db4 \
	--with-sg-config=%{sg_config} \
	--with-sg-dbhome=%{sg_dbhome} \
	--with-sg-logdir=%{sg_logdir} \
	--with-ldap=%_prefix 
make %{?jobs:-j%jobs}
pushd contrib
make %{?jobs:-j%jobs}
popd
# ---------------------------------------------------------------------------

%install
mkdir $RPM_BUILD_ROOT/etc
%makeinstall
# fix install dir
if [ -f $RPM_BUILD_ROOT/%{_bindir}/squidGuard ]; then
	mkdir -p $RPM_BUILD_ROOT/%{_sbindir}
	install -m755 $RPM_BUILD_ROOT/%{_bindir}/squidGuard  $RPM_BUILD_ROOT/%{_sbindir}/
	rm -rf $RPM_BUILD_ROOT/%{_bindir}
fi
# install blacklist
mkdir -p $RPM_BUILD_ROOT/var/lib/squidGuard/db/blacklist
install -m 644 test/blacklist/* $RPM_BUILD_ROOT/var/lib/squidGuard/db/blacklist
# install cgi
mkdir -p $RPM_BUILD_ROOT/%{cgidir}
mkdir -p $RPM_BUILD_ROOT/%{imgdir}
install -m755 samples/*.cgi  $RPM_BUILD_ROOT/%{cgidir}/
install -m644 samples/babel* $RPM_BUILD_ROOT/%{cgidir}/
install -m644 %{S:3}         $RPM_BUILD_ROOT/%{imgdir}/blocked.gif
# prepare logdir
mkdir -p $RPM_BUILD_ROOT%{sg_logdir}
# prepare logrotate
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
sed "s|@SG_LOGDIR@|%{sg_logdir}|g" %{SOURCE2} > $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
# clean up
rm -f {contrib,doc,samples,test}/{Makefile,*.in,*/*.in,.*.swp}
# install docu
mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}
cp -r {contrib,doc,samples,test} $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
cp ANNOUNCE CHANGELOG COPYING FAQ GPL ISSUES.txt README* $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
# ---------------------------------------------------------------------------

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,root,root)
%dir %{_defaultdocdir}/%{name}
%doc %{_defaultdocdir}/%{name}/ANNOUNCE
%doc %{_defaultdocdir}/%{name}/CHANGELOG
%doc %{_defaultdocdir}/%{name}/COPYING
%doc %{_defaultdocdir}/%{name}/FAQ
%doc %{_defaultdocdir}/%{name}/GPL
%doc %{_defaultdocdir}/%{name}/ISSUES.txt
%doc %{_defaultdocdir}/%{name}/README*
%attr(700, squid, root) %dir /var/lib/squidGuard
%attr(700, squid, root) %dir %{sg_dbhome}
%attr(700, squid, root) %dir %{sg_logdir}
%config(noreplace) %{sg_config}
%config(noreplace) /var/lib/squidGuard/db/blacklist
%config(noreplace) /etc/logrotate.d/%{name}
%{_sbindir}/*
%dir %{imgdir}
%{cgidir}/*
%{imgdir}/*

%files doc
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name}/contrib
%doc %{_defaultdocdir}/%{name}/doc
%doc %{_defaultdocdir}/%{name}/samples
%doc %{_defaultdocdir}/%{name}/test

%changelog
openSUSE Build Service is sponsored by