pyldb: avoid segfault when adding an element with no name
[nivanova/samba-autobuild/.git] / ctdb / packaging / RPM / ctdb.spec.in
1 %define with_systemd  %{?_with_systemd: 1} %{?!_with_systemd: 0}
2 %define initdir %{_sysconfdir}/init.d
3 Name: ctdb
4 Summary: Clustered TDB
5 Vendor: Samba Team
6 Packager: Samba Team <samba@samba.org>
7 Version: @VERSION@
8 Release: @RELEASE@
9 Epoch: 0
10 License: GNU GPL version 3
11 Group: System Environment/Daemons
12 URL: http://ctdb.samba.org/
13
14 Source: ctdb-%{version}.tar.gz
15
16 # Packages
17 Requires: coreutils, sed, gawk, iptables, iproute, procps, ethtool, sudo
18 # Commands - package name might vary
19 Requires: /usr/bin/killall, /bin/kill, /bin/netstat
20
21 Provides: ctdb = %{version}
22
23 Prefix: /usr
24 BuildRoot: %{_tmppath}/%{name}-%{version}-root
25
26 # Allow build with system libraries
27 # To enable, run rpmbuild with,
28 #      "--with system_talloc"
29 #      "--with system_tdb"
30 #      "--with system_tevent"
31 #%define with_included_talloc %{?_with_system_talloc: 0} %{?!_with_system_talloc: 1}
32 #%define with_included_tdb %{?_with_system_tdb: 0} %{?!_with_system_tdb: 1}
33 #%define with_included_tevent %{?_with_system_tevent: 0} %{?!_with_system_tevent: 1}
34
35 %define with_included_talloc 0
36 %define with_included_tevent 0
37 %define with_included_tdb 0
38
39 # Required minimum library versions when building with system libraries
40 %define libtalloc_version 2.0.8
41 %define libtdb_version 1.3.11
42 %define libtevent_version 0.9.16
43
44 %if ! %with_included_talloc
45 BuildRequires: libtalloc-devel >= %{libtalloc_version}
46 Requires: libtalloc >= %{libtalloc_version}
47 %endif
48 %if ! %with_included_tdb
49 BuildRequires: libtdb-devel >= %{libtdb_version}
50 Requires: libtdb >= %{libtdb_version}
51 %endif
52 %if ! %with_included_tevent
53 BuildRequires: libtevent-devel >= %{libtevent_version}
54 Requires: libtevent >= %{libtevent_version}
55 %endif
56
57 # To build the ctdb-pcp-pmda package, run rpmbuild with "--with pmda"
58 %define with_pcp_pmda  %{?_with_pmda: 1} %{?!_with_pmda: 0}
59 %if %with_pcp_pmda
60 BuildRequires: pcp-libs-devel
61 %endif
62
63 %if %{with_systemd}
64 BuildRequires: systemd-units
65 %endif
66
67 %description
68 ctdb is the clustered database used by samba
69
70 #######################################################################
71
72
73
74 %prep
75 %setup -q
76 # setup the init script and sysconfig file
77 %setup -T -D -n ctdb-%{version} -q
78
79 %build
80
81 ## check for ccache
82 if ccache -h >/dev/null 2>&1 ; then
83         CC="ccache gcc"
84 else
85         CC="gcc"
86 fi
87
88 export CC
89
90 CFLAGS="$RPM_OPT_FLAGS $EXTRA -D_GNU_SOURCE" \
91 $PYTHON ./buildtools/bin/waf configure \
92         --builtin-libraries=replace,popt \
93         --bundled-libraries=!talloc,!tevent,!tdb \
94         --minimum-library-version=talloc:%libtalloc_version,tdb:%libtdb_version,tevent:%libtevent_version \
95 %if %with_pcp_pmda
96         --enable-pmda \
97 %endif
98         --prefix=%{_prefix} \
99         --includedir=%{_includedir}/ctdb \
100         --libdir=%{_libdir} \
101         --libexecdir=%{_libexecdir} \
102         --sysconfdir=%{_sysconfdir} \
103         --mandir=%{_mandir} \
104         --localstatedir=%{_localstatedir}
105
106 $PYTHON ./buildtools/bin/waf build
107
108 %install
109 # Clean up in case there is trash left from a previous build
110 rm -rf $RPM_BUILD_ROOT
111
112 # Create the target build directory hierarchy
113 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d
114
115 DESTDIR=$RPM_BUILD_ROOT $PYTHON ./buildtools/bin/waf install
116
117 install -m644 config/ctdb.conf $RPM_BUILD_ROOT%{_sysconfdir}/ctdb
118 install -m644 config/ctdb.tunables $RPM_BUILD_ROOT%{_sysconfdir}/ctdb
119 install -m644 config/script.options $RPM_BUILD_ROOT%{_sysconfdir}/ctdb
120
121 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
122 install -m644 config/ctdb.sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/ctdb
123
124 %if %{with_systemd}
125 mkdir -p $RPM_BUILD_ROOT%{_unitdir}
126 install -m 755 config/ctdb.service $RPM_BUILD_ROOT%{_unitdir}
127 %else
128 mkdir -p $RPM_BUILD_ROOT%{initdir}
129 install -m755 config/ctdb.init $RPM_BUILD_ROOT%{initdir}/ctdb
130 %endif
131
132 # This is a hack. All documents should be installed in /usr/share/doc.
133 cp config/events/README README.eventscripts
134 rm -f $RPM_BUILD_ROOT%{_sysconfdir}/ctdb/nfs-checks.d/README
135 cp config/nfs-checks.d/README README.nfs-checks.d
136 cp config/notification.README README.notification
137
138 # Remove "*.old" files
139 find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
140
141 %clean
142 rm -rf $RPM_BUILD_ROOT
143
144 %post
145
146 # If mandatory 00.ctdb event script is not enabled then enable it and
147 # some other scripts.  The assumption here is that this is a
148 # first-time install or an upgrade to a version that requires event
149 # scripts to be enabled via symlinks.
150 required_script="00.ctdb"
151 required_path="%{_sysconfdir}/ctdb/events/legacy/${required_script}.script"
152 if [ ! -L "$required_path" ] && [ ! -e "$required_path" ] ; then
153         default_scripts="${required_script}
154                          01.reclock
155                          05.system
156                          10.interface
157                          "
158         for t in $default_scripts ; do
159                 tgt="%{_datadir}/ctdb/events/legacy/${t}.script"
160                 name="%{_sysconfdir}/ctdb/events/legacy/${t}.script"
161                 # Directory is created via install and files
162                 ln -s "$tgt" "$name"
163         done
164 fi
165
166 %preun
167
168 # Uninstall, not upgrade.  Clean up by removing any remaining links.
169 if [ "$1" = "0" ] ; then
170         for i in "%{_sysconfdir}/ctdb/events/legacy/"*.script ; do
171                 if [ -L "$i" ] ; then
172                         rm -f "$i"
173                 fi
174         done
175 fi
176
177 %files
178 %defattr(-,root,root)
179
180 %config(noreplace) %{_sysconfdir}/ctdb/ctdb.conf
181 %config(noreplace) %{_sysconfdir}/ctdb/ctdb.tunables
182 %config(noreplace) %{_sysconfdir}/ctdb/script.options
183 %{_sysconfdir}/ctdb/notify.sh
184 %config(noreplace) %{_sysconfdir}/ctdb/debug-hung-script.sh
185 %config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh
186 %config(noreplace) %{_sysconfdir}/ctdb/debug_locks.sh
187
188 %config(noreplace, missingok) %{_sysconfdir}/sysconfig/ctdb
189
190 %if %{with_systemd}
191 %{_unitdir}/ctdb.service
192 %else
193 %attr(755,root,root) %{initdir}/ctdb
194 %endif
195
196 %doc README COPYING
197 %doc README.eventscripts README.notification
198 %doc doc/recovery-process.txt
199 %doc doc/cluster_mutex_helper.txt
200 %doc doc/*.html
201 %doc doc/examples
202 %{_sysconfdir}/sudoers.d/ctdb
203 %dir %{_sysconfdir}/ctdb
204 %{_sysconfdir}/ctdb/functions
205 %dir %{_sysconfdir}/ctdb/events
206 %{_sysconfdir}/ctdb/events/*
207 %dir %{_sysconfdir}/ctdb/nfs-checks.d
208 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/00.portmapper.check
209 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/10.status.check
210 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/20.nfs.check
211 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/30.nlockmgr.check
212 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/40.mountd.check
213 %config(noreplace) %{_sysconfdir}/ctdb/nfs-checks.d/50.rquotad.check
214 %{_sysconfdir}/ctdb/statd-callout
215 %{_sysconfdir}/ctdb/nfs-linux-kernel-callout
216 %{_sbindir}/ctdbd
217 %{_sbindir}/ctdbd_wrapper
218 %{_bindir}/ctdb
219 %{_bindir}/ping_pong
220 %{_bindir}/ltdbtool
221 %{_bindir}/ctdb_diagnostics
222 %{_bindir}/onnode
223 %dir %{_libexecdir}/ctdb
224 %{_libexecdir}/ctdb/*
225 %dir %{_libdir}/ctdb
226 %{_libdir}/ctdb/lib*
227 %dir %{_datadir}/ctdb/events
228 %{_datadir}/ctdb/events/*
229 %{_mandir}/man1/ctdb.1.gz
230 %{_mandir}/man1/ctdb_diagnostics.1.gz
231 %{_mandir}/man1/ctdbd.1.gz
232 %{_mandir}/man1/ctdbd_wrapper.1.gz
233 %{_mandir}/man1/onnode.1.gz
234 %{_mandir}/man1/ltdbtool.1.gz
235 %{_mandir}/man1/ping_pong.1.gz
236 %{_mandir}/man5/ctdb.conf.5.gz
237 %{_mandir}/man5/ctdb-script.options.5.gz
238 %{_mandir}/man5/ctdb.sysconfig.5.gz
239 %{_mandir}/man7/ctdb.7.gz
240 %{_mandir}/man7/ctdb-statistics.7.gz
241 %{_mandir}/man7/ctdb-tunables.7.gz
242 %attr(0700,root,root) %dir %{_localstatedir}/lib/ctdb
243 %attr(0700,root,root) %dir %{_localstatedir}/lib/ctdb/*
244 %attr(0700,root,root) %dir %{_localstatedir}/run/ctdb
245
246
247 %package devel
248 Summary: CTDB development libraries
249 Group: Development/Libraries
250
251 %description devel
252 development libraries for ctdb
253
254 %files devel
255 %defattr(-,root,root)
256
257 %package tests
258 Summary: CTDB test suite
259 Group: Development/Tools
260 Requires: ctdb = %{version}
261 Requires: nc, tcpdump
262
263 %description tests
264 test suite for ctdb
265
266 %files tests
267 %defattr(-,root,root)
268 %dir %{_datadir}/%{name}/tests
269 %{_datadir}/%{name}/tests/*
270 %dir %{_libexecdir}/%{name}/tests
271 %{_libexecdir}/%{name}/tests/*
272 %{_bindir}/ctdb_run_tests
273 %{_bindir}/ctdb_run_cluster_tests
274 %{_bindir}/ctdb_local_daemons
275 %doc tests/README
276
277 %if %with_pcp_pmda
278
279 %package pcp-pmda
280 Summary: CTDB PCP pmda support
281 Group: Development/Tools
282 Requires: ctdb = %{version}
283 Requires: pcp-libs
284
285 %description pcp-pmda
286 Performance Co-Pilot (PCP) support for CTDB
287
288 %files pcp-pmda
289 %dir %{_localstatedir}/lib/pcp/pmdas/ctdb
290 %{_localstatedir}/lib/pcp/pmdas/ctdb/*
291
292 %endif