smbd: ignore POSIX and stale opens in have_file_open_below()
[samba4-gss.git] / ctdb / wscript
blobe9cd89436a3630f003af4bb07e8cb38a7630172e
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)
101 opt.add_option('--enable-pcap',
102 help=("Use pcap for packet capture (default=no)"),
103 action="store_true", dest='ctdb_pcap', default=False)
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 Options.options.ctdb_pcap or not sys.platform.startswith('linux'):
205 conf.DEFINE('ENABLE_PCAP', 1)
206 if not conf.env.ENABLE_PCAP:
207 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
208 else:
209 conf.find_program('pcap-config', var='PCAP_CONFIG')
210 if conf.env.PCAP_CONFIG:
211 conf.CHECK_CFG(path=conf.env.PCAP_CONFIG,
212 args="--cflags --libs",
213 package="",
214 uselib_store="PCAP")
215 if not conf.CHECK_HEADERS('pcap.h'):
216 Logs.error('Need libpcap')
217 sys.exit(1)
218 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
219 Logs.error('Need libpcap')
220 sys.exit(1)
221 conf.CHECK_FUNCS_IN('pcap_set_immediate_mode', 'pcap', headers='pcap.h')
223 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
224 checklibc=True, headers='execinfo.h'):
225 Logs.error('backtrace support not available')
227 have_pmda = False
228 if Options.options.ctdb_pmda:
229 pmda_support = True
231 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
232 together=True):
233 pmda_support = False
234 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
235 pmda_support = False
236 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
237 pmda_support = False
238 if pmda_support:
239 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
240 have_pmda = True
241 else:
242 Logs.error("PMDA support not available")
243 sys.exit(1)
244 if have_pmda:
245 Logs.info('Building with PMDA support')
246 conf.define('HAVE_PMDA', 1)
247 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
248 'lib/pcp/pmdas/ctdb')
250 have_infiniband = False
251 if Options.options.ctdb_infiniband:
252 ib_support = True
254 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
255 ib_support = False
256 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
257 ib_support = False
258 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
259 ib_support = False
260 if ib_support:
261 have_infiniband = True
262 else:
263 Logs.error("Infiniband support not available")
264 sys.exit(1)
265 if have_infiniband:
266 Logs.info('Building with Infiniband support')
267 conf.define('HAVE_INFINIBAND', 1)
268 conf.define('USE_INFINIBAND', 1)
270 have_etcd_reclock = False
271 if Options.options.ctdb_etcd_reclock:
272 try:
273 conf.check_python_module('etcd')
274 have_etcd_reclock = True
275 except:
276 Logs.error('etcd support not available')
277 sys.exit(1)
278 if have_etcd_reclock:
279 Logs.info('Building with etcd support')
280 conf.env.etcd_reclock = have_etcd_reclock
282 if Options.options.ctdb_ceph_reclock:
283 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
284 conf.CHECK_LIB('rados', shlib=True)):
285 Logs.info('Building with Ceph librados recovery lock support')
286 conf.define('HAVE_LIBRADOS', 1)
287 else:
288 Logs.error("Missing librados for Ceph recovery lock support")
289 sys.exit(1)
291 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
292 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
293 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
294 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
295 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
296 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
298 if Options.options.ctdb_logdir:
299 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
300 else:
301 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
303 if Options.options.ctdb_sockpath:
304 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
305 else:
306 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
307 'ctdbd.socket')
308 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
310 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
311 -DLOGDIR=\"%s\"
312 -DCTDB_DATADIR=\"%s\"
313 -DCTDB_ETCDIR=\"%s\"
314 -DCTDB_VARDIR=\"%s\"
315 -DCTDB_RUNDIR=\"%s\"''' % (
316 conf.env.CTDB_HELPER_BINDIR,
317 conf.env.CTDB_LOGDIR,
318 conf.env.CTDB_DATADIR,
319 conf.env.CTDB_ETCDIR,
320 conf.env.CTDB_VARDIR,
321 conf.env.CTDB_RUNDIR))
323 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
324 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
326 # Allow unified compilation and separate compilation of utilities
327 # to find includes
328 if not conf.env.standalone_ctdb:
329 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
330 else:
331 if Context.g_module.top == '.':
332 # Building from tarball
333 conf.ADD_EXTRA_INCLUDES('#include')
334 else:
335 # Building standalone CTDB from within Samba tree
336 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
337 conf.ADD_EXTRA_INCLUDES('#ctdb')
338 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
340 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
341 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
342 conf.SAMBA_CONFIG_H()
344 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
345 conf.env.ctdb_generate_manpages = True
346 else:
347 conf.env.ctdb_generate_manpages = False
349 Logs.info("xsltproc unavailable, checking for pre-built manpages")
350 conf.env.ctdb_prebuilt_manpages = []
351 manpages = manpages_binary + manpages_misc
352 if conf.env.etcd_reclock:
353 manpages += manpages_etcd
354 if conf.env.HAVE_LIBRADOS:
355 manpages += manpages_ceph
356 for m in manpages:
357 if os.path.exists(os.path.join("doc", m)):
358 Logs.info(" %s: yes" % (m))
359 conf.env.ctdb_prebuilt_manpages.append(m)
360 else:
361 Logs.info(" %s: no" % (m))
363 def build(bld):
364 if bld.env.standalone_ctdb:
365 # enable building of public headers in the build tree
366 bld.env.build_public_headers = 'include/public'
368 if bld.env.standalone_ctdb:
369 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
371 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
373 bld.RECURSE('lib/replace')
374 if bld.CHECK_FOR_THIRD_PARTY():
375 bld.RECURSE('third_party/popt')
376 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
377 bld.RECURSE('third_party/socket_wrapper')
379 bld.RECURSE('lib/tdb_wrap')
380 bld.RECURSE('lib/util')
381 bld.RECURSE('lib/async_req')
382 bld.RECURSE('lib/pthreadpool')
383 bld.RECURSE('lib/messaging')
385 bld.RECURSE('lib/talloc')
386 bld.RECURSE('lib/tevent')
387 bld.RECURSE('lib/tdb')
389 if bld.env.standalone_ctdb:
390 # If a combined build is implemented, CTDB will want to
391 # build against samba-util rather than samba-util-core.
392 # Similarly, other Samba subsystems expect samba-util. So,
393 # for a standalone build, just define a fake samba-util
394 # subsystem that pulls in samba-util-core.
395 bld.SAMBA_SUBSYSTEM('samba-util',
396 source='',
397 deps='samba-util-core')
399 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
400 source=bld.SUBDIR('tcp',
401 'tcp_connect.c tcp_init.c tcp_io.c'),
402 includes='include',
403 deps='''ctdb-protocol-util
404 ctdb-system
405 ctdb-util
406 replace
407 talloc
409 tevent
410 ''')
412 ib_deps = ''
413 if bld.env.HAVE_INFINIBAND:
414 bld.SAMBA_SUBSYSTEM('ctdb-ib',
415 source=bld.SUBDIR('ib',
416 '''ibwrapper.c ibw_ctdb.c
417 ibw_ctdb_init.c'''),
418 includes='include',
419 deps='replace talloc tevent tdb')
420 ib_deps = ' ctdb-ib rdmacm ibverbs'
422 bld.SAMBA_SUBSYSTEM('ctdb-system',
423 source=bld.SUBDIR('common',
424 'system_socket.c system.c'),
425 deps='''ctdb-protocol
426 ctdb-protocol-util
427 pcap
428 replace
429 samba-util
430 talloc
432 tevent
433 ''')
435 bld.SAMBA_SUBSYSTEM('ctdb-common',
436 source=bld.SUBDIR('common',
437 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
438 sock_io.c'''),
439 includes='include',
440 deps='''replace popt talloc tevent tdb popt ctdb-system
441 ctdb-protocol-util''')
443 bld.SAMBA_SUBSYSTEM('ctdb-util',
444 source=bld.SUBDIR('common',
445 '''cmdline.c
446 comm.c
447 db_hash.c
448 event_script.c
449 hash_count.c
450 logging.c
451 path.c
452 pidfile.c
453 pkt_read.c
454 pkt_write.c
455 rb_tree.c
456 reqid.c
457 run_event.c
458 run_proc.c
459 sock_client.c
460 srvid.c
461 tmon.c
462 tunable.c
463 '''),
464 deps='''samba-util
465 LIBASYNC_REQ
466 sys_rw
467 tevent-util
468 replace
469 talloc
470 tevent
472 popt
473 ''')
475 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
476 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
477 deps='talloc tdb')
479 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
480 source=bld.SUBDIR('protocol',
481 '''protocol_header.c protocol_packet.c
482 protocol_types.c
483 protocol_call.c
484 protocol_message.c
485 protocol_control.c
486 protocol_keepalive.c
487 protocol_tunnel.c
488 protocol_client.c
489 protocol_debug.c
490 protocol_sock.c'''),
491 deps='ctdb-protocol-basic replace talloc tdb')
493 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
494 source='protocol/protocol_util.c',
495 deps='replace talloc tdb')
497 bld.SAMBA_SUBSYSTEM('ctdb-client',
498 source=bld.SUBDIR('client',
499 '''client_connect.c client_call.c
500 client_message.c client_control.c
501 client_message_sync.c
502 client_control_sync.c
503 client_db.c client_util.c
504 client_tunnel.c
505 '''),
506 deps='''ctdb-protocol
507 ctdb-util
508 samba-util
509 replace
510 talloc
511 tevent
513 tdb-wrap
514 ''')
516 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
517 source=bld.SUBDIR('common',
518 '''sock_daemon.c'''),
519 deps='''samba-util ctdb-util ctdb-system tevent-util
520 LIBASYNC_REQ replace talloc tevent''')
522 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
523 source=bld.SUBDIR('server',
524 '''ipalloc_deterministic.c
525 ipalloc_nondeterministic.c
526 ipalloc_lcp2.c
527 ipalloc_common.c
528 ipalloc.c
529 '''),
530 includes='include',
531 deps='ctdb-protocol-util replace talloc tevent')
533 bld.SAMBA_BINARY('ctdb-path',
534 source='common/path_tool.c',
535 cflags='-DCTDB_PATH_TOOL',
536 deps='''ctdb-util samba-util talloc replace popt''',
537 install_path='${CTDB_HELPER_BINDIR}')
539 bld.SAMBA_SUBSYSTEM('ctdb-conf',
540 source='''conf/conf.c
541 conf/logging_conf.c
542 conf/cluster_conf.c
543 conf/database_conf.c
544 conf/event_conf.c
545 conf/failover_conf.c
546 conf/legacy_conf.c
547 conf/ctdb_config.c
548 ''',
549 deps='''ctdb-util talloc replace''')
551 bld.SAMBA_SUBSYSTEM('ctdb-conf-util',
552 source='''conf/node.c
553 ''',
554 deps='''ctdb-protocol
555 ctdb-protocol-util
556 replace
557 samba-util
558 talloc
559 ''')
561 bld.SAMBA_BINARY('ctdb-config',
562 source='conf/conf_tool.c',
563 cflags='-DCTDB_CONF_TOOL',
564 deps='''ctdb-conf
565 ctdb-util samba-util talloc replace popt''',
566 install_path='${CTDB_HELPER_BINDIR}')
568 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
569 source=bld.SUBDIR('event',
570 '''event_protocol.c
571 event_protocol_util.c
572 '''),
573 deps='ctdb-protocol-basic')
575 bld.SAMBA_LIBRARY('ctdb-event-client',
576 source='event/event_client.c',
577 deps='ctdb-event-protocol ctdb-util tevent talloc',
578 private_library=True)
580 bld.SAMBA_BINARY('ctdb-eventd',
581 source=bld.SUBDIR('event',
582 '''event_cmd.c
583 event_config.c
584 event_context.c
585 event_daemon.c
586 event_request.c
587 '''),
588 deps='''ctdb-event-protocol
589 ctdb-conf
590 ctdb-server-util samba-util ctdb-util
591 talloc tevent replace popt''',
592 install_path='${CTDB_HELPER_BINDIR}')
594 bld.SAMBA_BINARY('ctdb-event',
595 source='event/event_tool.c',
596 cflags='-DCTDB_EVENT_TOOL',
597 deps='''ctdb-event-client ctdb-event-protocol
598 ctdb-util samba-util talloc replace''',
599 install_path='${CTDB_HELPER_BINDIR}')
601 bld.SAMBA_BINARY('ctdbd',
602 source='server/ctdbd.c ' +
603 bld.SUBDIR('server',
604 '''ctdb_daemon.c ctdb_recoverd.c
605 ctdb_recover.c ctdb_freeze.c
606 ctdb_tunables.c ctdb_monitor.c
607 ctdb_server.c ctdb_control.c
608 ctdb_call.c ctdb_ltdb_server.c
609 ctdb_traverse.c eventscript.c
610 ctdb_takeover.c
611 ctdb_persistent.c ctdb_keepalive.c
612 ctdb_cluster_mutex.c
613 ctdb_logging.c
614 ctdb_uptime.c
615 ctdb_vacuum.c ctdb_banning.c
616 ctdb_statistics.c
617 ctdb_update_record.c
618 ctdb_lock.c ctdb_fork.c
619 ctdb_tunnel.c ctdb_client.c
620 '''),
621 includes='include',
622 deps='''ctdb-common
623 ctdb-conf
624 ctdb-conf-util
625 ctdb-event-protocol
626 ctdb-protocol
627 ctdb-system
628 ctdb-tcp
629 ctdb-util
630 popt
631 replace
632 sys_rw
633 talloc
634 talloc_report
636 tdb-wrap
637 tevent
638 ''' +
639 ib_deps,
640 install_path='${SBINDIR}',
641 manpages='ctdbd.1')
643 bld.SAMBA_BINARY('ctdb',
644 source='tools/ctdb.c',
645 deps='''ctdb-client
646 ctdb-conf
647 ctdb-conf-util
648 ctdb-protocol
649 ctdb-protocol-util
650 ctdb-system
651 ctdb-util
652 popt
653 samba-util
654 sys_rw
655 ''',
656 install_path='${BINDIR}',
657 manpages='ctdb.1')
659 bld.SAMBA_BINARY('ctdb_killtcp',
660 source='tools/ctdb_killtcp.c',
661 deps='''ctdb-protocol-util ctdb-util ctdb-system
662 samba-util replace''',
663 install_path='${CTDB_HELPER_BINDIR}')
665 bld.SAMBA_BINARY('ltdbtool',
666 source='tools/ltdbtool.c',
667 includes='include',
668 deps='tdb',
669 install_path='${BINDIR}',
670 manpages='ltdbtool.1')
672 bld.SAMBA_BINARY('ctdb_lock_helper',
673 source='server/ctdb_lock_helper.c',
674 deps='''samba-util sys_rw ctdb-system tevent-util
675 talloc tevent tdb''',
676 includes='include',
677 install_path='${CTDB_HELPER_BINDIR}')
679 bld.SAMBA_BINARY('ctdb_recovery_helper',
680 source='server/ctdb_recovery_helper.c',
681 deps='''ctdb-client ctdb-protocol ctdb-util
682 samba-util sys_rw replace tdb''',
683 install_path='${CTDB_HELPER_BINDIR}')
685 bld.SAMBA_BINARY("statd_callout",
686 source="failover/statd_callout.c",
687 install_path="${CTDB_HELPER_BINDIR}")
689 bld.SAMBA_BINARY('ctdb_takeover_helper',
690 source='server/ctdb_takeover_helper.c',
691 deps='''ctdb-client ctdb-protocol ctdb-util
692 samba-util sys_rw replace ctdb-ipalloc popt''',
693 install_path='${CTDB_HELPER_BINDIR}')
695 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
696 source='server/ctdb_mutex_fcntl_helper.c',
697 deps='''sys_rw ctdb-system tevent-util ctdb-util
698 talloc tevent
699 ''',
700 includes='include',
701 install_path='${CTDB_HELPER_BINDIR}')
703 bld.SAMBA_BINARY('ctdb_smnotify_helper',
704 source=('failover/smnotify_helper.c'),
705 deps='sys_rw replace',
706 install_path='${CTDB_HELPER_BINDIR}')
708 bld.SAMBA_BINARY('ping_pong',
709 source='utils/ping_pong/ping_pong.c',
710 deps='',
711 install_path='${BINDIR}',
712 manpages='ping_pong.1')
714 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
715 bld.SAMBA_BINARY('tdb_mutex_check',
716 source='utils/tdb/tdb_mutex_check.c',
717 deps='tdb pthread',
718 install_path='${CTDB_HELPER_BINDIR}')
720 if bld.env.HAVE_PMDA:
721 bld.SAMBA_BINARY('pmdactdb',
722 source='utils/pmda/pmda_ctdb.c',
723 deps='''ctdb-client ctdb-protocol ctdb-util
724 samba-util pcp_pmda pcp''',
725 install_path='${CTDB_PMDADIR}')
726 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
727 destname='Install')
728 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
729 destname='Remove')
730 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
731 destname='pmns')
732 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
733 destname='domain.h')
734 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
735 destname='help')
736 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
737 destname='README')
739 if bld.env.HAVE_LIBRADOS:
740 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
741 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
742 deps='talloc tevent rados',
743 includes='include',
744 install_path='${CTDB_HELPER_BINDIR}')
746 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
747 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
748 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
749 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
750 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
751 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
752 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
753 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
754 sed_cmdline = '-e "%s" ' * 8 % \
755 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
756 sed_expr6, sed_expr7, sed_expr8)
758 manpages_extra = list(manpages_misc)
759 if bld.env.etcd_reclock:
760 manpages_extra += manpages_etcd
761 if bld.env.HAVE_LIBRADOS:
762 manpages_extra += manpages_ceph
763 for f in manpages_binary + manpages_extra:
764 x = '%s.xml' % (f)
765 bld.SAMBA_GENERATOR(x,
766 source=os.path.join('doc', x),
767 target=x,
768 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
770 if bld.env.ctdb_generate_manpages:
771 bld.MANPAGES(' '.join(manpages_extra), True)
772 else:
773 for m in bld.env.ctdb_prebuilt_manpages:
774 bld.SAMBA_GENERATOR(m,
775 source=os.path.join("doc", m),
776 target=m,
777 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
778 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
780 bld.SAMBA_GENERATOR('ctdb-onnode',
781 source='tools/onnode',
782 target='onnode',
783 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
784 bld.INSTALL_FILES('${BINDIR}', 'onnode',
785 destname='onnode', chmod=MODE_755)
787 bld.SAMBA_GENERATOR('ctdb-diagnostics',
788 source='tools/ctdb_diagnostics',
789 target='ctdb_diagnostics',
790 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
791 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
792 destname='ctdb_diagnostics', chmod=MODE_755)
794 if bld.env.etcd_reclock:
795 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
796 source='utils/etcd/ctdb_etcd_lock',
797 target='ctdb_etcd_lock',
798 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
799 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
800 destname='ctdb_etcd_lock', chmod=MODE_744)
802 bld.SAMBA_GENERATOR('ctdb-natgw',
803 source='tools/ctdb_natgw',
804 target='ctdb_natgw',
805 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
806 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
807 destname='ctdb_natgw', chmod=MODE_755)
809 bld.SAMBA_GENERATOR('ctdb-lvs',
810 source='tools/ctdb_lvs',
811 target='ctdb_lvs',
812 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
813 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
814 destname='ctdb_lvs', chmod=MODE_755)
816 bld.SAMBA_GENERATOR("ctdb-statd-callout-helper",
817 source="tools/statd_callout_helper",
818 target="statd_callout_helper",
819 rule=f"sed {sed_cmdline} ${{SRC}} > ${{TGT}}")
820 bld.INSTALL_FILES("${CTDB_HELPER_BINDIR}", "statd_callout_helper",
821 destname="statd_callout_helper", chmod=MODE_755)
823 bld.symlink_as(os.path.join(bld.env.CTDB_ETCDIR, "statd-callout"),
824 os.path.join(bld.env.CTDB_HELPER_BINDIR, "statd_callout"))
826 def SUBDIR_MODE_callback(arg, dirname, fnames):
827 for f in fnames:
828 fl = os.path.join(dirname, f)
829 if os.path.isdir(fl) or os.path.islink(fl):
830 continue
831 mode = os.lstat(fl).st_mode & MODE_777
832 if arg['trim_path']:
833 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
834 arg['file_list'].append([fl, mode])
836 def SUBDIR_MODE(path, trim_path=None):
837 pd = {'trim_path': trim_path, 'file_list': []}
838 for dirname, _subdirs, fnames in os.walk(path):
839 SUBDIR_MODE_callback(pd, dirname, fnames)
840 return pd['file_list']
842 event_script_subdirs = [
843 'events/legacy',
846 etc_subdirs = [
847 'nfs-checks.d'
850 if bld.env.standalone_ctdb:
851 configdir = 'config'
852 else:
853 configdir = 'ctdb/config'
855 for t in event_script_subdirs:
856 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
857 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
858 for fmode in files:
859 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
860 destname=fmode[0], chmod=fmode[1])
862 for t in etc_subdirs:
863 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
864 for fmode in files:
865 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
866 destname=fmode[0], chmod=fmode[1])
868 # If this is a direct install and there are no event scripts
869 # linked/enabled then enable some standard ones
870 if os.environ.get('DESTDIR') is None:
871 fmt = 'events/legacy/%s.script'
872 required_script = '00.ctdb'
873 required_path = os.path.join(bld.env.CTDB_ETCDIR,
874 fmt % (required_script))
875 if not os.path.islink(required_path) and \
876 not os.path.exists(required_path):
877 default_scripts = [ required_script,
878 '01.reclock',
879 '05.system',
880 '10.interface',
881 '95.database',
883 for t in default_scripts:
884 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
885 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
886 bld.symlink_as(name, tgt)
888 bld.SAMBA_GENERATOR('ctdb-functions',
889 source='config/functions',
890 target='functions',
891 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
892 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
894 etc_scripts = [
895 'ctdb-backup-persistent-tdbs.sh',
896 'ctdb-crash-cleanup.sh',
897 'debug-hung-script.sh',
898 'debug_locks.sh',
899 'nfs-linux-kernel-callout',
900 'notify.sh',
903 for t in etc_scripts:
904 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
905 destname=t, chmod=MODE_755)
907 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
908 'config/notification.README',
909 destname='README')
911 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
912 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
913 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
915 for d in ['volatile', 'persistent', 'state']:
916 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
919 # Test-only below this point
922 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
923 return
925 bld.SAMBA_BINARY('errcode',
926 source='tests/src/errcode.c',
927 deps='replace',
928 install_path='${CTDB_TEST_LIBEXECDIR}')
930 bld.SAMBA_BINARY('sigcode',
931 source='tests/src/sigcode.c',
932 deps='replace',
933 install_path='${CTDB_TEST_LIBEXECDIR}')
935 # Unit tests
936 ctdb_util_tests = [
937 'cmdline_test',
938 'comm_client_test',
939 'comm_server_test',
940 'comm_test',
941 'conf_test',
942 'db_hash_test',
943 'event_script_test',
944 'hash_count_test',
945 'pidfile_test',
946 'pkt_read_test',
947 'pkt_write_test',
948 'run_event_test',
949 'run_proc_test',
950 'sock_io_test',
951 'srvid_test',
952 'tunable_test',
955 for target in ctdb_util_tests:
956 src = 'tests/src/' + target + '.c'
958 bld.SAMBA_BINARY(target,
959 source=src,
960 deps='''ctdb-tests-backtrace
961 LIBASYNC_REQ
962 samba-util
963 sys_rw
964 tevent-util
965 talloc
966 tevent
968 popt
969 ''',
970 install_path='${CTDB_TEST_LIBEXECDIR}')
972 bld.SAMBA_BINARY('reqid_test',
973 source='tests/src/reqid_test.c',
974 deps='samba-util talloc',
975 install_path='${CTDB_TEST_LIBEXECDIR}')
977 bld.SAMBA_BINARY('rb_test',
978 source='tests/src/rb_test.c',
979 deps='samba-util talloc',
980 install_path='${CTDB_TEST_LIBEXECDIR}')
982 bld.SAMBA_BINARY('ctdb_packet_parse',
983 source='tests/src/ctdb_packet_parse.c',
984 deps='talloc tevent tdb ctdb-protocol',
985 install_path='${CTDB_TEST_LIBEXECDIR}')
987 bld.SAMBA_BINARY('system_socket_test',
988 source='tests/src/system_socket_test.c',
989 deps='''ctdb-tests-backtrace
990 talloc
991 ctdb-protocol-util
992 pcap
993 ''',
994 install_path='${CTDB_TEST_LIBEXECDIR}')
996 bld.SAMBA_BINARY('porting_tests',
997 source='tests/src/porting_tests.c',
998 deps='samba-util ctdb-system popt',
999 install_path='${CTDB_TEST_LIBEXECDIR}')
1001 bld.SAMBA_BINARY('sock_daemon_test',
1002 source='tests/src/sock_daemon_test.c',
1003 deps='''ctdb-system talloc tevent tevent-util
1004 LIBASYNC_REQ samba-util sys_rw''',
1005 install_path='${CTDB_TEST_LIBEXECDIR}')
1007 bld.SAMBA_BINARY('ctdb_io_test',
1008 source='tests/src/ctdb_io_test.c',
1009 deps='''talloc tevent tdb samba-util sys_rw''',
1010 install_path='${CTDB_TEST_LIBEXECDIR}')
1012 bld.SAMBA_BINARY('ctdb-db-test',
1013 source='tests/src/db_test_tool.c',
1014 cflags='-DCTDB_DB_TEST_TOOL',
1015 deps='''ctdb-client ctdb-protocol
1016 ctdb-util samba-util talloc tevent replace''',
1017 install_path='${CTDB_TEST_LIBEXECDIR}')
1019 for target in ['tmon_ping_test', 'tmon_test']:
1020 src = 'tests/src/' + target + '.c'
1022 bld.SAMBA_BINARY(target,
1023 source=src,
1024 deps='''ctdb-util
1025 ctdb-tests-backtrace
1026 LIBASYNC_REQ
1027 samba-util
1028 sys_rw
1029 tevent-util
1030 talloc
1031 tevent
1033 popt
1034 ''',
1035 install_path='${CTDB_TEST_LIBEXECDIR}')
1037 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1038 source=bld.SUBDIR('tests/src',
1039 'protocol_common_basic.c'),
1040 deps='samba-util replace talloc')
1042 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1043 source=bld.SUBDIR('tests/src',
1044 '''protocol_common.c
1045 protocol_common_ctdb.c
1046 '''),
1047 deps='ctdb-protocol-tests-basic replace talloc tdb')
1049 bld.SAMBA_BINARY('protocol_basic_test',
1050 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
1051 deps='ctdb-protocol-tests-basic talloc',
1052 install_path='${CTDB_TEST_LIBEXECDIR}')
1054 ctdb_protocol_tests = [
1055 'protocol_types_test',
1056 'protocol_ctdb_test',
1057 'protocol_util_test',
1058 'protocol_types_compat_test',
1059 'protocol_ctdb_compat_test',
1062 for target in ctdb_protocol_tests:
1063 src = 'tests/src/' + target + '.c'
1065 bld.SAMBA_BINARY(target,
1066 source=src,
1067 deps='''ctdb-protocol-tests-common
1068 samba-util talloc tdb''',
1069 install_path='${CTDB_TEST_LIBEXECDIR}')
1071 bld.SAMBA_BINARY('event_protocol_test',
1072 source='event/event_protocol_test.c',
1073 deps='''ctdb-protocol-tests-basic
1074 ctdb-protocol-basic talloc''',
1075 install_path='${CTDB_TEST_LIBEXECDIR}')
1077 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1078 source=bld.SUBDIR('tests/src',
1079 '''cluster_wait.c
1080 test_options.c
1081 '''),
1082 deps='''ctdb-client
1083 samba-util
1084 replace
1085 popt
1086 talloc
1087 tevent
1088 tdb''')
1090 bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1091 source=bld.SUBDIR('tests/src',
1092 'test_backtrace.c'),
1093 deps='''samba-util
1094 replace''')
1096 # Test binaries
1097 ctdb_tests = [
1098 'g_lock_loop',
1099 'message_ring',
1100 'fetch_ring',
1101 'fetch_loop',
1102 'fetch_loop_key',
1103 'fetch_readonly',
1104 'fetch_readonly_loop',
1105 'transaction_loop',
1106 'update_record',
1107 'update_record_persistent',
1108 'lock_tdb',
1109 'dummy_client',
1110 'tunnel_test',
1111 'tunnel_cmd',
1114 for target in ctdb_tests:
1115 src = 'tests/src/' + target + '.c'
1117 bld.SAMBA_BINARY(target,
1118 source=src,
1119 includes='include',
1120 deps='''ctdb-client ctdb-protocol ctdb-util
1121 samba-util ctdb-tests-common''',
1122 install_path='${CTDB_TEST_LIBEXECDIR}')
1124 bld.SAMBA_BINARY('ctdb_takeover_tests',
1125 source='''tests/src/ctdb_takeover_tests.c
1126 tests/src/ipalloc_read_known_ips.c''',
1127 deps='''replace popt tdb tevent talloc ctdb-system
1128 samba-util tdb-wrap talloc_report
1129 ctdb-ipalloc ctdb-protocol ctdb-util''',
1130 includes='include',
1131 install_path='${CTDB_TEST_LIBEXECDIR}')
1133 bld.SAMBA_BINARY('fake_ctdbd',
1134 source='''tests/src/fake_ctdbd.c
1135 tests/src/ipalloc_read_known_ips.c''',
1136 deps='''ctdb-conf-util
1137 ctdb-protocol
1138 ctdb-protocol-util
1139 ctdb-system
1140 ctdb-util
1141 popt
1142 samba-util
1143 tevent-util
1144 LIBASYNC_REQ''',
1145 install_path='${CTDB_TEST_LIBEXECDIR}')
1147 bld.SAMBA_BINARY('cluster_mutex_test',
1148 source='tests/src/cluster_mutex_test.c',
1149 deps='''ctdb-tests-backtrace
1150 samba-util
1151 talloc
1152 tevent
1153 ''',
1154 install_path='${CTDB_TEST_LIBEXECDIR}')
1156 if bld.env.HAVE_INFINIBAND:
1157 bld.SAMBA_BINARY('ibwrapper_test',
1158 source='ib/ibwrapper_test.c',
1159 includes='include',
1160 deps='replace talloc ctdb-common sys_rw' +
1161 ib_deps,
1162 install_path='${CTDB_TEST_LIBEXECDIR}')
1164 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1165 bld.SAMBA_BINARY('test_mutex_raw',
1166 source='tests/src/test_mutex_raw.c',
1167 deps='pthread',
1168 install_path='${CTDB_TEST_LIBEXECDIR}')
1170 test_subdirs = [
1171 'CLUSTER',
1172 'INTEGRATION',
1173 'UNIT',
1174 'etc-ctdb'
1177 if bld.env.standalone_ctdb:
1178 testdir = 'tests'
1179 else:
1180 testdir = 'ctdb/tests'
1182 for t in test_subdirs:
1183 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1184 for fmode in files:
1185 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1186 destname=fmode[0], chmod=fmode[1])
1188 # Install tests/scripts directory, excluding files that need munging
1189 test_scripts = [
1190 'cluster.bash',
1191 'common.sh',
1192 'integration.bash',
1193 'integration_local_daemons.bash',
1194 'integration_real_cluster.bash',
1195 'unit.sh'
1198 for t in test_scripts:
1199 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1200 os.path.join('tests/scripts', t),
1201 destname=os.path.join('scripts', t))
1203 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1204 'tests/scripts/test_wrap',
1205 destname='scripts/test_wrap',
1206 chmod=MODE_755)
1208 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1209 source='tests/scripts/script_install_paths.sh',
1210 target='script_install_paths.sh',
1211 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1212 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1213 'script_install_paths.sh',
1214 destname='script_install_paths.sh', chmod=MODE_644)
1216 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1217 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1218 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1219 bld.SAMBA_GENERATOR('ctdb-test-runner',
1220 source='tests/run_tests.sh',
1221 target='ctdb_run_tests.sh',
1222 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1223 sed_expr1, sed_expr2))
1224 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1225 destname='ctdb_run_tests', chmod=MODE_755)
1226 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1227 'ctdb_run_tests')
1229 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1230 source='tests/local_daemons.sh',
1231 target='ctdb_local_daemons.sh',
1232 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1233 sed_expr1, sed_expr2))
1234 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1235 destname='ctdb_local_daemons', chmod=MODE_755)
1238 def testonly(ctx):
1239 cmd = 'tests/run_tests.sh'
1240 ret = samba_utils.RUN_COMMAND(cmd)
1241 if ret != 0:
1242 print('tests exited with exit status %d' % ret)
1243 sys.exit(ret)
1246 def test(ctx):
1247 Options.commands.append('build')
1248 Options.commands.append('testonly')
1251 def autotest(ctx):
1252 env = samba_utils.LOAD_ENVIRONMENT()
1253 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1254 ret = samba_utils.RUN_COMMAND(cmd)
1255 if ret != 0:
1256 print('autotest exited with exit status %d' % ret)
1257 sys.exit(ret)
1260 def show_version(ctx):
1261 print(get_version_string())
1264 def manpages(ctx):
1265 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1266 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1267 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1268 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1269 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1270 for t in manpages:
1271 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1272 ret = samba_utils.RUN_COMMAND(cmd)
1273 if ret != 0:
1274 print('Command %s failed with exit status %d' % (cmd, ret))
1275 sys.exit(ret)
1277 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1278 ret = samba_utils.RUN_COMMAND(cmd)
1279 if ret != 0:
1280 print('Command %s failed with exit status %d' % (cmd, ret))
1281 sys.exit(ret)
1284 def distonly(ctx):
1285 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1287 t = 'ctdb.spec'
1288 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1289 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1290 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1291 sed_expr1, sed_expr2, t)
1292 ret = samba_utils.RUN_COMMAND(cmd)
1293 if ret != 0:
1294 print('Command "%s" failed with exit status %d' % (cmd, ret))
1295 sys.exit(ret)
1296 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1298 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1299 for t in manpages:
1300 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1301 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1302 extend=True)
1304 samba_dist.dist()
1307 def dist():
1308 Options.commands.append('manpages')
1309 Options.commands.append('distonly')
1312 def rpmonly(ctx):
1313 opts = os.getenv('RPM_OPTIONS') or ''
1314 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1315 (opts, get_version_string())
1316 ret = samba_utils.RUN_COMMAND(cmd)
1317 if ret != 0:
1318 print('rpmbuild exited with exit status %d' % ret)
1319 sys.exit(ret)
1322 def rpm(ctx):
1323 Options.commands.append('manpages')
1324 Options.commands.append('distonly')
1325 Options.commands.append('rpmonly')
1328 def ctags(ctx):
1329 "build 'tags' file using ctags"
1330 source_root = os.path.dirname(Context.g_module.root_path)
1331 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1332 print("Running: %s" % cmd)
1333 ret = samba_utils.RUN_COMMAND(cmd)
1334 if ret != 0:
1335 print('ctags failed with exit status %d' % ret)
1336 sys.exit(ret)