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