]> granicus.if.org Git - icinga2/blob - icinga2.spec
Fix sending notifications for volatile checks on OK->OK changes
[icinga2] / icinga2.spec
1 #/******************************************************************************
2 # * Icinga 2                                                                   *
3 # * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)    *
4 # *                                                                            *
5 # * This program is free software; you can redistribute it and/or              *
6 # * modify it under the terms of the GNU General Public License                *
7 # * as published by the Free Software Foundation; either version 2             *
8 # * of the License, or (at your option) any later version.                     *
9 # *                                                                            *
10 # * This program is distributed in the hope that it will be useful,            *
11 # * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13 # * GNU General Public License for more details.                               *
14 # *                                                                            *
15 # * You should have received a copy of the GNU General Public License          *
16 # * along with this program; if not, write to the Free Software Foundation     *
17 # * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18 # ******************************************************************************/
19
20 %define revision 1
21
22 # make sure that _rundir is working on older systems
23 %if ! %{defined _rundir}
24 %define _rundir %{_localstatedir}/run
25 %endif
26
27 %define _libexecdir %{_prefix}/lib/
28
29 %if "%{_vendor}" == "redhat"
30 %define apachename httpd
31 %define apacheconfdir %{_sysconfdir}/httpd/conf.d
32 %define apacheuser apache
33 %define apachegroup apache
34 %if 0%{?el5}%{?el6}
35 %define use_systemd 0
36 %if %(uname -m) != "x86_64"
37 %define march_flag -march=i686
38 %endif
39 %else
40 # fedora and el>=7
41 %define use_systemd 1
42 %endif
43 %endif
44
45 %if "%{_vendor}" == "suse"
46 %define apachename apache2
47 %define apacheconfdir  %{_sysconfdir}/apache2/conf.d
48 %define apacheuser wwwrun
49 %define apachegroup www
50 %if 0%{?suse_version} >= 1310
51 %define use_systemd 1
52 %else
53 %define use_systemd 0
54 %endif
55 %endif
56
57 %define icinga_user icinga
58 %define icinga_group icinga
59 %define icingacmd_group icingacmd
60 %define icingaweb2name icingaweb2
61 %define icingaweb2version 2.0.0
62
63 %define icingaclassicconfdir %{_sysconfdir}/icinga
64
65 %define logmsg logger -t %{name}/rpm
66
67 Summary: Network monitoring application
68 Name: icinga2
69 Version: 2.2.2
70 Release: %{revision}%{?dist}
71 License: GPL-2.0+
72 Group: Applications/System
73 Source: https://github.com/Icinga/%{name}/archive/v%{version}.tar.gz
74 URL: http://www.icinga.org/
75 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
76 Requires: %{name}-bin = %{version}-%{release}
77
78 %description
79 Meta package for Icinga 2 Core, DB IDO and Web.
80
81 %package bin
82 Summary:      Icinga 2 binaries and libraries
83 Group:        Applications/System
84
85 %if "%{_vendor}" == "suse"
86 PreReq:        permissions
87 Provides:      monitoring_daemon
88 Recommends:    monitoring-plugins
89 %if 0%{?suse_version} >= 1310
90 BuildRequires: libyajl-devel
91 %endif
92 %endif
93 BuildRequires: openssl-devel
94 BuildRequires: gcc-c++
95 BuildRequires: libstdc++-devel
96 BuildRequires: cmake
97 BuildRequires: flex >= 2.5.35
98 BuildRequires: bison
99 BuildRequires: make
100 BuildRequires: readline-devel
101 BuildRequires: ncurses-devel
102
103 %if "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
104 # el5 requires packages.icinga.org
105 BuildRequires: boost153-devel
106 %else
107 %if "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
108 # sles 11 sp3 requires packages.icinga.org
109 BuildRequires: boost153-devel
110 %else
111 BuildRequires: boost-devel >= 1.41
112 %endif
113 %endif
114
115 %if 0%{?use_systemd}
116 BuildRequires: systemd
117 Requires: systemd
118 %endif
119
120 Requires: %{name}-common = %{version}-%{release}
121
122 %description bin
123 Icinga 2 is a general-purpose network monitoring application.
124 Provides binaries and libraries for Icinga 2 Core.
125
126 %package common
127 Summary:      Common Icinga 2 configuration
128 Group:        Applications/System
129 %if "%{_vendor}" == "redhat"
130 Requires(pre): shadow-utils
131 Requires(post): shadow-utils
132 %endif
133 %if "%{_vendor}" == "suse"
134 Recommends:   logrotate
135 %endif
136
137 %description common
138 Provides common directories, uid and gid among Icinga 2 related
139 packages.
140
141
142 %package doc
143 Summary:      Documentation for Icinga 2
144 Group:        Applications/System
145 Requires:     %{name} = %{version}-%{release}
146
147 %description doc
148 Provides documentation for Icinga 2.
149
150
151 %package ido-mysql
152 Summary:      IDO MySQL database backend for Icinga 2
153 Group:        Applications/System
154 %if "%{_vendor}" == "suse"
155 BuildRequires: libmysqlclient-devel
156 %endif
157 BuildRequires: mysql-devel
158 Requires: %{name} = %{version}-%{release}
159
160 %description ido-mysql
161 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
162 IDOUtils schema >= 1.12
163
164
165 %package ido-pgsql
166 Summary:      IDO PostgreSQL database backend for Icinga 2
167 Group:        Applications/System
168 BuildRequires: postgresql-devel
169 Requires: %{name} = %{version}-%{release}
170
171 %description ido-pgsql
172 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
173 IDOUtils schema >= 1.12
174
175
176 %package classicui-config
177 Summary:      Icinga 2 Classic UI Standalone configuration
178 Group:        Applications/System
179 BuildRequires: %{apachename}
180 Requires:     %{apachename}
181 Requires:     %{name} = %{version}-%{release}
182 %if "%{_vendor}" == "suse"
183 Recommends:   icinga-www
184 %endif
185 Provides:     icinga-classicui-config
186 Conflicts:    icinga-gui-config
187
188 %description classicui-config
189 Icinga 1.x Classic UI Standalone configuration with locations
190 for Icinga 2.
191
192
193 %prep
194 %setup -q -n %{name}-%{version}
195
196 %build
197 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
198          -DCMAKE_INSTALL_SYSCONFDIR=/etc \
199          -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
200          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
201          -DCMAKE_VERBOSE_MAKEFILE=ON \
202          -DBoost_NO_BOOST_CMAKE=ON \
203          -DICINGA2_RUNDIR=%{_rundir} \
204          -DICINGA2_USER=%{icinga_user} \
205          -DICINGA2_GROUP=%{icinga_group} \
206          -DICINGA2_COMMAND_GROUP=%{icingacmd_group} \
207          -DICINGA2_UNITY_BUILD=TRUE"
208 %if "%{_vendor}" == "redhat"
209 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
210 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
211 # details in https://dev.icinga.org/issues/5033
212 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
213  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
214  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
215  -DBoost_NO_SYSTEM_PATHS=TRUE \
216  -DBUILD_TESTING=FALSE \
217  -DBoost_NO_BOOST_CMAKE=TRUE"
218 %endif
219 %endif
220
221 %if "%{_vendor}" != "suse"
222 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
223 %else
224 %if 0%{?suse_version} < 1310
225 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
226  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
227  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
228  -DBoost_NO_SYSTEM_PATHS=TRUE \
229  -DBUILD_TESTING=FALSE \
230  -DBoost_NO_BOOST_CMAKE=TRUE"
231 %endif
232 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
233 %endif
234
235 %if 0%{?use_systemd}
236 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
237 %endif
238
239 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
240
241 make %{?_smp_mflags}
242
243
244 %install
245 make install \
246         DESTDIR="%{buildroot}"
247
248 # install classicui config
249 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
250 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
251 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
252
253 # remove features-enabled symlinks
254 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
255
256 # enable suse rc links
257 %if "%{_vendor}" == "suse"
258 %if 0%{?use_systemd}
259   ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
260 %else
261   ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
262 %endif
263 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
264 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
265 %endif
266
267
268 %clean
269 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
270
271 %pre common
272 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
273 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
274 getent passwd %{icinga_user} >/dev/null || %{_sbindir}/useradd -c "icinga" -s /sbin/nologin -r -d %{_localstatedir}/spool/%{name} -G %{icingacmd_group} -g %{icinga_group} %{icinga_user}
275
276 %if "%{_vendor}" == "suse"
277 %if 0%{?use_systemd}
278   %service_add_pre %{name}.service
279 %endif
280 %endif
281 exit 0
282
283 %if "%{_vendor}" == "suse"
284 %verifyscript bin
285 %verify_permissions -e %{_rundir}/%{name}/cmd
286
287 %if 0%{?suse_version} >= 1310
288 %post bin
289 %set_permissions %{_rundir}/%{name}/cmd
290 %endif
291 %endif
292
293 %post common
294 # suse
295 %if "%{_vendor}" == "suse"
296 %if 0%{?use_systemd}
297 %fillup_only  %{name}
298 %service_add_post %{name}.service
299 %else
300 %fillup_and_insserv %{name}
301 %endif
302
303 # initial installation, enable default features
304 for feature in checker notification mainlog; do
305         ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
306 done
307
308 exit 0
309
310 %else
311 # rhel
312
313 %if 0%{?use_systemd}
314 %systemd_post %{name}.service
315 %else
316 /sbin/chkconfig --add %{name}
317 %endif
318
319 if [ ${1:-0} -eq 1 ]
320 then
321         # initial installation, enable default features
322         for feature in checker notification mainlog; do
323                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
324         done
325 fi
326
327 exit 0
328
329 %endif
330 # suse/rhel
331
332 %postun common
333 # suse
334 %if "%{_vendor}" == "suse"
335 %if 0%{?using_systemd}
336   %service_del_postun %{name}.service
337 %else
338   %restart_on_update %{name}
339   %insserv_cleanup
340 %endif
341
342 %else
343 # rhel
344
345 %if 0%{?use_systemd}
346 %systemd_postun_with_restart %{name}.service
347 %else
348 if [ "$1" -ge  "1" ]; then
349         /sbin/service %{name} condrestart >/dev/null 2>&1 || :
350 fi
351 %endif
352
353 %endif
354 # suse / rhel
355
356 if [ "$1" = "0" ]; then
357         # deinstallation of the package - remove enabled features
358         rm -rf %{_sysconfdir}/%{name}/features-enabled
359 fi
360
361 exit 0
362
363 %preun common
364 # suse
365 %if "%{_vendor}" == "suse"
366
367 %if 0%{?use_systemd}
368   %service_del_preun %{name}.service
369 %else
370   %stop_on_removal %{name}
371 %endif
372
373 exit 0
374
375 %else
376 # rhel
377
378 %if 0%{?use_systemd}
379 %systemd_preun %{name}.service
380 %else
381 if [ "$1" = "0" ]; then
382         /sbin/service %{name} stop > /dev/null 2>&1 || :
383         /sbin/chkconfig --del %{name} || :
384 fi
385 %endif
386
387 exit 0
388
389 %endif
390 # suse / rhel
391
392 %post ido-mysql
393 if [ ${1:-0} -eq 1 ]
394 then
395         # initial installation, enable ido-mysql feature
396         ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
397 fi
398
399 exit 0
400
401 %postun ido-mysql
402 if [ "$1" = "0" ]; then
403         # deinstallation of the package - remove feature
404         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
405 fi
406
407 exit 0
408
409 %post ido-pgsql
410 if [ ${1:-0} -eq 1 ]
411 then
412         # initial installation, enable ido-pgsql feature
413         ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
414 fi
415
416 exit 0
417
418 %postun ido-pgsql
419 if [ "$1" = "0" ]; then
420         # deinstallation of the package - remove feature
421         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
422 fi
423
424 exit 0
425
426 %post classicui-config
427 if [ ${1:-0} -eq 1 ]
428 then
429         # initial installation, enable features
430         for feature in statusdata compatlog command; do
431                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
432         done
433 fi
434
435 exit 0
436
437 %postun classicui-config
438 if [ "$1" = "0" ]; then
439         # deinstallation of the package - remove feature
440         for feature in statusdata compatlog command; do
441                 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
442         done
443 fi
444
445 exit 0
446
447 %files
448 %defattr(-,root,root,-)
449 %doc COPYING
450
451 %files bin
452 %defattr(-,root,root,-)
453 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
454 %{_sbindir}/%{name}
455 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
456 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
457 %dir %{_libdir}/%{name}
458 %{_libdir}/%{name}/*.so*
459 %{_datadir}/%{name}
460 %exclude %{_datadir}/%{name}/include
461 %{_mandir}/man8/%{name}.8.gz
462
463 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
464 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
465 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
466 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
467 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
468 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
469
470 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
471 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
472
473 %files common
474 %defattr(-,root,root,-)
475 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
476 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
477 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
478 %{_sysconfdir}/bash_completion.d/%{name}
479 %if 0%{?use_systemd}
480 %attr(644,root,root) %{_unitdir}/%{name}.service
481 %else
482 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
483 %endif
484 %if "%{_vendor}" == "suse"
485 %{_sbindir}/rc%{name}
486 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
487 %else
488 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
489 %endif
490 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
492 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
493 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
494 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
495 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
496 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
497 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
498 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
499 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
500 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
501 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
502 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
503 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
504 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
505 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
506 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
507 %dir %{_libexecdir}/%{name}
508 %{_libexecdir}/%{name}/prepare-dirs
509 %{_libexecdir}/%{name}/safe-reload
510 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
511 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
512 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
513 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
514 %{_datadir}/%{name}/include
515
516 %files doc
517 %defattr(-,root,root,-)
518 %{_datadir}/doc/%{name}
519 %docdir %{_datadir}/doc/%{name}
520
521 %files ido-mysql
522 %defattr(-,root,root,-)
523 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
524 %{_libdir}/%{name}/libdb_ido_mysql*
525 %{_datadir}/icinga2-ido-mysql
526
527 %files ido-pgsql
528 %defattr(-,root,root,-)
529 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
530 %{_libdir}/%{name}/libdb_ido_pgsql*
531 %{_datadir}/icinga2-ido-pgsql
532
533 %files classicui-config
534 %defattr(-,root,root,-)
535 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
536 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
537 %config(noreplace) %{apacheconfdir}/icinga.conf
538 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
539
540 %changelog