File mrtg.spec of Package mrtg

# spec file for package mrtg
# 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

Name:           mrtg
Version:        2.17.7
Release:        0
Summary:        The Multirouter Traffic Grapher
License:        GPL-2.0-or-later
Group:          Productivity/Networking/Diagnostic
Source0:        %{name}-%{version}.tar.bz2
Source1:        rateup.1
Source2:        mrtg-traffic-sum.1 
Source3:        mrtg-rpmlintrc
# PATCH-FIX-OPENSUSE -- install icons in openSUSE specific directory
Patch0:         mrtg-icons_path.patch
# PATCH-FIX-OPENSUSE -- need to find a better solution for lib64
Patch3:         mrtg-lib64hack.patch
# PATCH-FIX-OPENSUSE -- some devices return 2**32-2 on ifSpeed (e. g. IBM FibreChannel switches)
Patch6:         mrtg-cfgmaker-ifhighspeed.patch
# PATCH-FIX-OPENSUSE -- some devices return 10 on ifSpeed (e. g. Cisco SG series 10G interfaces)
Patch7:         mrtg-ifHiSpeed-SG10G.patch
# PATCH-FIX-UPSTREAM -- add additional switches to cfgmaker
Patch20:        mrtg-switches.patch
BuildRequires:  automake
BuildRequires:  dos2unix
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
BuildRequires:  gd-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  zlib-devel
#BuildRequires:  xorg-x11
#BuildRequires:  xorg-x11-devel
Requires:       perl = %{perl_version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         iconsdir /srv/www/icons

The Multi Router Traffic Grapher is a tool primarily used to monitor the
traffic load on network links (typically by using SNMP). MRTG generates HTML
pages containing PNG images which provide a LIVE visual representation of this
traffic. MRTG typically produces daily, weekly, monthly, and yearly graphs.

In addition to monitoring via SNMP, MRTG can also generate graphs based on
the output of any application, allowing one to generate graphs of anything
that needs monitoring (for example, CPU and memory usage, email volumes, web
hits, etc). For faster data collection, MRTG can also interface to RRDtool.

The mrtg-doc package contains additional documentation, contributed scripts 
and configuration files that used to form part of the mrtg package.

%package doc
Summary:        Documentation and contrib files for mrtg
Group:          Productivity/Networking/Diagnostic
Requires:       %{name} == %{version}

%description doc
A collection of sample scripts and configuration files for the Multi Router
Traffic Grapher (MRTG). This package contains additional documentation and 
contributed files that ship with MRTG.

%setup -q
%patch0 -p0
%if "%{_lib}" == "lib64"
%patch3 -p0
%patch6 -p1
%patch7 -p1
# apply after git patches
%patch20 -p1

rm -rf contrib/mrtgindex.cgi
grep -rl "/usr/local/bin/perl" contrib | xargs sed -i -e "s@/usr/local/bin/perl@/usr/bin/perl@"
grep -rl "/usr/tardis/local/gnu/bin/perl5" contrib | xargs sed -i -e "s@/usr/tardis/local/gnu/bin/perl5@/usr/bin/perl@"
grep -rl "/usr/bin/perl5" contrib | xargs sed -i -e "s@/usr/bin/perl5@/usr/bin/perl@"
grep -rl "/usr/sepp/bin/perl" contrib | xargs sed -i -e "s@/usr/sepp/bin/perl@/usr/bin/perl@"
grep -rl "/store/bin/perl" contrib | xargs sed -i -e "s@/store/bin/perl@/usr/bin/perl@"
#contrib contains binaries (ie. zipfile) which we cannot convert,
#hopefully file utility seems to mark all the text files clearly
find contrib -type f | xargs file | grep -i text | cut -d: -f1 | xargs dos2unix
find contrib -type f -name "*.html" | xargs chmod 644
# disable the line below to get executable examples in the %%doc directory
find contrib -type f | xargs chmod 644

%configure \
make %{?_smp_mflags}

mkdir -p %{buildroot}%{iconsdir}
install -m 644 doc/mrtg-[lmr].png %{buildroot}%{iconsdir}
install -d -m 755 %{buildroot}%{_datadir}/apache2/icons
install -m 644 doc/mrtg-[lmr].png %{buildroot}%{_datadir}/apache2/icons
rm -rf %{buildroot}%{_datadir}/doc
rm -rf %{buildroot}%{_datadir}/mrtg2
install -Dm0644 %{SOURCE1} %{buildroot}%{_mandir}/man1/rateup.1
install -m0644  %{SOURCE2} %{buildroot}%{_mandir}/man1/mrtg-traffic-sum.1
# install and fix documentation
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples
cp -r contrib/* %{buildroot}%{_defaultdocdir}/%{name}/examples/
cp -r doc/*.{pod,txt,png} %{buildroot}%{_defaultdocdir}/%{name}/
cp -r CHANGES COPYING COPYRIGHT README THANKS %{buildroot}%{_defaultdocdir}/%{name}/
pushd %{buildroot}%{_defaultdocdir}/%{name}/
rm cfgmaker.pod indexmaker.pod mrtglib.pod
ln -s %{_bindir}/cfgmaker cfgmaker.pod
ln -s %{_bindir}/indexmaker indexmaker.pod
ln -s %{_libdir}/mrtg2/ mrtglib.pod
%if 0%{?suse_version} > 1020
%fdupes %{buildroot}%{_defaultdocdir}/%{name}

rm -rf %{buildroot}

%defattr(-, root, root)
%dir %{_defaultdocdir}/%{name}
%doc %{_defaultdocdir}/%{name}/C*
%doc %{_defaultdocdir}/%{name}/README
%doc %{_defaultdocdir}/%{name}/THANKS
%doc %{_mandir}/man?/*

%files doc
%defattr(-, root, root)
%dir %{_defaultdocdir}/%{name}/examples
%doc %{_defaultdocdir}/%{name}/examples/*
%doc %{_defaultdocdir}/%{name}/*.pod
%doc %{_defaultdocdir}/%{name}/*.txt
%doc %{_defaultdocdir}/%{name}/*.png

openSUSE Build Service is sponsored by