File nagiosgraph.spec of Package nagiosgraph

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

%if 0%{?suse_version}
%define layout suse
%if 0%{?suse_version} <= 1110
%define _libexecdir %{_prefix}/lib
%endif
%endif

#if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora_version}
#define layout redhat
#endif

Name:           nagiosgraph
Version:        1.5.1
Release:        1
License:        Artistic-2.0
Summary:        Visualization addon for nagios
Url:            http://nagiosgraph.sourceforge.net
Group:          System/Monitoring
Source:         http://downloads.sourceforge.net/nagiosgraph/%{name}-%{version}.tar.gz
# PATCH-FIX -- wrong fhs path
Patch0:         nagiosgraph-fhs.patch
# PATCH-FIX -- install_suse_layout
Patch1:         nagiosgraph-install.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         nagios-www
BuildRequires:  perl
BuildRequires:  rrdtool
#
Requires:       nagios-www
Requires:       rrdtool

%description
Nagiosgraph is an add-on of Nagios. It collects service performance data into
rrd format, and displays the resulting graphs via cgi.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
chmod 644 utils/*

%build

%install
DESTDIR=%{buildroot} perl install.pl --no-check-prereq --no-chown \
  --layout=%{layout}

%if 0%{?suse_version}
# install missing
install -d -m0755 %{buildroot}%{_localstatedir}/lib/nagios/rrd/%{name}
%endif

# fix install of css file
install -d %{buildroot}%{_datadir}/nagios/stylesheets
mv %{buildroot}%{_datadir}/nagios/%{name}.css %{buildroot}%{_datadir}/nagios/stylesheets/

# clean up not needed files
## pkged to docdir
rm -f %{buildroot}%{_sysconfdir}/%{name}/%{name}-{apache,commands,nagios}.*
rm -rf %{buildroot}%{_datadir}/%{name}/{examples,util}

%post
touch /tmp/dummy.log
for f in %{name} %{name}-cgi; do
  if [ ! -f %{_localstatedir}/log/nagios/${f}.log ]; then
    install -m0664 -o nagios -g nagcmd /tmp/dummy.log %{_localstatedir}/log/nagios/${f}.log
  fi
done
rm -f /tmp/dummy.log

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc AUTHORS CHANGELOG README TODO README.html INSTALL
%doc examples utils
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*.conf
%config(noreplace) %{_sysconfdir}/%{name}/map
%{_sysconfdir}/%{name}/ngshared.pm
%{_datadir}/%{name}
%{_datadir}/nagios/stylesheets/%{name}.css
%{_datadir}/nagios/%{name}.js
%{_libexecdir}/nagios/cgi/*.cgi
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/insert.pl
%dir %attr(0755,nagios,nagcmd) %{_localstatedir}/lib/nagios/rrd
%dir %attr(0755,nagios,nagcmd) %{_localstatedir}/lib/nagios/rrd/%{name}
%ghost %attr(664,nagios,nagcmd) %{_localstatedir}/log/nagios/*.log
# directories not owned by a package: but owned by nagios pkg
#%%dir %%{_datadir}/nagios/
#%%dir %%{_datadir}/nagios/stylesheets
#%%dir %%{_libexecdir}/nagios
#%%dir %%{_libexecdir}/nagios/cgi
#%%dir %%{_localstatedir}/log/nagios

%changelog
openSUSE Build Service is sponsored by