File ntop.spec of Package ntop

#
# spec file for package ntop
#
# Copyright (c) 2011 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:           ntop
BuildRequires:  dos2unix
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++
BuildRequires:  gd-devel
BuildRequires:  gdbm-devel
BuildRequires:  libGeoIP-devel
BuildRequires:  libart_lgpl-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  lsof
BuildRequires:  lua-devel
BuildRequires:  mysql-devel
BuildRequires:  net-snmp-devel
BuildRequires:  openssl-devel
BuildRequires:  readline-devel
%if 0%{?suse_version}
BuildRequires:  tcpd-devel
BuildRequires:  xorg-x11-devel
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq
PreReq:         /bin/cat
PreReq:         sysconfig
%if 0%{?suse_version} > 1100
BuildRequires:  libevent-devel
%else
BuildRequires:  libevent
%endif
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
BuildRequires:  libpcap-devel
BuildRequires:  rrdtool-devel
%else
BuildRequires:  libpcap
BuildRequires:  rrdtool
%endif
%else
%if 0%{?fedora_version}
BuildRequires:  libpcap-devel
BuildRequires:  rrdtool-devel
BuildRequires:  xorg-x11-devel
PreReq:         /bin/cat
PreReq:         /bin/fillup
PreReq:         /sbin/insserv
PreReq:         sysconfig
%else
%if 0%{?mandriva_version}
BuildRequires:  libpcap-devel
BuildRequires:  librrdtool-devel
BuildRequires:  rrdtool
PreReq:         /bin/cat
PreReq:         /bin/fillup
PreReq:         /sbin/insserv
PreReq:         sysconfig
%endif
%endif
%endif
Version:        4.0.3
Release:        1
License:        GPLv2+
#
%define pkg_name ntop
%define pkg_user ntop
%define pkg_home /var/lib/%{pkg_name}
#
%define _localstatedir /var/lib
#
%define xorg_libdir %{_libdir}
Summary:        Web-Based Network Traffic Monitor
Url:            http://www.ntop.org
Group:          Productivity/Networking/Diagnostic
Source:         %{name}-%{version}.tar.bz2
Source2:        rcntop
Source3:        rc.config.ntop
Source4:        passcheck.c
Source5:        README.SuSE
Source6:        etter.finger.os.gz
# PATCH-FIX-UPSTREAM ntop-%{version}.diff
Patch0:         ntop-%{version}.diff
# PATCH-FIX-UPSTREAM rrdPlugin.diff
Patch2:         rrdPlugin.diff
# PATCH-FIX-OPENSUSE dotpath.diff
Patch4:         dotpath.diff
# PATCH-FIX-UPSTREAM ntop-fix-segfault-on-exit.patch
Patch6:         ntop-fix-segfault-on-exit.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Ntop is a Web-based traffic monitor that shows network usage. It can be
used in both interactive or Web mode using the embedded Web server.

%prep
%setup -q
%patch0
%patch2
%patch4
%patch6
cp %SOURCE6 .

%build
%{?suse_update_config:%{suse_update_config -f gdchart* ntop . }}
# ntop wants to setup the files for the newer autoconf itself:
./autogen.sh
# NTOP_AUTOREBUILD=yes ./configure || echo "new autoconf prepared"
# now we are ready for the real configure...
CFLAGS="%{optflags} -DHAVE_NCURSES_H %{?xorg_cflags}" \
%configure \
	--x-libraries=%{xorg_libdir}	\
	--disable-static 		\
	--enable-sslv3			\
	--enable-i18n
make %{?_smp_mflags}
gcc -o passcheck %{optflags} %{SOURCE4} -lgdbm

%install
# remove old (pre SuSE Linux 7.0) README.Suse provided by ntop
rm -f docs/README.Suse
dos2unix python/templates/rrdAlarmStart.tmpl
make DESTDIR=%{buildroot} install install-man
chmod 644 %{buildroot}%{_sysconfdir}/ntop/oui.txt.gz
chmod 644 %{buildroot}%{_sysconfdir}/ntop/specialMAC.txt.gz
install -d %{buildroot}%{_sysconfdir}/init.d/
install -d %{buildroot}%{_sbindir}/
install -d %{buildroot}%{_localstatedir}/adm/fillup-templates/
install -m 755  %{SOURCE2} %{buildroot}%{_sysconfdir}/init.d/ntop
ln -sf ../../etc/init.d/ntop %{buildroot}%{_sbindir}/rcntop
install -m 644  %{SOURCE3} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.ntop
install -m 755 passcheck %{buildroot}%{_sbindir}/passcheck
mkdir -p %{buildroot}%{pkg_home}/rrd
# Get README.SuSE
cp %SOURCE5 .
find %{buildroot}%{_datadir}/ntop/html -type f -print0 | xargs -0 chmod 644
%if 0%{?suse_version} > 1020
%fdupes %{buildroot}%{_datadir}/ntop/html/
%endif
find %{buildroot} -name "*.la" -delete
rm docs/ntop-autotools.vsd
dos2unix docs/RedHat-rpmbuild-HOWTO.txt

%pre
/usr/sbin/groupadd -r %{pkg_user} &>/dev/null ||:
/usr/sbin/useradd  -g %{pkg_user} -s /bin/false -r -c "user for %{pkg_user}" -d %{pkg_home} %{pkg_user} &>/dev/null ||:

%preun
%if 0%{?suse_version} > 1020
%stop_on_removal
%endif

%post
%{fillup_and_insserv ntop}
# Are we in update mode?
if [ ${1:-0} -gt 1 ]; then
	if [ -f etc/sysconfig/ntopd -a ! -L etc/sysconfig/ntopd ]; then
		echo "Renaming config file ntopd to ntop"
		mv etc/sysconfig/ntopd etc/sysconfig/ntop
	fi
# change user wwwrun to user ntop
	sed -i -e 's/^[[:space:]]*NTOP_USER=\"wwwrun\"/NTOP_USER=\"ntop\"/' /etc/sysconfig/ntop
	chown -R %{pkg_user}:%{pkg_user} %{pkg_home}/rrd
fi
/sbin/ldconfig

%postun
/sbin/ldconfig
%{insserv_cleanup}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc docs/* AUTHORS CONTENTS COPYING ChangeLog MANIFESTO NEWS PORTING
%doc SUPPORT_NTOP.txt THANKS README.SuSE
%config %{_sysconfdir}/init.d/ntop
%{_bindir}/ntop
%{_libdir}/lib*.so
%{_sbindir}/rcntop
%{_sbindir}/passcheck
%dir %attr(-,%{pkg_user},%{pkg_user}) %{_datadir}/ntop
%{_datadir}/ntop/html
%{_datadir}/ntop/python
%dir %{_libdir}/ntop
%{_libdir}/ntop/plugins
%{_mandir}/man8/ntop.8.*
%{_localstatedir}/adm
%dir %attr(-,%{pkg_user},%{pkg_user}) %{pkg_home}
%dir %attr(-,%{pkg_user},%{pkg_user}) %{pkg_home}/rrd
%dir %{_sysconfdir}/ntop
%config %{_sysconfdir}/ntop/oui.txt.gz
%config %{_sysconfdir}/ntop/specialMAC.txt.gz
%config %{_sysconfdir}/ntop/etter.finger.os.gz
%{_sysconfdir}/ntop/GeoIPASNum.dat
%{_sysconfdir}/ntop/GeoLiteCity.dat

%changelog
openSUSE Build Service is sponsored by