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