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