]> granicus.if.org Git - icinga2/blob - icinga2.spec
Move the icinga2-prepare-dirs script to /usr/lib
[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 exit 0
259
260 %if "%{_vendor}" == "suse"
261 %verifyscript bin
262 %verify_permissions -e %{_rundir}/%{name}/cmd
263 %endif
264
265
266 %if "%{_vendor}" == "suse"
267 %if 0%{?use_systemd}
268 %pre bin
269   %service_add_pre %{name}.service
270 %endif
271 %endif
272
273 %post common
274 # suse
275 %if "%{_vendor}" == "suse"
276 %if 0%{?suse_version} >= 1310
277 %set_permissions %{_rundir}/%{name}/cmd
278 %endif
279 %if 0%{?use_systemd}
280 %fillup_only  %{name}
281 %service_add_post %{name}.service
282 %else
283 %fillup_and_insserv %{name}
284 %endif
285
286 # initial installation, enable default features
287 for feature in checker notification mainlog; do
288         ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
289 done
290
291 exit 0
292
293 %else
294 # rhel
295
296 %if 0%{?use_systemd}
297 %systemd_post %{name}.service
298 %else
299 /sbin/chkconfig --add %{name}
300 %endif
301
302 if [ ${1:-0} -eq 1 ]
303 then
304         # initial installation, enable default features
305         for feature in checker notification mainlog; do
306                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
307         done
308 fi
309
310 exit 0
311
312 %endif
313 # suse/rhel
314
315 %postun bin
316 # suse
317 %if "%{_vendor}" == "suse"
318 %if 0%{?using_systemd}
319   %service_del_postun %{name}.service
320 %else
321   %restart_on_update %{name}
322   %insserv_cleanup
323 %endif
324
325 %else
326 # rhel
327
328 %if 0%{?use_systemd}
329 %systemd_postun_with_restart %{name}.service
330 %else
331 if [ "$1" -ge  "1" ]; then
332         /sbin/service %{name} condrestart >/dev/null 2>&1 || :
333 fi
334 %endif
335
336 %endif
337 # suse / rhel
338
339 if [ "$1" = "0" ]; then
340         # deinstallation of the package - remove enabled features
341         rm -rf %{_sysconfdir}/%{name}/features-enabled
342 fi
343
344 exit 0
345
346 %preun bin
347 # suse
348 %if "%{_vendor}" == "suse"
349
350 %if 0%{?use_systemd}
351   %service_del_preun %{name}.service
352 %else
353   %stop_on_removal %{name}
354 %endif
355
356 exit 0
357
358 %else
359 # rhel
360
361 %if 0%{?use_systemd}
362 %systemd_preun %{name}.service
363 %else
364 if [ "$1" = "0" ]; then
365         /sbin/service %{name} stop > /dev/null 2>&1 || :
366         /sbin/chkconfig --del %{name} || :
367 fi
368 %endif
369
370 exit 0
371
372 %endif
373 # suse / rhel
374
375 %post ido-mysql
376 if [ ${1:-0} -eq 1 ]
377 then
378         # initial installation, enable ido-mysql feature
379         ln -sf ../features-available/ido-mysql.conf %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
380 fi
381
382 exit 0
383
384 %postun ido-mysql
385 if [ "$1" = "0" ]; then
386         # deinstallation of the package - remove feature
387         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-mysql.conf
388 fi
389
390 exit 0
391
392 %post ido-pgsql
393 if [ ${1:-0} -eq 1 ]
394 then
395         # initial installation, enable ido-pgsql feature
396         ln -sf ../features-available/ido-pgsql.conf %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
397 fi
398
399 exit 0
400
401 %postun ido-pgsql
402 if [ "$1" = "0" ]; then
403         # deinstallation of the package - remove feature
404         rm -f %{_sysconfdir}/%{name}/features-enabled/ido-pgsql.conf
405 fi
406
407 exit 0
408
409 %post classicui-config
410 if [ ${1:-0} -eq 1 ]
411 then
412         # initial installation, enable features
413         for feature in statusdata compatlog command; do
414                 ln -sf ../features-available/${feature}.conf %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
415         done
416 fi
417
418 exit 0
419
420 %postun classicui-config
421 if [ "$1" = "0" ]; then
422         # deinstallation of the package - remove feature
423         for feature in statusdata compatlog command; do
424                 rm -f %{_sysconfdir}/%{name}/features-enabled/${feature}.conf
425         done
426 fi
427
428 exit 0
429
430 %files
431 %defattr(-,root,root,-)
432 %doc COPYING
433
434 %files bin
435 %defattr(-,root,root,-)
436 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
437 %{_sbindir}/%{name}
438 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
439 %exclude %{_libdir}/%{name}/libdb_ido_pgsql*
440 %{_libdir}/%{name}
441 %{_datadir}/%{name}
442 %exclude %{_datadir}/%{name}/include
443 %{_mandir}/man8/%{name}.8.gz
444
445 %attr(0750,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/cache/%{name}
446 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
447 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat
448 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
449 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
450
451 %attr(0750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}
452 %attr(2750,%{icinga_user},%{icingacmd_group}) %ghost %{_rundir}/%{name}/cmd
453
454 %files common
455 %defattr(-,root,root,-)
456 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog tools/syntax
457 %attr(0750,%{icinga_user},%{icingacmd_group}) %dir %{_localstatedir}/log/%{name}
458 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
459 %{_sysconfdir}/bash_completion.d/%{name}
460 %if 0%{?use_systemd}
461 %attr(644,root,root) %{_unitdir}/%{name}.service
462 %else
463 %attr(755,root,root) %{_sysconfdir}/init.d/%{name}
464 %endif
465 %if "%{_vendor}" == "suse"
466 %{_sbindir}/rc%{name}
467 %{_localstatedir}/adm/fillup-templates/sysconfig.%{name}
468 %else
469 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
470 %endif
471 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
472 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
473 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
474 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
475 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
476 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/scripts
477 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
478 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/zones.d
479 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
480 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/init.conf
481 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
482 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
483 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
484 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
485 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
486 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*
487 %config(noreplace) %{_sysconfdir}/%{name}/scripts/*
488 /usr/lib/icinga2/prepare-dirs
489 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
490 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/perfdata
491 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}/tmp
492 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/include
493 %{_datadir}/%{name}/include
494
495 %files doc
496 %defattr(-,root,root,-)
497 %{_datadir}/doc/%{name}
498 %docdir %{_datadir}/doc/%{name}
499
500 %files ido-mysql
501 %defattr(-,root,root,-)
502 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
503 %{_libdir}/%{name}/libdb_ido_mysql*
504 %{_datadir}/icinga2-ido-mysql
505
506 %files ido-pgsql
507 %defattr(-,root,root,-)
508 %doc COPYING COPYING.Exceptions README.md NEWS AUTHORS ChangeLog
509 %{_libdir}/%{name}/libdb_ido_pgsql*
510 %{_datadir}/icinga2-ido-pgsql
511
512 %files classicui-config
513 %defattr(-,root,root,-)
514 %attr(0751,%{icinga_user},%{icinga_group}) %dir %{icingaclassicconfdir}
515 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
516 %config(noreplace) %{apacheconfdir}/icinga.conf
517 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
518
519 %changelog