File icingaweb2.spec of Package icingaweb2

#
# spec file for package icingaweb2
#
# Copyright (c) 2013-2015 Icinga Development Team | GPLv2+
#
# 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:           icingaweb2
Version:        2.3.4
Release:        0
License:        GPL-2.0+ and MIT and BSD-3-Clause
Summary:        Icinga Web 2
Url:            https://icinga.org
Group:          System/Monitoring
Source:         https://github.com/Icinga/icingaweb2/archive/v%{version}.tar.gz
Source1:	%{name}.permissions
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%if 0%{?fedora} || 0%{?rhel} || 0%{?amzn}
%define php             php
%define php_cli         php-cli
%define wwwconfigdir    %{_sysconfdir}/httpd/conf.d
%define wwwdir          %{_sysconfdir}/httpd
%define wwwuser         apache
%define zend            php-ZendFramework
%endif

%if 0%{?suse_version}
BuildRequires:  fdupes
%define wwwconfigdir    %{_sysconfdir}/apache2/conf.d
%define wwwdir          %{_sysconfdir}/apache2
%define wwwuser         wwwrun
%define zend            php5-ZendFramework
%define php php5
Requires:       apache2-mod_php5
%endif

Requires:       %{name}-common = %{version}
Requires:       %{name}-vendor-HTMLPurifier
Requires:       %{name}-vendor-JShrink
Requires:       %{name}-vendor-Parsedown
Requires:       %{name}-vendor-dompdf
Requires:       %{name}-vendor-lessphp
Requires:       php-Icinga = %{version}
%if 0%{?suse_version}
PreReq:         permissions
%endif
%{?amzn:Requires(pre):          shadow-utils}
%{?fedora:Requires(pre):        shadow-utils}
%{?rhel:Requires(pre):          shadow-utils}
%{?suse_version:Requires(pre):  pwdutils}

%description
Icinga Web 2 - the new web interface comes with a completely new design and
many user-friendly enhancements to find the relevant information even faster.

%define basedir         %{_datadir}/%{name}
%define bindir          %{_bindir}
%define configdir       %{_sysconfdir}/%{name}
%define logdir          %{_localstatedir}/log/%{name}
%define phpdir          %{_datadir}/php
%define icingawebgroup  icingaweb2
%define docsdir         %{_datadir}/doc/%{name}

%package common
Summary:        Common files for Icinga Web 2 and the Icinga CLI
Group:          System/Monitoring
%if 0%{?suse_version}
PreReq:         permissions
%endif
%{?amzn:Requires(pre):          shadow-utils}
%{?fedora:Requires(pre):        shadow-utils}
%{?rhel:Requires(pre):          shadow-utils}
%{?suse_version:Requires(pre):  pwdutils}

%description common
Common files for Icinga Web 2 and the Icinga CLI that are shared 
between all other icingaweb2 packages.

%package -n php-Icinga
Summary:        PHP library
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0
Requires:       %{php}-gd
Requires:       %{php}-intl
Requires:       %{zend} >= 1.12.18
#Requires:       %%{zend}-Db-Adapter-Pdo-Mysql
#Requires:       %%{zend}-Db-Adapter-Pdo-Pgsql
%{?amzn:Requires:           %{php}-pecl-imagick}
%{?fedora:Requires:         php-pecl-imagick}
%{?rhel:Requires:           php-pecl-imagick}
%{?suse_version:Requires:   %{php}-gettext %{php}-json %{php}-openssl %{php}-posix}

%description -n php-Icinga
Icinga Web 2 PHP library.

%package -n icingacli
Summary:        Icinga CLI
Group:          System/Monitoring
Requires:       %{name}-common = %{version}
Requires:       php-Icinga = %{version}
%{?amzn:Requires:           %{php_cli} >= 5.3.0 bash-completion}
%{?fedora:Requires:         %{php_cli} >= 5.3.0 bash-completion}
%{?rhel:Requires:           %{php_cli} >= 5.3.0 bash-completion}
%{?suse_version:Requires:   %{php} >= 5.3.0}

%description -n icingacli
Command line interface for Icinga.

%package vendor-dompdf
Version:        0.6.1
Release:        1
License:        LGPL-2.1
Summary:        Vendor library dompdf
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0

%description vendor-dompdf
Icinga Web 2 vendor library dompdf.

%package vendor-HTMLPurifier
Version:        4.6.0
Release:        1
License:        LGPL-2.1
Summary:        HTMLPurifier for Icinga Web 2
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0

%description vendor-HTMLPurifier
Icinga Web 2 vendor library HTMLPurifier.

%package vendor-JShrink
Version:        1.0.1
Release:        1
License:        BSD-3-Clause
Summary:        Vendor library JShrink
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0

%description vendor-JShrink
Icinga Web 2 vendor library JShrink.

%package vendor-lessphp
Version:        0.4.0
Release:        1
License:        MIT
Summary:        Vendor library lessphp
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0

%description vendor-lessphp
Icinga Web 2 vendor library lessphp.

%package vendor-Parsedown
Version:        1.0.0
Release:        1
License:        MIT
Summary:        Vendor library Parsedown
Group:          Development/Libraries
Requires:       %{php} >= 5.3.0

%description vendor-Parsedown
Icinga Web 2 vendor library Parsedown.

%prep
%setup -q
# rpmlint
chmod -x ./library/vendor/HTMLPurifier/DefinitionCache/Serializer/README


%build

%install
mkdir -p %{buildroot}{%{basedir}/{modules,library/vendor,public},%{bindir},%{configdir}/modules,%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}}
cp -prv application doc %{buildroot}%{basedir}
cp -pv etc/bash_completion.d/icingacli %{buildroot}%{_sysconfdir}/bash_completion.d/icingacli
cp -prv modules/{doc,monitoring,setup,test,translation} %{buildroot}%{basedir}/modules
cp -prv library/Icinga %{buildroot}%{phpdir}
cp -prv library/vendor/{HTMLPurifier,JShrink,Parsedown,dompdf,lessphp,HTMLPurifier.autoload.php,HTMLPurifier.php} %{buildroot}%{basedir}/library/vendor
cp -prv public/{css,font,img,js,error_norewrite.html,index.php} %{buildroot}%{basedir}/public
cp -pv packages/files/apache/icingaweb2.conf %{buildroot}%{wwwconfigdir}/icingaweb2.conf
cp -pv packages/files/bin/icingacli %{buildroot}%{bindir}
cp -pv packages/files/public/index.php %{buildroot}%{basedir}/public
cp -prv etc/schema %{buildroot}%{docsdir}
cp -prv packages/files/config/modules/{setup,translation} %{buildroot}%{configdir}/modules
%if 0%{?suse_version}
%fdupes %{buildroot}/%{basedir}/library
%endif
%find_lang icinga
# install permissions file
%{__install} -D -m 0644 %{S:1} %{buildroot}%{_sysconfdir}/permissions.d/%{name}


%pre
getent group icingacmd >/dev/null || groupadd -r icingacmd
%if 0%{?suse_version}
	%if 0%{?suse_version} == 1110
		usermod -A icingacmd,%{icingawebgroup} %{wwwuser}
	%else
		usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser}
	%endif
if [ "$1" = "1" ]; then
	# enable env, php5 and rewrite in apache on new installations
	if [ -x %{_sbindir}/a2enmod ]; then
		%{_sbindir}/a2enmod env >/dev/null
		%{_sbindir}/a2enmod php5 >/dev/null
		%{_sbindir}/a2enmod rewrite >/dev/null
	fi
fi
%endif

%clean
rm -rf %{buildroot}

%post
%if 0%{?suse_version} != 1110
	%set_permissions /etc/icingaweb2/modules/setup/
	%set_permissions /etc/icingaweb2/modules/translation/
	%set_permissions /var/log/icingaweb2/
%endif

%verifyscript
%verify_permissions -e /etc/icingaweb2/modules/setup/
%verify_permissions -e /etc/icingaweb2/modules/translation/
%verify_permissions -e /var/log/icingaweb2/

%files
%defattr(-,root,root)
%{basedir}/application/controllers
%{basedir}/application/fonts
%{basedir}/application/forms
%{basedir}/application/layouts
%{basedir}/application/views
%{basedir}/application/VERSION
%{basedir}/doc
%{basedir}/modules
%{basedir}/public
%dir %{wwwdir}
%dir %{wwwconfigdir}
%config(noreplace) %{wwwconfigdir}/icingaweb2.conf
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/setup
%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup/config.ini
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/translation
%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/translation/config.ini
%{docsdir}
%docdir %{docsdir}


%pre common
getent group %{icingawebgroup} >/dev/null || groupadd -r %{icingawebgroup}

%post common
%if 0%{?suse_version} != 1110
	%set_permissions /etc/icingaweb2/
	%set_permissions /etc/icingaweb2/modules/
%endif

%verifyscript common
%verify_permissions -e /etc/icingaweb2/
%verify_permissions -e /etc/icingaweb2/modules/

%files common -f icinga.lang
%defattr(-,root,root)
%{basedir}/application/locale
%dir %{basedir}
%dir %{basedir}/application
%dir %{basedir}/modules
%dir %{basedir}/library
%dir %{basedir}/library/vendor
%config(noreplace) %{_sysconfdir}/permissions.d/%{name}
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules


%files -n php-Icinga
%defattr(-,root,root)
%dir %{phpdir}
%{phpdir}/Icinga


%files -n icingacli
%defattr(-,root,root)
%{basedir}/application/clicommands
%config %{_sysconfdir}/bash_completion.d/icingacli
%attr(0755,root,root) %{bindir}/icingacli


%files vendor-dompdf
%defattr(-,root,root)
%{basedir}/library/vendor/dompdf


%files vendor-HTMLPurifier
%defattr(-,root,root)
%{basedir}/library/vendor/HTMLPurifier
%{basedir}/library/vendor/HTMLPurifier*.php

%files vendor-JShrink
%defattr(-,root,root)
%{basedir}/library/vendor/JShrink


%files vendor-lessphp
%defattr(-,root,root)
%{basedir}/library/vendor/lessphp


%files vendor-Parsedown
%defattr(-,root,root)
%{basedir}/library/vendor/Parsedown

%changelog
openSUSE Build Service is sponsored by