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