Add spec file for RHEL (CentOS and Fedora) packages

refs #6401
fixes #6894
This commit is contained in:
Eric Lippmann 2014-12-29 16:48:18 +01:00
parent 57121bf0ea
commit 2d0153464d
1 changed files with 198 additions and 200 deletions

View File

@ -1,237 +1,235 @@
#/**
# * This file is part of Icinga Web 2.
# *
# * Icinga Web 2 - Head for multiple monitoring backends.
# * Copyright (C) 2014 Icinga Development Team
# *
# * This program is free software; you can redistribute it and/or
# * modify it under the terms of the GNU General Public License
# * as published by the Free Software Foundation; either version 2
# * of the License, or (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# *
# * @copyright 2014 Icinga Development Team <info@icinga.org>
# * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2
# * @author Icinga Development Team <info@icinga.org>
# *
# */
%define revision 1
%define configdir %{_sysconfdir}/%{name}
%define sharedir %{_datadir}/%{name}
%define prefixdir %{_datadir}/%{name}
%define usermodparam -a -G
%define logdir %{_localstatedir}/log/%{name}
%define docdir %{sharedir}/doc
%if "%{_vendor}" == "suse"
%define phpname php5
%define phpzendname php5-ZendFramework
%define apache2modphpname apache2-mod_php5
%endif
# SLE 11 = 1110
%if 0%{?suse_version} == 1110
%define phpname php53
%define apache2modphpname apache2-mod_php53
%define usermodparam -A
%endif
%if "%{_vendor}" == "redhat"
%define phpname php
%define phpzendname php-ZendFramework
%endif
# el5 requires newer php53 rather than php (5.1)
%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
%define phpname php53
%endif
%if "%{_vendor}" == "suse"
%define apacheconfdir %{_sysconfdir}/apache2/conf.d
%define apacheuser wwwrun
%define apachegroup www
%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd
%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus
%endif
%if "%{_vendor}" == "redhat"
%define apacheconfdir %{_sysconfdir}/httpd/conf.d
%define apacheuser apache
%define apachegroup apache
%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd
%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus
%endif
Summary: Open Source host, service and network monitoring Web UI
Name: icingaweb2 Name: icingaweb2
Version: 0.0.1 Version: 2.0.0
Release: %{revision}%{?dist} Release: 1.beta2%{?dist}
License: GPLv2 Summary: Icinga Web 2
Group: Applications/System Group: Applications/System
URL: http://www.icinga.org License: GPL
URL: https://icinga.org
Source0: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
BuildArch: noarch BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
Packager: Icinga Team <info@icinga.org>
%if "%{_vendor}" == "suse" %if 0%{?fedora} || 0%{?rhel}
AutoReqProv: Off %define wwwconfigdir %{_sysconfdir}/httpd/conf.d
%define wwwuser apache
%if 0%{?rhel} == 5
%define php php53
%define php_cli php53-cli
%else
%define php php
%define php_cli php-cli
%endif
%if 0%{rhel} == 6
%define zend php-ZendFramework
%else
%define zend %{name}-vendor-Zend
%endif
%endif %endif
Source: icingaweb2-%{version}.tar.gz Requires(pre): shadow-utils
Requires: %{name}-common = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root Requires: php-Icinga = %{version}-%{release}
Requires: %{name}-vendor-dompdf
BuildRequires: %{phpname} >= 5.3.0 Requires: %{name}-vendor-HTMLPurifier
BuildRequires: %{phpname}-devel >= 5.3.0 Requires: %{name}-vendor-JShrink
BuildRequires: %{phpname}-ldap Requires: %{name}-vendor-lessphp
BuildRequires: %{phpname}-pdo Requires: %{name}-vendor-Parsedown
BuildRequires: %{phpzendname} Requires: %{zend}
%if "%{_vendor}" != "suse"
BuildRequires: %{phpzendname}-Db-Adapter-Pdo
BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Mysql
BuildRequires: %{phpzendname}-Db-Adapter-Pdo-Pgsql
%endif
%if "%{_vendor}" == "redhat"
%endif
%if "%{_vendor}" == "suse"
Requires: %{phpname}-devel >= 5.3.0
BuildRequires: %{phpname}-json
BuildRequires: %{phpname}-sockets
BuildRequires: %{phpname}-dom
%endif
Requires: %{phpname} >= 5.3.0
Requires: %{phpzendname}
Requires: %{phpname}-ldap
Requires: %{phpname}-pdo
%if "%{_vendor}" == "redhat"
Requires: %{phpname}-common
Requires: %{phpzendname}-Db-Adapter-Pdo
Requires: %{phpzendname}-Db-Adapter-Pdo-Mysql
Requires: php-pear
%endif
%if "%{_vendor}" == "suse"
Requires: %{phpname}-pear
Requires: %{phpname}-dom
Requires: %{phpname}-tokenizer
Requires: %{phpname}-gettext
Requires: %{phpname}-ctype
Requires: %{phpname}-json
Requires: %{apache2modphpname}
%endif
Requires: php-Icinga
%description %description
Icinga Web 2 for Icinga 2 or Icinga 1.x using multiple backends Icinga Web 2
for example DB IDO.
%define basedir %{_datadir}/%{name}
%define bindir %{_bindir}
%define configdir %{_sysconfdir}/%{name}
%define logdir %{_localstatedir}/log/%{name}
%define phpdir %{_datadir}/php
%define icingawebgroup icingaweb2
%package common
Summary: Common files for Icinga Web 2 and the Icinga CLI
Group: Applications/System
%description common
Common files for Icinga Web 2 and the Icinga CLI
%package -n php-Icinga
Summary: Icinga Web 2 PHP library
Group: Development/Libraries
Requires: %{php} >= 5.3.0
%description -n php-Icinga
Icinga Web 2 PHP library
%package -n icingacli %package -n icingacli
Summary: Icinga CLI Summary: Icinga CLI
Group: Applications/System Group: Applications/System
Requires: %{name} = %{version}-%{release} Requires: %{name}-common = %{version}-%{release}
Requires: php-Icinga Requires: php-Icinga = %{version}-%{release}
Requires: %{php_cli} >= 5.3.0
%description -n icingacli %description -n icingacli
Icinga CLI using php-Icinga Icinga Web 2 backend. Icinga CLI
%package -n php-Icinga
Summary: Icinga Web 2 PHP Libraries
Group: Applications/System
Requires: %{name} = %{version}-%{release}
Requires: %{phpname} >= 5.3.0
Requires: %{phpzendname}
%description -n php-Icinga %package vendor-dompdf
Icinga Web 2 PHP Libraries required by the web frontend and cli tool. Version: 0.6.1
Release: 1%{?dist}
Summary: Icinga Web 2 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%{?dist}
Summary: Icinga Web 2 vendor library HTMLPurifier
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%{?dist}
Summary: Icinga Web 2 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%{?dist}
Summary: Icinga Web 2 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%{?dist}
Summary: Icinga Web 2 vendor library Parsedown
Group: Development/Libraries
Requires: %{php} >= 5.3.0
%description vendor-Parsedown
Icinga Web 2 vendor library Parsedown
%package vendor-Zend
Version: 1.12.9
Release: 1%{?dist}
Summary: Icinga Web 2 vendor library Zend Framework
Group: Development/Libraries
Requires: %{php} >= 5.3.0
%description vendor-Zend
Icinga Web 2 vendor library Zend
%prep %prep
#VERSION=0.0.1; git archive --format=tar --prefix=icingaweb2-$VERSION/ HEAD | gzip >icingaweb2-$VERSION.tar.gz %setup -q
%setup -q -n %{name}-%{version}
%build %build
%install %install
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} rm -rf %{buildroot}
mkdir -p %{buildroot}/{%{basedir}/{modules,library,public},%{bindir},%{configdir},%{logdir},%{phpdir},%{wwwconfigdir}}
# prepare configuration for sub packages cp -prv application doc var %{buildroot}/%{basedir}
cp -prv modules/{monitoring,setup} %{buildroot}/%{basedir}/modules
# install rhel apache config cp -prv library/Icinga %{buildroot}/%{phpdir}
install -D -m0644 packages/files/apache/icingaweb.conf %{buildroot}/%{apacheconfdir}/icingaweb.conf cp -prv library/vendor %{buildroot}/%{basedir}/library
cp -prv public/{css,img,js,error_norewrite.html} %{buildroot}/%{basedir}/public
# install public, library, modules cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icingaweb2.conf
%{__mkdir} -p %{buildroot}/%{sharedir} cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir}
%{__mkdir} -p %{buildroot}/%{logdir} cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public
%{__mkdir} -p %{buildroot}/%{docdir}
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/dashboard
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/modules/monitoring
%{__mkdir} -p %{buildroot}/%{_sysconfdir}/%{name}/enabledModules
# make sure to install local icingacli for setup wizard token generation & webserver config
%{__cp} -r application doc library modules public bin %{buildroot}/%{sharedir}/
# enable the monitoring module by default
ln -s %{sharedir}/modules/monitoring %{buildroot}/%{_sysconfdir}/%{name}/enabledModules/monitoring
## config
# symlink icingacli
mkdir -p %{buildroot}/usr/bin
ln -sf %{sharedir}/bin/icingacli %{buildroot}/usr/bin/icingacli
%pre %pre
# Add apacheuser in the icingacmd group getent group icingacmd >/dev/null || groupadd -r icingacmd
# If the group exists, add the apacheuser in the icingacmd group. usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser}
# It is not neccessary that icinga2-web is installed on the same system as exit 0
# icinga and only on systems with icinga installed the icingacmd
# group exists. In all other cases the user used for ssh access has
# to be added to the icingacmd group on the remote icinga server.
getent group icingacmd > /dev/null
if [ $? -eq 0 ]; then
%{_sbindir}/usermod %{usermodparam} icingacmd %{apacheuser}
fi
%preun
%post
%clean %clean
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} rm -rf %{buildroot}
%files %files
# main dirs
%defattr(-,root,root) %defattr(-,root,root)
%doc etc/schema doc packages/RPM.md %{basedir}/application/controllers
%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/public %{basedir}/application/fonts
%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/modules %{basedir}/application/forms
# configs %{basedir}/application/layouts
%{basedir}/application/views
%{basedir}/doc
%{basedir}/modules
%{basedir}/public
%{wwwconfigdir}/icingaweb2.conf
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
%pre common
getent group %{icingawebgroup} >/dev/null || groupadd -r %{icingawebgroup}
exit 0
%files common
%defattr(-,root,root) %defattr(-,root,root)
%config(noreplace) %attr(-,root,root) %{apacheconfdir}/icingaweb.conf %{basedir}/application/locale
%config(noreplace) %attr(-,%{apacheuser},%{apachegroup}) %{configdir} %dir %{basedir}/modules
# logs %attr(2770,root,%{icingawebgroup}) %config(noreplace) %{configdir}
%attr(2775,%{apacheuser},%{apachegroup}) %dir %{logdir}
# shipped docs
%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/doc
%files -n php-Icinga %files -n php-Icinga
%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/application %defattr(-,root,root)
%attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/library %{phpdir}/Icinga
%files -n icingacli %files -n icingacli
%attr(0755,root,root) /usr/bin/icingacli %defattr(-,root,root)
%attr(0755,root,root) %{sharedir}/bin/icingacli %{basedir}/application/clicommands
%attr(0755,root,root) %{sharedir}/bin/license_writer.py %attr(0755,root,root) %{bindir}/icingacli
%changelog
%files vendor-dompdf
%defattr(-,root,root)
%{basedir}/library/vendor/dompdf
%files vendor-HTMLPurifier
%defattr(-,root,root)
%{basedir}/library/vendor/HTMLPurifier
%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
%files vendor-Zend
%defattr(-,root,root)
%{basedir}/library/vendor/Zend