File ntop.spec of Package ntop
#
# spec file for package ntop
#
# Copyright (c) 2013 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
Version: 5.0.1
Release: 0
Summary: Web-Based Network Traffic Monitor
License: GPL-2.0+
Group: Productivity/Networking/Diagnostic
Url: http://www.ntop.org
%define pkg_user ntop
%define pkg_home /var/lib/%{name}
%define xorg_libdir %{_libdir}
Requires: graphviz
Requires: logrotate
# TODO: Use the files from the GeoIP package to avoid duplicate work
# and wasting space
#TODO: Requires: GeoIP
#TODO: BuildRequires: GeoIP
BuildRequires: freetype2-devel
BuildRequires: gcc-c++
BuildRequires: gd-devel
BuildRequires: gdbm-devel
BuildRequires: gzip
BuildRequires: libart_lgpl-devel
BuildRequires: libjpeg-devel
BuildRequires: libpng-devel
BuildRequires: libtool
BuildRequires: lsof
BuildRequires: lua-devel
BuildRequires: mysql-devel
BuildRequires: net-snmp-devel
BuildRequires: openssl-devel
BuildRequires: python-devel
BuildRequires: readline-devel
#
# openSUSE
#
%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: libGeoIP-devel
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
%endif
#
# Fedora
#
%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
%endif
#
# Mandriva
#
%if 0%{?mandriva_version}
BuildRequires: libpcap-devel
BuildRequires: librrdtool-devel
BuildRequires: rrdtool
PreReq: /bin/cat
PreReq: /bin/fillup
PreReq: /sbin/insserv
PreReq: sysconfig
%endif
Source: %{name}-%{version}.tar.bz2
Source2: rcntop
Source3: rc.config.ntop
Source4: passcheck.c
Source5: README.SuSE
#Source6: etter.finger.os.gz
Source10: ntop-rpmlintrc
Patch0: ntop-disable_ethernet_fingerprint_database_download.patch
Patch1: ntop-disable_darwin.patch
Patch2: ntop-fix-manpage-errors.patch
Patch3: ntop-dot-path.patch
Patch4: ntop-fix-netflow-plugin-links.patch
Patch5: ntop-default_user.patch
Patch8: ntop-fix-timestamp.patch
Patch10: ntop-disable_svn_check.patch
Patch11: ntop-no-return-in-nonvoid-function.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
%patch1
%patch2
%patch3
%patch4
%patch5
%patch8
%patch10
%patch11
#cp %%{SOURCE6} .
# fix/remove files with wrong encoding
#rm docs/RedHat-rpmbuild-HOWTO.txt
#rm docs/ntop-autotools.vsd docs/INSTALL
rm -f docs/README.Suse
cp %{SOURCE5} docs/README.Suse
sed -i "s|||g" python/templates/rrdAlarmStart.tmpl
chmod -x python/templates/rrdAlarmStart.tmpl docs/ntop-autotools.vsd
# Remove build time references so build-compare can do its work
modified="$(sed -n '/^----/n;s/ - .*$//;p;q' "%{_sourcedir}/%{name}.changes")"
DATE="\"$(date -d "${modified}" "+%%b %%e %%Y")\""
TIME="\"$(date -d "${modified}" "+%%H:%%M:%%S")\""
sed -i "s/__DATE__/${DATE}/g;s/__TIME__/${TIME}/g" configure.in
%build
# ntop wants to setup the files for the newer autoconf itself:
CFLAGS="%{optflags}" ./autogen.sh \
--prefix=%{_prefix} \
--libdir=%{_libdir} \
--sysconfdir=%{_sysconfdir} \
--localstatedir=%{_localstatedir}/lib \
--x-libraries=%{xorg_libdir} \
--disable-static \
--enable-jumbo-frames \
--enable-snmp
make %{?_smp_mflags}
gcc -o passcheck %{optflags} %{SOURCE4} -lgdbm
%install
%makeinstall
#%%makeinstall install-man
#chmod 644 %%{buildroot}%%{_sysconfdir}/ntop/oui.txt.gz
#chmod 644 %%{buildroot}%%{_sysconfdir}/ntop/specialMAC.txt.gz
# install init file and symlink
%{__mkdir_p} %{buildroot}%{_sbindir}
install -Dm 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/init.d/%{name}
ln -sf ../../%{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
# install fillup template for /etc/sysconfig
install -Dm 644 %{SOURCE3} %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
install -m 755 passcheck %{buildroot}%{_sbindir}/passcheck
#mkdir -p %%{buildroot}%%{pkg_home}/rrd
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
find %{buildroot}%{_libdir} -name "*.a" -delete
# install /var/lib/ntop, so ntop can store it's databases
#mkdir -p %%{buildroot}%%{_localstatedir}/lib/%%{name}/rrd/{flows,graphics,interfaces}
# install logrotate script
%{__mkdir_p} %{buildroot}%{_sysconfdir}/logrotate.d
%{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}
cat >> %{buildroot}%{_sysconfdir}/logrotate.d/%{name} << EOF
/var/log/ntop/*.log {
weekly
missingok
rotate 4
# ntop doesn't handle SIGHUP
copytruncate
compress
notifempty
create 640 %{pkg_user} %{pkg_user}
%if 0%{?suse_version} > 1200
su %{pkg_user} %{pkg_user}
%endif
}
EOF
# TODO: link to GeoIP databases
# extract the files in %%{_sysconfdir}/%%{name} as ntop expects them uncompressed
#gunzip %%{buildroot}%%{_sysconfdir}/%%{name}/*.gz
%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 %{name}
%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
%{insserv_cleanup}
%{restart_on_update}
/sbin/ldconfig
%files
%defattr(-,root,root)
%doc docs/* AUTHORS CONTENTS COPYING ChangeLog MANIFESTO NEWS PORTING
%doc SUPPORT_NTOP.txt THANKS
%{_bindir}/ntop
%{_sbindir}/rcntop
%{_sbindir}/passcheck
%{_libdir}/lib*.so
%dir %{_libdir}/ntop
%{_libdir}/ntop/plugins
%{_mandir}/man8/ntop.8.*
%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
# make suggests us to own the directory for the ntop user,
# but at the moment everything runs as expected.
# do not switch until you really know that you need it:
#%%dir %%attr(-,%%{pkg_user},%%{pkg_user}) %%{_datadir}/%%{name}
%dir %{_datadir}/%{name}
%{_datadir}/ntop/html
%{_datadir}/ntop/python
%dir %{_sysconfdir}/ntop
%config(noreplace) %{_sysconfdir}/%{name}/*
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %attr(750,%{pkg_user},%{pkg_user}) %{_localstatedir}/log/%{name}
%config %{_sysconfdir}/init.d/ntop
#%%attr(-,%%{pkg_user},%%{pkg_user}) %%dir %%{_localstatedir}/lib/%%{name}
#%%attr(-,%%{pkg_user},%%{pkg_user}) %%dir %%{_localstatedir}/lib/%%{name}/rrd
#%%attr(-,%%{pkg_user},%%{pkg_user}) %%dir %%{_localstatedir}/lib/%%{name}/rrd/*
%changelog