File cacti.spec of Package cacti

#
# spec file for package cacti
#
# Copyright (c) 2012 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:           cacti
Version:        0.8.8a
Release:        0.0
Summary:        Web Front-End to Monitor System Data via RRDtool
License:        GPL-2.0+
Group:          System/Monitoring
Url:            http://www.cacti.net/
Source0:        %{name}-%{version}.tar.bz2
Source1:        %{name}.cron
Source2:        %{name}-httpd.conf
Source3:        %{name}.logrotate
Source4:        %{name}-httpd.conf.default
Source5:        %{name}-httpd.conf.vhost
Source6:        %{name}-httpd.conf.nonsuse
Source7:        %{name}.cron.new
# PATCH-FIX-OPENSUSE cacti-0.8.8-cacti-log-path.patch
Patch0:         %{name}-%{version}-cacti-log-path.patch
# PATCH-FIX-OPENSUSE cacti-0.8.8-cacti-script.patch
Patch1:         %{name}-%{version}-cacti-script.patch
Provides:       cacti-system
%if 0%{?suse_version}
BuildRequires:  apache2-devel
Requires:       cron
Requires:       apache2
Requires:       apache2-mod_php5
Requires:       php5-mysql
Requires:       php5-sockets
Requires:       php5-snmp
Requires:       rrdtool
%endif
%if 0%{?fedora_version} ||  0%{?rhel_version} || 0%{?centos_version}
BuildRequires:  httpd-devel
Requires:       httpd
Requires:       rrdtool
%endif
%if 0%{?centos_version}
Requires:       php-mysql
Requires:       php-snmp
%endif
%if 0%{?rhel_version}
Requires:       php-mysql
#Requires:       php-snmp
%endif
%if 0%{?fedora_version}
Requires:       php-mysqlnd
Requires:       php-snmp
%endif
%if 0%{?mandriva_version}
BuildRequires:  apache-devel
Requires:       apache
Requires:       apache-mod_php
Requires:       php-mysql
Requires:       php-sockets
Requires:       php-snmp
Requires:       rrdtool
%endif
Requires:       logrotate
Requires:       net-snmp
Obsoletes:      cacti-PA
Provides:	cacti-PA
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if 0%{?suse_version}
%define apxs    /usr/sbin/apxs2
%else
%define apxs    /usr/sbin/apxs
%endif
%define apache2_sysconfdir       %(%{apxs} -q SYSCONFDIR)
%if 0%{?suse_version} <= 1210
%define prefix %{_datadir}/cacti
%else
%define prefix /srv/www/cacti
%endif

%description
Cacti is a complete front-end to RRDtool: it stores all necessary
information for creating graphs and populates them with data from a
MySQL database. The front-end is completely PHP driven. Along with
being ableto maintain graphs, data sources, and round robin archives
ina database, Cacti also handles data gathering. There exists an SNMP
support for those accustomed to creating traffic graphs with MRTG as
well.

%prep
%setup -q
%patch0 -p1
%patch1 -p1

%build
#nothing to build

%install
#delete the *.orig files
find . -type f -name "*\.orig" -exec rm {} \;
install -d -m 755 %{buildroot}%{prefix}
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{name}
cp *.php        %{buildroot}%{prefix}
cp -pr lib      %{buildroot}%{prefix}
cp -pr include  %{buildroot}%{prefix}
cp -pr images   %{buildroot}%{prefix}
cp -pr install  %{buildroot}%{prefix}
cp -pr resource %{buildroot}%{prefix}
cp -pr rra      %{buildroot}%{prefix}
#cp -pr scripts  %{buildroot}%{prefix}
#cp -pr cli      %{buildroot}%{prefix}
install -d -m 755 scripts %{buildroot}%{prefix}/scripts
install -m 755 scripts/* %{buildroot}%{prefix}/scripts
install -d -m 755 cli %{buildroot}%{prefix}/cli
install -m 755 cli/* %{buildroot}%{prefix}/cli
install -m 644 *.sql %{buildroot}%{prefix}
# cron task
install -d -m 755 %{buildroot}%{_sysconfdir}/cron.d
%if 0%{?suse_version} > 1210
install -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/cron.d/cacti
%endif
%if 0%{?suse_version} <= 1210
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/cron.d/cacti
%endif
%if ! 0%{?suse_version}
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/cron.d/cacti
%endif
# apache2 config
%if 0%{?suse_version} > 1210
mkdir -p %{buildroot}/%{apache2_sysconfdir}/conf.d
cp -avL %{SOURCE4} %{buildroot}/%{apache2_sysconfdir}/conf.d/%{name}.conf
mkdir -p %{buildroot}/%{apache2_sysconfdir}/vhosts.d/conf.d
cp -avL %{SOURCE5} %{buildroot}/%{apache2_sysconfdir}/vhosts.d/conf.d/%{name}.conf
%endif
%if 0%{?suse_version} <= 1210
install -d -m 755 %{buildroot}%{apache2_sysconfdir}/conf.d
install -m 644 %{SOURCE2} %{buildroot}%{apache2_sysconfdir}/conf.d/cacti.conf
%endif
%if ! 0%{?suse_version}
mkdir -p %{buildroot}/%{apache2_sysconfdir}/../conf.d
cp -avL %{SOURCE6} %{buildroot}/%{apache2_sysconfdir}/../conf.d/%{name}.conf
%endif
# logrotate config
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d/
install -m 644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
# Set the correct permissions for pl and sh files
#find %{buildroot}%{prefix} -type f -name "*.sh" -o -name "*.pl" -exec chmod ugo+x {} \;
# compute files list without config file
find %{buildroot}%{prefix} -type d | sed -e 's|'%{buildroot}'|%dir |' >> %{name}.list
find %{buildroot}%{prefix} -type f ! -name config.php | sed -e 's|'%{buildroot}'||' >> %{name}.list

%files -f %{name}.list
%defattr(-,root,root)
%doc LICENSE docs/*
%attr(-,wwwrun,www) %dir %{_localstatedir}/lib/cacti
%attr(-,wwwrun,www) %dir %{_localstatedir}/log/cacti
%config(noreplace) %{prefix}/include/config.php
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%if 0%{?suse_version} <= 1210
%dir %{apache2_sysconfdir}/conf.d
%config(noreplace) %{apache2_sysconfdir}/conf.d/cacti.conf
%endif
%if 0%{?suse_version} > 1210
%dir %{apache2_sysconfdir}/conf.d
%config (noreplace) %{apache2_sysconfdir}/conf.d/%{name}.conf
%dir %{apache2_sysconfdir}/vhosts.d/conf.d
%config (noreplace) %{apache2_sysconfdir}/vhosts.d/conf.d/%{name}.conf
%endif
%if ! 0%{?suse_version}
%dir %{apache2_sysconfdir}/../conf.d
%config (noreplace) %{apache2_sysconfdir}/../conf.d/%{name}.conf
%endif

%post
%if 0%{?suse_version}
chown -R wwwrun.www %{prefix}/rra
%endif

%changelog