pmacct/pmacct.spec

223 lines
6.6 KiB
RPMSpec

#
# spec file for package pmacct
#
# Copyright (c) 2016 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/
#
%if 0%{?suse_version} > 1230
%bcond_without systemd
%else
%bcond_with systemd
%endif
Name: pmacct
Version: 1.7.0
Release: 0
Summary: Accounting and aggregation toolsuite for IPv4 and IPv6
License: GPL-2.0
Group: Productivity/Networking/Diagnostic
Url: http://www.pmacct.net/
Source: http://www.pmacct.net/pmacct-%{version}.tar.gz
Source1: nfacctd.init
Source2: pmacctd.init
Source3: sfacctd.init
Source4: pmacct.nfacctd.service
Source5: pmacct.pmacctd.service
Source6: pmacct.sfacctd.service
Source7: pmacct.nfacctd.sysconfig
Source8: pmacct.pmacctd.sysconfig
Source9: pmacct.sfacctd.sysconfig
Source10: nfacctd.conf
Source11: pmacctd.conf
Source12: sfacctd.conf
Source20: pmacct.1
# needed for psql header detection on SLES11SP4 and openSUSE 13.1
Patch2: pmacct-pgsql-fix-header-detection-without-autoreconf.diff
BuildRequires: libmysqlclient-devel
BuildRequires: libpcap-devel
BuildRequires: libstdc++-devel
BuildRequires: pkg-config
BuildRequires: postgresql-devel
BuildRequires: sqlite-devel >= 3.0.0
%if 0%{?is_opensuse} == 1
BuildRequires: libnetfilter_log-devel
%endif
%if 0%{?suse_version} > 1110
BuildRequires: libGeoIP-devel
%endif
%if 0%{?suse_version} >= 1310 && 0%{?is_opensuse} == 1
BuildRequires: pkgconfig(jansson)
%endif
%if %{with systemd}
%{?systemd_requires}
BuildRequires: systemd-rpm-macros
%else
PreReq: %insserv_prereq
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
pmacct is a small set of passive network monitoring tools to measure, account,
classify and aggregate IPv4 and IPv6 traffic; a pluggable and flexible
architecture allows to store the collected traffic data into memory tables or
SQL (MySQL, SQLite, PostgreSQL) databases. pmacct supports fully customizable
historical data breakdown, flow sampling, filtering and tagging, recovery
actions, and triggers. Libpcap, sFlow v2/v4/v5 and NetFlow v1/v5/v7/v8/v9 are
supported, both unicast and multicast. Also, a client program makes it easy to
export data to tools like RRDtool, GNUPlot, Net-SNMP, MRTG, and Cacti.
%prep
%setup -q
%patch2 -p1
# fix permissions
chmod -x sql/pmacct-*
%build
export CFLAGS="%{optflags} -Wno-return-type -D_FORTIFY_SOURCE=0"
%configure \
--sysconfdir=%{_sysconfdir}/%{name} \
--enable-mmap \
--enable-l2 \
--enable-ipv6 \
--enable-mysql \
--enable-pgsql \
--enable-sqlite3 \
%if 0%{?suse_version} > 1110
--enable-geoip \
%endif
%if 0%{?suse_version} >= 1310 && 0%{?is_opensuse} == 1
--enable-jansson \
%endif
--enable-64bit \
%if 0%{?is_opensuse} == 1
--enable-nflog \
%endif
--enable-threads
make %{?_smp_mflags}
%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
install -d 0755 %{buildroot}/var/adm/fillup-templates/
install -m 0644 %{SOURCE7} "%{buildroot}/var/adm/fillup-templates/sysconfig.nfacctd"
install -m 0644 %{SOURCE8} "%{buildroot}/var/adm/fillup-templates/sysconfig.pmacctd"
install -m 0644 %{SOURCE9} "%{buildroot}/var/adm/fillup-templates/sysconfig.sfacctd"
%if %{with systemd}
install -d %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE4} %{buildroot}%{_unitdir}/nfacctd.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcnfacctd
install -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/pmacctd.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcpmacctd
install -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/sfacctd.service
ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcsfacctd
%else
install -d %{buildroot}%{_sysconfdir}/init.d
install -m 0755 %{SOURCE1} %{buildroot}/%{_sysconfdir}/init.d/nfacctd
install -m 0755 %{SOURCE2} %{buildroot}/%{_sysconfdir}/init.d/pmacctd
install -m 0755 %{SOURCE3} %{buildroot}/%{_sysconfdir}/init.d/sfacctd
ln -sf ../..%{_initddir}/nfacctd %{buildroot}%{_sbindir}/rcnfacctd
ln -sf ../..%{_initddir}/pmacctd %{buildroot}%{_sbindir}/rcpmacctd
ln -sf ../..%{_initddir}/sfacctd %{buildroot}%{_sbindir}/rcsfacctd
%endif
# examples
install -d %{buildroot}%{_sysconfdir}/pmacct/
install -m 0600 %{SOURCE10} %{buildroot}/%{_sysconfdir}/pmacct/nfacctd.conf
install -m 0600 %{SOURCE11} %{buildroot}/%{_sysconfdir}/pmacct/pmacctd.conf
install -m 0600 %{SOURCE12} %{buildroot}/%{_sysconfdir}/pmacct/sfacctd.conf
# manpage
install -d "%{buildroot}%{_mandir}/man1/"
install -m 644 %{SOURCE20} "%{buildroot}%{_mandir}/man1/"
%pre
%if %{with systemd}
%service_add_pre nfacctd.service pmacctd.service sfacctd.service
%endif
%post
%if %{with systemd}
%service_add_post nfacctd.service pmacctd.service sfacctd.service
%{fillup_only -n nfacctd}
%{fillup_only -n pmacctd}
%{fillup_only -n sfacctd}
%else
%{fillup_and_insserv -n nfacctd}
%{fillup_and_insserv -n pmacctd}
%{fillup_and_insserv -n sfacctd}
%endif
%preun
%if %{with systemd}
%service_del_preun nfacctd.service pmacctd.service sfacctd.service
%else
%stop_on_removal nfacctd pmacctd sfacctd
%endif
%postun
%if %{with systemd}
%service_del_postun nfacctd.service pmacctd.service sfacctd.service
%else
%restart_on_update nfacctd pmacctd sfacctd
%insserv_cleanup
%endif
%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog CONFIG-KEYS COPYING FAQS QUICKSTART TOOLS UPGRADE
%doc docs examples sql
#
%{_mandir}/man1/pmacct.1%{ext_man}
#
%{_bindir}/pmacct
#
%{_sbindir}/nfacctd
%{_sbindir}/pmacctd
%{_sbindir}/sfacctd
%if 0%{?is_opensuse} == 1
%{_sbindir}/uacctd
%endif
%{_sbindir}/pmtelemetryd
%{_sbindir}/pmbgpd
%{_sbindir}/pmbmpd
#
%{_sbindir}/rcnfacctd
%{_sbindir}/rcpmacctd
%{_sbindir}/rcsfacctd
#
%if %{with systemd}
%{_unitdir}/*.service
%else
%config %{_sysconfdir}/init.d/*
%endif
#
%dir %{_sysconfdir}/pmacct
%config(noreplace) %{_sysconfdir}/pmacct/nfacctd.conf
%config(noreplace) %{_sysconfdir}/pmacct/pmacctd.conf
%config(noreplace) %{_sysconfdir}/pmacct/sfacctd.conf
/var/adm/fillup-templates/sysconfig.nfacctd
/var/adm/fillup-templates/sysconfig.pmacctd
/var/adm/fillup-templates/sysconfig.sfacctd
%changelog