s3: libsmb: Fix cli_resolve_path() to cope with DFS paths passed in as well as local...
[Samba.git] / ctdb / wscript
blobc082c3b7a7ddd566dd41445f1a292f74bac35369
1 #!/usr/bin/env python
3 APPNAME = 'ctdb'
5 import sys, os
7 # find the buildtools directory
8 top = '.'
9 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
10 top = top + '/..'
11 sys.path.insert(0, top + '/buildtools/wafsamba')
13 out = 'bin'
15 from waflib import Options, Logs, Errors, Context
16 import wafsamba
17 from wafsamba import samba_dist, samba_utils
18 from samba_utils import MODE_644, MODE_744, MODE_755, MODE_777
20 if os.path.isfile('./VERSION'):
21 vdir = '.'
22 elif os.path.isfile('../VERSION'):
23 vdir = '..'
24 else:
25 Logs.error("VERSION file not found")
27 default_prefix = Options.default_prefix = '/usr/local'
29 samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
30 lib/tevent:lib/tevent lib/tdb:lib/tdb
31 third_party/socket_wrapper:third_party/socket_wrapper
32 third_party/popt:third_party/popt
33 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
34 lib/ccan:lib/ccan libcli/util:libcli/util
35 lib/async_req:lib/async_req
36 lib/pthreadpool:lib/pthreadpool
37 lib/messaging:lib/messaging
38 buildtools:buildtools third_party/waf:third_party/waf''')
40 manpages_binary = [
41 'ctdb.1',
42 'ctdbd.1',
43 'ltdbtool.1',
44 'ping_pong.1'
47 manpages_misc = [
48 'ctdb_diagnostics.1',
49 'onnode.1',
50 'ctdb.conf.5',
51 'ctdb-script.options.5',
52 'ctdb.sysconfig.5',
53 'ctdb.7',
54 'ctdb-statistics.7',
55 'ctdb-tunables.7',
58 manpages_etcd = [
59 'ctdb-etcd.7',
62 manpages_ceph = [
63 'ctdb_mutex_ceph_rados_helper.7',
66 VERSION = ''
68 def get_version():
69 import samba_version
70 env = samba_utils.LOAD_ENVIRONMENT()
72 return samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
74 def get_version_string():
75 if Context.g_module.VERSION:
76 return Context.g_module.VERSION
77 version = get_version()
78 Context.g_module.VERSION = version.STRING.replace('-', '.')
79 return Context.g_module.VERSION
81 def options(opt):
82 opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
84 opt.RECURSE('lib/replace')
86 opt.RECURSE('lib/util')
88 opt.RECURSE('lib/talloc')
89 opt.RECURSE('lib/tevent')
90 opt.RECURSE('lib/tdb')
92 opt.add_option('--enable-infiniband',
93 help=("Turn on infiniband support (default=no)"),
94 action="store_true", dest='ctdb_infiniband', default=False)
95 opt.add_option('--enable-pmda',
96 help=("Turn on PCP pmda support (default=no)"),
97 action="store_true", dest='ctdb_pmda', default=False)
98 opt.add_option('--enable-etcd-reclock',
99 help=("Enable etcd recovery lock helper (default=no)"),
100 action="store_true", dest='ctdb_etcd_reclock', default=False)
102 opt.add_option('--with-libcephfs',
103 help=("Directory under which libcephfs is installed"),
104 action="store", dest='libcephfs_dir', default=None)
105 opt.add_option('--enable-ceph-reclock',
106 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
107 action="store_true", dest='ctdb_ceph_reclock', default=False)
109 opt.add_option('--with-logdir',
110 help=("Path to log directory"),
111 action="store", dest='ctdb_logdir', default=None)
112 opt.add_option('--with-socketpath',
113 help=("path to CTDB daemon socket"),
114 action="store", dest='ctdb_sockpath', default=None)
117 def configure(conf):
118 # No need to build python bindings for talloc/tevent/tdb
119 if conf.IN_LAUNCH_DIR():
120 conf.env.standalone_ctdb = True
121 Options.options.disable_python = True
123 conf.RECURSE('lib/replace')
125 conf.CHECK_HEADERS(headers='''sys/socket.h
126 netinet/in.h
127 netinet/if_ether.h
128 netinet/ip.h
129 netinet/ip6.h
130 netinet/icmp6.h''',
131 together=True)
133 conf.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
134 define='HAVE_AF_PACKET',
135 headers='sys/socket.h linux/if_packet.h')
137 conf.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
138 define='HAVE_PACKETSOCKET',
139 headers='sys/socket.h linux/if_packet.h')
141 conf.CHECK_CODE('''pthread_mutex_t m;
142 int pid = 0;
143 m.__data.__owner = pid;
144 ''',
145 'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER',
146 headers='pthread.h',
147 msg='Checking for internal POSIX mutex owner field')
148 if not conf.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
149 # This is unsupported - please see note in debug_locks.sh
150 Logs.info('Building without unsupported mutex debugging hack')
152 if conf.env.standalone_ctdb:
153 conf.SAMBA_CHECK_PERL(mandatory=True)
155 # This is just for consistency and to check the version for the
156 # build system, see Options.options.disable_python = True above
157 conf.SAMBA_CHECK_PYTHON()
158 conf.SAMBA_CHECK_PYTHON_HEADERS()
160 # We just want gnutls_rnd for rand subsystem
161 conf.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
164 if conf.CHECK_FOR_THIRD_PARTY():
165 conf.RECURSE('third_party/popt')
166 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
167 conf.RECURSE('third_party/socket_wrapper')
168 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
169 else:
170 if not conf.CHECK_POPT():
171 raise Errors.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
172 else:
173 conf.define('USING_SYSTEM_POPT', 1)
174 conf.env.SOCKET_WRAPPER_SO_PATH = ''
177 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
178 if not conf.CHECK_SOCKET_WRAPPER():
179 raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
180 else:
181 conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
182 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
184 conf.RECURSE('lib/util')
186 conf.RECURSE('lib/talloc')
187 conf.RECURSE('lib/tevent')
188 conf.RECURSE('lib/tdb')
190 conf.CHECK_HEADERS('sched.h')
191 conf.CHECK_HEADERS('procinfo.h')
192 if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'):
193 Logs.error('Need thread_setsched() on AIX')
194 sys.exit(1)
195 elif not conf.CHECK_FUNCS('sched_setscheduler'):
196 Logs.error('Need sched_setscheduler()')
197 sys.exit(1)
198 conf.CHECK_FUNCS('mlockall')
199 conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
201 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
202 conf.DEFINE('ETIME', 'ETIMEDOUT')
204 if sys.platform.startswith('linux'):
205 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
206 else:
207 if not conf.CHECK_HEADERS('pcap.h'):
208 Logs.error('Need libpcap')
209 sys.exit(1)
210 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
211 Logs.error('Need libpcap')
212 sys.exit(1)
214 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
215 checklibc=True, headers='execinfo.h'):
216 Logs.error('backtrace support not available')
218 have_pmda = False
219 if Options.options.ctdb_pmda:
220 pmda_support = True
222 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
223 together=True):
224 pmda_support = False
225 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
226 pmda_support = False
227 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
228 pmda_support = False
229 if pmda_support:
230 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
231 have_pmda = True
232 else:
233 Logs.error("PMDA support not available")
234 sys.exit(1)
235 if have_pmda:
236 Logs.info('Building with PMDA support')
237 conf.define('HAVE_PMDA', 1)
238 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
239 'lib/pcp/pmdas/ctdb')
241 have_infiniband = False
242 if Options.options.ctdb_infiniband:
243 ib_support = True
245 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
246 ib_support = False
247 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
248 ib_support = False
249 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
250 ib_support = False
251 if ib_support:
252 have_infiniband = True
253 else:
254 Logs.error("Infiniband support not available")
255 sys.exit(1)
256 if have_infiniband:
257 Logs.info('Building with Infiniband support')
258 conf.define('HAVE_INFINIBAND', 1)
259 conf.define('USE_INFINIBAND', 1)
261 have_etcd_reclock = False
262 if Options.options.ctdb_etcd_reclock:
263 try:
264 conf.check_python_module('etcd')
265 have_etcd_reclock = True
266 except:
267 Logs.error('etcd support not available')
268 sys.exit(1)
269 if have_etcd_reclock:
270 Logs.info('Building with etcd support')
271 conf.env.etcd_reclock = have_etcd_reclock
273 if Options.options.libcephfs_dir:
274 Logs.error('''--with-libcephfs no longer supported, please use compiler
275 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
276 sys.exit(1)
278 if Options.options.ctdb_ceph_reclock:
279 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
280 conf.CHECK_LIB('rados', shlib=True)):
281 Logs.info('Building with Ceph librados recovery lock support')
282 conf.define('HAVE_LIBRADOS', 1)
283 else:
284 Logs.error("Missing librados for Ceph recovery lock support")
285 sys.exit(1)
287 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
288 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
289 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
290 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
291 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
292 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
294 if Options.options.ctdb_logdir:
295 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
296 else:
297 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
299 if Options.options.ctdb_sockpath:
300 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
301 else:
302 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
303 'ctdbd.socket')
304 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
306 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
307 -DLOGDIR=\"%s\"
308 -DCTDB_DATADIR=\"%s\"
309 -DCTDB_ETCDIR=\"%s\"
310 -DCTDB_VARDIR=\"%s\"
311 -DCTDB_RUNDIR=\"%s\"''' % (
312 conf.env.CTDB_HELPER_BINDIR,
313 conf.env.CTDB_LOGDIR,
314 conf.env.CTDB_DATADIR,
315 conf.env.CTDB_ETCDIR,
316 conf.env.CTDB_VARDIR,
317 conf.env.CTDB_RUNDIR))
319 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
320 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
322 # Allow unified compilation and separate compilation of utilities
323 # to find includes
324 if not conf.env.standalone_ctdb:
325 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
326 else:
327 if Context.g_module.top == '.':
328 # Building from tarball
329 conf.ADD_EXTRA_INCLUDES('#include')
330 else:
331 # Building standalone CTDB from within Samba tree
332 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
333 conf.ADD_EXTRA_INCLUDES('#ctdb')
334 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
336 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
337 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
338 conf.SAMBA_CONFIG_H()
340 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
341 conf.env.ctdb_generate_manpages = True
342 else:
343 conf.env.ctdb_generate_manpages = False
345 Logs.info("xsltproc unavailable, checking for pre-built manpages")
346 conf.env.ctdb_prebuilt_manpages = []
347 manpages = manpages_binary + manpages_misc
348 if conf.env.etcd_reclock:
349 manpages += manpages_etcd
350 if conf.env.HAVE_LIBRADOS:
351 manpages += manpages_ceph
352 for m in manpages:
353 if os.path.exists(os.path.join("doc", m)):
354 Logs.info(" %s: yes" % (m))
355 conf.env.ctdb_prebuilt_manpages.append(m)
356 else:
357 Logs.info(" %s: no" % (m))
359 def build(bld):
360 if bld.env.standalone_ctdb:
361 # enable building of public headers in the build tree
362 bld.env.build_public_headers = 'include/public'
364 if bld.env.standalone_ctdb:
365 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
367 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
369 bld.RECURSE('lib/replace')
370 if bld.CHECK_FOR_THIRD_PARTY():
371 bld.RECURSE('third_party/popt')
372 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
373 bld.RECURSE('third_party/socket_wrapper')
375 bld.RECURSE('lib/tdb_wrap')
376 bld.RECURSE('lib/util')
377 bld.RECURSE('lib/async_req')
378 bld.RECURSE('lib/pthreadpool')
379 bld.RECURSE('lib/messaging')
381 bld.RECURSE('lib/talloc')
382 bld.RECURSE('lib/tevent')
383 bld.RECURSE('lib/tdb')
385 if bld.env.standalone_ctdb:
386 # If a combined build is implemented, CTDB will want to
387 # build against samba-util rather than samba-util-core.
388 # Similarly, other Samba subsystems expect samba-util. So,
389 # for a standalone build, just define a fake samba-util
390 # subsystem that pulls in samba-util-core.
391 bld.SAMBA_SUBSYSTEM('samba-util',
392 source='',
393 deps='samba-util-core')
395 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
396 source=bld.SUBDIR('tcp',
397 'tcp_connect.c tcp_init.c tcp_io.c'),
398 includes='include',
399 deps='replace tdb talloc tevent')
401 ib_deps = ''
402 if bld.env.HAVE_INFINIBAND:
403 bld.SAMBA_SUBSYSTEM('ctdb-ib',
404 source=bld.SUBDIR('ib',
405 '''ibwrapper.c ibw_ctdb.c
406 ibw_ctdb_init.c'''),
407 includes='include',
408 deps='replace talloc tevent tdb')
409 ib_deps = ' ctdb-ib rdmacm ibverbs'
411 bld.SAMBA_SUBSYSTEM('ctdb-system',
412 source=bld.SUBDIR('common',
413 'system_socket.c system.c'),
414 deps='replace talloc tevent tdb pcap samba-util')
416 bld.SAMBA_SUBSYSTEM('ctdb-common',
417 source=bld.SUBDIR('common',
418 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
419 sock_io.c'''),
420 includes='include',
421 deps='''replace popt talloc tevent tdb popt ctdb-system
422 ctdb-protocol-util''')
424 bld.SAMBA_SUBSYSTEM('ctdb-util',
425 source=bld.SUBDIR('common',
426 '''cmdline.c
427 comm.c
428 conf.c
429 db_hash.c
430 event_script.c
431 hash_count.c
432 line.c
433 logging.c
434 path.c
435 pidfile.c
436 pkt_read.c
437 pkt_write.c
438 rb_tree.c
439 reqid.c
440 run_event.c
441 run_proc.c
442 sock_client.c
443 srvid.c
444 tmon.c
445 tunable.c
446 '''),
447 deps='''samba-util
448 LIBASYNC_REQ
449 sys_rw
450 tevent-util
451 replace
452 talloc
453 tevent
455 popt
456 ''')
458 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
459 source='common/logging_conf.c',
460 deps='ctdb-util talloc')
462 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
463 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
464 deps='talloc tdb')
466 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
467 source=bld.SUBDIR('protocol',
468 '''protocol_header.c protocol_packet.c
469 protocol_types.c
470 protocol_call.c
471 protocol_message.c
472 protocol_control.c
473 protocol_keepalive.c
474 protocol_tunnel.c
475 protocol_client.c
476 protocol_debug.c
477 protocol_sock.c'''),
478 deps='ctdb-protocol-basic replace talloc tdb')
480 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
481 source='protocol/protocol_util.c',
482 deps='ctdb-util replace talloc tdb')
484 bld.SAMBA_SUBSYSTEM('ctdb-client',
485 source=bld.SUBDIR('client',
486 '''client_connect.c client_call.c
487 client_message.c client_control.c
488 client_message_sync.c
489 client_control_sync.c
490 client_db.c client_util.c
491 client_tunnel.c
492 '''),
493 deps='''ctdb-protocol
494 ctdb-util
495 samba-util
496 replace
497 talloc
498 tevent
500 tdb-wrap
501 ''')
503 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
504 source=bld.SUBDIR('common',
505 '''sock_daemon.c'''),
506 deps='''samba-util ctdb-util ctdb-system tevent-util
507 LIBASYNC_REQ replace talloc tevent''')
509 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
510 source=bld.SUBDIR('server',
511 '''ipalloc_deterministic.c
512 ipalloc_nondeterministic.c
513 ipalloc_lcp2.c
514 ipalloc_common.c
515 ipalloc.c
516 '''),
517 includes='include',
518 deps='ctdb-protocol-util replace talloc tevent')
520 bld.SAMBA_BINARY('ctdb-path',
521 source='common/path_tool.c',
522 cflags='-DCTDB_PATH_TOOL',
523 deps='''ctdb-util samba-util talloc replace popt''',
524 install_path='${CTDB_HELPER_BINDIR}')
526 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
527 source='cluster/cluster_conf.c',
528 deps='ctdb-util')
530 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
531 source='database/database_conf.c',
532 deps='ctdb-util')
534 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
535 source='event/event_conf.c',
536 deps='ctdb-util')
538 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
539 source='failover/failover_conf.c',
540 deps='ctdb-util')
542 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
543 source='server/legacy_conf.c',
544 deps='ctdb-util')
546 bld.SAMBA_BINARY('ctdb-config',
547 source='common/conf_tool.c',
548 cflags='-DCTDB_CONF_TOOL',
549 deps='''ctdb-logging-conf
550 ctdb-event-conf
551 ctdb-cluster-conf
552 ctdb-database-conf
553 ctdb-failover-conf
554 ctdb-legacy-conf
555 ctdb-util samba-util talloc replace popt''',
556 install_path='${CTDB_HELPER_BINDIR}')
558 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
559 source=bld.SUBDIR('event',
560 '''event_protocol.c
561 event_protocol_util.c
562 '''),
563 deps='ctdb-protocol-basic')
565 bld.SAMBA_LIBRARY('ctdb-event-client',
566 source='event/event_client.c',
567 deps='ctdb-event-protocol ctdb-util tevent talloc',
568 private_library=True)
570 bld.SAMBA_BINARY('ctdb-eventd',
571 source=bld.SUBDIR('event',
572 '''event_cmd.c
573 event_config.c
574 event_context.c
575 event_daemon.c
576 event_request.c
577 '''),
578 deps='''ctdb-event-protocol
579 ctdb-event-conf ctdb-logging-conf
580 ctdb-server-util samba-util ctdb-util
581 talloc tevent replace popt''',
582 install_path='${CTDB_HELPER_BINDIR}')
584 bld.SAMBA_BINARY('ctdb-event',
585 source='event/event_tool.c',
586 cflags='-DCTDB_EVENT_TOOL',
587 deps='''ctdb-event-client ctdb-event-protocol
588 ctdb-util samba-util talloc replace''',
589 install_path='${CTDB_HELPER_BINDIR}')
591 bld.SAMBA_BINARY('ctdbd',
592 source='server/ctdbd.c ' +
593 bld.SUBDIR('server',
594 '''ctdb_daemon.c ctdb_recoverd.c
595 ctdb_recover.c ctdb_freeze.c
596 ctdb_tunables.c ctdb_monitor.c
597 ctdb_server.c ctdb_control.c
598 ctdb_call.c ctdb_ltdb_server.c
599 ctdb_traverse.c eventscript.c
600 ctdb_takeover.c
601 ctdb_persistent.c ctdb_keepalive.c
602 ctdb_cluster_mutex.c
603 ctdb_logging.c
604 ctdb_uptime.c
605 ctdb_vacuum.c ctdb_banning.c
606 ctdb_statistics.c
607 ctdb_update_record.c
608 ctdb_lock.c ctdb_fork.c
609 ctdb_tunnel.c ctdb_client.c
610 ctdb_config.c
611 '''),
612 includes='include',
613 deps='''ctdb-common ctdb-system ctdb-protocol
614 ctdb-tcp ctdb-util replace sys_rw popt
615 ctdb-logging-conf
616 ctdb-cluster-conf
617 ctdb-database-conf
618 ctdb-event-conf
619 ctdb-failover-conf
620 ctdb-legacy-conf
621 ctdb-event-protocol
622 talloc tevent tdb-wrap tdb talloc_report''' +
623 ib_deps,
624 install_path='${SBINDIR}',
625 manpages='ctdbd.1')
627 bld.SAMBA_BINARY('ctdb',
628 source='tools/ctdb.c',
629 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
630 ctdb-util ctdb-system samba-util sys_rw popt''',
631 install_path='${BINDIR}',
632 manpages='ctdb.1')
634 bld.SAMBA_BINARY('ctdb_killtcp',
635 source='tools/ctdb_killtcp.c',
636 deps='''ctdb-protocol-util ctdb-util ctdb-system
637 samba-util replace''',
638 install_path='${CTDB_HELPER_BINDIR}')
640 bld.SAMBA_BINARY('ltdbtool',
641 source='tools/ltdbtool.c',
642 includes='include',
643 deps='tdb',
644 install_path='${BINDIR}',
645 manpages='ltdbtool.1')
647 bld.SAMBA_BINARY('ctdb_lock_helper',
648 source='server/ctdb_lock_helper.c',
649 deps='''samba-util sys_rw ctdb-system tevent-util
650 talloc tevent tdb''',
651 includes='include',
652 install_path='${CTDB_HELPER_BINDIR}')
654 bld.SAMBA_BINARY('ctdb_recovery_helper',
655 source='server/ctdb_recovery_helper.c',
656 deps='''ctdb-client ctdb-protocol ctdb-util
657 samba-util sys_rw replace tdb''',
658 install_path='${CTDB_HELPER_BINDIR}')
660 bld.SAMBA_BINARY('ctdb_takeover_helper',
661 source='server/ctdb_takeover_helper.c',
662 deps='''ctdb-client ctdb-protocol ctdb-util
663 samba-util sys_rw replace ctdb-ipalloc popt''',
664 install_path='${CTDB_HELPER_BINDIR}')
666 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
667 source='server/ctdb_mutex_fcntl_helper.c',
668 deps='''sys_rw ctdb-system tevent-util ctdb-util
669 talloc tevent
670 ''',
671 includes='include',
672 install_path='${CTDB_HELPER_BINDIR}')
674 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
675 source='utils/smnotify/smnotify.x',
676 target='utils/smnotify/smnotify.h',
677 rule='rpcgen -h ${SRC} > ${TGT}')
679 xdr_buf_hack = 'grep -Fv "register int32_t *buf;"'
681 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
682 source='utils/smnotify/smnotify.x',
683 target='utils/smnotify/gen_xdr.c',
684 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
686 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
687 source='utils/smnotify/smnotify.x',
688 target='utils/smnotify/gen_smnotify.c',
689 rule='rpcgen -l ${SRC} > ${TGT}')
691 bld.SAMBA_BINARY('smnotify',
692 source=bld.SUBDIR('utils/smnotify',
693 'smnotify.c gen_smnotify.c gen_xdr.c'),
694 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
695 includes='utils utils/smnotify',
696 install_path='${CTDB_HELPER_BINDIR}')
698 bld.SAMBA_BINARY('ping_pong',
699 source='utils/ping_pong/ping_pong.c',
700 deps='',
701 install_path='${BINDIR}',
702 manpages='ping_pong.1')
704 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
705 bld.SAMBA_BINARY('tdb_mutex_check',
706 source='utils/tdb/tdb_mutex_check.c',
707 deps='tdb pthread',
708 install_path='${CTDB_HELPER_BINDIR}')
710 if bld.env.HAVE_PMDA:
711 bld.SAMBA_BINARY('pmdactdb',
712 source='utils/pmda/pmda_ctdb.c',
713 deps='''ctdb-client ctdb-protocol ctdb-util
714 samba-util pcp_pmda pcp''',
715 install_path='${CTDB_PMDADIR}')
716 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
717 destname='Install')
718 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
719 destname='Remove')
720 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
721 destname='pmns')
722 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
723 destname='domain.h')
724 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
725 destname='help')
726 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
727 destname='README')
729 if bld.env.HAVE_LIBRADOS:
730 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
731 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
732 deps='talloc tevent rados',
733 includes='include',
734 install_path='${CTDB_HELPER_BINDIR}')
736 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
737 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
738 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
739 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
740 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
741 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
742 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
743 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
744 sed_cmdline = '-e "%s" ' * 8 % \
745 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
746 sed_expr6, sed_expr7, sed_expr8)
748 manpages_extra = list(manpages_misc)
749 if bld.env.etcd_reclock:
750 manpages_extra += manpages_etcd
751 if bld.env.HAVE_LIBRADOS:
752 manpages_extra += manpages_ceph
753 for f in manpages_binary + manpages_extra:
754 x = '%s.xml' % (f)
755 bld.SAMBA_GENERATOR(x,
756 source=os.path.join('doc', x),
757 target=x,
758 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
760 if bld.env.ctdb_generate_manpages:
761 bld.MANPAGES(' '.join(manpages_extra), True)
762 else:
763 for m in bld.env.ctdb_prebuilt_manpages:
764 bld.SAMBA_GENERATOR(m,
765 source=os.path.join("doc", m),
766 target=m,
767 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
768 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
770 bld.SAMBA_GENERATOR('ctdb-onnode',
771 source='tools/onnode',
772 target='onnode',
773 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
774 bld.INSTALL_FILES('${BINDIR}', 'onnode',
775 destname='onnode', chmod=MODE_755)
777 bld.SAMBA_GENERATOR('ctdb-diagnostics',
778 source='tools/ctdb_diagnostics',
779 target='ctdb_diagnostics',
780 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
781 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
782 destname='ctdb_diagnostics', chmod=MODE_755)
784 if bld.env.etcd_reclock:
785 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
786 source='utils/etcd/ctdb_etcd_lock',
787 target='ctdb_etcd_lock',
788 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
789 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
790 destname='ctdb_etcd_lock', chmod=MODE_744)
792 bld.SAMBA_GENERATOR('ctdb-natgw',
793 source='tools/ctdb_natgw',
794 target='ctdb_natgw',
795 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
796 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
797 destname='ctdb_natgw', chmod=MODE_755)
799 bld.SAMBA_GENERATOR('ctdb-lvs',
800 source='tools/ctdb_lvs',
801 target='ctdb_lvs',
802 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
803 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
804 destname='ctdb_lvs', chmod=MODE_755)
806 def SUBDIR_MODE_callback(arg, dirname, fnames):
807 for f in fnames:
808 fl = os.path.join(dirname, f)
809 if os.path.isdir(fl) or os.path.islink(fl):
810 continue
811 mode = os.lstat(fl).st_mode & MODE_777
812 if arg['trim_path']:
813 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
814 arg['file_list'].append([fl, mode])
816 def SUBDIR_MODE(path, trim_path=None):
817 pd = {'trim_path': trim_path, 'file_list': []}
818 for dirname, _subdirs, fnames in os.walk(path):
819 SUBDIR_MODE_callback(pd, dirname, fnames)
820 return pd['file_list']
822 event_script_subdirs = [
823 'events/legacy',
826 etc_subdirs = [
827 'nfs-checks.d'
830 if bld.env.standalone_ctdb:
831 configdir = 'config'
832 else:
833 configdir = 'ctdb/config'
835 for t in event_script_subdirs:
836 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
837 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
838 for fmode in files:
839 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
840 destname=fmode[0], chmod=fmode[1])
842 for t in etc_subdirs:
843 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
844 for fmode in files:
845 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
846 destname=fmode[0], chmod=fmode[1])
848 # If this is a direct install and there are no event scripts
849 # linked/enabled then enable some standard ones
850 if os.environ.get('DESTDIR') is None:
851 fmt = 'events/legacy/%s.script'
852 required_script = '00.ctdb'
853 required_path = os.path.join(bld.env.CTDB_ETCDIR,
854 fmt % (required_script))
855 if not os.path.islink(required_path) and \
856 not os.path.exists(required_path):
857 default_scripts = [ required_script,
858 '01.reclock',
859 '05.system',
860 '10.interface',
862 for t in default_scripts:
863 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
864 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
865 bld.symlink_as(name, tgt)
867 bld.SAMBA_GENERATOR('ctdb-functions',
868 source='config/functions',
869 target='functions',
870 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
871 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
873 etc_scripts = [
874 'ctdb-crash-cleanup.sh',
875 'debug-hung-script.sh',
876 'debug_locks.sh',
877 'nfs-linux-kernel-callout',
878 'notify.sh',
879 'statd-callout'
882 for t in etc_scripts:
883 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
884 destname=t, chmod=MODE_755)
886 bld.SAMBA_GENERATOR('ctdb-sudoers',
887 source='config/ctdb.sudoers',
888 target='ctdb.sudoers',
889 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
890 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
891 destname='ctdb')
893 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
894 'config/notification.README',
895 destname='README')
897 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
898 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
899 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
901 for d in ['volatile', 'persistent', 'state']:
902 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
905 # Test-only below this point
908 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
909 return
911 bld.SAMBA_BINARY('errcode',
912 source='tests/src/errcode.c',
913 deps='replace',
914 install_path='${CTDB_TEST_LIBEXECDIR}')
916 bld.SAMBA_BINARY('sigcode',
917 source='tests/src/sigcode.c',
918 deps='replace',
919 install_path='${CTDB_TEST_LIBEXECDIR}')
921 # Unit tests
922 ctdb_util_tests = [
923 'cmdline_test',
924 'comm_client_test',
925 'comm_server_test',
926 'comm_test',
927 'conf_test',
928 'db_hash_test',
929 'event_script_test',
930 'hash_count_test',
931 'line_test',
932 'pidfile_test',
933 'pkt_read_test',
934 'pkt_write_test',
935 'run_event_test',
936 'run_proc_test',
937 'sock_io_test',
938 'srvid_test',
939 'tunable_test',
942 for target in ctdb_util_tests:
943 src = 'tests/src/' + target + '.c'
945 bld.SAMBA_BINARY(target,
946 source=src,
947 deps='''ctdb-tests-backtrace
948 LIBASYNC_REQ
949 samba-util
950 sys_rw
951 tevent-util
952 talloc
953 tevent
955 popt
956 ''',
957 install_path='${CTDB_TEST_LIBEXECDIR}')
959 bld.SAMBA_BINARY('reqid_test',
960 source='tests/src/reqid_test.c',
961 deps='samba-util talloc',
962 install_path='${CTDB_TEST_LIBEXECDIR}')
964 bld.SAMBA_BINARY('rb_test',
965 source='tests/src/rb_test.c',
966 deps='samba-util talloc',
967 install_path='${CTDB_TEST_LIBEXECDIR}')
969 bld.SAMBA_BINARY('ctdb_packet_parse',
970 source='tests/src/ctdb_packet_parse.c',
971 deps='talloc tevent tdb ctdb-protocol',
972 install_path='${CTDB_TEST_LIBEXECDIR}')
974 bld.SAMBA_BINARY('system_socket_test',
975 source='tests/src/system_socket_test.c',
976 deps='''ctdb-tests-backtrace
977 talloc
978 ctdb-protocol-util
979 pcap
980 ''',
981 install_path='${CTDB_TEST_LIBEXECDIR}')
983 bld.SAMBA_BINARY('porting_tests',
984 source='tests/src/porting_tests.c',
985 deps='samba-util ctdb-system popt',
986 install_path='${CTDB_TEST_LIBEXECDIR}')
988 bld.SAMBA_BINARY('sock_daemon_test',
989 source='tests/src/sock_daemon_test.c',
990 deps='''ctdb-system talloc tevent tevent-util
991 LIBASYNC_REQ samba-util sys_rw''',
992 install_path='${CTDB_TEST_LIBEXECDIR}')
994 bld.SAMBA_BINARY('ctdb_io_test',
995 source='tests/src/ctdb_io_test.c',
996 deps='''talloc tevent tdb samba-util sys_rw''',
997 install_path='${CTDB_TEST_LIBEXECDIR}')
999 bld.SAMBA_BINARY('ctdb-db-test',
1000 source='tests/src/db_test_tool.c',
1001 cflags='-DCTDB_DB_TEST_TOOL',
1002 deps='''ctdb-client ctdb-protocol
1003 ctdb-util samba-util talloc tevent replace''',
1004 install_path='${CTDB_TEST_LIBEXECDIR}')
1006 for target in ['tmon_ping_test', 'tmon_test']:
1007 src = 'tests/src/' + target + '.c'
1009 bld.SAMBA_BINARY(target,
1010 source=src,
1011 deps='''ctdb-util
1012 ctdb-tests-backtrace
1013 LIBASYNC_REQ
1014 samba-util
1015 sys_rw
1016 tevent-util
1017 talloc
1018 tevent
1020 popt
1021 ''',
1022 install_path='${CTDB_TEST_LIBEXECDIR}')
1024 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1025 source=bld.SUBDIR('tests/src',
1026 'protocol_common_basic.c'),
1027 deps='samba-util replace talloc')
1029 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1030 source=bld.SUBDIR('tests/src',
1031 '''protocol_common.c
1032 protocol_common_ctdb.c
1033 '''),
1034 deps='ctdb-protocol-tests-basic replace talloc tdb')
1036 bld.SAMBA_BINARY('protocol_basic_test',
1037 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
1038 deps='ctdb-protocol-tests-basic talloc',
1039 install_path='${CTDB_TEST_LIBEXECDIR}')
1041 ctdb_protocol_tests = [
1042 'protocol_types_test',
1043 'protocol_ctdb_test',
1044 'protocol_util_test',
1045 'protocol_types_compat_test',
1046 'protocol_ctdb_compat_test',
1049 for target in ctdb_protocol_tests:
1050 src = 'tests/src/' + target + '.c'
1052 bld.SAMBA_BINARY(target,
1053 source=src,
1054 deps='''ctdb-protocol-tests-common
1055 samba-util ctdb-util talloc tdb''',
1056 install_path='${CTDB_TEST_LIBEXECDIR}')
1058 bld.SAMBA_BINARY('event_protocol_test',
1059 source='event/event_protocol_test.c',
1060 deps='''ctdb-protocol-tests-basic
1061 ctdb-protocol-basic talloc''',
1062 install_path='${CTDB_TEST_LIBEXECDIR}')
1064 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1065 source=bld.SUBDIR('tests/src',
1066 '''cluster_wait.c
1067 test_options.c
1068 '''),
1069 deps='''ctdb-client
1070 samba-util
1071 replace
1072 popt
1073 talloc
1074 tevent
1075 tdb''')
1077 bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1078 source=bld.SUBDIR('tests/src',
1079 'test_backtrace.c'),
1080 deps='''samba-util
1081 replace''')
1083 # Test binaries
1084 ctdb_tests = [
1085 'g_lock_loop',
1086 'message_ring',
1087 'fetch_ring',
1088 'fetch_loop',
1089 'fetch_loop_key',
1090 'fetch_readonly',
1091 'fetch_readonly_loop',
1092 'transaction_loop',
1093 'update_record',
1094 'update_record_persistent',
1095 'lock_tdb',
1096 'dummy_client',
1097 'tunnel_test',
1098 'tunnel_cmd',
1101 for target in ctdb_tests:
1102 src = 'tests/src/' + target + '.c'
1104 bld.SAMBA_BINARY(target,
1105 source=src,
1106 includes='include',
1107 deps='''ctdb-client ctdb-protocol ctdb-util
1108 samba-util ctdb-tests-common''',
1109 install_path='${CTDB_TEST_LIBEXECDIR}')
1111 bld.SAMBA_BINARY('ctdb_takeover_tests',
1112 source='''tests/src/ctdb_takeover_tests.c
1113 tests/src/ipalloc_read_known_ips.c''',
1114 deps='''replace popt tdb tevent talloc ctdb-system
1115 samba-util tdb-wrap talloc_report
1116 ctdb-ipalloc ctdb-protocol ctdb-util''',
1117 includes='include',
1118 install_path='${CTDB_TEST_LIBEXECDIR}')
1120 bld.SAMBA_BINARY('fake_ctdbd',
1121 source='''tests/src/fake_ctdbd.c
1122 tests/src/ipalloc_read_known_ips.c''',
1123 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1124 ctdb-system samba-util tevent-util
1125 LIBASYNC_REQ popt''',
1126 install_path='${CTDB_TEST_LIBEXECDIR}')
1128 bld.SAMBA_BINARY('cluster_mutex_test',
1129 source='tests/src/cluster_mutex_test.c',
1130 deps='''ctdb-tests-backtrace
1131 samba-util
1132 talloc
1133 tevent
1134 ''',
1135 install_path='${CTDB_TEST_LIBEXECDIR}')
1137 if bld.env.HAVE_INFINIBAND:
1138 bld.SAMBA_BINARY('ibwrapper_test',
1139 source='ib/ibwrapper_test.c',
1140 includes='include',
1141 deps='replace talloc ctdb-common sys_rw' +
1142 ib_deps,
1143 install_path='${CTDB_TEST_LIBEXECDIR}')
1145 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1146 bld.SAMBA_BINARY('test_mutex_raw',
1147 source='tests/src/test_mutex_raw.c',
1148 deps='pthread',
1149 install_path='${CTDB_TEST_LIBEXECDIR}')
1151 test_subdirs = [
1152 'CLUSTER',
1153 'INTEGRATION',
1154 'UNIT',
1155 'etc-ctdb'
1158 if bld.env.standalone_ctdb:
1159 testdir = 'tests'
1160 else:
1161 testdir = 'ctdb/tests'
1163 for t in test_subdirs:
1164 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1165 for fmode in files:
1166 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1167 destname=fmode[0], chmod=fmode[1])
1169 # Install tests/scripts directory, excluding files that need munging
1170 test_scripts = [
1171 'cluster.bash',
1172 'common.sh',
1173 'integration.bash',
1174 'integration_local_daemons.bash',
1175 'integration_real_cluster.bash',
1176 'unit.sh'
1179 for t in test_scripts:
1180 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1181 os.path.join('tests/scripts', t),
1182 destname=os.path.join('scripts', t))
1184 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1185 'tests/scripts/test_wrap',
1186 destname='scripts/test_wrap',
1187 chmod=MODE_755)
1189 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1190 source='tests/scripts/script_install_paths.sh',
1191 target='script_install_paths.sh',
1192 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1193 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1194 'script_install_paths.sh',
1195 destname='script_install_paths.sh', chmod=MODE_644)
1197 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1198 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1199 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1200 bld.SAMBA_GENERATOR('ctdb-test-runner',
1201 source='tests/run_tests.sh',
1202 target='ctdb_run_tests.sh',
1203 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1204 sed_expr1, sed_expr2))
1205 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1206 destname='ctdb_run_tests', chmod=MODE_755)
1207 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1208 'ctdb_run_tests')
1210 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1211 source='tests/local_daemons.sh',
1212 target='ctdb_local_daemons.sh',
1213 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1214 sed_expr1, sed_expr2))
1215 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1216 destname='ctdb_local_daemons', chmod=MODE_755)
1219 def testonly(ctx):
1220 cmd = 'tests/run_tests.sh'
1221 ret = samba_utils.RUN_COMMAND(cmd)
1222 if ret != 0:
1223 print('tests exited with exit status %d' % ret)
1224 sys.exit(ret)
1227 def test(ctx):
1228 Options.commands.append('build')
1229 Options.commands.append('testonly')
1232 def autotest(ctx):
1233 env = samba_utils.LOAD_ENVIRONMENT()
1234 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1235 ret = samba_utils.RUN_COMMAND(cmd)
1236 if ret != 0:
1237 print('autotest exited with exit status %d' % ret)
1238 sys.exit(ret)
1241 def show_version(ctx):
1242 print(get_version_string())
1245 def manpages(ctx):
1246 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1247 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1248 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1249 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1250 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1251 for t in manpages:
1252 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1253 ret = samba_utils.RUN_COMMAND(cmd)
1254 if ret != 0:
1255 print('Command %s failed with exit status %d' % (cmd, ret))
1256 sys.exit(ret)
1258 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1259 ret = samba_utils.RUN_COMMAND(cmd)
1260 if ret != 0:
1261 print('Command %s failed with exit status %d' % (cmd, ret))
1262 sys.exit(ret)
1265 def distonly(ctx):
1266 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1268 t = 'ctdb.spec'
1269 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1270 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1271 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1272 sed_expr1, sed_expr2, t)
1273 ret = samba_utils.RUN_COMMAND(cmd)
1274 if ret != 0:
1275 print('Command "%s" failed with exit status %d' % (cmd, ret))
1276 sys.exit(ret)
1277 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1279 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1280 for t in manpages:
1281 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1282 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1283 extend=True)
1285 samba_dist.dist()
1288 def dist():
1289 Options.commands.append('manpages')
1290 Options.commands.append('distonly')
1293 def rpmonly(ctx):
1294 opts = os.getenv('RPM_OPTIONS') or ''
1295 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1296 (opts, get_version_string())
1297 ret = samba_utils.RUN_COMMAND(cmd)
1298 if ret != 0:
1299 print('rpmbuild exited with exit status %d' % ret)
1300 sys.exit(ret)
1303 def rpm(ctx):
1304 Options.commands.append('manpages')
1305 Options.commands.append('distonly')
1306 Options.commands.append('rpmonly')
1309 def ctags(ctx):
1310 "build 'tags' file using ctags"
1311 source_root = os.path.dirname(Context.g_module.root_path)
1312 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1313 print("Running: %s" % cmd)
1314 ret = samba_utils.RUN_COMMAND(cmd)
1315 if ret != 0:
1316 print('ctags failed with exit status %d' % ret)
1317 sys.exit(ret)