pytest:dsdb: check that there is a gkdi root key
[samba.git] / ctdb / wscript
bloba7b04541014400806a8725ad2bcd241156887c42
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('--with-libcephfs',
106 help=("Directory under which libcephfs is installed"),
107 action="store", dest='libcephfs_dir', default=None)
108 opt.add_option('--enable-ceph-reclock',
109 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
110 action="store_true", dest='ctdb_ceph_reclock', default=False)
112 opt.add_option('--with-logdir',
113 help=("Path to log directory"),
114 action="store", dest='ctdb_logdir', default=None)
115 opt.add_option('--with-socketpath',
116 help=("path to CTDB daemon socket"),
117 action="store", dest='ctdb_sockpath', default=None)
120 def configure(conf):
121 # No need to build python bindings for talloc/tevent/tdb
122 if conf.IN_LAUNCH_DIR():
123 conf.env.standalone_ctdb = True
124 Options.options.disable_python = True
126 conf.RECURSE('lib/replace')
128 conf.CHECK_HEADERS(headers='''sys/socket.h
129 netinet/in.h
130 netinet/if_ether.h
131 netinet/ip.h
132 netinet/ip6.h
133 netinet/icmp6.h''',
134 together=True)
136 conf.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
137 define='HAVE_AF_PACKET',
138 headers='sys/socket.h linux/if_packet.h')
140 conf.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
141 define='HAVE_PACKETSOCKET',
142 headers='sys/socket.h linux/if_packet.h')
144 conf.CHECK_CODE('''pthread_mutex_t m;
145 int pid = 0;
146 m.__data.__owner = pid;
147 ''',
148 'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER',
149 headers='pthread.h',
150 msg='Checking for internal POSIX mutex owner field')
151 if not conf.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
152 # This is unsupported - please see note in debug_locks.sh
153 Logs.info('Building without unsupported mutex debugging hack')
155 if conf.env.standalone_ctdb:
156 conf.SAMBA_CHECK_PERL(mandatory=True)
158 # This is just for consistency and to check the version for the
159 # build system, see Options.options.disable_python = True above
160 conf.SAMBA_CHECK_PYTHON()
161 conf.SAMBA_CHECK_PYTHON_HEADERS()
163 # We just want gnutls_rnd for rand subsystem
164 conf.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
167 if conf.CHECK_FOR_THIRD_PARTY():
168 conf.RECURSE('third_party/popt')
169 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
170 conf.RECURSE('third_party/socket_wrapper')
171 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
172 else:
173 if not conf.CHECK_POPT():
174 raise Errors.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
175 else:
176 conf.define('USING_SYSTEM_POPT', 1)
177 conf.env.SOCKET_WRAPPER_SO_PATH = ''
180 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
181 if not conf.CHECK_SOCKET_WRAPPER():
182 raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
183 else:
184 conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
185 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
187 conf.RECURSE('lib/util')
189 conf.RECURSE('lib/talloc')
190 conf.RECURSE('lib/tevent')
191 conf.RECURSE('lib/tdb')
193 conf.CHECK_HEADERS('sched.h')
194 conf.CHECK_HEADERS('procinfo.h')
195 if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'):
196 Logs.error('Need thread_setsched() on AIX')
197 sys.exit(1)
198 elif not conf.CHECK_FUNCS('sched_setscheduler'):
199 Logs.error('Need sched_setscheduler()')
200 sys.exit(1)
201 conf.CHECK_FUNCS('mlockall')
202 conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
204 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
205 conf.DEFINE('ETIME', 'ETIMEDOUT')
207 if Options.options.ctdb_pcap or not sys.platform.startswith('linux'):
208 conf.DEFINE('ENABLE_PCAP', 1)
209 if not conf.env.ENABLE_PCAP:
210 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
211 else:
212 conf.find_program('pcap-config', var='PCAP_CONFIG')
213 if conf.env.PCAP_CONFIG:
214 conf.CHECK_CFG(path=conf.env.PCAP_CONFIG,
215 args="--cflags --libs",
216 package="",
217 uselib_store="PCAP")
218 if not conf.CHECK_HEADERS('pcap.h'):
219 Logs.error('Need libpcap')
220 sys.exit(1)
221 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
222 Logs.error('Need libpcap')
223 sys.exit(1)
224 conf.CHECK_FUNCS_IN('pcap_set_immediate_mode', 'pcap', headers='pcap.h')
226 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
227 checklibc=True, headers='execinfo.h'):
228 Logs.error('backtrace support not available')
230 have_pmda = False
231 if Options.options.ctdb_pmda:
232 pmda_support = True
234 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
235 together=True):
236 pmda_support = False
237 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
238 pmda_support = False
239 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
240 pmda_support = False
241 if pmda_support:
242 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
243 have_pmda = True
244 else:
245 Logs.error("PMDA support not available")
246 sys.exit(1)
247 if have_pmda:
248 Logs.info('Building with PMDA support')
249 conf.define('HAVE_PMDA', 1)
250 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
251 'lib/pcp/pmdas/ctdb')
253 have_infiniband = False
254 if Options.options.ctdb_infiniband:
255 ib_support = True
257 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
258 ib_support = False
259 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
260 ib_support = False
261 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
262 ib_support = False
263 if ib_support:
264 have_infiniband = True
265 else:
266 Logs.error("Infiniband support not available")
267 sys.exit(1)
268 if have_infiniband:
269 Logs.info('Building with Infiniband support')
270 conf.define('HAVE_INFINIBAND', 1)
271 conf.define('USE_INFINIBAND', 1)
273 have_etcd_reclock = False
274 if Options.options.ctdb_etcd_reclock:
275 try:
276 conf.check_python_module('etcd')
277 have_etcd_reclock = True
278 except:
279 Logs.error('etcd support not available')
280 sys.exit(1)
281 if have_etcd_reclock:
282 Logs.info('Building with etcd support')
283 conf.env.etcd_reclock = have_etcd_reclock
285 if Options.options.libcephfs_dir:
286 Logs.error('''--with-libcephfs no longer supported, please use compiler
287 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
288 sys.exit(1)
290 if Options.options.ctdb_ceph_reclock:
291 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
292 conf.CHECK_LIB('rados', shlib=True)):
293 Logs.info('Building with Ceph librados recovery lock support')
294 conf.define('HAVE_LIBRADOS', 1)
295 else:
296 Logs.error("Missing librados for Ceph recovery lock support")
297 sys.exit(1)
299 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
300 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
301 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
302 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
303 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
304 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
306 if Options.options.ctdb_logdir:
307 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
308 else:
309 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
311 if Options.options.ctdb_sockpath:
312 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
313 else:
314 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
315 'ctdbd.socket')
316 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
318 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
319 -DLOGDIR=\"%s\"
320 -DCTDB_DATADIR=\"%s\"
321 -DCTDB_ETCDIR=\"%s\"
322 -DCTDB_VARDIR=\"%s\"
323 -DCTDB_RUNDIR=\"%s\"''' % (
324 conf.env.CTDB_HELPER_BINDIR,
325 conf.env.CTDB_LOGDIR,
326 conf.env.CTDB_DATADIR,
327 conf.env.CTDB_ETCDIR,
328 conf.env.CTDB_VARDIR,
329 conf.env.CTDB_RUNDIR))
331 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
332 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
334 # Allow unified compilation and separate compilation of utilities
335 # to find includes
336 if not conf.env.standalone_ctdb:
337 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
338 else:
339 if Context.g_module.top == '.':
340 # Building from tarball
341 conf.ADD_EXTRA_INCLUDES('#include')
342 else:
343 # Building standalone CTDB from within Samba tree
344 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
345 conf.ADD_EXTRA_INCLUDES('#ctdb')
346 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
348 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
349 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
350 conf.SAMBA_CONFIG_H()
352 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
353 conf.env.ctdb_generate_manpages = True
354 else:
355 conf.env.ctdb_generate_manpages = False
357 Logs.info("xsltproc unavailable, checking for pre-built manpages")
358 conf.env.ctdb_prebuilt_manpages = []
359 manpages = manpages_binary + manpages_misc
360 if conf.env.etcd_reclock:
361 manpages += manpages_etcd
362 if conf.env.HAVE_LIBRADOS:
363 manpages += manpages_ceph
364 for m in manpages:
365 if os.path.exists(os.path.join("doc", m)):
366 Logs.info(" %s: yes" % (m))
367 conf.env.ctdb_prebuilt_manpages.append(m)
368 else:
369 Logs.info(" %s: no" % (m))
371 def build(bld):
372 if bld.env.standalone_ctdb:
373 # enable building of public headers in the build tree
374 bld.env.build_public_headers = 'include/public'
376 if bld.env.standalone_ctdb:
377 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
379 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
381 bld.RECURSE('lib/replace')
382 if bld.CHECK_FOR_THIRD_PARTY():
383 bld.RECURSE('third_party/popt')
384 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
385 bld.RECURSE('third_party/socket_wrapper')
387 bld.RECURSE('lib/tdb_wrap')
388 bld.RECURSE('lib/util')
389 bld.RECURSE('lib/async_req')
390 bld.RECURSE('lib/pthreadpool')
391 bld.RECURSE('lib/messaging')
393 bld.RECURSE('lib/talloc')
394 bld.RECURSE('lib/tevent')
395 bld.RECURSE('lib/tdb')
397 if bld.env.standalone_ctdb:
398 # If a combined build is implemented, CTDB will want to
399 # build against samba-util rather than samba-util-core.
400 # Similarly, other Samba subsystems expect samba-util. So,
401 # for a standalone build, just define a fake samba-util
402 # subsystem that pulls in samba-util-core.
403 bld.SAMBA_SUBSYSTEM('samba-util',
404 source='',
405 deps='samba-util-core')
407 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
408 source=bld.SUBDIR('tcp',
409 'tcp_connect.c tcp_init.c tcp_io.c'),
410 includes='include',
411 deps='replace tdb talloc tevent')
413 ib_deps = ''
414 if bld.env.HAVE_INFINIBAND:
415 bld.SAMBA_SUBSYSTEM('ctdb-ib',
416 source=bld.SUBDIR('ib',
417 '''ibwrapper.c ibw_ctdb.c
418 ibw_ctdb_init.c'''),
419 includes='include',
420 deps='replace talloc tevent tdb')
421 ib_deps = ' ctdb-ib rdmacm ibverbs'
423 bld.SAMBA_SUBSYSTEM('ctdb-system',
424 source=bld.SUBDIR('common',
425 'system_socket.c system.c'),
426 deps='replace talloc tevent tdb pcap samba-util')
428 bld.SAMBA_SUBSYSTEM('ctdb-common',
429 source=bld.SUBDIR('common',
430 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
431 sock_io.c'''),
432 includes='include',
433 deps='''replace popt talloc tevent tdb popt ctdb-system
434 ctdb-protocol-util''')
436 bld.SAMBA_SUBSYSTEM('ctdb-util',
437 source=bld.SUBDIR('common',
438 '''cmdline.c
439 comm.c
440 conf.c
441 db_hash.c
442 event_script.c
443 hash_count.c
444 line.c
445 logging.c
446 path.c
447 pidfile.c
448 pkt_read.c
449 pkt_write.c
450 rb_tree.c
451 reqid.c
452 run_event.c
453 run_proc.c
454 sock_client.c
455 srvid.c
456 tmon.c
457 tunable.c
458 '''),
459 deps='''samba-util
460 LIBASYNC_REQ
461 sys_rw
462 tevent-util
463 replace
464 talloc
465 tevent
467 popt
468 ''')
470 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
471 source='common/logging_conf.c',
472 deps='ctdb-util talloc')
474 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
475 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
476 deps='talloc tdb')
478 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
479 source=bld.SUBDIR('protocol',
480 '''protocol_header.c protocol_packet.c
481 protocol_types.c
482 protocol_call.c
483 protocol_message.c
484 protocol_control.c
485 protocol_keepalive.c
486 protocol_tunnel.c
487 protocol_client.c
488 protocol_debug.c
489 protocol_sock.c'''),
490 deps='ctdb-protocol-basic replace talloc tdb')
492 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
493 source='protocol/protocol_util.c',
494 deps='ctdb-util replace talloc tdb')
496 bld.SAMBA_SUBSYSTEM('ctdb-client',
497 source=bld.SUBDIR('client',
498 '''client_connect.c client_call.c
499 client_message.c client_control.c
500 client_message_sync.c
501 client_control_sync.c
502 client_db.c client_util.c
503 client_tunnel.c
504 '''),
505 deps='''ctdb-protocol
506 ctdb-util
507 samba-util
508 replace
509 talloc
510 tevent
512 tdb-wrap
513 ''')
515 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
516 source=bld.SUBDIR('common',
517 '''sock_daemon.c'''),
518 deps='''samba-util ctdb-util ctdb-system tevent-util
519 LIBASYNC_REQ replace talloc tevent''')
521 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
522 source=bld.SUBDIR('server',
523 '''ipalloc_deterministic.c
524 ipalloc_nondeterministic.c
525 ipalloc_lcp2.c
526 ipalloc_common.c
527 ipalloc.c
528 '''),
529 includes='include',
530 deps='ctdb-protocol-util replace talloc tevent')
532 bld.SAMBA_BINARY('ctdb-path',
533 source='common/path_tool.c',
534 cflags='-DCTDB_PATH_TOOL',
535 deps='''ctdb-util samba-util talloc replace popt''',
536 install_path='${CTDB_HELPER_BINDIR}')
538 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
539 source='cluster/cluster_conf.c',
540 deps='ctdb-util')
542 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
543 source='database/database_conf.c',
544 deps='ctdb-util')
546 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
547 source='event/event_conf.c',
548 deps='ctdb-util')
550 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
551 source='failover/failover_conf.c',
552 deps='ctdb-util')
554 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
555 source='server/legacy_conf.c',
556 deps='ctdb-util')
558 bld.SAMBA_BINARY('ctdb-config',
559 source='common/conf_tool.c',
560 cflags='-DCTDB_CONF_TOOL',
561 deps='''ctdb-logging-conf
562 ctdb-event-conf
563 ctdb-cluster-conf
564 ctdb-database-conf
565 ctdb-failover-conf
566 ctdb-legacy-conf
567 ctdb-util samba-util talloc replace popt''',
568 install_path='${CTDB_HELPER_BINDIR}')
570 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
571 source=bld.SUBDIR('event',
572 '''event_protocol.c
573 event_protocol_util.c
574 '''),
575 deps='ctdb-protocol-basic')
577 bld.SAMBA_LIBRARY('ctdb-event-client',
578 source='event/event_client.c',
579 deps='ctdb-event-protocol ctdb-util tevent talloc',
580 private_library=True)
582 bld.SAMBA_BINARY('ctdb-eventd',
583 source=bld.SUBDIR('event',
584 '''event_cmd.c
585 event_config.c
586 event_context.c
587 event_daemon.c
588 event_request.c
589 '''),
590 deps='''ctdb-event-protocol
591 ctdb-event-conf ctdb-logging-conf
592 ctdb-server-util samba-util ctdb-util
593 talloc tevent replace popt''',
594 install_path='${CTDB_HELPER_BINDIR}')
596 bld.SAMBA_BINARY('ctdb-event',
597 source='event/event_tool.c',
598 cflags='-DCTDB_EVENT_TOOL',
599 deps='''ctdb-event-client ctdb-event-protocol
600 ctdb-util samba-util talloc replace''',
601 install_path='${CTDB_HELPER_BINDIR}')
603 bld.SAMBA_BINARY('ctdbd',
604 source='server/ctdbd.c ' +
605 bld.SUBDIR('server',
606 '''ctdb_daemon.c ctdb_recoverd.c
607 ctdb_recover.c ctdb_freeze.c
608 ctdb_tunables.c ctdb_monitor.c
609 ctdb_server.c ctdb_control.c
610 ctdb_call.c ctdb_ltdb_server.c
611 ctdb_traverse.c eventscript.c
612 ctdb_takeover.c
613 ctdb_persistent.c ctdb_keepalive.c
614 ctdb_cluster_mutex.c
615 ctdb_logging.c
616 ctdb_uptime.c
617 ctdb_vacuum.c ctdb_banning.c
618 ctdb_statistics.c
619 ctdb_update_record.c
620 ctdb_lock.c ctdb_fork.c
621 ctdb_tunnel.c ctdb_client.c
622 ctdb_config.c
623 '''),
624 includes='include',
625 deps='''ctdb-common ctdb-system ctdb-protocol
626 ctdb-tcp ctdb-util replace sys_rw popt
627 ctdb-logging-conf
628 ctdb-cluster-conf
629 ctdb-database-conf
630 ctdb-event-conf
631 ctdb-failover-conf
632 ctdb-legacy-conf
633 ctdb-event-protocol
634 talloc tevent tdb-wrap tdb talloc_report''' +
635 ib_deps,
636 install_path='${SBINDIR}',
637 manpages='ctdbd.1')
639 bld.SAMBA_BINARY('ctdb',
640 source='tools/ctdb.c',
641 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
642 ctdb-util ctdb-system samba-util sys_rw popt''',
643 install_path='${BINDIR}',
644 manpages='ctdb.1')
646 bld.SAMBA_BINARY('ctdb_killtcp',
647 source='tools/ctdb_killtcp.c',
648 deps='''ctdb-protocol-util ctdb-util ctdb-system
649 samba-util replace''',
650 install_path='${CTDB_HELPER_BINDIR}')
652 bld.SAMBA_BINARY('ltdbtool',
653 source='tools/ltdbtool.c',
654 includes='include',
655 deps='tdb',
656 install_path='${BINDIR}',
657 manpages='ltdbtool.1')
659 bld.SAMBA_BINARY('ctdb_lock_helper',
660 source='server/ctdb_lock_helper.c',
661 deps='''samba-util sys_rw ctdb-system tevent-util
662 talloc tevent tdb''',
663 includes='include',
664 install_path='${CTDB_HELPER_BINDIR}')
666 bld.SAMBA_BINARY('ctdb_recovery_helper',
667 source='server/ctdb_recovery_helper.c',
668 deps='''ctdb-client ctdb-protocol ctdb-util
669 samba-util sys_rw replace tdb''',
670 install_path='${CTDB_HELPER_BINDIR}')
672 bld.SAMBA_BINARY('ctdb_takeover_helper',
673 source='server/ctdb_takeover_helper.c',
674 deps='''ctdb-client ctdb-protocol ctdb-util
675 samba-util sys_rw replace ctdb-ipalloc popt''',
676 install_path='${CTDB_HELPER_BINDIR}')
678 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
679 source='server/ctdb_mutex_fcntl_helper.c',
680 deps='''sys_rw ctdb-system tevent-util ctdb-util
681 talloc tevent
682 ''',
683 includes='include',
684 install_path='${CTDB_HELPER_BINDIR}')
686 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
687 source='utils/smnotify/smnotify.x',
688 target='utils/smnotify/smnotify.h',
689 rule='rpcgen -h ${SRC} > ${TGT}')
691 xdr_buf_hack = 'grep -Fv "register int32_t *buf;"'
693 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
694 source='utils/smnotify/smnotify.x',
695 target='utils/smnotify/gen_xdr.c',
696 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
698 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
699 source='utils/smnotify/smnotify.x',
700 target='utils/smnotify/gen_smnotify.c',
701 rule='rpcgen -l ${SRC} > ${TGT}')
703 bld.SAMBA_BINARY('smnotify',
704 source=bld.SUBDIR('utils/smnotify',
705 'smnotify.c gen_smnotify.c gen_xdr.c'),
706 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
707 includes='utils utils/smnotify',
708 install_path='${CTDB_HELPER_BINDIR}')
710 bld.SAMBA_BINARY('ping_pong',
711 source='utils/ping_pong/ping_pong.c',
712 deps='',
713 install_path='${BINDIR}',
714 manpages='ping_pong.1')
716 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
717 bld.SAMBA_BINARY('tdb_mutex_check',
718 source='utils/tdb/tdb_mutex_check.c',
719 deps='tdb pthread',
720 install_path='${CTDB_HELPER_BINDIR}')
722 if bld.env.HAVE_PMDA:
723 bld.SAMBA_BINARY('pmdactdb',
724 source='utils/pmda/pmda_ctdb.c',
725 deps='''ctdb-client ctdb-protocol ctdb-util
726 samba-util pcp_pmda pcp''',
727 install_path='${CTDB_PMDADIR}')
728 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
729 destname='Install')
730 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
731 destname='Remove')
732 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
733 destname='pmns')
734 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
735 destname='domain.h')
736 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
737 destname='help')
738 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
739 destname='README')
741 if bld.env.HAVE_LIBRADOS:
742 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
743 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
744 deps='talloc tevent rados',
745 includes='include',
746 install_path='${CTDB_HELPER_BINDIR}')
748 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
749 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
750 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
751 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
752 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
753 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
754 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
755 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
756 sed_cmdline = '-e "%s" ' * 8 % \
757 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
758 sed_expr6, sed_expr7, sed_expr8)
760 manpages_extra = list(manpages_misc)
761 if bld.env.etcd_reclock:
762 manpages_extra += manpages_etcd
763 if bld.env.HAVE_LIBRADOS:
764 manpages_extra += manpages_ceph
765 for f in manpages_binary + manpages_extra:
766 x = '%s.xml' % (f)
767 bld.SAMBA_GENERATOR(x,
768 source=os.path.join('doc', x),
769 target=x,
770 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
772 if bld.env.ctdb_generate_manpages:
773 bld.MANPAGES(' '.join(manpages_extra), True)
774 else:
775 for m in bld.env.ctdb_prebuilt_manpages:
776 bld.SAMBA_GENERATOR(m,
777 source=os.path.join("doc", m),
778 target=m,
779 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
780 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
782 bld.SAMBA_GENERATOR('ctdb-onnode',
783 source='tools/onnode',
784 target='onnode',
785 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
786 bld.INSTALL_FILES('${BINDIR}', 'onnode',
787 destname='onnode', chmod=MODE_755)
789 bld.SAMBA_GENERATOR('ctdb-diagnostics',
790 source='tools/ctdb_diagnostics',
791 target='ctdb_diagnostics',
792 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
793 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
794 destname='ctdb_diagnostics', chmod=MODE_755)
796 if bld.env.etcd_reclock:
797 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
798 source='utils/etcd/ctdb_etcd_lock',
799 target='ctdb_etcd_lock',
800 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
801 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
802 destname='ctdb_etcd_lock', chmod=MODE_744)
804 bld.SAMBA_GENERATOR('ctdb-natgw',
805 source='tools/ctdb_natgw',
806 target='ctdb_natgw',
807 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
808 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
809 destname='ctdb_natgw', chmod=MODE_755)
811 bld.SAMBA_GENERATOR('ctdb-lvs',
812 source='tools/ctdb_lvs',
813 target='ctdb_lvs',
814 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
815 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
816 destname='ctdb_lvs', chmod=MODE_755)
818 def SUBDIR_MODE_callback(arg, dirname, fnames):
819 for f in fnames:
820 fl = os.path.join(dirname, f)
821 if os.path.isdir(fl) or os.path.islink(fl):
822 continue
823 mode = os.lstat(fl).st_mode & MODE_777
824 if arg['trim_path']:
825 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
826 arg['file_list'].append([fl, mode])
828 def SUBDIR_MODE(path, trim_path=None):
829 pd = {'trim_path': trim_path, 'file_list': []}
830 for dirname, _subdirs, fnames in os.walk(path):
831 SUBDIR_MODE_callback(pd, dirname, fnames)
832 return pd['file_list']
834 event_script_subdirs = [
835 'events/legacy',
838 etc_subdirs = [
839 'nfs-checks.d'
842 if bld.env.standalone_ctdb:
843 configdir = 'config'
844 else:
845 configdir = 'ctdb/config'
847 for t in event_script_subdirs:
848 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
849 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
850 for fmode in files:
851 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
852 destname=fmode[0], chmod=fmode[1])
854 for t in etc_subdirs:
855 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
856 for fmode in files:
857 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
858 destname=fmode[0], chmod=fmode[1])
860 # If this is a direct install and there are no event scripts
861 # linked/enabled then enable some standard ones
862 if os.environ.get('DESTDIR') is None:
863 fmt = 'events/legacy/%s.script'
864 required_script = '00.ctdb'
865 required_path = os.path.join(bld.env.CTDB_ETCDIR,
866 fmt % (required_script))
867 if not os.path.islink(required_path) and \
868 not os.path.exists(required_path):
869 default_scripts = [ required_script,
870 '01.reclock',
871 '05.system',
872 '10.interface',
874 for t in default_scripts:
875 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
876 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
877 bld.symlink_as(name, tgt)
879 bld.SAMBA_GENERATOR('ctdb-functions',
880 source='config/functions',
881 target='functions',
882 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
883 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
885 etc_scripts = [
886 'ctdb-crash-cleanup.sh',
887 'debug-hung-script.sh',
888 'debug_locks.sh',
889 'nfs-linux-kernel-callout',
890 'notify.sh',
891 'statd-callout'
894 for t in etc_scripts:
895 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
896 destname=t, chmod=MODE_755)
898 bld.SAMBA_GENERATOR('ctdb-sudoers',
899 source='config/ctdb.sudoers',
900 target='ctdb.sudoers',
901 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
902 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
903 destname='ctdb')
905 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
906 'config/notification.README',
907 destname='README')
909 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
910 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
911 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
913 for d in ['volatile', 'persistent', 'state']:
914 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
917 # Test-only below this point
920 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
921 return
923 bld.SAMBA_BINARY('errcode',
924 source='tests/src/errcode.c',
925 deps='replace',
926 install_path='${CTDB_TEST_LIBEXECDIR}')
928 bld.SAMBA_BINARY('sigcode',
929 source='tests/src/sigcode.c',
930 deps='replace',
931 install_path='${CTDB_TEST_LIBEXECDIR}')
933 # Unit tests
934 ctdb_util_tests = [
935 'cmdline_test',
936 'comm_client_test',
937 'comm_server_test',
938 'comm_test',
939 'conf_test',
940 'db_hash_test',
941 'event_script_test',
942 'hash_count_test',
943 'line_test',
944 'pidfile_test',
945 'pkt_read_test',
946 'pkt_write_test',
947 'run_event_test',
948 'run_proc_test',
949 'sock_io_test',
950 'srvid_test',
951 'tunable_test',
954 for target in ctdb_util_tests:
955 src = 'tests/src/' + target + '.c'
957 bld.SAMBA_BINARY(target,
958 source=src,
959 deps='''ctdb-tests-backtrace
960 LIBASYNC_REQ
961 samba-util
962 sys_rw
963 tevent-util
964 talloc
965 tevent
967 popt
968 ''',
969 install_path='${CTDB_TEST_LIBEXECDIR}')
971 bld.SAMBA_BINARY('reqid_test',
972 source='tests/src/reqid_test.c',
973 deps='samba-util talloc',
974 install_path='${CTDB_TEST_LIBEXECDIR}')
976 bld.SAMBA_BINARY('rb_test',
977 source='tests/src/rb_test.c',
978 deps='samba-util talloc',
979 install_path='${CTDB_TEST_LIBEXECDIR}')
981 bld.SAMBA_BINARY('ctdb_packet_parse',
982 source='tests/src/ctdb_packet_parse.c',
983 deps='talloc tevent tdb ctdb-protocol',
984 install_path='${CTDB_TEST_LIBEXECDIR}')
986 bld.SAMBA_BINARY('system_socket_test',
987 source='tests/src/system_socket_test.c',
988 deps='''ctdb-tests-backtrace
989 talloc
990 ctdb-protocol-util
991 pcap
992 ''',
993 install_path='${CTDB_TEST_LIBEXECDIR}')
995 bld.SAMBA_BINARY('porting_tests',
996 source='tests/src/porting_tests.c',
997 deps='samba-util ctdb-system popt',
998 install_path='${CTDB_TEST_LIBEXECDIR}')
1000 bld.SAMBA_BINARY('sock_daemon_test',
1001 source='tests/src/sock_daemon_test.c',
1002 deps='''ctdb-system talloc tevent tevent-util
1003 LIBASYNC_REQ samba-util sys_rw''',
1004 install_path='${CTDB_TEST_LIBEXECDIR}')
1006 bld.SAMBA_BINARY('ctdb_io_test',
1007 source='tests/src/ctdb_io_test.c',
1008 deps='''talloc tevent tdb samba-util sys_rw''',
1009 install_path='${CTDB_TEST_LIBEXECDIR}')
1011 bld.SAMBA_BINARY('ctdb-db-test',
1012 source='tests/src/db_test_tool.c',
1013 cflags='-DCTDB_DB_TEST_TOOL',
1014 deps='''ctdb-client ctdb-protocol
1015 ctdb-util samba-util talloc tevent replace''',
1016 install_path='${CTDB_TEST_LIBEXECDIR}')
1018 for target in ['tmon_ping_test', 'tmon_test']:
1019 src = 'tests/src/' + target + '.c'
1021 bld.SAMBA_BINARY(target,
1022 source=src,
1023 deps='''ctdb-util
1024 ctdb-tests-backtrace
1025 LIBASYNC_REQ
1026 samba-util
1027 sys_rw
1028 tevent-util
1029 talloc
1030 tevent
1032 popt
1033 ''',
1034 install_path='${CTDB_TEST_LIBEXECDIR}')
1036 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1037 source=bld.SUBDIR('tests/src',
1038 'protocol_common_basic.c'),
1039 deps='samba-util replace talloc')
1041 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1042 source=bld.SUBDIR('tests/src',
1043 '''protocol_common.c
1044 protocol_common_ctdb.c
1045 '''),
1046 deps='ctdb-protocol-tests-basic replace talloc tdb')
1048 bld.SAMBA_BINARY('protocol_basic_test',
1049 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
1050 deps='ctdb-protocol-tests-basic talloc',
1051 install_path='${CTDB_TEST_LIBEXECDIR}')
1053 ctdb_protocol_tests = [
1054 'protocol_types_test',
1055 'protocol_ctdb_test',
1056 'protocol_util_test',
1057 'protocol_types_compat_test',
1058 'protocol_ctdb_compat_test',
1061 for target in ctdb_protocol_tests:
1062 src = 'tests/src/' + target + '.c'
1064 bld.SAMBA_BINARY(target,
1065 source=src,
1066 deps='''ctdb-protocol-tests-common
1067 samba-util ctdb-util talloc tdb''',
1068 install_path='${CTDB_TEST_LIBEXECDIR}')
1070 bld.SAMBA_BINARY('event_protocol_test',
1071 source='event/event_protocol_test.c',
1072 deps='''ctdb-protocol-tests-basic
1073 ctdb-protocol-basic talloc''',
1074 install_path='${CTDB_TEST_LIBEXECDIR}')
1076 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1077 source=bld.SUBDIR('tests/src',
1078 '''cluster_wait.c
1079 test_options.c
1080 '''),
1081 deps='''ctdb-client
1082 samba-util
1083 replace
1084 popt
1085 talloc
1086 tevent
1087 tdb''')
1089 bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1090 source=bld.SUBDIR('tests/src',
1091 'test_backtrace.c'),
1092 deps='''samba-util
1093 replace''')
1095 # Test binaries
1096 ctdb_tests = [
1097 'g_lock_loop',
1098 'message_ring',
1099 'fetch_ring',
1100 'fetch_loop',
1101 'fetch_loop_key',
1102 'fetch_readonly',
1103 'fetch_readonly_loop',
1104 'transaction_loop',
1105 'update_record',
1106 'update_record_persistent',
1107 'lock_tdb',
1108 'dummy_client',
1109 'tunnel_test',
1110 'tunnel_cmd',
1113 for target in ctdb_tests:
1114 src = 'tests/src/' + target + '.c'
1116 bld.SAMBA_BINARY(target,
1117 source=src,
1118 includes='include',
1119 deps='''ctdb-client ctdb-protocol ctdb-util
1120 samba-util ctdb-tests-common''',
1121 install_path='${CTDB_TEST_LIBEXECDIR}')
1123 bld.SAMBA_BINARY('ctdb_takeover_tests',
1124 source='''tests/src/ctdb_takeover_tests.c
1125 tests/src/ipalloc_read_known_ips.c''',
1126 deps='''replace popt tdb tevent talloc ctdb-system
1127 samba-util tdb-wrap talloc_report
1128 ctdb-ipalloc ctdb-protocol ctdb-util''',
1129 includes='include',
1130 install_path='${CTDB_TEST_LIBEXECDIR}')
1132 bld.SAMBA_BINARY('fake_ctdbd',
1133 source='''tests/src/fake_ctdbd.c
1134 tests/src/ipalloc_read_known_ips.c''',
1135 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1136 ctdb-system samba-util tevent-util
1137 LIBASYNC_REQ popt''',
1138 install_path='${CTDB_TEST_LIBEXECDIR}')
1140 bld.SAMBA_BINARY('cluster_mutex_test',
1141 source='tests/src/cluster_mutex_test.c',
1142 deps='''ctdb-tests-backtrace
1143 samba-util
1144 talloc
1145 tevent
1146 ''',
1147 install_path='${CTDB_TEST_LIBEXECDIR}')
1149 if bld.env.HAVE_INFINIBAND:
1150 bld.SAMBA_BINARY('ibwrapper_test',
1151 source='ib/ibwrapper_test.c',
1152 includes='include',
1153 deps='replace talloc ctdb-common sys_rw' +
1154 ib_deps,
1155 install_path='${CTDB_TEST_LIBEXECDIR}')
1157 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1158 bld.SAMBA_BINARY('test_mutex_raw',
1159 source='tests/src/test_mutex_raw.c',
1160 deps='pthread',
1161 install_path='${CTDB_TEST_LIBEXECDIR}')
1163 test_subdirs = [
1164 'CLUSTER',
1165 'INTEGRATION',
1166 'UNIT',
1167 'etc-ctdb'
1170 if bld.env.standalone_ctdb:
1171 testdir = 'tests'
1172 else:
1173 testdir = 'ctdb/tests'
1175 for t in test_subdirs:
1176 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1177 for fmode in files:
1178 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1179 destname=fmode[0], chmod=fmode[1])
1181 # Install tests/scripts directory, excluding files that need munging
1182 test_scripts = [
1183 'cluster.bash',
1184 'common.sh',
1185 'integration.bash',
1186 'integration_local_daemons.bash',
1187 'integration_real_cluster.bash',
1188 'unit.sh'
1191 for t in test_scripts:
1192 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1193 os.path.join('tests/scripts', t),
1194 destname=os.path.join('scripts', t))
1196 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1197 'tests/scripts/test_wrap',
1198 destname='scripts/test_wrap',
1199 chmod=MODE_755)
1201 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1202 source='tests/scripts/script_install_paths.sh',
1203 target='script_install_paths.sh',
1204 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1205 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1206 'script_install_paths.sh',
1207 destname='script_install_paths.sh', chmod=MODE_644)
1209 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1210 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1211 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1212 bld.SAMBA_GENERATOR('ctdb-test-runner',
1213 source='tests/run_tests.sh',
1214 target='ctdb_run_tests.sh',
1215 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1216 sed_expr1, sed_expr2))
1217 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1218 destname='ctdb_run_tests', chmod=MODE_755)
1219 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1220 'ctdb_run_tests')
1222 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1223 source='tests/local_daemons.sh',
1224 target='ctdb_local_daemons.sh',
1225 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1226 sed_expr1, sed_expr2))
1227 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1228 destname='ctdb_local_daemons', chmod=MODE_755)
1231 def testonly(ctx):
1232 cmd = 'tests/run_tests.sh'
1233 ret = samba_utils.RUN_COMMAND(cmd)
1234 if ret != 0:
1235 print('tests exited with exit status %d' % ret)
1236 sys.exit(ret)
1239 def test(ctx):
1240 Options.commands.append('build')
1241 Options.commands.append('testonly')
1244 def autotest(ctx):
1245 env = samba_utils.LOAD_ENVIRONMENT()
1246 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1247 ret = samba_utils.RUN_COMMAND(cmd)
1248 if ret != 0:
1249 print('autotest exited with exit status %d' % ret)
1250 sys.exit(ret)
1253 def show_version(ctx):
1254 print(get_version_string())
1257 def manpages(ctx):
1258 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1259 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1260 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1261 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1262 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1263 for t in manpages:
1264 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1265 ret = samba_utils.RUN_COMMAND(cmd)
1266 if ret != 0:
1267 print('Command %s failed with exit status %d' % (cmd, ret))
1268 sys.exit(ret)
1270 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1271 ret = samba_utils.RUN_COMMAND(cmd)
1272 if ret != 0:
1273 print('Command %s failed with exit status %d' % (cmd, ret))
1274 sys.exit(ret)
1277 def distonly(ctx):
1278 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1280 t = 'ctdb.spec'
1281 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1282 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1283 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1284 sed_expr1, sed_expr2, t)
1285 ret = samba_utils.RUN_COMMAND(cmd)
1286 if ret != 0:
1287 print('Command "%s" failed with exit status %d' % (cmd, ret))
1288 sys.exit(ret)
1289 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1291 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1292 for t in manpages:
1293 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1294 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1295 extend=True)
1297 samba_dist.dist()
1300 def dist():
1301 Options.commands.append('manpages')
1302 Options.commands.append('distonly')
1305 def rpmonly(ctx):
1306 opts = os.getenv('RPM_OPTIONS') or ''
1307 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1308 (opts, get_version_string())
1309 ret = samba_utils.RUN_COMMAND(cmd)
1310 if ret != 0:
1311 print('rpmbuild exited with exit status %d' % ret)
1312 sys.exit(ret)
1315 def rpm(ctx):
1316 Options.commands.append('manpages')
1317 Options.commands.append('distonly')
1318 Options.commands.append('rpmonly')
1321 def ctags(ctx):
1322 "build 'tags' file using ctags"
1323 source_root = os.path.dirname(Context.g_module.root_path)
1324 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1325 print("Running: %s" % cmd)
1326 ret = samba_utils.RUN_COMMAND(cmd)
1327 if ret != 0:
1328 print('ctags failed with exit status %d' % ret)
1329 sys.exit(ret)