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 third_party/socket_wrapper:third_party/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''')
52 'ctdb-script.options.5',
64 'ctdb_mutex_ceph_rados_helper.7',
69 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
71 opt
.RECURSE('lib/replace')
73 opt
.RECURSE('lib/util')
75 opt
.RECURSE('lib/talloc')
76 opt
.RECURSE('lib/tevent')
77 opt
.RECURSE('lib/tdb')
79 opt
.add_option('--enable-infiniband',
80 help=("Turn on infiniband support (default=no)"),
81 action
="store_true", dest
='ctdb_infiniband', default
=False)
82 opt
.add_option('--enable-pmda',
83 help=("Turn on PCP pmda support (default=no)"),
84 action
="store_true", dest
='ctdb_pmda', default
=False)
85 opt
.add_option('--enable-etcd-reclock',
86 help=("Enable etcd recovery lock helper (default=no)"),
87 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
88 opt
.add_option('--enable-ceph-reclock',
89 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
90 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
92 opt
.add_option('--with-logdir',
93 help=("Path to log directory"),
94 action
="store", dest
='ctdb_logdir', default
=None)
95 opt
.add_option('--with-socketpath',
96 help=("path to CTDB daemon socket"),
97 action
="store", dest
='ctdb_sockpath', default
=None)
102 # No need to build python bindings for talloc/tevent/tdb
103 if conf
.IN_LAUNCH_DIR():
104 conf
.env
.standalone_ctdb
= True
105 Options
.options
.disable_python
= True
107 conf
.RECURSE('lib/replace')
109 conf
.CHECK_HEADERS(headers
='''sys/socket.h
117 conf
.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
118 define
='HAVE_AF_PACKET',
119 headers
='sys/socket.h linux/if_packet.h')
121 conf
.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
122 define
='HAVE_PACKETSOCKET',
123 headers
='sys/socket.h linux/if_packet.h')
125 if conf
.env
.standalone_ctdb
:
126 conf
.SAMBA_CHECK_PERL(mandatory
=True)
128 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
129 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
131 if conf
.CHECK_FOR_THIRD_PARTY():
132 conf
.RECURSE('third_party/popt')
133 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
134 conf
.RECURSE('third_party/socket_wrapper')
135 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
137 if not conf
.CHECK_POPT():
138 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
140 conf
.define('USING_SYSTEM_POPT', 1)
141 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
144 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
145 if not conf
.CHECK_SOCKET_WRAPPER():
146 raise Utils
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
148 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
149 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
151 conf
.RECURSE('lib/util')
153 conf
.RECURSE('lib/talloc')
154 conf
.RECURSE('lib/tevent')
155 conf
.RECURSE('lib/tdb')
157 conf
.CHECK_HEADERS('sched.h')
158 conf
.CHECK_HEADERS('procinfo.h')
159 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
160 Logs
.error('Need thread_setsched() on AIX')
162 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
163 Logs
.error('Need sched_setscheduler()')
165 conf
.CHECK_FUNCS('mlockall')
167 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
168 conf
.DEFINE('ETIME', 'ETIMEDOUT')
170 if sys
.platform
.startswith('linux'):
171 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
173 if not conf
.CHECK_HEADERS('pcap.h'):
174 Logs
.error('Need libpcap')
176 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
177 Logs
.error('Need libpcap')
180 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
181 checklibc
=True, headers
='execinfo.h'):
182 Logs
.error('backtrace support not available')
185 if Options
.options
.ctdb_pmda
:
188 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
191 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
193 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
196 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
199 Logs
.error("PMDA support not available")
202 Logs
.info('Building with PMDA support')
203 conf
.define('HAVE_PMDA', 1)
204 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
205 'lib/pcp/pmdas/ctdb')
207 have_infiniband
= False
208 if Options
.options
.ctdb_infiniband
:
211 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
213 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
215 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
218 have_infiniband
= True
220 Logs
.error("Infiniband support not available")
223 Logs
.info('Building with Infiniband support')
224 conf
.define('HAVE_INFINIBAND', 1)
225 conf
.define('USE_INFINIBAND', 1)
227 have_etcd_reclock
= False
228 if Options
.options
.ctdb_etcd_reclock
:
230 conf
.check_python_module('etcd')
231 have_etcd_reclock
= True
233 Logs
.error('etcd support not available')
235 if have_etcd_reclock
:
236 Logs
.info('Building with etcd support')
237 conf
.env
.etcd_reclock
= have_etcd_reclock
239 if Options
.options
.ctdb_ceph_reclock
:
240 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
241 conf
.CHECK_LIB('rados', shlib
=True)):
242 Logs
.info('Building with Ceph librados recovery lock support')
243 conf
.define('HAVE_LIBRADOS', 1)
245 Logs
.error("Missing librados for Ceph recovery lock support")
248 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
249 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
250 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
251 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
252 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
254 if Options
.options
.ctdb_logdir
:
255 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
257 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
259 if Options
.options
.ctdb_sockpath
:
260 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
262 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
264 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
266 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
270 -DCTDB_RUNDIR=\"%s\"''' % (
271 conf
.env
.CTDB_HELPER_BINDIR
,
272 conf
.env
.CTDB_LOGDIR
,
273 conf
.env
.CTDB_ETCDIR
,
274 conf
.env
.CTDB_VARDIR
,
275 conf
.env
.CTDB_RUNDIR
))
277 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
279 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
281 # Allow unified compilation and separate compilation of utilities
283 if not conf
.env
.standalone_ctdb
:
284 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
287 # Building from tarball
288 conf
.ADD_EXTRA_INCLUDES('#include')
290 # Building standalone CTDB from within Samba tree
291 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
292 conf
.ADD_EXTRA_INCLUDES('#ctdb')
293 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
295 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
296 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
297 conf
.SAMBA_CONFIG_H()
299 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
300 conf
.env
.ctdb_generate_manpages
= True
302 conf
.env
.ctdb_generate_manpages
= False
304 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
305 conf
.env
.ctdb_prebuilt_manpages
= []
306 manpages
= manpages_binary
+ manpages_misc
307 if conf
.env
.etcd_reclock
:
308 manpages
+= manpages_etcd
309 if conf
.env
.HAVE_LIBRADOS
:
310 manpages
+= manpages_ceph
312 if os
.path
.exists(os
.path
.join("doc", m
)):
313 Logs
.info(" %s: yes" % (m
))
314 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
316 Logs
.info(" %s: no" % (m
))
318 def gen_ctdb_version(task
):
319 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
320 fp
.write('/* This file is auto-generated from waf */\n')
321 fp
.write('#include "version.h"\n')
323 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
328 if bld
.env
.standalone_ctdb
:
329 # enable building of public headers in the build tree
330 bld
.env
.build_public_headers
= 'include/public'
332 if bld
.env
.standalone_ctdb
:
333 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
335 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
336 target
='include/ctdb_version.h',
337 rule
=gen_ctdb_version
,
338 dep_vars
=['VERSION'])
339 t
.env
.VERSION
= VERSION
341 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
343 bld
.RECURSE('lib/replace')
344 if bld
.CHECK_FOR_THIRD_PARTY():
345 bld
.RECURSE('third_party/popt')
346 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
347 bld
.RECURSE('third_party/socket_wrapper')
349 bld
.RECURSE('lib/tdb_wrap')
350 bld
.RECURSE('lib/util')
351 bld
.RECURSE('lib/async_req')
353 bld
.RECURSE('lib/talloc')
354 bld
.RECURSE('lib/tevent')
355 bld
.RECURSE('lib/tdb')
357 if bld
.env
.standalone_ctdb
:
358 # If a combined build is implemented, CTDB will want to
359 # build against samba-util rather than samba-util-core.
360 # Similarly, other Samba subsystems expect samba-util. So,
361 # for a standalone build, just define a fake samba-util
362 # subsystem that pulls in samba-util-core.
363 bld
.SAMBA_SUBSYSTEM('samba-util',
365 deps
='samba-util-core')
367 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
368 source
=bld
.SUBDIR('tcp',
369 'tcp_connect.c tcp_init.c tcp_io.c'),
371 deps
='replace tdb talloc tevent')
374 if bld
.env
.HAVE_INFINIBAND
:
375 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
376 source
=bld
.SUBDIR('ib',
377 '''ibwrapper.c ibw_ctdb.c
380 deps
='replace talloc tevent tdb')
381 ib_deps
= ' ctdb-ib rdmacm ibverbs'
383 bld
.SAMBA_SUBSYSTEM('ctdb-system',
384 source
=bld
.SUBDIR('common',
385 'system_socket.c system.c'),
387 deps
='replace talloc tevent tdb pcap samba-util')
389 bld
.SAMBA_SUBSYSTEM('ctdb-common',
390 source
=bld
.SUBDIR('common',
391 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
394 deps
='''replace popt talloc tevent tdb popt ctdb-system
395 ctdb-protocol-util''')
397 bld
.SAMBA_SUBSYSTEM('ctdb-util',
398 source
=bld
.SUBDIR('common',
399 '''db_hash.c srvid.c reqid.c
400 pkt_read.c pkt_write.c comm.c
401 logging.c rb_tree.c tunable.c
403 hash_count.c run_event.c
404 sock_client.c version.c
405 cmdline.c path.c conf.c
407 deps
='''samba-util sys_rw tevent-util
408 replace talloc tevent tdb popt''')
410 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
411 source
='common/logging_conf.c',
412 deps
='ctdb-util talloc')
414 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
415 source
=bld
.SUBDIR('protocol', 'protocol_basic.c'),
418 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
419 source
=bld
.SUBDIR('protocol',
420 '''protocol_header.c protocol_packet.c
431 deps
='ctdb-protocol-basic replace talloc tdb')
433 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
434 source
='protocol/protocol_util.c',
435 deps
='replace talloc tdb')
437 bld
.SAMBA_SUBSYSTEM('ctdb-client',
438 source
=bld
.SUBDIR('client',
439 '''client_connect.c client_call.c
440 client_message.c client_control.c
441 client_message_sync.c
442 client_control_sync.c
443 client_db.c client_util.c
447 deps
='replace talloc tevent tdb tdb-wrap')
449 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
450 source
=bld
.SUBDIR('common',
451 '''sock_daemon.c'''),
452 deps
='''samba-util ctdb-util ctdb-system tevent-util
453 LIBASYNC_REQ replace talloc tevent''')
455 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
456 source
=bld
.SUBDIR('server',
457 '''ipalloc_deterministic.c
458 ipalloc_nondeterministic.c
464 deps
='ctdb-protocol-util replace talloc tevent')
466 bld
.SAMBA_BINARY('ctdb-path',
467 source
='common/path_tool.c',
468 cflags
='-DCTDB_PATH_TOOL',
469 deps
='''ctdb-util samba-util talloc replace popt''',
470 install_path
='${CTDB_HELPER_BINDIR}')
472 bld
.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
473 source
='cluster/cluster_conf.c',
476 bld
.SAMBA_SUBSYSTEM('ctdb-database-conf',
477 source
='database/database_conf.c',
480 bld
.SAMBA_SUBSYSTEM('ctdb-event-conf',
481 source
='event/event_conf.c',
484 bld
.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
485 source
='server/legacy_conf.c',
488 bld
.SAMBA_BINARY('ctdb-config',
489 source
='common/conf_tool.c',
490 cflags
='-DCTDB_CONF_TOOL',
491 deps
='''ctdb-logging-conf
496 ctdb-util samba-util talloc replace popt''',
497 install_path
='${CTDB_HELPER_BINDIR}')
499 bld
.SAMBA_SUBSYSTEM('ctdb-event-protocol',
500 source
=bld
.SUBDIR('event',
502 event_protocol_util.c
504 deps
='ctdb-protocol-basic')
506 bld
.SAMBA_LIBRARY('ctdb-event-client',
507 source
='event/event_client.c',
508 deps
='ctdb-event-protocol ctdb-util tevent talloc',
509 private_library
=True)
511 bld
.SAMBA_BINARY('ctdb-eventd',
512 source
=bld
.SUBDIR('event',
519 deps
='''ctdb-event-protocol
520 ctdb-event-conf ctdb-logging-conf
521 ctdb-server-util samba-util ctdb-util
522 talloc tevent replace popt''',
523 install_path
='${CTDB_HELPER_BINDIR}')
525 bld
.SAMBA_BINARY('ctdb-event',
526 source
='event/event_tool.c',
527 cflags
='-DCTDB_EVENT_TOOL',
528 deps
='''ctdb-event-client ctdb-event-protocol
529 ctdb-util samba-util talloc replace''',
530 install_path
='${CTDB_HELPER_BINDIR}')
532 bld
.SAMBA_BINARY('ctdbd',
533 source
='server/ctdbd.c ' +
535 '''ctdb_daemon.c ctdb_recoverd.c
536 ctdb_recover.c ctdb_freeze.c
537 ctdb_tunables.c ctdb_monitor.c
538 ctdb_server.c ctdb_control.c
539 ctdb_call.c ctdb_ltdb_server.c
540 ctdb_traverse.c eventscript.c
542 ctdb_persistent.c ctdb_keepalive.c
546 ctdb_vacuum.c ctdb_banning.c
549 ctdb_lock.c ctdb_fork.c
550 ctdb_tunnel.c ctdb_client.c
554 deps
='''ctdb-common ctdb-system ctdb-protocol
555 ctdb-tcp ctdb-util replace sys_rw popt
561 talloc tevent tdb-wrap tdb talloc_report''' +
563 install_path
='${SBINDIR}',
566 bld
.SAMBA_BINARY('ctdb',
567 source
='tools/ctdb.c',
568 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
569 ctdb-util ctdb-system samba-util sys_rw popt''',
570 install_path
='${BINDIR}',
573 bld
.SAMBA_BINARY('ctdb_killtcp',
574 source
='tools/ctdb_killtcp.c',
575 deps
='''ctdb-protocol-util ctdb-util ctdb-system
576 samba-util replace''',
577 install_path
='${CTDB_HELPER_BINDIR}')
579 bld
.SAMBA_BINARY('ltdbtool',
580 source
='tools/ltdbtool.c',
583 install_path
='${BINDIR}',
584 manpages
='ltdbtool.1')
586 bld
.SAMBA_BINARY('ctdb_lock_helper',
587 source
='server/ctdb_lock_helper.c',
588 deps
='''samba-util sys_rw ctdb-system tevent-util
589 talloc tevent tdb''',
591 install_path
='${CTDB_HELPER_BINDIR}')
593 bld
.SAMBA_BINARY('ctdb_recovery_helper',
594 source
='server/ctdb_recovery_helper.c',
595 deps
='''ctdb-client ctdb-protocol ctdb-util
596 samba-util sys_rw replace tdb''',
597 install_path
='${CTDB_HELPER_BINDIR}')
599 bld
.SAMBA_BINARY('ctdb_takeover_helper',
600 source
='server/ctdb_takeover_helper.c',
601 deps
='''ctdb-client ctdb-protocol ctdb-util
602 samba-util sys_rw replace ctdb-ipalloc popt''',
603 install_path
='${CTDB_HELPER_BINDIR}')
605 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
606 source
='server/ctdb_mutex_fcntl_helper.c',
607 deps
='sys_rw ctdb-system',
609 install_path
='${CTDB_HELPER_BINDIR}')
611 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
612 source
='utils/smnotify/smnotify.x',
613 target
='utils/smnotify/smnotify.h',
614 rule
='rpcgen -h ${SRC} > ${TGT}')
616 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
618 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
619 source
='utils/smnotify/smnotify.x',
620 target
='utils/smnotify/gen_xdr.c',
621 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
623 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
624 source
='utils/smnotify/smnotify.x',
625 target
='utils/smnotify/gen_smnotify.c',
626 rule
='rpcgen -l ${SRC} > ${TGT}')
628 bld
.SAMBA_BINARY('smnotify',
629 source
=bld
.SUBDIR('utils/smnotify',
630 'smnotify.c gen_smnotify.c gen_xdr.c'),
631 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
632 includes
='utils utils/smnotify',
633 install_path
='${CTDB_HELPER_BINDIR}')
635 bld
.SAMBA_BINARY('ping_pong',
636 source
='utils/ping_pong/ping_pong.c',
638 install_path
='${BINDIR}',
639 manpages
='ping_pong.1')
641 if bld
.env
.HAVE_PMDA
:
642 bld
.SAMBA_BINARY('pmdactdb',
643 source
='utils/pmda/pmda_ctdb.c',
645 deps
='''ctdb-client ctdb-protocol ctdb-util
646 samba-util pcp_pmda pcp''',
647 install_path
='${CTDB_PMDADIR}')
648 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
650 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
652 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
654 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
656 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
658 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
661 if bld
.env
.HAVE_LIBRADOS
:
662 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
663 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
664 deps
='talloc tevent rados',
666 install_path
='${CTDB_HELPER_BINDIR}')
668 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
669 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
670 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
671 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
672 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
673 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
674 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
675 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
676 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
677 sed_expr6
, sed_expr7
)
679 manpages_extra
= manpages_misc
680 if bld
.env
.etcd_reclock
:
681 manpages_extra
+= manpages_etcd
682 if bld
.env
.HAVE_LIBRADOS
:
683 manpages_extra
+= manpages_ceph
684 for f
in manpages_binary
+ manpages_extra
:
686 bld
.SAMBA_GENERATOR(x
,
687 source
=os
.path
.join('doc', x
),
689 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
691 if bld
.env
.ctdb_generate_manpages
:
692 bld
.MANPAGES(' '.join(manpages_extra
), True)
694 for m
in bld
.env
.ctdb_prebuilt_manpages
:
695 bld
.SAMBA_GENERATOR(m
,
696 source
=os
.path
.join("doc", m
),
698 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
699 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
701 bld
.SAMBA_GENERATOR('ctdb-onnode',
702 source
='tools/onnode',
704 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
705 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
706 destname
='onnode', chmod
=0755)
708 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
709 source
='tools/ctdb_diagnostics',
710 target
='ctdb_diagnostics',
711 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
712 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
713 destname
='ctdb_diagnostics', chmod
=0755)
715 if bld
.env
.etcd_reclock
:
716 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
717 source
='utils/etcd/ctdb_etcd_lock',
718 target
='ctdb_etcd_lock',
719 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
720 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
721 destname
='ctdb_etcd_lock', chmod
=0744)
723 bld
.SAMBA_GENERATOR('ctdb-natgw',
724 source
='tools/ctdb_natgw',
726 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
727 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
728 destname
='ctdb_natgw', chmod
=0755)
730 bld
.SAMBA_GENERATOR('ctdb-lvs',
731 source
='tools/ctdb_lvs',
733 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
734 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
735 destname
='ctdb_lvs', chmod
=0755)
737 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
738 source
='config/ctdbd_wrapper',
739 target
='ctdbd_wrapper',
740 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
741 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
742 destname
='ctdbd_wrapper', chmod
=0755)
744 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
746 fl
= os
.path
.join(dirname
, f
)
747 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
749 mode
= os
.lstat(fl
).st_mode
& 0777
751 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
752 arg
['file_list'].append([fl
, mode
])
754 def SUBDIR_MODE(path
, trim_path
=None):
755 pd
= {'trim_path': trim_path
, 'file_list': []}
756 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
757 return pd
['file_list']
764 if bld
.env
.standalone_ctdb
:
767 configdir
= 'ctdb/config'
769 for t
in etc_subdirs
:
770 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
772 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
773 destname
=fmode
[0], chmod
=fmode
[1])
775 bld
.SAMBA_GENERATOR('ctdb-functions',
776 source
='config/functions',
778 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
779 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
782 'ctdb-crash-cleanup.sh',
783 'debug-hung-script.sh',
785 'nfs-linux-kernel-callout',
790 for t
in etc_scripts
:
791 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
792 destname
=t
, chmod
=0755)
794 bld
.SAMBA_GENERATOR('ctdb-sudoers',
795 source
='config/ctdb.sudoers',
796 target
='ctdb.sudoers',
797 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
798 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
801 bld
.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
802 'config/notification.README',
805 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
806 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
807 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
809 for d
in ['volatile', 'persistent', 'state']:
810 bld
.install_dir(os
.path
.join(bld
.env
.CTDB_VARDIR
, d
))
830 for target
in ctdb_unit_tests
:
831 src
= 'tests/src/' + target
+ '.c'
833 bld
.SAMBA_BINARY(target
,
835 deps
='''talloc tevent tdb tevent-util popt
836 LIBASYNC_REQ samba-util sys_rw''',
837 install_path
='${CTDB_TEST_LIBEXECDIR}')
839 bld
.SAMBA_BINARY('reqid_test',
840 source
='tests/src/reqid_test.c',
842 install_path
='${CTDB_TEST_LIBEXECDIR}')
844 bld
.SAMBA_BINARY('rb_test',
845 source
='tests/src/rb_test.c',
846 deps
='samba-util talloc',
847 install_path
='${CTDB_TEST_LIBEXECDIR}')
849 bld
.SAMBA_BINARY('ctdb_packet_parse',
850 source
='tests/src/ctdb_packet_parse.c',
851 deps
='talloc tevent tdb ctdb-protocol',
852 install_path
='${CTDB_TEST_LIBEXECDIR}')
854 bld
.SAMBA_BINARY('porting_tests',
855 source
='tests/src/porting_tests.c',
856 deps
='samba-util ctdb-system popt',
857 install_path
='${CTDB_TEST_LIBEXECDIR}')
859 bld
.SAMBA_BINARY('sock_daemon_test',
860 source
='tests/src/sock_daemon_test.c',
861 deps
='''ctdb-system talloc tevent tevent-util
862 LIBASYNC_REQ samba-util sys_rw''',
863 install_path
='${CTDB_TEST_LIBEXECDIR}')
865 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
866 source
=bld
.SUBDIR('tests/src',
867 'protocol_common_basic.c'),
868 deps
='replace talloc')
870 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
871 source
=bld
.SUBDIR('tests/src',
873 protocol_common_ctdb.c
876 deps
='ctdb-protocol-tests-basic replace talloc tdb')
878 bld
.SAMBA_BINARY('protocol_basic_test',
879 source
=bld
.SUBDIR('tests/src', 'protocol_basic_test.c'),
880 deps
='ctdb-protocol-tests-basic talloc',
881 install_path
='${CTDB_TEST_LIBEXECDIR}')
883 ctdb_protocol_tests
= [
884 'protocol_types_test',
885 'protocol_ctdb_test',
886 'protocol_util_test',
887 'protocol_types_compat_test',
888 'protocol_ctdb_compat_test',
891 for target
in ctdb_protocol_tests
:
892 src
= 'tests/src/' + target
+ '.c'
894 bld
.SAMBA_BINARY(target
,
896 deps
='''ctdb-protocol-tests-common
897 samba-util talloc tdb''',
898 install_path
='${CTDB_TEST_LIBEXECDIR}')
900 bld
.SAMBA_BINARY('event_protocol_test',
901 source
='event/event_protocol_test.c',
902 deps
='''ctdb-protocol-tests-basic
903 ctdb-protocol-basic talloc''',
904 install_path
='${CTDB_TEST_LIBEXECDIR}')
906 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
907 source
=bld
.SUBDIR('tests/src',
908 'cluster_wait.c test_options.c'),
910 deps
='samba-util replace popt talloc tevent tdb')
920 'fetch_readonly_loop',
923 'update_record_persistent',
930 for target
in ctdb_tests
:
931 src
= 'tests/src/' + target
+ '.c'
933 bld
.SAMBA_BINARY(target
,
936 deps
='''ctdb-client ctdb-protocol ctdb-util
937 samba-util ctdb-tests-common''',
938 install_path
='${CTDB_TEST_LIBEXECDIR}')
940 bld
.SAMBA_BINARY('ctdb_takeover_tests',
941 source
='''tests/src/ctdb_takeover_tests.c
942 tests/src/ipalloc_read_known_ips.c''',
943 deps
='''replace popt tdb tevent talloc ctdb-system
944 samba-util tdb-wrap talloc_report
945 ctdb-ipalloc ctdb-protocol ctdb-util''',
947 install_path
='${CTDB_TEST_LIBEXECDIR}')
949 bld
.SAMBA_BINARY('fake_ctdbd',
950 source
='''tests/src/fake_ctdbd.c
951 tests/src/ipalloc_read_known_ips.c''',
952 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
953 ctdb-system samba-util tevent-util
954 LIBASYNC_REQ popt''',
955 install_path
='${CTDB_TEST_LIBEXECDIR}')
957 if bld
.env
.HAVE_INFINIBAND
:
958 bld
.SAMBA_BINARY('ibwrapper_test',
959 source
='ib/ibwrapper_test.c',
961 deps
='replace talloc ctdb-common sys_rw' +
963 install_path
='${CTDB_TEST_LIBEXECDIR}')
965 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
966 bld
.SAMBA_BINARY('test_mutex_raw',
967 source
='tests/src/test_mutex_raw.c',
969 install_path
='${CTDB_TEST_LIBEXECDIR}')
985 if bld
.env
.standalone_ctdb
:
988 testdir
= 'ctdb/tests'
990 for t
in test_subdirs
:
991 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
993 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
994 destname
=fmode
[0], chmod
=fmode
[1])
996 # Install tests/scripts directory without test_wrap
1003 for t
in test_scripts
:
1004 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
1005 os
.path
.join('tests/scripts', t
),
1006 destname
=os
.path
.join('scripts', t
))
1008 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1009 bld
.env
.CTDB_TEST_LIBEXECDIR
)
1010 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
1011 source
='tests/scripts/test_wrap',
1013 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
1014 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
1015 destname
='test_wrap', chmod
=0755)
1017 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1018 source
='tests/scripts/script_install_paths.sh',
1019 target
='script_install_paths.sh',
1020 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
1021 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
1022 'script_install_paths.sh',
1023 destname
='script_install_paths.sh', chmod
=0644)
1025 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
1026 'CTDB_TEST_DIR
', bld.env.CTDB_TEST_DATADIR,
1027 'TEST_BIN_DIR
', bld.env.CTDB_TEST_LIBEXECDIR)
1028 sed_expr2 = 's
@^\
(export CTDB_TESTS_ARE_INSTALLED\
)=false
@\\1=true
@'
1029 bld.SAMBA_GENERATOR('ctdb
-test
-runner
',
1030 source='tests
/run_tests
.sh
',
1031 target='ctdb_run_tests
.sh
',
1032 rule='sed
-e
"%s" -e
"%s" ${SRC}
> ${TGT}
' % (
1033 sed_expr1, sed_expr2))
1034 bld.INSTALL_FILES('${BINDIR}
', 'ctdb_run_tests
.sh
',
1035 destname='ctdb_run_tests
', chmod=0755)
1036 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests
'),
1041 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
1042 ret = samba_utils.RUN_COMMAND(cmd)
1044 print('tests exited with exit status
%d' % ret)
1050 Scripting.commands.append('build
')
1051 Scripting.commands.append('testonly
')
1055 env = samba_utils.LOAD_ENVIRONMENT()
1056 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
1057 ret = samba_utils.RUN_COMMAND(cmd)
1059 print('autotest exited with exit status
%d' % ret)
1063 def show_version(ctx):
1068 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
1069 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
1070 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
1071 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
1072 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1074 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
1075 ret = samba_utils.RUN_COMMAND(cmd)
1077 print('Command
%s failed with exit status
%d' % (cmd, ret))
1080 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
1081 ret = samba_utils.RUN_COMMAND(cmd)
1083 print('Command
%s failed with exit status
%d' % (cmd, ret))
1088 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
1090 distfile = file('.distversion
', 'w
')
1091 for field in version.vcs_fields:
1092 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1094 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1097 sed_expr1 = 's
/@VERSION@/%s/g
' % VERSION
1098 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1099 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1100 sed_expr1, sed_expr2, t)
1101 ret = samba_utils.RUN_COMMAND(cmd)
1103 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1105 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1107 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1109 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1110 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1118 Scripting.commands.append('manpages
')
1119 Scripting.commands.append('distonly
')
1123 opts = os.getenv('RPM_OPTIONS
') or ''
1124 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % (opts, VERSION)
1125 ret = samba_utils.RUN_COMMAND(cmd)
1127 print('rpmbuild exited with exit status
%d' % ret)
1133 Scripting.commands.append('manpages
')
1134 Scripting.commands.append('distonly
')
1135 Scripting.commands.append('rpmonly
')
1139 "build 'tags
' file using ctags"
1141 source_root = os.path.dirname(Utils.g_module.root_path)
1142 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1143 print("Running: %s" % cmd)
1144 ret = samba_utils.RUN_COMMAND(cmd)
1146 print('ctags failed with exit status
%d' % ret)