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