#/******************************************************************************
# * Icinga 2 *
-# * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
+# * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
# * *
# * This program is free software; you can redistribute it and/or *
# * modify it under the terms of the GNU General Public License *
Summary: Network monitoring application
Name: icinga2
-Version: 2.3.4
+Version: 2.6.2
Release: %{revision}%{?dist}
License: GPL-2.0+
Group: Applications/System
Source: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
-URL: https://www.icinga.org/
+URL: https://www.icinga.com/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: %{name}-bin = %{version}-%{release}
BuildRequires: libyajl-devel
%endif
%endif
-BuildRequires: openssl-devel
+BuildRequires: libedit-devel
+BuildRequires: ncurses-devel
+%if "%{_vendor}" == "suse" && 0%{?suse_version} < 1210
+BuildRequires: gcc48-c++
+BuildRequires: libstdc++48-devel
+BuildRequires: libopenssl1-devel
+%else
BuildRequires: gcc-c++
BuildRequires: libstdc++-devel
+BuildRequires: openssl-devel
+%endif
BuildRequires: cmake
BuildRequires: flex >= 2.5.35
BuildRequires: bison
BuildRequires: make
+%if 0%{?fedora}
+BuildRequires: wxGTK3-devel
+%endif
-%if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
-# el5 requires packages.icinga.org
+%if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+# el5 and el6 require packages.icinga.com
BuildRequires: boost153-devel
%else
%if 0%{?build_icinga_org} && "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
-# sles 11 sp3 requires packages.icinga.org
+# sles 11 sp3 requires packages.icinga.com
BuildRequires: boost153-devel
%else
BuildRequires: boost-devel >= 1.41
Requires: systemd
%endif
-Requires: %{name}-common = %{version}-%{release}
+Requires: %{name}-libs = %{version}-%{release}
%description bin
Icinga 2 is a general-purpose network monitoring application.
-Provides binaries and libraries for Icinga 2 Core.
+Provides binaries for Icinga 2 Core.
%package common
Summary: Common Icinga 2 configuration
Provides documentation for Icinga 2.
+%package libs
+Summary: Libraries for Icinga 2
+Group: Applications/System
+Requires: %{name}-common = %{version}-%{release}
+
+%description libs
+Provides internal libraries for the daemon or studio.
+
+
%package ido-mysql
Summary: IDO MySQL database backend for Icinga 2
Group: Applications/System
%if "%{_vendor}" == "suse"
BuildRequires: libmysqlclient-devel
+%if 0%{?suse_version} >= 1310
+BuildRequires: mysql-devel
%endif
+
+%else
BuildRequires: mysql-devel
+%endif #suse
+
Requires: %{name} = %{version}-%{release}
%description ido-mysql
%package ido-pgsql
Summary: IDO PostgreSQL database backend for Icinga 2
Group: Applications/System
+%if "%{_vendor}" == "suse" && 0%{?suse_version} < 1210
+BuildRequires: postgresql-devel >= 8.4
+%else
BuildRequires: postgresql-devel
+%endif
Requires: %{name} = %{version}-%{release}
%description ido-pgsql
Icinga 1.x Classic UI Standalone configuration with locations
for Icinga 2.
+%if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+%global selinux_variants mls targeted
+%{!?_selinux_policy_version: %global _selinux_policy_version %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2>/dev/null)}
+%global modulename %{name}
+
+%package selinux
+Summary: SELinux policy module supporting icinga2
+Group: System Environment/Base
+BuildRequires: checkpolicy, selinux-policy-devel, /usr/share/selinux/devel/policyhelp, hardlink
+%if "%{_selinux_policy_version}" != ""
+Requires: selinux-policy >= %{_selinux_policy_version}
+%endif
+Requires: %{name} = %{version}-%{release}
+Requires(post): /usr/sbin/semodule, /sbin/restorecon
+Requires(postun): /usr/sbin/semodule, /sbin/restorecon
+
+%description selinux
+SELinux policy module supporting icinga2
+%endif
+
+
+%if 0%{?fedora}
+%package studio
+Summary: Studio for Icinga 2
+Group: Applications/System
+Requires: %{name}-libs = %{version}-%{release}
+Requires: wxGTK3
+
+%description studio
+Provides a GUI for the Icinga 2 API.
+%endif
+
+
+%package -n vim-icinga2
+Summary: Vim syntax highlighting for icinga2
+Group: Applications/System
+%if "%{_vendor}" == "suse"
+Requires: vim-data
+%else
+Requires: vim-filesystem
+%endif
+
+%description -n vim-icinga2
+Vim syntax highlighting for icinga2
+
+
+%package -n nano-icinga2
+Summary: Nano syntax highlighting for icinga2
+Group: Applications/System
+Requires: nano
+
+%description -n nano-icinga2
+Nano syntax highlighting for icinga2
%prep
%setup -q -n %{name}-%{version}
-DCMAKE_INSTALL_SYSCONFDIR=/etc \
-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DICINGA2_LTO_BUILD=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DBoost_NO_BOOST_CMAKE=ON \
-DICINGA2_RUNDIR=%{_rundir} \
-DICINGA2_USER=%{icinga_user} \
-DICINGA2_GROUP=%{icinga_group} \
-DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
+%if 0%{?fedora}
+CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_WITH_STUDIO=true"
+%endif
%if "%{_vendor}" == "redhat"
-%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
+%if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
# Boost_VERSION 1.41.0 vs 101400 - disable build tests
-# details in https://dev.icinga.org/issues/5033
+# details in https://dev.icinga.com/issues/5033
CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
-DBOOST_INCLUDEDIR=/usr/include/boost153 \
-DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
-DBUILD_TESTING=FALSE \
-DBoost_NO_BOOST_CMAKE=TRUE"
%endif
+%if 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
+CMAKE_OPTS="$CMAKE_OPTS -DBUILD_TESTING=FALSE"
+%endif
%endif
%if "%{_vendor}" != "suse"
make %{?_smp_mflags}
+%if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+cd tools/selinux
+for selinuxvariant in %{selinux_variants}
+do
+ make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile
+ mv %{modulename}.pp %{modulename}.pp.${selinuxvariant}
+ make NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
+done
+cd -
+%endif
%install
make install \
mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
%endif
+%if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+cd tools/selinux
+for selinuxvariant in %{selinux_variants}
+do
+ install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
+ install -p -m 644 %{modulename}.pp.${selinuxvariant} \
+ %{buildroot}%{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp
+done
+cd -
+
+/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
+%endif
+
+%if 0%{?fedora}
+mkdir -p "%{buildroot}%{_datadir}/icinga2-studio"
+install -p -m 644 icinga-studio/icinga.ico %{buildroot}%{_datadir}/icinga2-studio
+
+mkdir -p "%{buildroot}%{_datadir}/applications"
+echo "[Desktop Entry]
+Name=Icinga 2 Studio
+Comment=API viewer for Icinga 2
+TryExec=icinga-studio
+Exec=icinga-studio
+Icon=/usr/share/icinga2-studio/icinga.ico
+StartupNotify=true
+Terminal=false
+Type=Application
+Categories=GTK;Utility;
+Keywords=Monitoring;" > %{buildroot}%{_datadir}/applications/icinga2-studio.desktop
+%endif
+
+%if "%{_vendor}" == "suse"
+%if 0%{?suse_version} >= 1310
+install -D -m 0644 tools/syntax/vim/syntax/%{name}.vim %{buildroot}%{_datadir}/vim/vim74/syntax/%{name}.vim
+install -D -m 0644 tools/syntax/vim/ftdetect/%{name}.vim %{buildroot}%{_datadir}/vim/vim74/ftdetect/%{name}.vim
+%else
+install -D -m 0644 tools/syntax/vim/syntax/%{name}.vim %{buildroot}%{_datadir}/vim/vim72/syntax/%{name}.vim
+install -D -m 0644 tools/syntax/vim/ftdetect/%{name}.vim %{buildroot}%{_datadir}/vim/vim72/ftdetect/%{name}.vim
+%endif
+%else
+install -D -m 0644 tools/syntax/vim/syntax/%{name}.vim %{buildroot}%{_datadir}/vim/vimfiles/syntax/%{name}.vim
+install -D -m 0644 tools/syntax/vim/ftdetect/%{name}.vim %{buildroot}%{_datadir}/vim/vimfiles/ftdetect/%{name}.vim
+%endif
+
+install -D -m 0644 tools/syntax/nano/%{name}.nanorc %{buildroot}%{_datadir}/nano/%{name}.nanorc
%clean
[ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
%service_add_pre %{name}.service
%endif
%endif
-exit 0
%if "%{_vendor}" == "suse"
%verifyscript bin
%verify_permissions -e %{_rundir}/%{name}/cmd
+%endif
-%if 0%{?suse_version} >= 1310
%post bin
+
+# suse
+%if "%{_vendor}" == "suse"
+
+%if 0%{?suse_version} >= 1310
%set_permissions %{_rundir}/%{name}/cmd
%endif
-%endif
+
+%endif #suse/rhel
%post common
# suse
exit 0
+%if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+%post selinux
+for selinuxvariant in %{selinux_variants}
+do
+ /usr/sbin/semodule -s ${selinuxvariant} -i \
+ %{_datadir}/selinux/${selinuxvariant}/%{modulename}.pp &> /dev/null || :
+done
+/sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
+/sbin/fixfiles -R icinga2-common restore &> /dev/null || :
+/sbin/semanage port -a -t icinga2_port_t -p tcp 5665 &> /dev/null || :
+
+%postun selinux
+if [ $1 -eq 0 ] ; then
+ /sbin/semanage port -d -t icinga2_port_t -p tcp 5665 &> /dev/null || :
+ for selinuxvariant in %{selinux_variants}
+ do
+ /usr/sbin/semodule -s ${selinuxvariant} -r %{modulename} &> /dev/null || :
+ done
+ /sbin/fixfiles -R icinga2-bin restore &> /dev/null || :
+ /sbin/fixfiles -R icinga2-common restore &> /dev/null || :
+fi
+%endif
+
+
%files
%defattr(-,root,root,-)
%doc COPYING
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
%{_sbindir}/%{name}
-%exclude %{_libdir}/%{name}/libdb_ido_mysql*
-%exclude %{_libdir}/%{name}/libdb_ido_pgsql*
-%dir %{_libdir}/%{name}
-%{_libdir}/%{name}/*.so*
+%dir %{_libdir}/%{name}/sbin
+%{_libdir}/%{name}/sbin/%{name}
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/include
%{_mandir}/man8/%{name}.8.gz
%attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
%attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
+%files libs
+%defattr(-,root,root,-)
+%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
+%exclude %{_libdir}/%{name}/libdb_ido_mysql*
+%exclude %{_libdir}/%{name}/libdb_ido_pgsql*
+%dir %{_libdir}/%{name}
+%{_libdir}/%{name}/*.so*
+
%files common
%defattr(-,root,root,-)
%doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
%else
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%endif
-%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
+%attr(0750,root,%{icinga_group}) %dir %{_sysconfdir}/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
%exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
-%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
+%config(noreplace) %attr(0640,root,%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
%config(noreplace) %{apacheconfdir}/icinga.conf
%config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
+%if "%{_vendor}" == "redhat" && !(0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
+%files selinux
+%defattr(-,root,root,0755)
+%doc tools/selinux/*
+%{_datadir}/selinux/*/%{modulename}.pp
+%endif
+
+%if 0%{?fedora}
+%files studio
+%defattr(-,root,root,-)
+%{_bindir}/icinga-studio
+%{_datadir}/icinga2-studio
+%{_datadir}/applications/icinga2-studio.desktop
+%endif
+
+%files -n vim-icinga2
+%defattr(-,root,root,-)
+%if "%{_vendor}" == "suse"
+%if 0%{?suse_version} >= 1310
+%{_datadir}/vim/vim74/syntax/%{name}.vim
+%{_datadir}/vim/vim74/ftdetect/%{name}.vim
+%else
+%{_datadir}/vim/vim72/syntax/%{name}.vim
+%{_datadir}/vim/vim72/ftdetect/%{name}.vim
+%endif
+%else
+%{_datadir}/vim/vimfiles/syntax/%{name}.vim
+%{_datadir}/vim/vimfiles/ftdetect/%{name}.vim
+%endif
+
+%files -n nano-icinga2
+%defattr(-,root,root,-)
+%{_datadir}/nano/%{name}.nanorc
+
%changelog