9 # find the buildtools directory
11 while not os
.path
.exists(srcdir
+'/buildtools') and len(srcdir
.split('/')) < 5:
12 srcdir
= srcdir
+ '/..'
13 sys
.path
.insert(0, srcdir
+ '/buildtools/wafsamba')
15 import wafsamba
, samba_dist
, Options
, Logs
, Utils
16 import samba_utils
, samba_version
18 env
= samba_utils
.LOAD_ENVIRONMENT()
19 if os
.path
.isfile('./VERSION'):
21 elif os
.path
.isfile('../VERSION'):
24 Logs
.error("VERSION file not found")
26 version
= samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
27 VERSION
= version
.STRING
.replace('-', '.')
29 default_prefix
= Options
.default_prefix
= '/usr/local'
31 samba_dist
.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
32 lib/tevent:lib/tevent lib/tdb:lib/tdb
33 lib/socket_wrapper:lib/socket_wrapper
34 third_party/popt:third_party/popt
35 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
36 lib/ccan:lib/ccan libcli/util:libcli/util
37 lib/async_req:lib/async_req
38 buildtools:buildtools third_party/waf:third_party/waf''')
62 'ctdb_mutex_ceph_rados_helper.7',
67 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
69 opt
.RECURSE('lib/replace')
71 opt
.RECURSE('lib/util')
73 opt
.RECURSE('lib/talloc')
74 opt
.RECURSE('lib/tevent')
75 opt
.RECURSE('lib/tdb')
77 opt
.add_option('--enable-infiniband',
78 help=("Turn on infiniband support (default=no)"),
79 action
="store_true", dest
='ctdb_infiniband', default
=False)
80 opt
.add_option('--enable-pmda',
81 help=("Turn on PCP pmda support (default=no)"),
82 action
="store_true", dest
='ctdb_pmda', default
=False)
83 opt
.add_option('--enable-etcd-reclock',
84 help=("Enable etcd recovery lock helper (default=no)"),
85 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
87 opt
.add_option('--with-libcephfs',
88 help=("Directory under which libcephfs is installed"),
89 action
="store", dest
='libcephfs_dir', default
=None)
90 opt
.add_option('--enable-ceph-reclock',
91 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
92 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
94 opt
.add_option('--with-logdir',
95 help=("Path to log directory"),
96 action
="store", dest
='ctdb_logdir', default
=None)
97 opt
.add_option('--with-socketpath',
98 help=("path to CTDB daemon socket"),
99 action
="store", dest
='ctdb_sockpath', default
=None)
104 # No need to build python bindings for talloc/tevent/tdb
105 if conf
.IN_LAUNCH_DIR():
106 conf
.env
.standalone_ctdb
= True
107 Options
.options
.disable_python
= True
109 conf
.RECURSE('lib/replace')
111 if conf
.env
.standalone_ctdb
:
112 conf
.SAMBA_CHECK_PERL(mandatory
=True)
114 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
115 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
117 if conf
.CHECK_FOR_THIRD_PARTY():
118 conf
.RECURSE('third_party/popt')
120 if not conf
.CHECK_POPT():
121 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
123 conf
.define('USING_SYSTEM_POPT', 1)
125 conf
.RECURSE('lib/util')
127 conf
.RECURSE('lib/talloc')
128 conf
.RECURSE('lib/tevent')
129 conf
.RECURSE('lib/tdb')
130 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
131 conf
.RECURSE('lib/socket_wrapper')
132 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
134 conf
.CHECK_HEADERS('sched.h')
135 conf
.CHECK_HEADERS('procinfo.h')
136 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
137 Logs
.error('Need thread_setsched() on AIX')
139 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
140 Logs
.error('Need sched_setscheduler()')
142 conf
.CHECK_FUNCS('mlockall')
144 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
145 conf
.DEFINE('ETIME', 'ETIMEDOUT')
147 if sys
.platform
.startswith('linux'):
148 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
150 if not conf
.CHECK_HEADERS('pcap.h'):
151 Logs
.error('Need libpcap')
153 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
154 Logs
.error('Need libpcap')
157 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
158 checklibc
=True, headers
='execinfo.h'):
159 Logs
.error('backtrace support not available')
162 if Options
.options
.ctdb_pmda
:
165 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
168 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
170 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
173 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
176 Logs
.error("PMDA support not available")
179 Logs
.info('Building with PMDA support')
180 conf
.define('HAVE_PMDA', 1)
181 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
182 'lib/pcp/pmdas/ctdb')
184 have_infiniband
= False
185 if Options
.options
.ctdb_infiniband
:
188 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
190 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
192 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
195 have_infiniband
= True
197 Logs
.error("Infiniband support not available")
200 Logs
.info('Building with Infiniband support')
201 conf
.define('HAVE_INFINIBAND', 1)
202 conf
.define('USE_INFINIBAND', 1)
204 have_etcd_reclock
= False
205 if Options
.options
.ctdb_etcd_reclock
:
207 conf
.check_python_module('etcd')
208 have_etcd_reclock
= True
210 Logs
.error('etcd support not available')
212 if have_etcd_reclock
:
213 Logs
.info('Building with etcd support')
214 conf
.env
.etcd_reclock
= have_etcd_reclock
216 if Options
.options
.ctdb_ceph_reclock
:
217 # Use custom libcephfs library path if provided. XXX The top level build
218 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
219 if Options
.options
.libcephfs_dir
:
220 conf
.env
['CPPPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/include'
221 conf
.env
['LIBPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/lib'
222 conf
.env
['LIBPATH_CEPH-COMMON'] = conf
.env
['LIBPATH_RADOS'] + '/ceph'
224 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
225 conf
.CHECK_LIB('rados', shlib
=True)):
226 conf
.CHECK_LIB('ceph-common', shlib
=True)
227 Logs
.info('Building with Ceph librados recovery lock support')
228 conf
.define('HAVE_LIBRADOS', 1)
230 Logs
.error("Missing librados for Ceph recovery lock support")
233 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
234 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
235 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
236 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
237 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
239 if Options
.options
.ctdb_logdir
:
240 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
242 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
244 if Options
.options
.ctdb_sockpath
:
245 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
247 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
249 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
251 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
255 -DCTDB_RUNDIR=\"%s\"''' % (
256 conf
.env
.CTDB_HELPER_BINDIR
,
257 conf
.env
.CTDB_LOGDIR
,
258 conf
.env
.CTDB_ETCDIR
,
259 conf
.env
.CTDB_VARDIR
,
260 conf
.env
.CTDB_RUNDIR
))
262 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
264 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
266 # Allow unified compilation and separate compilation of utilities
268 if not conf
.env
.standalone_ctdb
:
269 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
272 # Building from tarball
273 conf
.ADD_EXTRA_INCLUDES('#include')
275 # Building standalone CTDB from within Samba tree
276 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
277 conf
.ADD_EXTRA_INCLUDES('#ctdb')
278 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
280 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
281 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
282 conf
.SAMBA_CONFIG_H()
284 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
285 conf
.env
.ctdb_generate_manpages
= True
287 conf
.env
.ctdb_generate_manpages
= False
289 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
290 conf
.env
.ctdb_prebuilt_manpages
= []
291 manpages
= manpages_binary
+ manpages_misc
292 if conf
.env
.etcd_reclock
:
293 manpages
+= manpages_etcd
294 if conf
.env
.HAVE_LIBRADOS
:
295 manpages
+= manpages_ceph
297 if os
.path
.exists(os
.path
.join("doc", m
)):
298 Logs
.info(" %s: yes" % (m
))
299 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
301 Logs
.info(" %s: no" % (m
))
303 def gen_ctdb_version(task
):
304 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
305 fp
.write('/* This file is auto-generated from waf */\n')
306 fp
.write('#include "version.h"\n')
308 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
313 if bld
.env
.standalone_ctdb
:
314 # enable building of public headers in the build tree
315 bld
.env
.build_public_headers
= 'include/public'
317 if bld
.env
.standalone_ctdb
:
318 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
320 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
321 target
='include/ctdb_version.h',
322 rule
=gen_ctdb_version
,
323 dep_vars
=['VERSION'])
324 t
.env
.VERSION
= VERSION
326 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
328 bld
.RECURSE('lib/replace')
329 if bld
.CHECK_FOR_THIRD_PARTY():
330 bld
.RECURSE('third_party/popt')
332 bld
.RECURSE('lib/tdb_wrap')
333 bld
.RECURSE('lib/util')
334 bld
.RECURSE('lib/async_req')
336 bld
.RECURSE('lib/talloc')
337 bld
.RECURSE('lib/tevent')
338 bld
.RECURSE('lib/tdb')
339 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
340 bld
.RECURSE('lib/socket_wrapper')
342 if bld
.env
.standalone_ctdb
:
343 # If a combined build is implemented, CTDB will want to
344 # build against samba-util rather than samba-util-core.
345 # Similarly, other Samba subsystems expect samba-util. So,
346 # for a standalone build, just define a fake samba-util
347 # subsystem that pulls in samba-util-core.
348 bld
.SAMBA_SUBSYSTEM('samba-util',
350 deps
='samba-util-core')
352 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
353 source
=bld
.SUBDIR('tcp',
354 'tcp_connect.c tcp_init.c tcp_io.c'),
356 deps
='replace tdb talloc tevent')
359 if bld
.env
.HAVE_INFINIBAND
:
360 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
361 source
=bld
.SUBDIR('ib',
362 '''ibwrapper.c ibw_ctdb.c
365 deps
='replace talloc tevent tdb')
366 ib_deps
= ' ctdb-ib rdmacm ibverbs'
368 if sys
.platform
.startswith('linux'):
369 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
370 elif sys
.platform
.startswith('aix'):
371 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
372 elif sys
.platform
.startswith('freebsd'):
373 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
374 elif sys
.platform
.startswith('gnukfreebsd'):
375 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
376 elif sys
.platform
== 'gnu':
377 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
379 Logs
.error("Platform %s not supported" % sys
.platform
)
381 bld
.SAMBA_SUBSYSTEM('ctdb-system',
382 source
=bld
.SUBDIR('common',
383 'system_common.c system_util.c') +
386 deps
='replace talloc tevent tdb pcap samba-util')
388 bld
.SAMBA_SUBSYSTEM('ctdb-common',
389 source
=bld
.SUBDIR('common',
390 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
393 deps
='replace popt talloc tevent tdb popt ctdb-system')
395 bld
.SAMBA_SUBSYSTEM('ctdb-util',
396 source
=bld
.SUBDIR('common',
397 '''db_hash.c srvid.c reqid.c
398 pkt_read.c pkt_write.c comm.c
399 logging.c rb_tree.c tunable.c
401 hash_count.c run_event.c'''),
402 deps
='''samba-util sys_rw tevent-util
403 replace talloc tevent tdb''')
405 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
406 source
=bld
.SUBDIR('protocol',
407 '''protocol_header.c protocol_packet.c
408 protocol_types.c protocol_call.c
414 protocol_event.c'''),
416 deps
='replace talloc tdb')
418 bld
.SAMBA_SUBSYSTEM('ctdb-client',
419 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
421 deps
='''replace popt talloc tevent tdb
422 samba-util tdb-wrap ctdb-util''')
424 bld
.SAMBA_SUBSYSTEM('ctdb-client2',
425 source
=bld
.SUBDIR('client',
426 '''client_connect.c client_call.c
427 client_message.c client_control.c
428 client_message_sync.c
429 client_control_sync.c
430 client_db.c client_util.c
434 deps
='replace talloc tevent tdb tdb-wrap')
436 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
437 source
=bld
.SUBDIR('common',
438 '''sock_daemon.c'''),
439 deps
='''samba-util ctdb-util tevent-util
440 replace talloc tevent''')
442 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
443 source
=bld
.SUBDIR('server',
444 '''ipalloc_deterministic.c
445 ipalloc_nondeterministic.c
451 deps
='ctdb-protocol replace talloc tevent')
453 bld
.SAMBA_BINARY('ctdbd',
454 source
='server/ctdbd.c ' +
456 '''ctdb_daemon.c ctdb_recoverd.c
457 ctdb_recover.c ctdb_freeze.c
458 ctdb_tunables.c ctdb_monitor.c
459 ctdb_server.c ctdb_control.c
460 ctdb_call.c ctdb_ltdb_server.c
461 ctdb_traverse.c eventscript.c
463 ctdb_persistent.c ctdb_keepalive.c
467 ctdb_vacuum.c ctdb_banning.c
470 ctdb_lock.c ctdb_fork.c'''),
472 deps
='''ctdb-ipalloc ctdb-client ctdb-common ctdb-system
473 ctdb-tcp ctdb-util replace sys_rw popt
474 talloc tevent tdb talloc_report''' +
476 install_path
='${SBINDIR}',
479 bld
.SAMBA_BINARY('ctdb',
480 source
='tools/ctdb.c',
481 deps
='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
482 samba-util sys_rw popt''',
483 install_path
='${BINDIR}',
486 bld
.SAMBA_BINARY('ctdb_killtcp',
487 source
='tools/ctdb_killtcp.c',
488 deps
='''ctdb-protocol ctdb-util ctdb-system
489 samba-util replace''',
490 install_path
='${CTDB_HELPER_BINDIR}')
492 bld
.SAMBA_BINARY('ctdb_event',
493 source
='tools/ctdb_event.c',
494 deps
='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
495 samba-util replace''',
496 install_path
='${CTDB_HELPER_BINDIR}')
498 bld
.SAMBA_BINARY('ltdbtool',
499 source
='tools/ltdbtool.c',
502 install_path
='${BINDIR}',
503 manpages
='ltdbtool.1')
505 bld
.SAMBA_BINARY('ctdb_eventd',
506 source
='server/ctdb_eventd.c',
507 deps
='''ctdb-server-util ctdb-protocol ctdb-util
508 samba-util LIBASYNC_REQ replace popt''',
509 install_path
='${CTDB_HELPER_BINDIR}')
511 bld
.SAMBA_BINARY('ctdb_lock_helper',
512 source
='server/ctdb_lock_helper.c',
513 deps
='''samba-util sys_rw ctdb-system tevent-util
514 talloc tevent tdb''',
516 install_path
='${CTDB_HELPER_BINDIR}')
518 bld
.SAMBA_BINARY('ctdb_recovery_helper',
519 source
='server/ctdb_recovery_helper.c',
520 deps
='''ctdb-client2 ctdb-protocol ctdb-util
521 samba-util sys_rw replace tdb''',
522 install_path
='${CTDB_HELPER_BINDIR}')
524 bld
.SAMBA_BINARY('ctdb_takeover_helper',
525 source
='server/ctdb_takeover_helper.c',
526 deps
='''ctdb-client2 ctdb-protocol ctdb-util
527 samba-util sys_rw replace ctdb-ipalloc popt''',
528 install_path
='${CTDB_HELPER_BINDIR}')
530 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
531 source
='server/ctdb_mutex_fcntl_helper.c',
532 deps
='sys_rw ctdb-system',
534 install_path
='${CTDB_HELPER_BINDIR}')
536 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
537 source
='utils/smnotify/smnotify.x',
538 target
='utils/smnotify/smnotify.h',
539 rule
='rpcgen -h ${SRC} > ${TGT}')
541 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
543 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
544 source
='utils/smnotify/smnotify.x',
545 target
='utils/smnotify/gen_xdr.c',
546 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
548 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
549 source
='utils/smnotify/smnotify.x',
550 target
='utils/smnotify/gen_smnotify.c',
551 rule
='rpcgen -l ${SRC} > ${TGT}')
553 bld
.SAMBA_BINARY('smnotify',
554 source
=bld
.SUBDIR('utils/smnotify',
555 'smnotify.c gen_smnotify.c gen_xdr.c'),
556 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
557 includes
='utils utils/smnotify',
558 install_path
='${CTDB_HELPER_BINDIR}')
560 bld
.SAMBA_BINARY('ping_pong',
561 source
='utils/ping_pong/ping_pong.c',
563 install_path
='${BINDIR}',
564 manpages
='ping_pong.1')
566 if bld
.env
.HAVE_PMDA
:
567 bld
.SAMBA_BINARY('pmdactdb',
568 source
='utils/pmda/pmda_ctdb.c',
570 deps
='''ctdb-client2 ctdb-protocol ctdb-util
571 samba-util pcp_pmda pcp''',
572 install_path
='${CTDB_PMDADIR}')
573 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
575 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
577 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
579 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
581 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
583 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
586 if bld
.env
.HAVE_LIBRADOS
:
587 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
588 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
589 deps
='talloc tevent rados ceph-common',
591 install_path
='${CTDB_HELPER_BINDIR}')
593 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
594 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
595 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
596 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
597 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
598 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
599 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
600 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
601 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
602 sed_expr6
, sed_expr7
)
604 manpages_extra
= manpages_misc
605 if bld
.env
.etcd_reclock
:
606 manpages_extra
+= manpages_etcd
607 if bld
.env
.HAVE_LIBRADOS
:
608 manpages_extra
+= manpages_ceph
609 for f
in manpages_binary
+ manpages_extra
:
611 bld
.SAMBA_GENERATOR(x
,
612 source
=os
.path
.join('doc', x
),
614 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
616 if bld
.env
.ctdb_generate_manpages
:
617 bld
.MANPAGES(' '.join(manpages_extra
), True)
619 for m
in bld
.env
.ctdb_prebuilt_manpages
:
620 bld
.SAMBA_GENERATOR(m
,
621 source
=os
.path
.join("doc", m
),
623 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
624 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
626 bld
.SAMBA_GENERATOR('ctdb-onnode',
627 source
='tools/onnode',
629 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
630 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
631 destname
='onnode', chmod
=0755)
633 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
634 source
='tools/ctdb_diagnostics',
635 target
='ctdb_diagnostics',
636 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
637 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
638 destname
='ctdb_diagnostics', chmod
=0755)
640 if bld
.env
.etcd_reclock
:
641 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
642 source
='utils/etcd/ctdb_etcd_lock',
643 target
='ctdb_etcd_lock',
644 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
645 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
646 destname
='ctdb_etcd_lock', chmod
=0744)
648 bld
.SAMBA_GENERATOR('ctdb-natgw',
649 source
='tools/ctdb_natgw',
651 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
652 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
653 destname
='ctdb_natgw', chmod
=0755)
655 bld
.SAMBA_GENERATOR('ctdb-lvs',
656 source
='tools/ctdb_lvs',
658 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
659 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
660 destname
='ctdb_lvs', chmod
=0755)
662 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
663 source
='config/ctdbd_wrapper',
664 target
='ctdbd_wrapper',
665 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
666 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
667 destname
='ctdbd_wrapper', chmod
=0755)
669 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
671 fl
= os
.path
.join(dirname
, f
)
672 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
674 mode
= os
.lstat(fl
).st_mode
& 0777
676 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
677 arg
['file_list'].append([fl
, mode
])
679 def SUBDIR_MODE(path
, trim_path
=None):
680 pd
= {'trim_path': trim_path
, 'file_list': []}
681 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
682 return pd
['file_list']
689 if bld
.env
.standalone_ctdb
:
692 configdir
= 'ctdb/config'
694 for t
in etc_subdirs
:
695 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
697 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
698 destname
=fmode
[0], chmod
=fmode
[1])
700 bld
.SAMBA_GENERATOR('ctdb-functions',
701 source
='config/functions',
703 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
704 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
707 'ctdb-crash-cleanup.sh',
708 'debug-hung-script.sh',
711 'nfs-linux-kernel-callout',
716 for t
in etc_scripts
:
717 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
718 destname
=t
, chmod
=0755)
720 bld
.SAMBA_GENERATOR('ctdb-sudoers',
721 source
='config/ctdb.sudoers',
722 target
='ctdb.sudoers',
723 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
724 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
727 bld
.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
730 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
731 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
732 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
743 'protocol_types_test',
744 'protocol_client_test',
753 for target
in ctdb_unit_tests
:
754 src
= 'tests/src/' + target
+ '.c'
756 bld
.SAMBA_BINARY(target
,
758 deps
='''talloc tevent tdb tevent-util
759 LIBASYNC_REQ samba-util sys_rw''',
760 install_path
='${CTDB_TEST_LIBEXECDIR}')
762 bld
.SAMBA_BINARY('reqid_test',
763 source
='tests/src/reqid_test.c',
765 install_path
='${CTDB_TEST_LIBEXECDIR}')
767 bld
.SAMBA_BINARY('rb_test',
768 source
='tests/src/rb_test.c',
769 deps
='samba-util talloc',
770 install_path
='${CTDB_TEST_LIBEXECDIR}')
772 bld
.SAMBA_BINARY('ctdb_packet_parse',
773 source
='tests/src/ctdb_packet_parse.c',
774 deps
='talloc tevent tdb ctdb-protocol',
775 install_path
='${CTDB_TEST_LIBEXECDIR}')
777 bld
.SAMBA_BINARY('porting_tests',
778 source
='tests/src/porting_tests.c',
779 deps
='samba-util ctdb-system popt',
780 install_path
='${CTDB_TEST_LIBEXECDIR}')
783 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
784 source
=bld
.SUBDIR('tests/src',
785 'cluster_wait.c test_options.c'),
787 deps
='samba-util replace popt talloc tevent tdb')
789 bld
.SAMBA_BINARY('protocol_util_test',
790 source
='tests/src/protocol_util_test.c',
791 deps
='talloc ctdb-protocol samba-util',
792 install_path
='${CTDB_TEST_LIBEXECDIR}')
802 'fetch_readonly_loop',
805 'update_record_persistent',
810 for target
in ctdb_tests
:
811 src
= 'tests/src/' + target
+ '.c'
813 bld
.SAMBA_BINARY(target
,
816 deps
='''ctdb-client2 ctdb-protocol ctdb-util
817 samba-util ctdb-tests-common''',
818 install_path
='${CTDB_TEST_LIBEXECDIR}')
820 bld
.SAMBA_BINARY('ctdb_takeover_tests',
821 source
='''tests/src/ctdb_takeover_tests.c
822 tests/src/ipalloc_read_known_ips.c''',
823 deps
='''replace popt tdb tevent talloc ctdb-system
824 samba-util tdb-wrap talloc_report
825 ctdb-ipalloc ctdb-protocol ctdb-util''',
827 install_path
='${CTDB_TEST_LIBEXECDIR}')
829 bld
.SAMBA_BINARY('fake_ctdbd',
830 source
='''tests/src/fake_ctdbd.c
831 tests/src/ipalloc_read_known_ips.c''',
832 deps
='''ctdb-util ctdb-protocol ctdb-system
833 samba-util tevent-util LIBASYNC_REQ popt''',
834 install_path
='${CTDB_TEST_LIBEXECDIR}')
836 if bld
.env
.HAVE_INFINIBAND
:
837 bld
.SAMBA_BINARY('ibwrapper_test',
838 source
='ib/ibwrapper_test.c',
840 deps
='replace talloc ctdb-client ctdb-common sys_rw' +
842 install_path
='${CTDB_TEST_LIBEXECDIR}')
844 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
845 bld
.SAMBA_BINARY('test_mutex_raw',
846 source
='tests/src/test_mutex_raw.c',
848 install_path
='${CTDB_TEST_LIBEXECDIR}')
864 if bld
.env
.standalone_ctdb
:
867 testdir
= 'ctdb/tests'
869 for t
in test_subdirs
:
870 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
872 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
873 destname
=fmode
[0], chmod
=fmode
[1])
875 # Install tests/scripts directory without test_wrap
882 for t
in test_scripts
:
883 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
884 os
.path
.join('tests/scripts', t
),
885 destname
=os
.path
.join('scripts', t
))
887 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
888 bld
.env
.CTDB_TEST_LIBEXECDIR
)
889 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
890 source
='tests/scripts/test_wrap',
892 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
893 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
894 destname
='test_wrap', chmod
=0755)
896 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
897 source
='tests/scripts/script_install_paths.sh',
898 target
='script_install_paths.sh',
899 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
900 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
901 'script_install_paths.sh',
902 destname
='script_install_paths.sh', chmod
=0644)
904 sed_expr1
= 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
905 bld
.env
.CTDB_TEST_DATADIR
, bld
.env
.CTDB_TEST_LIBEXECDIR
)
906 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
907 bld
.SAMBA_GENERATOR('ctdb-test-runner',
908 source
='tests/run_tests.sh',
909 target
='ctdb_run_tests.sh',
910 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
911 sed_expr1
, sed_expr2
))
912 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
913 destname
='ctdb_run_tests', chmod
=0755)
914 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
917 test_eventscript_links
= [
921 'nfs-linux-kernel-callout',
925 test_link_dir
= os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
,
926 'eventscripts/etc-ctdb')
927 for t
in test_eventscript_links
:
928 bld
.symlink_as(os
.path
.join(test_link_dir
, t
),
929 os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
931 # Tests that use onnode need to overwrite link to in-tree
932 # functions file when installed
933 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'onnode/functions'),
934 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'functions'))
935 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'simple/functions'),
936 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'functions'))
938 # Need a link to nodes file because $CTDB_BASE is overridden
939 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'simple/nodes'),
940 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'nodes'))
944 cmd
= 'tests/run_tests.sh -V tests/var'
945 ret
= samba_utils
.RUN_COMMAND(cmd
)
947 print('tests exited with exit status %d' % ret
)
953 Scripting
.commands
.append('build')
954 Scripting
.commands
.append('testonly')
958 env
= samba_utils
.LOAD_ENVIRONMENT()
959 ld
= 'LD_PRELOAD=%s' % env
.SOCKET_WRAPPER_SO_PATH
960 cmd
= '%s tests/run_tests.sh -e -S -C' % ld
961 ret
= samba_utils
.RUN_COMMAND(cmd
)
963 print('autotest exited with exit status %d' % ret
)
967 def show_version(ctx
):
972 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
973 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
974 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
975 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
976 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
978 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
979 ret
= samba_utils
.RUN_COMMAND(cmd
)
981 print('Command %s failed with exit status %d' % (cmd
, ret
))
984 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
985 ret
= samba_utils
.RUN_COMMAND(cmd
)
987 print('Command %s failed with exit status %d' % (cmd
, ret
))
992 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
994 distfile
= file('.distversion', 'w')
995 for field
in version
.vcs_fields
:
996 distfile
.write('%s=%s\n' % (field
, str(version
.vcs_fields
[field
])))
998 samba_dist
.DIST_FILES('ctdb/.distversion:.distversion', extend
=True)
1001 sed_expr1
= 's/@VERSION@/%s/g' % VERSION
1002 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
1003 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1004 sed_expr1
, sed_expr2
, t
)
1005 ret
= samba_utils
.RUN_COMMAND(cmd
)
1007 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1009 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1011 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1013 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1014 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1022 Scripting
.commands
.append('manpages')
1023 Scripting
.commands
.append('distonly')
1027 opts
= os
.getenv('RPM_OPTIONS') or ''
1028 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts
, VERSION
)
1029 ret
= samba_utils
.RUN_COMMAND(cmd
)
1031 print('rpmbuild exited with exit status %d' % ret
)
1037 Scripting
.commands
.append('manpages')
1038 Scripting
.commands
.append('distonly')
1039 Scripting
.commands
.append('rpmonly')
1043 "build 'tags' file using ctags"
1045 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1046 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1047 print("Running: %s" % cmd
)
1048 ret
= samba_utils
.RUN_COMMAND(cmd
)
1050 print('ctags failed with exit status %d' % ret
)