File nconf.spec of Package nconf

#
# spec file for package nconf
#
# Copyright (c) 2012 Lars Vogdt <lars@linux-schulserver.de>
#
# 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:           nconf
Version:        1.4.0
Release:        1
License:        GPL-2.0+
Summary:        Enterprise Nagios configurator
Url:            https://github.com/Bonsaif/new-nconf
Group:          System/Monitoring
BuildRequires:  apache2-devel
# needed for the symlink (see install)
BuildRequires:  nagios
BuildRequires:  nagios-rpm-macros
# SLE 11 does not allow the nconf.orig directory
# as the post-build-script can not be disabled, we
# skip the whole post-build-script section on SLE-11 and rely on
# the younger post-build-sections on openSUSE 11.4 and bejond
%if 0%{?suse_version} < 1140
BuildRequires:  -post-build-checks
%endif
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
%endif
Source0:        %{name}-v%{version}-final2.tar.gz
Source1:        %{name}-http.conf
Source2:        imagepak-base.tar.gz
Source4:        %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE -- allow the deploy local script to use the default
#                       pathnames of the openSUSE configuration
Patch1:         nconf-1.2.5.0-deploy_local.patch
# PATCH-FIX-UPSTREAM -- database error due to wrong default for max_length
Patch2:         fix_wrong_default_max_length.patch
# PATCH-FIX-OPENSUSE -- default path should start with /srv/www instead of /var/www on SUSE
Patch3:	        nconf-fix-SUSE-output-dir.patch
Requires(pre):  apache2
Requires(pre):  mysql
Requires:       nagios
Requires:       nconf-layout >= %{version}
Requires:       perl >= 5.6
Requires:       perl-DBD-mysql
Requires:       perl-DBI
Requires:       php-mysql
Requires:       tar
Recommends:     openssh
Recommends:     rsync
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%define         apache2_sysconfdir %{_sysconfdir}/apache2
%define         installdir /srv/www/nconf

%description
NConf is a PHP based web-tool for configuring the Nagios monitoring software.
It differs from similar tools by offering enterprise-class features like host
templates, dependencies and to configure a large-scale, distributed Nagios
server topology.

%package layout-fresh
Summary:        Fresh layout for NCONF
Group:          System/Monitoring
Requires:       %{name}
Provides:       nconf-layout = %{version}

%description layout-fresh
This package contains the 'fresh' layout for the Enterprise Nagios
configurator.

%package installation
Summary:        Installation files of NCONF
Group:          System/Monitoring
Requires:       %{name} = %{version}

%description installation
This package contains some files needed for installation that should
be removed afterwards.

%prep
%setup -q -n new-%{name}-nconf-v%{version}-final2
%patch1 -p1
%patch2 -p1
%patch3 -p1
sed -i "s|/bin/mail|/usr/bin/mail|g" INSTALL_/create_database.sql
find . -name .gitignore -delete
pushd img/logos/
tar -xf %{SOURCE2}
popd

%build
#

%install
install -Dm640 %{SOURCE1} %{buildroot}/%{apache2_sysconfdir}/conf.d/nagios-nconf.conf
mkdir -p %{buildroot}/%{_defaultdocdir}/%{name}
mv CHANGELOG COPYRIGHT LICENSE README %{buildroot}/%{_defaultdocdir}/%{name}/
mkdir -p %{buildroot}/%{installdir}
cp -r * %{buildroot}/%{installdir}/
sed -i "s|/var/www/html/nconf/output/|%{installdir}/output/|;\
		s|/usr/local/bin/nagios|%{_sbindir}/nagios|;\
        s|/usr/local/nagios/etc/|%{nagios_sysconfdir}|;" %{buildroot}/%{installdir}/ADD-ONS/deploy_local.sh
chmod +x %{buildroot}/%{installdir}/bin/*.pl
chmod +x %{buildroot}/%{installdir}/ADD-ONS/*.sh
pushd %{buildroot}/%{installdir}/bin/
ln -s /usr/sbin/nagios nagios
popd
mkdir -p %{buildroot}%{_localstatedir}/lib/nagios/spool/checkresults
%if 0%{?suse_version} > 1020
%fdupes %{buildroot}
%endif

%clean
rm -rf %{buildroot}

%post
# Fresh install?
if [ ${1:-0} -eq 1 ]; then
  # enable php5 in apache config
  if [ -x %{_sbindir}/a2enmod ]; then
    if grep -q php5 %{_sysconfdir}/sysconfig/apache2 1>&2 2>/dev/null; then
      %{_sbindir}/a2enmod php5 >/dev/null
    fi
  fi
fi

%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name}/
%config(noreplace) %{apache2_sysconfdir}/conf.d/nagios-nconf.conf
%{installdir}/
%defattr(0770,nagios,nagcmd)
%dir %{_localstatedir}/lib/nagios/spool
%dir %{_localstatedir}/lib/nagios/spool/checkresults
%defattr(-,wwwrun,root)
%{installdir}/config
%{installdir}/output
%{installdir}/static_cfg
%{installdir}/temp
%exclude %{installdir}/design_templates/nconf_fresh
%exclude %{installdir}/INSTALL*
%exclude %{installdir}/UPDATE*

%files layout-fresh
%defattr(-,root,root)
%{installdir}/design_templates/nconf_fresh

%files installation
%defattr(-,root,root)
%{installdir}/INSTALL*
%{installdir}/UPDATE*

%changelog
openSUSE Build Service is sponsored by