]> granicus.if.org Git - icinga2/blob - icinga2.spec
Add timestamp option for checkresult test script
[icinga2] / icinga2.spec
1 #/******************************************************************************
2 # * Icinga 2                                                                   *
3 # * Copyright (C) 2012-2015 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.3.4
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: https://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: libedit-devel
94 BuildRequires: ncurses-devel
95 BuildRequires: openssl-devel
96 BuildRequires: gcc-c++
97 BuildRequires: libstdc++-devel
98 BuildRequires: cmake
99 BuildRequires: flex >= 2.5.35
100 BuildRequires: bison
101 BuildRequires: make
102
103 %if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6")
104 # el5 and el6 require packages.icinga.org
105 BuildRequires: boost153-devel
106 %else
107 %if 0%{?build_icinga_org} && "%{_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 %if "%{_vendor}" == "redhat"
208 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5" || 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
209 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
210 # details in https://dev.icinga.org/issues/5033
211 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
212  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
213  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
214  -DBoost_NO_SYSTEM_PATHS=TRUE \
215  -DBUILD_TESTING=FALSE \
216  -DBoost_NO_BOOST_CMAKE=TRUE"
217 %endif
218 %if 0%{?el6} || 0%{?rhel} == 6 || "%{?dist}" == ".el6"
219 CMAKE_OPTS="$CMAKE_OPTS -DBUILD_TESTING=FALSE"
220 %endif
221 %endif
222
223 %if "%{_vendor}" != "suse"
224 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
225 %else
226 %if 0%{?suse_version} < 1310
227 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
228  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
229  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
230  -DBoost_NO_SYSTEM_PATHS=TRUE \
231  -DBUILD_TESTING=FALSE \
232  -DBoost_NO_BOOST_CMAKE=TRUE"
233 %endif
234 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
235 %endif
236
237 %if 0%{?use_systemd}
238 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
239 %endif
240
241 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
242
243 make %{?_smp_mflags}
244
245
246 %install
247 make install \
248         DESTDIR="%{buildroot}"
249
250 # install classicui config
251 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
252 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
253 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
254
255 # remove features-enabled symlinks
256 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
257
258 # enable suse rc links
259 %if "%{_vendor}" == "suse"
260 %if 0%{?use_systemd}
261   ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
262 %else
263   ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
264 %endif
265 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
266 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
267 %endif
268
269
270 %clean
271 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
272
273 %pre common
274 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
275 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
276 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}
277
278 %if "%{_vendor}" == "suse"
279 %if 0%{?use_systemd}
280   %service_add_pre %{name}.service
281 %endif
282 %endif
283 exit 0
284
285 %if "%{_vendor}" == "suse"
286 %verifyscript bin
287 %verify_permissions -e %{_rundir}/%{name}/cmd
288
289 %if 0%{?suse_version} >= 1310
290 %post bin
291 %set_permissions %{_rundir}/%{name}/cmd
292 %endif
293 %endif
294
295 %post common
296 # suse
297 %if "%{_vendor}" == "suse"
298 %if 0%{?use_systemd}
299 %fillup_only  %{name}
300 %service_add_post %{name}.service
301 %else
302 %fillup_and_insserv %{name}
303 %endif
304
305 # initial installation, enable default features
306 for feature in checker notification mainlog; do
307         ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
308 done
309
310 exit 0
311
312 %else
313 # rhel
314
315 %if 0%{?use_systemd}
316 %systemd_post %{name}.service
317 %else
318 /sbin/chkconfig --add %{name}
319 %endif
320
321 if [ ${1:-0} -eq 1 ]
322 then
323         # initial installation, enable default features
324         for feature in checker notification mainlog; do
325                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
326         done
327 fi
328
329 exit 0
330
331 %endif
332 # suse/rhel
333
334 %postun common
335 # suse
336 %if "%{_vendor}" == "suse"
337 %if 0%{?using_systemd}
338   %service_del_postun %{name}.service
339 %else
340   %restart_on_update %{name}
341   %insserv_cleanup
342 %endif
343
344 %else
345 # rhel
346
347 %if 0%{?use_systemd}
348 %systemd_postun_with_restart %{name}.service
349 %else
350 if [ "$1" -ge  "1" ]; then
351         /sbin/service %{name} condrestart >/dev/null 2>&1 || :
352 fi
353 %endif
354
355 %endif
356 # suse / rhel
357
358 if [ "$1" = "0" ]; then
359         # deinstallation of the package - remove enabled features
360         rm -rf %{_sysconfdir}/%{name}/features-enabled
361 fi
362
363 exit 0
364
365 %preun common
366 # suse
367 %if "%{_vendor}" == "suse"
368
369 %if 0%{?use_systemd}
370   %service_del_preun %{name}.service
371 %else
372   %stop_on_removal %{name}
373 %endif
374
375 exit 0
376
377 %else
378 # rhel
379
380 %if 0%{?use_systemd}
381 %systemd_preun %{name}.service
382 %else
383 if [ "$1" = "0" ]; then
384         /sbin/service %{name} stop > /dev/null 2>&1 || :
385         /sbin/chkconfig --del %{name} || :
386 fi
387 %endif
388
389 exit 0
390
391 %endif
392 # suse / rhel
393
394 %post ido-mysql
395 if [ ${1:-0} -eq 1 ]
396 then
397         # initial installation, enable ido-mysql feature
398         ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
399 fi
400
401 exit 0
402
403 %postun ido-mysql
404 if [ "$1" = "0" ]; then
405         # deinstallation of the package - remove feature
406         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
407 fi
408
409 exit 0
410
411 %post ido-pgsql
412 if [ ${1:-0} -eq 1 ]
413 then
414         # initial installation, enable ido-pgsql feature
415         ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
416 fi
417
418 exit 0
419
420 %postun ido-pgsql
421 if [ "$1" = "0" ]; then
422         # deinstallation of the package - remove feature
423         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
424 fi
425
426 exit 0
427
428 %post classicui-config
429 if [ ${1:-0} -eq 1 ]
430 then
431         # initial installation, enable features
432         for feature in statusdata compatlog command; do
433                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
434         done
435 fi
436
437 exit 0
438
439 %postun classicui-config
440 if [ "$1" = "0" ]; then
441         # deinstallation of the package - remove feature
442         for feature in statusdata compatlog command; do
443                 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
444         done
445 fi
446
447 exit 0
448
449 %files
450 %defattr(-,root,root,-)
451 %doc COPYING
452
453 %files bin
454 %defattr(-,root,root,-)
455 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
456 %{_sbindir}/%{name}
457 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
458 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
459 %dir %{_libdir}/%{name}
460 %{_libdir}/%{name}/*.so*
461 %dir %{_libdir}/%{name}/sbin
462 %{_libdir}/%{name}/sbin/%{name}
463 %{_datadir}/%{name}
464 %exclude %{_datadir}/%{name}/include
465 %{_mandir}/man8/%{name}.8.gz
466
467 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
468 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
469 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
470 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
471 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
472 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
473
474 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
475 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
476
477 %files common
478 %defattr(-,root,root,-)
479 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
480 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
481 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
482 %{_sysconfdir}/bash_completion.d/%{name}
483 %if 0%{?use_systemd}
484 %attr(644,root,root) %{_unitdir}/%{name}.service
485 %else
486 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
487 %endif
488 %if "%{_vendor}" == "suse"
489 %{_sbindir}/rc%{name}
490 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
491 %else
492 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
493 %endif
494 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
495 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
496 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
497 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
498 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
499 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
500 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
501 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
502 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
503 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
504 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
505 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
506 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
507 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
508 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
509 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
510 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
511 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
512 %dir %{_libexecdir}/%{name}
513 %{_libexecdir}/%{name}/prepare-dirs
514 %{_libexecdir}/%{name}/safe-reload
515 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
516 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
517 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
518 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
519 %{_datadir}/%{name}/include
520
521 %files doc
522 %defattr(-,root,root,-)
523 %{_datadir}/doc/%{name}
524 %docdir %{_datadir}/doc/%{name}
525
526 %files ido-mysql
527 %defattr(-,root,root,-)
528 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
529 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
530 %{_libdir}/%{name}/libdb_ido_mysql*
531 %{_datadir}/icinga2-ido-mysql
532
533 %files ido-pgsql
534 %defattr(-,root,root,-)
535 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
536 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-pgsql.conf
537 %{_libdir}/%{name}/libdb_ido_pgsql*
538 %{_datadir}/icinga2-ido-pgsql
539
540 %files classicui-config
541 %defattr(-,root,root,-)
542 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
543 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
544 %config(noreplace) %{apacheconfdir}/icinga.conf
545 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
546
547 %changelog