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