Name: icingaweb2
Version: 2.12.3
Release: 1%{?dist}
Summary: Icinga Web

Group: Applications/System
License: GPLv2+
URL: https://icinga.com

Source0: icingaweb2-2.12.3.tgz
Source1: icingaweb2-rpm.tgz

BuildArch: noarch

Requires: httpd
Requires: php(httpd)

Requires: icingaweb2-common = 2.12.3-1%{?dist}
Requires: php-icinga = 2.12.3-1%{?dist}
Requires: icingacli = 2.12.3-1%{?dist}
Requires: icinga-l10n >= 1.1.0

%description
Lightweight and extensible web interface to tackle your monitoring challenge.

%prep
%autosetup
install -d sources
cd sources
tar -xzf %_topdir/SOURCES/icingaweb2-rpm.tgz
cd -

cd sources/SELinux
for selinuxvariant in mls targeted; 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

install -d %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/icingaweb2
cp -pr application doc library modules public schema %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/icingaweb2
install -dm 2770 %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/etc/icingaweb2 %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/etc/icingaweb2/{enabledModules,modules}
install -Dpm 0644 etc/bash_completion.d/icingacli %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/bash-completion/completions/icingacli
install -Dpm 0644 sources/index.php %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/icingaweb2/public/index.php
install -d %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/php
mv %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/icingaweb2/library/Icinga %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/php
install -dm 2770 %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/var/cache/icingaweb2 %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/var/lib/icingaweb2
install -dm 2775 %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/var/log/icingaweb2
install -Dpm 0644 sources/icingaweb2.conf %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/etc/httpd/conf.d/icingaweb2.conf
install -Dpm 0755 sources/icingacli %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/bin/icingacli
for selinuxvariant in mls targeted; do
install -Dpm 0644 sources/SELinux/icingaweb2.pp.${selinuxvariant} %_topdir/BUILDROOT/icingaweb2-2.12.3-1%{?dist}.%{_arch}/usr/share/selinux/${selinuxvariant}/icingaweb2.pp
done


%pre
getent group icingacmd >/dev/null || groupadd -r icingacmd
usermod -a -G icingacmd,icingaweb2 apache

%files
%doc CHANGELOG.md
%doc README.md
%docdir /usr/share/icingaweb2/doc
%license LICENSE
/usr/share/icingaweb2/application/controllers
/usr/share/icingaweb2/application/fonts
/usr/share/icingaweb2/application/forms
/usr/share/icingaweb2/application/layouts
/usr/share/icingaweb2/application/views
/usr/share/icingaweb2/application/VERSION
/usr/share/icingaweb2/doc
/usr/share/icingaweb2/modules
/usr/share/icingaweb2/public
/usr/share/icingaweb2/schema
%config(noreplace) /etc/httpd/conf.d/icingaweb2.conf

%package common
Summary: Common files for Icinga Web and the Icinga CLI

Requires(pre): shadow-utils

%description common
Manages common files for Icinga Web and the Icinga CLI.

%files common
%attr(-, -, icingaweb2) %dir /var/cache/icingaweb2
%attr(-, -, icingaweb2) %dir /var/log/icingaweb2
%attr(-, -, icingaweb2) %dir /var/lib/icingaweb2
%attr(-, -, icingaweb2) %config(noreplace) %dir /etc/icingaweb2
%attr(-, -, icingaweb2) %config(noreplace) %dir /etc/icingaweb2/modules
%attr(-, -, icingaweb2) %dir /etc/icingaweb2/enabledModules

%pre common
getent group icingaweb2 >/dev/null || groupadd -r icingaweb2

%package selinux
Summary: Icinga Web SELinux policy
BuildRequires: checkpolicy
BuildRequires: selinux-policy-devel
Requires: icingaweb2 = 2.12.3-1%{?dist}
Requires: selinux-policy

Requires(post): policycoreutils
Requires(postun): policycoreutils

%description selinux
SELinux policy for Icinga Web.

%files selinux
%license LICENSE
/usr/share/selinux/*/icingaweb2.pp

%post selinux
for selinuxvariant in mls targeted; do
/usr/sbin/semodule -s ${selinuxvariant} -i /usr/share/selinux/${selinuxvariant}/icingaweb2.pp &> /dev/null || true
done
/usr/sbin/fixfiles -R icingaweb2 restore || true
for dir in /var/log/icingaweb2 /var/lib/icingaweb2 /etc/icingaweb2; do
/usr/sbin/restorecon -R ${dir} || true
done

%postun selinux
if [ $1 -eq 0 ]; then
for selinuxvariant in mls targeted; do
/usr/sbin/semodule -s ${selinuxvariant} -r icingaweb2 &> /dev/null || true
done
/usr/sbin/fixfiles -R icingaweb2 restore || true
for dir in /var/log/icingaweb2 /var/lib/icingaweb2 /etc/icingaweb2; do
if [ -d ${dir} ]; then
/usr/sbin/restorecon -R ${dir} &> /dev/null || true
fi
done
fi

%package -n icingacli
Summary: Icinga CLI
Requires: php-cli
Requires: bash-completion
Requires: icingaweb2-common = 2.12.3-1%{?dist}
Requires: php-icinga = 2.12.3-1%{?dist}
Requires: icinga-l10n >= 1.1.0

%description -n icingacli
Icinga command line interface.

%files -n icingacli
%license LICENSE
/usr/share/icingaweb2/application/clicommands
/usr/share/bash-completion/completions/icingacli
/usr/bin/icingacli

%package -n php-icinga
Summary: Icinga Web PHP library
Group: Development/Libraries
Obsoletes: php-Icinga <= 2.12.3
Obsoletes: icingaweb2-vendor-dompdf <= 2.12.0
Obsoletes: icingaweb2-vendor-HTMLPurifier <= 1:2.12.0
Obsoletes: icingaweb2-vendor-JShrink <= 2.12.0
Obsoletes: icingaweb2-vendor-lessphp <= 2.12.0
Obsoletes: icingaweb2-vendor-Parsedown <= 2.12.0
Obsoletes: icingaweb2-vendor-zf1 <= 2.12.0
Requires: php-curl
Requires: php-dom
Requires: php-fileinfo
Requires: php-gd
Requires: php-gettext
Requires: php-intl
Requires: php-json
Requires: php-ldap
Requires: php-mbstring
Requires: php-openssl
Requires: php-pdo
Requires: php-pdo_mysql
Requires: php-pdo_pgsql

Requires: php-process

Requires: php-xml
Requires: icinga-php-library >= 0.13.2
Requires: icinga-php-thirdparty >= 0.12.0

%description -n php-icinga
Icinga Web PHP and vendor libraries.

%files -n php-icinga
%license LICENSE
/usr/share/php/Icinga

%changelog
* Wed Mar 26 2025 Icinga GmbH <info@icinga.com> - 2.12.3-1
- Version 2.12.3-1