]> granicus.if.org Git - icinga2/blob - icinga2.spec
Fix validator for TimePeriod ranges
[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.2.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: 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
101 %if 0%{?build_icinga_org} && "%{_vendor}" == "redhat" && (0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5")
102 # el5 requires packages.icinga.org
103 BuildRequires: boost153-devel
104 %else
105 %if 0%{?build_icinga_org} && "%{_vendor}" == "suse" && 0%{?suse_version} < 1310
106 # sles 11 sp3 requires packages.icinga.org
107 BuildRequires: boost153-devel
108 %else
109 BuildRequires: boost-devel >= 1.41
110 %endif
111 %endif
112
113 %if 0%{?use_systemd}
114 BuildRequires: systemd
115 Requires: systemd
116 %endif
117
118 Requires: %{name}-common = %{version}-%{release}
119
120 %description bin
121 Icinga 2 is a general-purpose network monitoring application.
122 Provides binaries and libraries for Icinga 2 Core.
123
124 %package common
125 Summary:      Common Icinga 2 configuration
126 Group:        Applications/System
127 %if "%{_vendor}" == "redhat"
128 Requires(pre): shadow-utils
129 Requires(post): shadow-utils
130 %endif
131 %if "%{_vendor}" == "suse"
132 Recommends:   logrotate
133 %endif
134
135 %description common
136 Provides common directories, uid and gid among Icinga 2 related
137 packages.
138
139
140 %package doc
141 Summary:      Documentation for Icinga 2
142 Group:        Applications/System
143 Requires:     %{name} = %{version}-%{release}
144
145 %description doc
146 Provides documentation for Icinga 2.
147
148
149 %package ido-mysql
150 Summary:      IDO MySQL database backend for Icinga 2
151 Group:        Applications/System
152 %if "%{_vendor}" == "suse"
153 BuildRequires: libmysqlclient-devel
154 %endif
155 BuildRequires: mysql-devel
156 Requires: %{name} = %{version}-%{release}
157
158 %description ido-mysql
159 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
160 IDOUtils schema >= 1.12
161
162
163 %package ido-pgsql
164 Summary:      IDO PostgreSQL database backend for Icinga 2
165 Group:        Applications/System
166 BuildRequires: postgresql-devel
167 Requires: %{name} = %{version}-%{release}
168
169 %description ido-pgsql
170 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
171 IDOUtils schema >= 1.12
172
173
174 %package classicui-config
175 Summary:      Icinga 2 Classic UI Standalone configuration
176 Group:        Applications/System
177 BuildRequires: %{apachename}
178 Requires:     %{apachename}
179 Requires:     %{name} = %{version}-%{release}
180 %if "%{_vendor}" == "suse"
181 Recommends:   icinga-www
182 %endif
183 Provides:     icinga-classicui-config
184 Conflicts:    icinga-gui-config
185
186 %description classicui-config
187 Icinga 1.x Classic UI Standalone configuration with locations
188 for Icinga 2.
189
190
191 %prep
192 %setup -q -n %{name}-%{version}
193
194 %build
195 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
196          -DCMAKE_INSTALL_SYSCONFDIR=/etc \
197          -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
198          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
199          -DCMAKE_VERBOSE_MAKEFILE=ON \
200          -DBoost_NO_BOOST_CMAKE=ON \
201          -DICINGA2_RUNDIR=%{_rundir} \
202          -DICINGA2_USER=%{icinga_user} \
203          -DICINGA2_GROUP=%{icinga_group} \
204          -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
205 %if "%{_vendor}" == "redhat"
206 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
207 # Boost_VERSION 1.41.0 vs 101400 - disable build tests
208 # details in https://dev.icinga.org/issues/5033
209 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
210  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
211  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
212  -DBoost_NO_SYSTEM_PATHS=TRUE \
213  -DBUILD_TESTING=FALSE \
214  -DBoost_NO_BOOST_CMAKE=TRUE"
215 %endif
216 %endif
217
218 %if "%{_vendor}" != "suse"
219 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_libdir}/nagios/plugins"
220 %else
221 %if 0%{?suse_version} < 1310
222 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost153 \
223  -DBOOST_INCLUDEDIR=/usr/include/boost153 \
224  -DBoost_ADDITIONAL_VERSIONS='1.53;1.53.0' \
225  -DBoost_NO_SYSTEM_PATHS=TRUE \
226  -DBUILD_TESTING=FALSE \
227  -DBoost_NO_BOOST_CMAKE=TRUE"
228 %endif
229 CMAKE_OPTS="$CMAKE_OPTS -DICINGA2_PLUGINDIR=%{_prefix}/lib/nagios/plugins"
230 %endif
231
232 %if 0%{?use_systemd}
233 CMAKE_OPTS="$CMAKE_OPTS -DUSE_SYSTEMD=ON"
234 %endif
235
236 cmake $CMAKE_OPTS -DCMAKE_C_FLAGS:STRING="%{optflags} %{?march_flag}" -DCMAKE_CXX_FLAGS:STRING="%{optflags} %{?march_flag}" .
237
238 make %{?_smp_mflags}
239
240
241 %install
242 make install \
243         DESTDIR="%{buildroot}"
244
245 # install classicui config
246 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
247 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
248 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
249
250 # remove features-enabled symlinks
251 rm -f %{buildroot}/%{_sysconfdir}/%{name}/features-enabled/*.conf
252
253 # enable suse rc links
254 %if "%{_vendor}" == "suse"
255 %if 0%{?use_systemd}
256   ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{name}
257 %else
258   ln -sf ../../%{_initrddir}/%{name} "%{buildroot}%{_sbindir}/rc%{name}"
259 %endif
260 mkdir -p "%{buildroot}%{_localstatedir}/adm/fillup-templates/"
261 mv "%{buildroot}%{_sysconfdir}/sysconfig/%{name}" "%{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.%{name}"
262 %endif
263
264
265 %clean
266 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
267
268 %pre common
269 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
270 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
271 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}
272
273 %if "%{_vendor}" == "suse"
274 %if 0%{?use_systemd}
275   %service_add_pre %{name}.service
276 %endif
277 %endif
278 exit 0
279
280 %if "%{_vendor}" == "suse"
281 %verifyscript bin
282 %verify_permissions -e %{_rundir}/%{name}/cmd
283
284 %if 0%{?suse_version} >= 1310
285 %post bin
286 %set_permissions %{_rundir}/%{name}/cmd
287 %endif
288 %endif
289
290 %post common
291 # suse
292 %if "%{_vendor}" == "suse"
293 %if 0%{?use_systemd}
294 %fillup_only  %{name}
295 %service_add_post %{name}.service
296 %else
297 %fillup_and_insserv %{name}
298 %endif
299
300 # initial installation, enable default features
301 for feature in checker notification mainlog; do
302         ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
303 done
304
305 exit 0
306
307 %else
308 # rhel
309
310 %if 0%{?use_systemd}
311 %systemd_post %{name}.service
312 %else
313 /sbin/chkconfig --add %{name}
314 %endif
315
316 if [ ${1:-0} -eq 1 ]
317 then
318         # initial installation, enable default features
319         for feature in checker notification mainlog; do
320                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
321         done
322 fi
323
324 exit 0
325
326 %endif
327 # suse/rhel
328
329 %postun common
330 # suse
331 %if "%{_vendor}" == "suse"
332 %if 0%{?using_systemd}
333   %service_del_postun %{name}.service
334 %else
335   %restart_on_update %{name}
336   %insserv_cleanup
337 %endif
338
339 %else
340 # rhel
341
342 %if 0%{?use_systemd}
343 %systemd_postun_with_restart %{name}.service
344 %else
345 if [ "$1" -ge  "1" ]; then
346         /sbin/service %{name} condrestart >/dev/null 2>&1 || :
347 fi
348 %endif
349
350 %endif
351 # suse / rhel
352
353 if [ "$1" = "0" ]; then
354         # deinstallation of the package - remove enabled features
355         rm -rf %{_sysconfdir}/%{name}/features-enabled
356 fi
357
358 exit 0
359
360 %preun common
361 # suse
362 %if "%{_vendor}" == "suse"
363
364 %if 0%{?use_systemd}
365   %service_del_preun %{name}.service
366 %else
367   %stop_on_removal %{name}
368 %endif
369
370 exit 0
371
372 %else
373 # rhel
374
375 %if 0%{?use_systemd}
376 %systemd_preun %{name}.service
377 %else
378 if [ "$1" = "0" ]; then
379         /sbin/service %{name} stop > /dev/null 2>&1 || :
380         /sbin/chkconfig --del %{name} || :
381 fi
382 %endif
383
384 exit 0
385
386 %endif
387 # suse / rhel
388
389 %post ido-mysql
390 if [ ${1:-0} -eq 1 ]
391 then
392         # initial installation, enable ido-mysql feature
393         ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
394 fi
395
396 exit 0
397
398 %postun ido-mysql
399 if [ "$1" = "0" ]; then
400         # deinstallation of the package - remove feature
401         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
402 fi
403
404 exit 0
405
406 %post ido-pgsql
407 if [ ${1:-0} -eq 1 ]
408 then
409         # initial installation, enable ido-pgsql feature
410         ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
411 fi
412
413 exit 0
414
415 %postun ido-pgsql
416 if [ "$1" = "0" ]; then
417         # deinstallation of the package - remove feature
418         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
419 fi
420
421 exit 0
422
423 %post classicui-config
424 if [ ${1:-0} -eq 1 ]
425 then
426         # initial installation, enable features
427         for feature in statusdata compatlog command; do
428                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
429         done
430 fi
431
432 exit 0
433
434 %postun classicui-config
435 if [ "$1" = "0" ]; then
436         # deinstallation of the package - remove feature
437         for feature in statusdata compatlog command; do
438                 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
439         done
440 fi
441
442 exit 0
443
444 %files
445 %defattr(-,root,root,-)
446 %doc COPYING
447
448 %files bin
449 %defattr(-,root,root,-)
450 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
451 %{_sbindir}/%{name}
452 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
453 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
454 %dir %{_libdir}/%{name}
455 %{_libdir}/%{name}/*.so*
456 %{_datadir}/%{name}
457 %exclude %{_datadir}/%{name}/include
458 %{_mandir}/man8/%{name}.8.gz
459
460 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
461 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
462 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/crash
463 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
464 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
465 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
466
467 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
468 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
469
470 %files common
471 %defattr(-,root,root,-)
472 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
473 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
474 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
475 %{_sysconfdir}/bash_completion.d/%{name}
476 %if 0%{?use_systemd}
477 %attr(644,root,root) %{_unitdir}/%{name}.service
478 %else
479 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
480 %endif
481 %if "%{_vendor}" == "suse"
482 %{_sbindir}/rc%{name}
483 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
484 %else
485 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
486 %endif
487 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
488 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
490 %exclude %{_sysconfdir}/%{name}/features-available/ido-*.conf
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
492 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
493 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
494 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
495 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
496 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
497 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
498 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
499 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
500 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
501 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
502 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
503 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
504 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
505 %dir %{_libexecdir}/%{name}
506 %{_libexecdir}/%{name}/prepare-dirs
507 %{_libexecdir}/%{name}/safe-reload
508 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
509 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
510 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
511 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
512 %{_datadir}/%{name}/include
513
514 %files doc
515 %defattr(-,root,root,-)
516 %{_datadir}/doc/%{name}
517 %docdir %{_datadir}/doc/%{name}
518
519 %files ido-mysql
520 %defattr(-,root,root,-)
521 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
522 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/ido-mysql.conf
523 %{_libdir}/%{name}/libdb_ido_mysql*
524 %{_datadir}/icinga2-ido-mysql
525
526 %files ido-pgsql
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-pgsql.conf
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