File ntopng.spec of Package ntopng
#
# spec file for package ntopng
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%bcond_with nedge
Name: ntopng
Version: 5.0
Release: 0
Summary: Web-based network traffic monitoring
License: GPL-3.0-only
Group: Productivity/Networking/Other
URL: https://www.ntop.org/
Source: https://github.com/ntop/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: ntopng-user.conf
Source2: ntopng@.service
Source3: ntopng-rpmlintrc
Source4: ntopng.service
Source5: README.SUSE
Source6: ntopng.target
Patch0: 001-Enable-building-against-the-dynamic-libndpi-library.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gcc-c++
BuildRequires: groff
BuildRequires: libmysqlclient-devel
BuildRequires: libpcap-devel
BuildRequires: libtool
BuildRequires: openldap2-devel
BuildRequires: pkgconfig >= 0.9.0
BuildRequires: readline-devel
BuildRequires: sysuser-tools
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(hiredis)
BuildRequires: pkgconfig(json-c)
BuildRequires: pkgconfig(libcap)
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(libmaxminddb)
BuildRequires: pkgconfig(libndpi) >= 4.0
BuildRequires: pkgconfig(librrd)
BuildRequires: pkgconfig(libssl)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libzmq)
BuildRequires: pkgconfig(radcli)
BuildRequires: pkgconfig(sqlite3)
Requires: logrotate
Requires: redis >= 2.4.0
Requires(post): %fillup_prereq
Recommends: geoipupdate
Obsoletes: ntopng-data < %{version}
Provides: ntopng-data = %{version}
%sysusers_requires
%if %{with nedge}
BuildRequires: pkgconfig(libnetfilter_conntrack)
BuildRequires: pkgconfig(libnetfilter_queue)
BuildRequires: pkgconfig(libnfnetlink)
%endif
%description
ntopng is a web-based network traffic monitoring application released under GPLv3.
It is the new incarnation of the original ntop written in 1998, and now revamped
in terms of performance, usability, and features.
%prep
%setup -q
%patch0 -p1
%build
%sysusers_generate_pre %{SOURCE1} %{name}
./autogen.sh
export CFLAGS="%{optflags} $(pkg-config --cflags libnetfilter_queue) -fpermissive"
export CXXFLAGS="%{optflags} $(pkg-config --cflags libnetfilter_queue) -fpermissive -I/usr/include/mysql"
%configure \
%if %{with nedge}
--with-nedge \
%endif
--with-ndpi-includes=%{_includedir}/ndpi/
%make_build
%install
install -d %{buildroot}%{_sysusersdir}
install -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/
install -d %{buildroot}%{_sbindir}
install -d %{buildroot}%{_fillupdir}
install -d %{buildroot}%{_datadir}/ntopng/httpdocs/geoip
install -d %{buildroot}%{_localstatedir}/log/%{name}
install -d %{buildroot}%{_localstatedir}/lib/%{name}
install -d %{buildroot}%{_docdir}/%{name}
install -D -p -m 0755 ntopng %{buildroot}%{_bindir}/ntopng
install -D -p -m 0755 httpdocs/misc/ntopng-utils-manage-config %{buildroot}%{_bindir}/ntopng-utils-manage-config
install -D -p -m 0644 %{_builddir}/%{name}-%{version}/ntopng.8 %{buildroot}%{_mandir}/man8/ntopng.8
install -D -p -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/ntopng.service
install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}/ntopng@.service
install -D -p -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/ntopng.target
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rcntopng
install -D -p -m 0644 packages%{_sysconfdir}/logrotate.d/ntopng %{buildroot}%{_sysconfdir}/logrotate.d/ntopng
install -D -p -m 0644 packages%{_sysconfdir}/ntopng/ntopng.conf %{buildroot}%{_sysconfdir}/ntopng/ntopng.conf
cp -Lr httpdocs scripts %{buildroot}%{_datadir}/ntopng
install -p -m 0644 %{SOURCE5} %{buildroot}%{_docdir}/%{name}/README.SUSE
%pre -f ntopng.pre
%service_add_pre ntopng.service ntopng@.service
%preun
%service_del_preun ntopng.service ntopng@.service ntopng.target
%postun
%service_del_postun ntopng.service ntopng@.service ntopng.target
%post
%service_add_post ntopng.service ntopng@.service
%files
%{_sysusersdir}/%{name}-user.conf
%license LICENSE COPYING
%doc CHANGELOG.md doc/README.* README.SUSE
%dir %{_sysconfdir}/ntopng
%config(noreplace) %{_sysconfdir}/ntopng/ntopng.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_bindir}/ntopng
%{_bindir}/ntopng-utils-manage-config
%{_unitdir}/ntopng.service
%{_unitdir}/ntopng@.service
%{_unitdir}/ntopng.target
%{_sbindir}/rcntopng
%{_datadir}/ntopng
%{_mandir}/man8/ntopng.8%{?ext_man}
%dir %{_localstatedir}/log/%{name}
%dir %attr(700, ntopng, ntopng) %{_localstatedir}/lib/%{name}
%changelog