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