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