You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
6.5 KiB

%define selinux_variants mls targeted
%define php php
%define php_cli php-cli
%define php_common php-common
%define wwwconfigdir %{_sysconfdir}/httpd/conf.d
%define wwwuser apache
%define php_version 8.0.0
%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}
Name: icingaweb2
Version: 2.12.2
Release: 1%{?dist}
Summary: Icinga Web 2
Group: Applications/System
License: GPLv2+ and MIT and BSD
URL: https://icinga.com
Source0: https://github.com/Icinga/icingaweb2/archive/refs/tags/v%{version}.tar.gz
Source1: icingaweb2.te
Source2: icingaweb2.if
Source3: icingaweb2.fc
Source4: icingacli
Source5: icingaweb2.conf
Source6: icingaweb2.index.php
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
Requires: %{php}-mysqlnd
Requires: %{php}-pgsql
Requires: %{php}-ldap
Requires(pre): shadow-utils
Requires: php >= %{php_version}
Requires: php-common >= %{php_version}
Requires: icinga-l10n >= 1.0.0
Requires: icingacli = %{version}-%{release}
Requires: %{name}-common = %{version}-%{release}
Requires: php-icinga = %{version}-%{release}
%description
Icinga Web 2
%package common
Summary: Common files for Icinga Web 2 and the Icinga CLI
Group: Applications/System
Requires(pre): shadow-utils
%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-common >= %{php_version}
Requires: php-gd
Requires: php-intl
Requires: php-mbstring
Requires: php-json
#Requires: php-pecl-imagick
Provides: php-Icinga
%description -n php-icinga
Icinga Web 2 PHP library
%package -n icingacli
Summary: Icinga CLI
Group: Applications/System
Requires: icinga-l10n
Requires: %{name}-common = %{version}-%{release}
Requires: php-icinga = %{version}-%{release}
Requires: bash-completion
Requires: php-cli >= %{php_version}
%description -n icingacli
Icinga CLI
%package selinux
Summary: SELinux policy for Icinga Web 2
BuildRequires: checkpolicy, selinux-policy-devel, hardlink
Requires: %{name} = %{version}-%{release}
Requires(post): policycoreutils
Requires(postun): policycoreutils
%description selinux
SELinux policy for Icinga Web 2
%prep
%setup -q
mkdir selinux
cp -p %{SOURCE1} selinux
cp -p %{SOURCE2} selinux
cp -p %{SOURCE3} selinux
%build
cd selinux
for selinuxvariant in %{selinux_variants}
do
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
mv icingaweb2.pp icingaweb2.pp.${selinuxvariant}
make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
done
cd -
%install
rm -rf %{buildroot}
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/{monitoring,setup,doc,translation} %{buildroot}/%{basedir}/modules
cp -prv library/Icinga %{buildroot}/%{phpdir}
cp -prv public/{css,font,img,js,error_norewrite.html,error_unavailable.html} %{buildroot}/%{basedir}/public
cp -pv %{SOURCE5} %{buildroot}/%{wwwconfigdir}/icingaweb2.conf
cp -pv %{SOURCE4} %{buildroot}/%{bindir}
%if 0%{?php_bin:1}
sed -i '1 s~#!.*~#!%{php_bin}~' %{buildroot}/%{bindir}/icingacli
%endif
cp -pv %{SOURCE6} %{buildroot}/%{basedir}/public/index.php
cp -prv schema %{buildroot}/%{docsdir}
#cp -prv packages/files/config/modules/{setup,translation} %{buildroot}/%{configdir}/modules
cd selinux
for selinuxvariant in %{selinux_variants}
do
install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
install -p -m 644 icingaweb2.pp.${selinuxvariant} %{buildroot}%{_datadir}/selinux/${selinuxvariant}/icingaweb2.pp
done
cd -
%pre
getent group icingacmd >/dev/null || groupadd -r icingacmd
usermod -a -G icingacmd,%{icingawebgroup} %{wwwuser}
exit 0
%clean
rm -rf %{buildroot}
%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
%config(noreplace) %{wwwconfigdir}/icingaweb2.conf
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
%{docsdir}
%docdir %{docsdir}
%pre common
getent group %{icingawebgroup} >/dev/null || groupadd -r %{icingawebgroup}
exit 0
%files common
%defattr(-,root,root)
%dir %{basedir}
%dir %{basedir}/application
%dir %{basedir}/library
%dir %{basedir}/library/vendor
%dir %{basedir}/modules
#%{basedir}/application/locale
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules
%files -n php-icinga
%defattr(-,root,root)
%{phpdir}/Icinga
%files -n icingacli
%defattr(-,root,root)
%{basedir}/application/clicommands
%{_sysconfdir}/bash_completion.d/icingacli
%attr(0755,root,root) %{bindir}/icingacli
%post selinux
for selinuxvariant in %{selinux_variants}
do
%{_sbindir}/semodule -s ${selinuxvariant} -i %{_datadir}/selinux/${selinuxvariant}/icingaweb2.pp &> /dev/null || :
done
%{_sbindir}/restorecon -R %{basedir} &> /dev/null || :
%{_sbindir}/restorecon -R %{configdir} &> /dev/null || :
%{_sbindir}/restorecon -R %{logdir} &> /dev/null || :
%postun selinux
if [ $1 -eq 0 ] ; then
for selinuxvariant in %{selinux_variants}
do
%{_sbindir}/semodule -s ${selinuxvariant} -r icingaweb2 &> /dev/null || :
done
[ -d %{basedir} ] && %{_sbindir}/restorecon -R %{basedir} &> /dev/null || :
[ -d %{configdir} ] && %{_sbindir}/restorecon -R %{configdir} &> /dev/null || :
[ -d %{logdir} ] && %{_sbindir}/restorecon -R %{logdir} &> /dev/null || :
fi
%files selinux
%defattr(-,root,root,0755)
%doc selinux/*
%{_datadir}/selinux/*/icingaweb2.pp
%changelog