]> granicus.if.org Git - icinga2/blob - icinga2.spec
Create RPM package for ido-pgsql.
[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.3
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 %if "%{_vendor}" == "redhat"
68 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
69 # el5 requires EPEL
70 BuildRequires: boost%{el5_boost_version}-devel
71 BuildRequires: boost%{el5_boost_version}
72 Requires: boost%{el5_boost_version}-program-options
73 Requires: boost%{el5_boost_version}-system
74 Requires: boost%{el5_boost_version}-test
75 Requires: boost%{el5_boost_version}-thread
76 %else
77 BuildRequires: boost-devel >= 1.41
78 Requires: boost-program-options >= 1.41
79 Requires: boost-system >= 1.41
80 Requires: boost-test >= 1.41
81 Requires: boost-thread >= 1.41
82 %endif
83 %endif
84
85 %if "%{_vendor}" == "suse"
86 %if 0%{?sles_version} == 11
87 BuildRequires: libgfortran46
88 BuildRequires: boost-license%{sles_boost_version}
89 BuildRequires: boost-devel >= 1.41
90 Requires: boost-license%{sles_boost_version}
91 Requires: libboost_program_options%{sles_boost_version}
92 Requires: libboost_system%{sles_boost_version}
93 Requires: libboost_test%{sles_boost_version}
94 Requires: libboost_thread%{sles_boost_version}
95 %else
96 BuildRequires: boost-devel >= 1.41
97 Requires: libboost_program_options%{opensuse_boost_version}
98 Requires: libboost_system%{opensuse_boost_version}
99 Requires: libboost_test%{opensuse_boost_version}
100 Requires: libboost_thread%{opensuse_boost_version}
101 %endif
102 %endif
103
104 Requires: %{name}-common = %{version}
105
106 %description
107 Icinga is a general-purpose network monitoring application.
108
109 %package common
110 Summary:      Common Icinga 2 configuration
111 Group:        Applications/System
112 %if "%{_vendor}" == "redhat"
113 Requires(pre): shadow-utils
114 Requires(post): shadow-utils
115 %endif
116
117 %description common
118 Provides common directories, uid and gid among Icinga 2 related
119 packages.
120
121
122 %package doc
123 Summary:      Documentation for Icinga 2
124 Group:        Applications/System
125 Requires:     %{name} = %{version}-%{release}
126
127 %description doc
128 Documentation for Icinga 2
129
130
131 %package ido-mysql
132 Summary:      IDO MySQL database backend for Icinga 2
133 Group:        Applications/System
134 %if "%{_vendor}" == "suse"
135 BuildRequires: libmysqlclient-devel
136 Requires: libmysqlclient18
137 %endif
138 %if "%{_vendor}" == "redhat"
139 # el5 only provides mysql package
140 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
141 BuildRequires: mysql
142 %else
143 BuildRequires: mysql-libs
144 BuildRequires: mysql
145 %endif
146 BuildRequires: mysql-devel
147 Requires: mysql
148 %endif
149 Requires: %{name} = %{version}-%{release}
150
151 %description ido-mysql
152 Icinga 2 IDO mysql database backend. Compatible with Icinga 1.x
153 IDOUtils schema >= 1.10
154
155
156 %package ido-pgsql
157 Summary:      IDO PostgreSQL database backend for Icinga 2
158 Group:        Applications/System
159 %if "%{_vendor}" == "suse"
160 BuildRequires: postgresql-libs
161 %endif
162 BuildRequires: postgresql-devel
163 Requires: postgresql-libs
164 Requires: %{name} = %{version}-%{release}
165
166 %description ido-pgsql
167 Icinga 2 IDO PostgreSQL database backend. Compatible with Icinga 1.x
168 IDOUtils schema >= 1.10
169
170
171 %package classicui-config
172 Summary:      Icinga 2 Classic UI Standalone configuration
173 Group:        Applications/System
174 Requires:     %{apachename}
175 Requires:     %{name} = %{version}-%{release}
176 Provides:     icinga-classicui-config
177 Conflicts:    icinga-gui-config
178
179 %description classicui-config
180 Icinga 1.x Classic UI Standalone configuration with locations
181 for Icinga 2.
182
183
184 %prep
185 %setup -q -n %{name}-%{version}
186
187 %build
188 CMAKE_OPTS="-DCMAKE_INSTALL_PREFIX=/usr \
189          -DCMAKE_INSTALL_SYSCONFDIR=/etc \
190                  -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
191          -DCMAKE_BUILD_TYPE=RelWithDebInfo \
192          -DICINGA2_USER=%{icinga_user} \
193          -DICINGA2_GROUP=%{icinga_group} \
194              -DICINGA2_COMMAND_USER=%{icinga_user} \
195              -DICINGA2_COMMAND_GROUP=%{icingacmd_group}"
196 %if "%{_vendor}" == "redhat"
197 %if 0%{?el5} || 0%{?rhel} == 5 || "%{?dist}" == ".el5"
198 CMAKE_OPTS="$CMAKE_OPTS -DBOOST_LIBRARYDIR=/usr/lib/boost141 \
199  -DBOOST_INCLUDEDIR=/usr/include/boost141 \
200  -DBoost_ADDITIONAL_VERSIONS='1.41;1.41.0'"
201 %endif
202 %endif
203 cmake $CMAKE_OPTS . 
204
205 make %{?_smp_mflags}
206
207 %install
208 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
209 make install \
210         DESTDIR="%{buildroot}"
211
212 # install classicui config
213 install -D -m 0644 etc/icinga/icinga-classic.htpasswd %{buildroot}%{icingaclassicconfdir}/passwd
214 install -D -m 0644 etc/icinga/cgi.cfg %{buildroot}%{icingaclassicconfdir}/cgi.cfg
215 install -D -m 0644 etc/icinga/icinga-classic-apache.conf %{buildroot}%{apacheconfdir}/icinga.conf
216
217 # fix plugin path on x64
218 sed -i 's@plugindir = .*@plugindir = "%{_libdir}/nagios/plugins"@' %{buildroot}/%{_sysconfdir}/%{name}/conf.d/macros.conf
219
220 %clean
221 [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot}
222
223 %pre common
224 getent group %{icinga_group} >/dev/null || %{_sbindir}/groupadd -r %{icinga_group}
225 getent group %{icingacmd_group} >/dev/null || %{_sbindir}/groupadd -r %{icingacmd_group}
226 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}
227 exit 0
228
229 %post ido-mysql
230 if [ ${1:-0} -eq 1 ]
231 then
232         # initial installation, enable ido-mysql feature
233         %{_sbindir}/icinga2-enable-feature ido-mysql
234 fi
235
236 %postun ido-mysql
237 if [ "$1" = "0" ]; then
238         # deinstallation of the package - remove feature
239         test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-mysql
240 fi
241
242 %post ido-pgsql
243 if [ ${1:-0} -eq 1 ]
244 then
245         # initial installation, enable ido-pgsql feature
246         %{_sbindir}/icinga2-enable-feature ido-pgsql
247 fi
248
249 %postun ido-pgsql
250 if [ "$1" = "0" ]; then
251         # deinstallation of the package - remove feature
252         test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature ido-pgsql
253 fi
254
255 %post classicui-config
256 if [ ${1:-0} -eq 1 ]
257 then
258         # initial installation, enable features
259         %{_sbindir}/icinga2-enable-feature statusdata
260         %{_sbindir}/icinga2-enable-feature compatlog
261         %{_sbindir}/icinga2-enable-feature command
262 fi
263
264 %postun classicui-config
265 if [ "$1" = "0" ]; then
266         # deinstallation of the package - remove feature
267         test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature statusdata
268         test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature compatlog
269         test -x %{_sbindir}/icinga2-disable-feature && %{_sbindir}/icinga2-disable-feature command
270 fi
271
272 %files
273 %defattr(-,root,root,-)
274 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
275 %attr(755,-,-) %{_sysconfdir}/init.d/%{name}
276 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
277 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
278 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
279 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/%{name}.conf
280 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
281 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
282 %config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-enabled/*.conf
283 %{_sbindir}/%{name}
284 %{_bindir}/%{name}-migrate-config
285 %{_bindir}/%{name}-build-ca
286 %{_bindir}/%{name}-build-key
287 %{_sbindir}/%{name}-enable-feature
288 %{_sbindir}/%{name}-disable-feature
289 %exclude %{_libdir}/%{name}/libdb_ido_mysql*
290 %{_libdir}/%{name}
291 %{_datadir}/%{name}
292 %exclude %{_datadir}/%{name}/itl
293 %{_mandir}/man8/%{name}.8.gz
294
295 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/cache/%{name}
296 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}
297 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat
298 %attr(0755,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/log/%{name}/compat/archives
299 %attr(0755,%{icinga_user},%{icinga_group}) %{_localstatedir}/run/%{name}
300 %attr(0750,%{icinga_user},%{icinga_group}) %{_localstatedir}/lib/%{name}
301
302 %attr(2755,%{icinga_user},%{icingacmd_group}) %{_localstatedir}/run/icinga2/cmd
303
304 %files common
305 %defattr(-,root,root,-)
306 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
307 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_localstatedir}/spool/%{name}
308 %attr(0750,%{icinga_user},%{icinga_group}) %dir %{_datadir}/%{name}/itl
309 %{_datadir}/%{name}/itl
310
311 %files doc
312 %defattr(-,root,root,-)
313 %doc COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
314 %{_datadir}/doc/%{name}
315 %docdir %{_datadir}/doc/%{name}
316
317 %files ido-mysql
318 %defattr(-,root,root,-)
319 %doc components/db_ido_mysql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
320 %{_libdir}/%{name}/libdb_ido_mysql*
321
322 %files ido-pgsql
323 %defattr(-,root,root,-)
324 %doc components/db_ido_pgsql/schema COPYING COPYING.Exceptions README NEWS AUTHORS ChangeLog
325 %{_libdir}/%{name}/libdb_ido_pgsql*
326
327 %files classicui-config
328 %defattr(-,root,root,-)
329 %config(noreplace) %{icingaclassicconfdir}/cgi.cfg
330 %config(noreplace) %{apacheconfdir}/icinga.conf
331 %config(noreplace) %attr(0640,root,%{apachegroup}) %{icingaclassicconfdir}/passwd
332
333
334 %changelog
335 * Tue Oct 01 2013 Michael Friedrich <michael.friedrich@netways.de> - 0.0.3-1
336 - revamp package
337
338 * Sat May 04 2013 Michael Friedrich <michael.friedrich@netways.de> - 0.0.2-1
339 - new initscript in initdir
340 - itl is installed into datadir
341 - man pages in mandir
342 - use name macro to avoid typos
343
344 * Fri Nov 19 2012 Gunnar Beutner <gunnar.beutner@netways.de> - 0.0.1-1
345 - initial version