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_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
250 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
251 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
252 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
253 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
255 if Options.options.ctdb_logdir:
256 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
258 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
260 if Options.options.ctdb_sockpath:
261 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
263 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
265 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
267 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
269 -DCTDB_DATADIR=\"%s\"
272 -DCTDB_RUNDIR=\"%s\"''' % (
273 conf.env.CTDB_HELPER_BINDIR,
274 conf.env.CTDB_LOGDIR,
275 conf.env.CTDB_DATADIR,
276 conf.env.CTDB_ETCDIR,
277 conf.env.CTDB_VARDIR,
278 conf.env.CTDB_RUNDIR))
280 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
281 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
283 # Allow unified compilation and separate compilation of utilities
285 if not conf.env.standalone_ctdb:
286 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
289 # Building from tarball
290 conf.ADD_EXTRA_INCLUDES('#include')
292 # Building standalone CTDB from within Samba tree
293 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
294 conf.ADD_EXTRA_INCLUDES('#ctdb')
295 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
297 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
298 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
299 conf.SAMBA_CONFIG_H()
301 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
302 conf.env.ctdb_generate_manpages = True
304 conf.env.ctdb_generate_manpages = False
306 Logs.info("xsltproc unavailable, checking for pre-built manpages")
307 conf.env.ctdb_prebuilt_manpages = []
308 manpages = manpages_binary + manpages_misc
309 if conf.env.etcd_reclock:
310 manpages += manpages_etcd
311 if conf.env.HAVE_LIBRADOS:
312 manpages += manpages_ceph
314 if os.path.exists(os.path.join("doc", m)):
315 Logs.info(" %s: yes" % (m))
316 conf.env.ctdb_prebuilt_manpages.append(m)
318 Logs.info(" %s: no" % (m))
320 def gen_ctdb_version(task):
321 fp = file(task.outputs[0].bldpath(task.env), 'w')
322 fp.write('/* This file is auto-generated from waf */\n')
323 fp.write('#include "version.h"\n')
325 fp.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION)
330 if bld.env.standalone_ctdb:
331 # enable building of public headers in the build tree
332 bld.env.build_public_headers = 'include/public'
334 if bld.env.standalone_ctdb:
335 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
337 t = bld.SAMBA_GENERATOR('ctdb-version-header',
338 target='include/ctdb_version.h',
339 rule=gen_ctdb_version,
340 dep_vars=['VERSION'])
341 t.env.VERSION = VERSION
343 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
345 bld.RECURSE('lib/replace')
346 if bld.CHECK_FOR_THIRD_PARTY():
347 bld.RECURSE('third_party/popt')
348 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
349 bld.RECURSE('third_party/socket_wrapper')
351 bld.RECURSE('lib/tdb_wrap')
352 bld.RECURSE('lib/util')
353 bld.RECURSE('lib/async_req')
355 bld.RECURSE('lib/talloc')
356 bld.RECURSE('lib/tevent')
357 bld.RECURSE('lib/tdb')
359 if bld.env.standalone_ctdb:
360 # If a combined build is implemented, CTDB will want to
361 # build against samba-util rather than samba-util-core.
362 # Similarly, other Samba subsystems expect samba-util. So,
363 # for a standalone build, just define a fake samba-util
364 # subsystem that pulls in samba-util-core.
365 bld.SAMBA_SUBSYSTEM('samba-util',
367 deps='samba-util-core')
369 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
370 source=bld.SUBDIR('tcp',
371 'tcp_connect.c tcp_init.c tcp_io.c'),
373 deps='replace tdb talloc tevent')
376 if bld.env.HAVE_INFINIBAND:
377 bld.SAMBA_SUBSYSTEM('ctdb-ib',
378 source=bld.SUBDIR('ib',
379 '''ibwrapper.c ibw_ctdb.c
382 deps='replace talloc tevent tdb')
383 ib_deps = ' ctdb-ib rdmacm ibverbs'
385 bld.SAMBA_SUBSYSTEM('ctdb-system',
386 source=bld.SUBDIR('common',
387 'system_socket.c system.c'),
389 deps='replace talloc tevent tdb pcap samba-util')
391 bld.SAMBA_SUBSYSTEM('ctdb-common',
392 source=bld.SUBDIR('common',
393 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
396 deps='''replace popt talloc tevent tdb popt ctdb-system
397 ctdb-protocol-util''')
399 bld.SAMBA_SUBSYSTEM('ctdb-util',
400 source=bld.SUBDIR('common',
401 '''db_hash.c srvid.c reqid.c
402 pkt_read.c pkt_write.c comm.c
403 logging.c rb_tree.c tunable.c
406 run_event.c event_script.c
407 sock_client.c version.c
408 cmdline.c path.c conf.c line.c
410 deps='''samba-util sys_rw tevent-util
411 replace talloc tevent tdb popt''')
413 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
414 source='common/logging_conf.c',
415 deps='ctdb-util talloc')
417 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
418 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
421 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
422 source=bld.SUBDIR('protocol',
423 '''protocol_header.c protocol_packet.c
434 deps='ctdb-protocol-basic replace talloc tdb')
436 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
437 source='protocol/protocol_util.c',
438 deps='ctdb-util replace talloc tdb')
440 bld.SAMBA_SUBSYSTEM('ctdb-client',
441 source=bld.SUBDIR('client',
442 '''client_connect.c client_call.c
443 client_message.c client_control.c
444 client_message_sync.c
445 client_control_sync.c
446 client_db.c client_util.c
450 deps='replace talloc tevent tdb tdb-wrap')
452 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
453 source=bld.SUBDIR('common',
454 '''sock_daemon.c'''),
455 deps='''samba-util ctdb-util ctdb-system tevent-util
456 LIBASYNC_REQ replace talloc tevent''')
458 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
459 source=bld.SUBDIR('server',
460 '''ipalloc_deterministic.c
461 ipalloc_nondeterministic.c
467 deps='ctdb-protocol-util replace talloc tevent')
469 bld.SAMBA_BINARY('ctdb-path',
470 source='common/path_tool.c',
471 cflags='-DCTDB_PATH_TOOL',
472 deps='''ctdb-util samba-util talloc replace popt''',
473 install_path='${CTDB_HELPER_BINDIR}')
475 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
476 source='cluster/cluster_conf.c',
479 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
480 source='database/database_conf.c',
483 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
484 source='event/event_conf.c',
487 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
488 source='server/legacy_conf.c',
491 bld.SAMBA_BINARY('ctdb-config',
492 source='common/conf_tool.c',
493 cflags='-DCTDB_CONF_TOOL',
494 deps='''ctdb-logging-conf
499 ctdb-util samba-util talloc replace popt''',
500 install_path='${CTDB_HELPER_BINDIR}')
502 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
503 source=bld.SUBDIR('event',
505 event_protocol_util.c
507 deps='ctdb-protocol-basic')
509 bld.SAMBA_LIBRARY('ctdb-event-client',
510 source='event/event_client.c',
511 deps='ctdb-event-protocol ctdb-util tevent talloc',
512 private_library=True)
514 bld.SAMBA_BINARY('ctdb-eventd',
515 source=bld.SUBDIR('event',
522 deps='''ctdb-event-protocol
523 ctdb-event-conf ctdb-logging-conf
524 ctdb-server-util samba-util ctdb-util
525 talloc tevent replace popt''',
526 install_path='${CTDB_HELPER_BINDIR}')
528 bld.SAMBA_BINARY('ctdb-event',
529 source='event/event_tool.c',
530 cflags='-DCTDB_EVENT_TOOL',
531 deps='''ctdb-event-client ctdb-event-protocol
532 ctdb-util samba-util talloc replace''',
533 install_path='${CTDB_HELPER_BINDIR}')
535 bld.SAMBA_BINARY('ctdbd',
536 source='server/ctdbd.c ' +
538 '''ctdb_daemon.c ctdb_recoverd.c
539 ctdb_recover.c ctdb_freeze.c
540 ctdb_tunables.c ctdb_monitor.c
541 ctdb_server.c ctdb_control.c
542 ctdb_call.c ctdb_ltdb_server.c
543 ctdb_traverse.c eventscript.c
545 ctdb_persistent.c ctdb_keepalive.c
549 ctdb_vacuum.c ctdb_banning.c
552 ctdb_lock.c ctdb_fork.c
553 ctdb_tunnel.c ctdb_client.c
557 deps='''ctdb-common ctdb-system ctdb-protocol
558 ctdb-tcp ctdb-util replace sys_rw popt
565 talloc tevent tdb-wrap tdb talloc_report''' +
567 install_path='${SBINDIR}',
570 bld.SAMBA_BINARY('ctdb',
571 source='tools/ctdb.c',
572 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
573 ctdb-util ctdb-system samba-util sys_rw popt''',
574 install_path='${BINDIR}',
577 bld.SAMBA_BINARY('ctdb_killtcp',
578 source='tools/ctdb_killtcp.c',
579 deps='''ctdb-protocol-util ctdb-util ctdb-system
580 samba-util replace''',
581 install_path='${CTDB_HELPER_BINDIR}')
583 bld.SAMBA_BINARY('ltdbtool',
584 source='tools/ltdbtool.c',
587 install_path='${BINDIR}',
588 manpages='ltdbtool.1')
590 bld.SAMBA_BINARY('ctdb_lock_helper',
591 source='server/ctdb_lock_helper.c',
592 deps='''samba-util sys_rw ctdb-system tevent-util
593 talloc tevent tdb''',
595 install_path='${CTDB_HELPER_BINDIR}')
597 bld.SAMBA_BINARY('ctdb_recovery_helper',
598 source='server/ctdb_recovery_helper.c',
599 deps='''ctdb-client ctdb-protocol ctdb-util
600 samba-util sys_rw replace tdb''',
601 install_path='${CTDB_HELPER_BINDIR}')
603 bld.SAMBA_BINARY('ctdb_takeover_helper',
604 source='server/ctdb_takeover_helper.c',
605 deps='''ctdb-client ctdb-protocol ctdb-util
606 samba-util sys_rw replace ctdb-ipalloc popt''',
607 install_path='${CTDB_HELPER_BINDIR}')
609 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
610 source='server/ctdb_mutex_fcntl_helper.c',
611 deps='sys_rw ctdb-system',
613 install_path='${CTDB_HELPER_BINDIR}')
615 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
616 source='utils/smnotify/smnotify.x',
617 target='utils/smnotify/smnotify.h',
618 rule='rpcgen -h ${SRC} > ${TGT}')
620 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
622 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
623 source='utils/smnotify/smnotify.x',
624 target='utils/smnotify/gen_xdr.c',
625 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
627 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
628 source='utils/smnotify/smnotify.x',
629 target='utils/smnotify/gen_smnotify.c',
630 rule='rpcgen -l ${SRC} > ${TGT}')
632 bld.SAMBA_BINARY('smnotify',
633 source=bld.SUBDIR('utils/smnotify',
634 'smnotify.c gen_smnotify.c gen_xdr.c'),
635 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
636 includes='utils utils/smnotify',
637 install_path='${CTDB_HELPER_BINDIR}')
639 bld.SAMBA_BINARY('ping_pong',
640 source='utils/ping_pong/ping_pong.c',
642 install_path='${BINDIR}',
643 manpages='ping_pong.1')
645 if bld.env.HAVE_PMDA:
646 bld.SAMBA_BINARY('pmdactdb',
647 source='utils/pmda/pmda_ctdb.c',
649 deps='''ctdb-client ctdb-protocol ctdb-util
650 samba-util pcp_pmda pcp''',
651 install_path='${CTDB_PMDADIR}')
652 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
654 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
656 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
658 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
660 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
662 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
665 if bld.env.HAVE_LIBRADOS:
666 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
667 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
668 deps='talloc tevent rados',
670 install_path='${CTDB_HELPER_BINDIR}')
672 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
673 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
674 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
675 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
676 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
677 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
678 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
679 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
680 sed_cmdline = '-e "%s" ' * 8 % \
681 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
682 sed_expr6, sed_expr7, sed_expr8)
684 manpages_extra = manpages_misc
685 if bld.env.etcd_reclock:
686 manpages_extra += manpages_etcd
687 if bld.env.HAVE_LIBRADOS:
688 manpages_extra += manpages_ceph
689 for f in manpages_binary + manpages_extra:
691 bld.SAMBA_GENERATOR(x,
692 source=os.path.join('doc', x),
694 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
696 if bld.env.ctdb_generate_manpages:
697 bld.MANPAGES(' '.join(manpages_extra), True)
699 for m in bld.env.ctdb_prebuilt_manpages:
700 bld.SAMBA_GENERATOR(m,
701 source=os.path.join("doc", m),
703 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
704 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
706 bld.SAMBA_GENERATOR('ctdb-onnode',
707 source='tools/onnode',
709 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
710 bld.INSTALL_FILES('${BINDIR}', 'onnode',
711 destname='onnode', chmod=0755)
713 bld.SAMBA_GENERATOR('ctdb-diagnostics',
714 source='tools/ctdb_diagnostics',
715 target='ctdb_diagnostics',
716 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
717 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
718 destname='ctdb_diagnostics', chmod=0755)
720 if bld.env.etcd_reclock:
721 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
722 source='utils/etcd/ctdb_etcd_lock',
723 target='ctdb_etcd_lock',
724 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
725 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
726 destname='ctdb_etcd_lock', chmod=0744)
728 bld.SAMBA_GENERATOR('ctdb-natgw',
729 source='tools/ctdb_natgw',
731 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
732 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
733 destname='ctdb_natgw', chmod=0755)
735 bld.SAMBA_GENERATOR('ctdb-lvs',
736 source='tools/ctdb_lvs',
738 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
739 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
740 destname='ctdb_lvs', chmod=0755)
742 bld.SAMBA_GENERATOR('ctdbd-wrapper',
743 source='config/ctdbd_wrapper',
744 target='ctdbd_wrapper',
745 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
746 bld.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
747 destname='ctdbd_wrapper', chmod=0755)
749 def SUBDIR_MODE_callback(arg, dirname, fnames):
751 fl = os.path.join(dirname, f)
752 if os.path.isdir(fl) or os.path.islink(fl):
754 mode = os.lstat(fl).st_mode & 0777
756 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
757 arg['file_list'].append([fl, mode])
759 def SUBDIR_MODE(path, trim_path=None):
760 pd = {'trim_path': trim_path, 'file_list': []}
761 os.path.walk(path, SUBDIR_MODE_callback, pd)
762 return pd['file_list']
764 event_script_subdirs = [
772 if bld.env.standalone_ctdb:
775 configdir = 'ctdb/config'
777 for t in event_script_subdirs:
778 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
779 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
781 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
782 destname=fmode[0], chmod=fmode[1])
784 for t in etc_subdirs:
785 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
787 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
788 destname=fmode[0], chmod=fmode[1])
790 # If this is a direct install and there are no event scripts
791 # linked/enabled then enable some standard ones
792 if os.environ.get('DESTDIR') is None:
793 fmt = 'events/legacy/%s.script'
794 required_script = '00.ctdb'
795 required_path = os.path.join(bld.env.CTDB_ETCDIR,
796 fmt % (required_script))
797 if not os.path.islink(required_path) and \
798 not os.path.exists(required_path):
799 default_scripts = [ required_script,
804 for t in default_scripts:
805 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
806 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
807 bld.symlink_as(name, tgt)
809 bld.SAMBA_GENERATOR('ctdb-functions',
810 source='config/functions',
812 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
813 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
816 'ctdb-crash-cleanup.sh',
817 'debug-hung-script.sh',
819 'nfs-linux-kernel-callout',
824 for t in etc_scripts:
825 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
826 destname=t, chmod=0755)
828 bld.SAMBA_GENERATOR('ctdb-sudoers',
829 source='config/ctdb.sudoers',
830 target='ctdb.sudoers',
831 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
832 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
835 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
836 'config/notification.README',
839 bld.install_dir(bld.env.CTDB_LOGDIR)
840 bld.install_dir(bld.env.CTDB_RUNDIR)
841 bld.install_dir(bld.env.CTDB_VARDIR)
843 for d in ['volatile', 'persistent', 'state']:
844 bld.install_dir(os.path.join(bld.env.CTDB_VARDIR, d))
846 bld.SAMBA_BINARY('errcode',
847 source='tests/src/errcode.c',
849 install_path='${CTDB_TEST_LIBEXECDIR}')
851 bld.SAMBA_BINARY('sigcode',
852 source='tests/src/sigcode.c',
854 install_path='${CTDB_TEST_LIBEXECDIR}')
876 for target in ctdb_unit_tests:
877 src = 'tests/src/' + target + '.c'
879 bld.SAMBA_BINARY(target,
881 deps='''talloc tevent tdb tevent-util popt
882 LIBASYNC_REQ samba-util sys_rw''',
883 install_path='${CTDB_TEST_LIBEXECDIR}')
885 bld.SAMBA_BINARY('reqid_test',
886 source='tests/src/reqid_test.c',
888 install_path='${CTDB_TEST_LIBEXECDIR}')
890 bld.SAMBA_BINARY('rb_test',
891 source='tests/src/rb_test.c',
892 deps='samba-util talloc',
893 install_path='${CTDB_TEST_LIBEXECDIR}')
895 bld.SAMBA_BINARY('ctdb_packet_parse',
896 source='tests/src/ctdb_packet_parse.c',
897 deps='talloc tevent tdb ctdb-protocol',
898 install_path='${CTDB_TEST_LIBEXECDIR}')
900 bld.SAMBA_BINARY('porting_tests',
901 source='tests/src/porting_tests.c',
902 deps='samba-util ctdb-system popt',
903 install_path='${CTDB_TEST_LIBEXECDIR}')
905 bld.SAMBA_BINARY('sock_daemon_test',
906 source='tests/src/sock_daemon_test.c',
907 deps='''ctdb-system talloc tevent tevent-util
908 LIBASYNC_REQ samba-util sys_rw''',
909 install_path='${CTDB_TEST_LIBEXECDIR}')
911 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
912 source=bld.SUBDIR('tests/src',
913 'protocol_common_basic.c'),
914 deps='replace talloc')
916 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
917 source=bld.SUBDIR('tests/src',
919 protocol_common_ctdb.c
922 deps='ctdb-protocol-tests-basic replace talloc tdb')
924 bld.SAMBA_BINARY('protocol_basic_test',
925 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
926 deps='ctdb-protocol-tests-basic talloc',
927 install_path='${CTDB_TEST_LIBEXECDIR}')
929 ctdb_protocol_tests = [
930 'protocol_types_test',
931 'protocol_ctdb_test',
932 'protocol_util_test',
933 'protocol_types_compat_test',
934 'protocol_ctdb_compat_test',
937 for target in ctdb_protocol_tests:
938 src = 'tests/src/' + target + '.c'
940 bld.SAMBA_BINARY(target,
942 deps='''ctdb-protocol-tests-common
943 samba-util ctdb-util talloc tdb''',
944 install_path='${CTDB_TEST_LIBEXECDIR}')
946 bld.SAMBA_BINARY('event_protocol_test',
947 source='event/event_protocol_test.c',
948 deps='''ctdb-protocol-tests-basic
949 ctdb-protocol-basic talloc''',
950 install_path='${CTDB_TEST_LIBEXECDIR}')
952 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
953 source=bld.SUBDIR('tests/src',
954 'cluster_wait.c test_options.c'),
956 deps='samba-util replace popt talloc tevent tdb')
966 'fetch_readonly_loop',
969 'update_record_persistent',
976 for target in ctdb_tests:
977 src = 'tests/src/' + target + '.c'
979 bld.SAMBA_BINARY(target,
982 deps='''ctdb-client ctdb-protocol ctdb-util
983 samba-util ctdb-tests-common''',
984 install_path='${CTDB_TEST_LIBEXECDIR}')
986 bld.SAMBA_BINARY('ctdb_takeover_tests',
987 source='''tests/src/ctdb_takeover_tests.c
988 tests/src/ipalloc_read_known_ips.c''',
989 deps='''replace popt tdb tevent talloc ctdb-system
990 samba-util tdb-wrap talloc_report
991 ctdb-ipalloc ctdb-protocol ctdb-util''',
993 install_path='${CTDB_TEST_LIBEXECDIR}')
995 bld.SAMBA_BINARY('fake_ctdbd',
996 source='''tests/src/fake_ctdbd.c
997 tests/src/ipalloc_read_known_ips.c''',
998 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
999 ctdb-system samba-util tevent-util
1000 LIBASYNC_REQ popt''',
1001 install_path='${CTDB_TEST_LIBEXECDIR}')
1003 if bld.env.HAVE_INFINIBAND:
1004 bld.SAMBA_BINARY('ibwrapper_test',
1005 source='ib/ibwrapper_test.c',
1007 deps='replace talloc ctdb-common sys_rw' +
1009 install_path='${CTDB_TEST_LIBEXECDIR}')
1011 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux'):
1012 bld.SAMBA_BINARY('test_mutex_raw',
1013 source='tests/src/test_mutex_raw.c',
1015 install_path='${CTDB_TEST_LIBEXECDIR}')
1031 if bld.env.standalone_ctdb:
1034 testdir = 'ctdb/tests'
1036 for t in test_subdirs:
1037 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1039 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1040 destname=fmode[0], chmod=fmode[1])
1042 # Install tests/scripts directory without test_wrap
1049 for t in test_scripts:
1050 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1051 os.path.join('tests/scripts', t),
1052 destname=os.path.join('scripts', t))
1054 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1055 bld.env.CTDB_TEST_LIBEXECDIR)
1056 bld.SAMBA_GENERATOR('ctdb-test-wrap',
1057 source='tests/scripts/test_wrap',
1059 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
1060 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
1061 destname='test_wrap', chmod=0755)
1063 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1064 source='tests/scripts/script_install_paths.sh',
1065 target='script_install_paths.sh',
1066 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1067 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1068 'script_install_paths.sh',
1069 destname='script_install_paths.sh', chmod=0644)
1071 sed_expr1 = 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
1072 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR,
1073 'TEST_BIN_DIR', bld.env.CTDB_TEST_LIBEXECDIR)
1074 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1075 bld.SAMBA_GENERATOR('ctdb-test-runner',
1076 source='tests/run_tests.sh',
1077 target='ctdb_run_tests.sh',
1078 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1079 sed_expr1, sed_expr2))
1080 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1081 destname='ctdb_run_tests', chmod=0755)
1082 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1087 cmd = 'tests/run_tests.sh -V tests/var'
1088 ret = samba_utils.RUN_COMMAND(cmd)
1090 print('tests exited with exit status %d' % ret)
1096 Scripting.commands.append('build')
1097 Scripting.commands.append('testonly')
1101 env = samba_utils.LOAD_ENVIRONMENT()
1102 cmd = 'tests/run_tests.sh -e -S %s -C' % env.SOCKET_WRAPPER_SO_PATH
1103 ret = samba_utils.RUN_COMMAND(cmd)
1105 print('autotest exited with exit status %d' % ret)
1109 def show_version(ctx):
1114 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1115 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1116 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1117 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1118 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1120 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1121 ret = samba_utils.RUN_COMMAND(cmd)
1123 print('Command %s failed with exit status %d' % (cmd, ret))
1126 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1127 ret = samba_utils.RUN_COMMAND(cmd)
1129 print('Command %s failed with exit status %d' % (cmd, ret))
1134 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1136 distfile = file('.distversion', 'w')
1137 for field in version.vcs_fields:
1138 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1140 samba_dist.DIST_FILES('ctdb/.distversion:.distversion', extend=True)
1143 sed_expr1 = 's/@VERSION@/%s/g' % VERSION
1144 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1145 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1146 sed_expr1, sed_expr2, t)
1147 ret = samba_utils.RUN_COMMAND(cmd)
1149 print('Command "%s" failed with exit status %d' % (cmd, ret))
1151 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1153 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1155 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1156 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1164 Scripting.commands.append('manpages')
1165 Scripting.commands.append('distonly')
1169 opts = os.getenv('RPM_OPTIONS') or ''
1170 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts, VERSION)
1171 ret = samba_utils.RUN_COMMAND(cmd)
1173 print('rpmbuild exited with exit status %d' % ret)
1179 Scripting.commands.append('manpages')
1180 Scripting.commands.append('distonly')
1181 Scripting.commands.append('rpmonly')
1185 "build 'tags' file using ctags"
1187 source_root = os.path.dirname(Utils.g_module.root_path)
1188 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1189 print("Running: %s" % cmd)
1190 ret = samba_utils.RUN_COMMAND(cmd)
1192 print('ctags failed with exit status %d' % ret)