smbd: use metadata_fsp(fsp) in copy_access_posix_acl() for SMB_VFS_SYS_ACL_SET_FD
[samba.git] / ctdb / wscript
blobe89f6548af3514817e55963a536fc3c9c19b09f7
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='replace tdb talloc tevent ctdb-protocol-util')
405 ib_deps = ''
406 if bld.env.HAVE_INFINIBAND:
407 bld.SAMBA_SUBSYSTEM('ctdb-ib',
408 source=bld.SUBDIR('ib',
409 '''ibwrapper.c ibw_ctdb.c
410 ibw_ctdb_init.c'''),
411 includes='include',
412 deps='replace talloc tevent tdb')
413 ib_deps = ' ctdb-ib rdmacm ibverbs'
415 bld.SAMBA_SUBSYSTEM('ctdb-system',
416 source=bld.SUBDIR('common',
417 'system_socket.c system.c'),
418 deps='replace talloc tevent tdb pcap samba-util')
420 bld.SAMBA_SUBSYSTEM('ctdb-common',
421 source=bld.SUBDIR('common',
422 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
423 sock_io.c'''),
424 includes='include',
425 deps='''replace popt talloc tevent tdb popt ctdb-system
426 ctdb-protocol-util''')
428 bld.SAMBA_SUBSYSTEM('ctdb-util',
429 source=bld.SUBDIR('common',
430 '''cmdline.c
431 comm.c
432 db_hash.c
433 event_script.c
434 hash_count.c
435 logging.c
436 path.c
437 pidfile.c
438 pkt_read.c
439 pkt_write.c
440 rb_tree.c
441 reqid.c
442 run_event.c
443 run_proc.c
444 sock_client.c
445 srvid.c
446 tmon.c
447 tunable.c
448 '''),
449 deps='''samba-util
450 LIBASYNC_REQ
451 sys_rw
452 tevent-util
453 replace
454 talloc
455 tevent
457 popt
458 ''')
460 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
461 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
462 deps='talloc tdb')
464 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
465 source=bld.SUBDIR('protocol',
466 '''protocol_header.c protocol_packet.c
467 protocol_types.c
468 protocol_call.c
469 protocol_message.c
470 protocol_control.c
471 protocol_keepalive.c
472 protocol_tunnel.c
473 protocol_client.c
474 protocol_debug.c
475 protocol_sock.c'''),
476 deps='ctdb-protocol-basic replace talloc tdb')
478 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
479 source='protocol/protocol_util.c',
480 deps='replace talloc tdb')
482 bld.SAMBA_SUBSYSTEM('ctdb-client',
483 source=bld.SUBDIR('client',
484 '''client_connect.c client_call.c
485 client_message.c client_control.c
486 client_message_sync.c
487 client_control_sync.c
488 client_db.c client_util.c
489 client_tunnel.c
490 '''),
491 deps='''ctdb-protocol
492 ctdb-util
493 samba-util
494 replace
495 talloc
496 tevent
498 tdb-wrap
499 ''')
501 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
502 source=bld.SUBDIR('common',
503 '''sock_daemon.c'''),
504 deps='''samba-util ctdb-util ctdb-system tevent-util
505 LIBASYNC_REQ replace talloc tevent''')
507 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
508 source=bld.SUBDIR('server',
509 '''ipalloc_deterministic.c
510 ipalloc_nondeterministic.c
511 ipalloc_lcp2.c
512 ipalloc_common.c
513 ipalloc.c
514 '''),
515 includes='include',
516 deps='ctdb-protocol-util replace talloc tevent')
518 bld.SAMBA_BINARY('ctdb-path',
519 source='common/path_tool.c',
520 cflags='-DCTDB_PATH_TOOL',
521 deps='''ctdb-util samba-util talloc replace popt''',
522 install_path='${CTDB_HELPER_BINDIR}')
524 bld.SAMBA_SUBSYSTEM('ctdb-conf',
525 source='''conf/conf.c
526 conf/logging_conf.c
527 conf/cluster_conf.c
528 conf/database_conf.c
529 conf/event_conf.c
530 conf/failover_conf.c
531 conf/legacy_conf.c
532 conf/ctdb_config.c
533 ''',
534 deps='''ctdb-util talloc replace''')
536 bld.SAMBA_SUBSYSTEM('ctdb-conf-util',
537 source='''conf/node.c
538 ''',
539 deps='''ctdb-protocol
540 ctdb-protocol-util
541 replace
542 samba-util
543 talloc
544 ''')
546 bld.SAMBA_BINARY('ctdb-config',
547 source='conf/conf_tool.c',
548 cflags='-DCTDB_CONF_TOOL',
549 deps='''ctdb-conf
550 ctdb-util samba-util talloc replace popt''',
551 install_path='${CTDB_HELPER_BINDIR}')
553 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
554 source=bld.SUBDIR('event',
555 '''event_protocol.c
556 event_protocol_util.c
557 '''),
558 deps='ctdb-protocol-basic')
560 bld.SAMBA_LIBRARY('ctdb-event-client',
561 source='event/event_client.c',
562 deps='ctdb-event-protocol ctdb-util tevent talloc',
563 private_library=True)
565 bld.SAMBA_BINARY('ctdb-eventd',
566 source=bld.SUBDIR('event',
567 '''event_cmd.c
568 event_config.c
569 event_context.c
570 event_daemon.c
571 event_request.c
572 '''),
573 deps='''ctdb-event-protocol
574 ctdb-conf
575 ctdb-server-util samba-util ctdb-util
576 talloc tevent replace popt''',
577 install_path='${CTDB_HELPER_BINDIR}')
579 bld.SAMBA_BINARY('ctdb-event',
580 source='event/event_tool.c',
581 cflags='-DCTDB_EVENT_TOOL',
582 deps='''ctdb-event-client ctdb-event-protocol
583 ctdb-util samba-util talloc replace''',
584 install_path='${CTDB_HELPER_BINDIR}')
586 bld.SAMBA_BINARY('ctdbd',
587 source='server/ctdbd.c ' +
588 bld.SUBDIR('server',
589 '''ctdb_daemon.c ctdb_recoverd.c
590 ctdb_recover.c ctdb_freeze.c
591 ctdb_tunables.c ctdb_monitor.c
592 ctdb_server.c ctdb_control.c
593 ctdb_call.c ctdb_ltdb_server.c
594 ctdb_traverse.c eventscript.c
595 ctdb_takeover.c
596 ctdb_persistent.c ctdb_keepalive.c
597 ctdb_cluster_mutex.c
598 ctdb_logging.c
599 ctdb_uptime.c
600 ctdb_vacuum.c ctdb_banning.c
601 ctdb_statistics.c
602 ctdb_update_record.c
603 ctdb_lock.c ctdb_fork.c
604 ctdb_tunnel.c ctdb_client.c
605 '''),
606 includes='include',
607 deps='''ctdb-common
608 ctdb-conf
609 ctdb-conf-util
610 ctdb-event-protocol
611 ctdb-protocol
612 ctdb-system
613 ctdb-tcp
614 ctdb-util
615 popt
616 replace
617 sys_rw
618 talloc
619 talloc_report
621 tdb-wrap
622 tevent
623 ''' +
624 ib_deps,
625 install_path='${SBINDIR}',
626 manpages='ctdbd.1')
628 bld.SAMBA_BINARY('ctdb',
629 source='tools/ctdb.c',
630 deps='''ctdb-client
631 ctdb-conf
632 ctdb-conf-util
633 ctdb-protocol
634 ctdb-protocol-util
635 ctdb-system
636 ctdb-util
637 popt
638 samba-util
639 sys_rw
640 ''',
641 install_path='${BINDIR}',
642 manpages='ctdb.1')
644 bld.SAMBA_BINARY('ctdb_killtcp',
645 source='tools/ctdb_killtcp.c',
646 deps='''ctdb-protocol-util ctdb-util ctdb-system
647 samba-util replace''',
648 install_path='${CTDB_HELPER_BINDIR}')
650 bld.SAMBA_BINARY('ltdbtool',
651 source='tools/ltdbtool.c',
652 includes='include',
653 deps='tdb',
654 install_path='${BINDIR}',
655 manpages='ltdbtool.1')
657 bld.SAMBA_BINARY('ctdb_lock_helper',
658 source='server/ctdb_lock_helper.c',
659 deps='''samba-util sys_rw ctdb-system tevent-util
660 talloc tevent tdb''',
661 includes='include',
662 install_path='${CTDB_HELPER_BINDIR}')
664 bld.SAMBA_BINARY('ctdb_recovery_helper',
665 source='server/ctdb_recovery_helper.c',
666 deps='''ctdb-client ctdb-protocol ctdb-util
667 samba-util sys_rw replace tdb''',
668 install_path='${CTDB_HELPER_BINDIR}')
670 bld.SAMBA_BINARY("statd_callout",
671 source="failover/statd_callout.c",
672 install_path="${CTDB_HELPER_BINDIR}")
674 bld.SAMBA_BINARY('ctdb_takeover_helper',
675 source='server/ctdb_takeover_helper.c',
676 deps='''ctdb-client ctdb-protocol ctdb-util
677 samba-util sys_rw replace ctdb-ipalloc popt''',
678 install_path='${CTDB_HELPER_BINDIR}')
680 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
681 source='server/ctdb_mutex_fcntl_helper.c',
682 deps='''sys_rw ctdb-system tevent-util ctdb-util
683 talloc tevent
684 ''',
685 includes='include',
686 install_path='${CTDB_HELPER_BINDIR}')
688 bld.SAMBA_BINARY('ctdb_smnotify_helper',
689 source=('failover/smnotify_helper.c'),
690 deps='sys_rw replace',
691 install_path='${CTDB_HELPER_BINDIR}')
693 bld.SAMBA_BINARY('ping_pong',
694 source='utils/ping_pong/ping_pong.c',
695 deps='',
696 install_path='${BINDIR}',
697 manpages='ping_pong.1')
699 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
700 bld.SAMBA_BINARY('tdb_mutex_check',
701 source='utils/tdb/tdb_mutex_check.c',
702 deps='tdb pthread',
703 install_path='${CTDB_HELPER_BINDIR}')
705 if bld.env.HAVE_PMDA:
706 bld.SAMBA_BINARY('pmdactdb',
707 source='utils/pmda/pmda_ctdb.c',
708 deps='''ctdb-client ctdb-protocol ctdb-util
709 samba-util pcp_pmda pcp''',
710 install_path='${CTDB_PMDADIR}')
711 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
712 destname='Install')
713 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
714 destname='Remove')
715 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
716 destname='pmns')
717 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
718 destname='domain.h')
719 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
720 destname='help')
721 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
722 destname='README')
724 if bld.env.HAVE_LIBRADOS:
725 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
726 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
727 deps='talloc tevent rados',
728 includes='include',
729 install_path='${CTDB_HELPER_BINDIR}')
731 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
732 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
733 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
734 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
735 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
736 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
737 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
738 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
739 sed_cmdline = '-e "%s" ' * 8 % \
740 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
741 sed_expr6, sed_expr7, sed_expr8)
743 manpages_extra = list(manpages_misc)
744 if bld.env.etcd_reclock:
745 manpages_extra += manpages_etcd
746 if bld.env.HAVE_LIBRADOS:
747 manpages_extra += manpages_ceph
748 for f in manpages_binary + manpages_extra:
749 x = '%s.xml' % (f)
750 bld.SAMBA_GENERATOR(x,
751 source=os.path.join('doc', x),
752 target=x,
753 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
755 if bld.env.ctdb_generate_manpages:
756 bld.MANPAGES(' '.join(manpages_extra), True)
757 else:
758 for m in bld.env.ctdb_prebuilt_manpages:
759 bld.SAMBA_GENERATOR(m,
760 source=os.path.join("doc", m),
761 target=m,
762 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
763 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
765 bld.SAMBA_GENERATOR('ctdb-onnode',
766 source='tools/onnode',
767 target='onnode',
768 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
769 bld.INSTALL_FILES('${BINDIR}', 'onnode',
770 destname='onnode', chmod=MODE_755)
772 bld.SAMBA_GENERATOR('ctdb-diagnostics',
773 source='tools/ctdb_diagnostics',
774 target='ctdb_diagnostics',
775 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
776 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
777 destname='ctdb_diagnostics', chmod=MODE_755)
779 if bld.env.etcd_reclock:
780 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
781 source='utils/etcd/ctdb_etcd_lock',
782 target='ctdb_etcd_lock',
783 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
784 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
785 destname='ctdb_etcd_lock', chmod=MODE_744)
787 bld.SAMBA_GENERATOR('ctdb-natgw',
788 source='tools/ctdb_natgw',
789 target='ctdb_natgw',
790 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
791 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
792 destname='ctdb_natgw', chmod=MODE_755)
794 bld.SAMBA_GENERATOR('ctdb-lvs',
795 source='tools/ctdb_lvs',
796 target='ctdb_lvs',
797 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
798 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
799 destname='ctdb_lvs', chmod=MODE_755)
801 bld.SAMBA_GENERATOR("ctdb-statd-callout-helper",
802 source="tools/statd_callout_helper",
803 target="statd_callout_helper",
804 rule=f"sed {sed_cmdline} ${{SRC}} > ${{TGT}}")
805 bld.INSTALL_FILES("${CTDB_HELPER_BINDIR}", "statd_callout_helper",
806 destname="statd_callout_helper", chmod=MODE_755)
808 bld.symlink_as(os.path.join(bld.env.CTDB_ETCDIR, "statd-callout"),
809 os.path.join(bld.env.CTDB_HELPER_BINDIR, "statd_callout"))
811 def SUBDIR_MODE_callback(arg, dirname, fnames):
812 for f in fnames:
813 fl = os.path.join(dirname, f)
814 if os.path.isdir(fl) or os.path.islink(fl):
815 continue
816 mode = os.lstat(fl).st_mode & MODE_777
817 if arg['trim_path']:
818 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
819 arg['file_list'].append([fl, mode])
821 def SUBDIR_MODE(path, trim_path=None):
822 pd = {'trim_path': trim_path, 'file_list': []}
823 for dirname, _subdirs, fnames in os.walk(path):
824 SUBDIR_MODE_callback(pd, dirname, fnames)
825 return pd['file_list']
827 event_script_subdirs = [
828 'events/legacy',
831 etc_subdirs = [
832 'nfs-checks.d'
835 if bld.env.standalone_ctdb:
836 configdir = 'config'
837 else:
838 configdir = 'ctdb/config'
840 for t in event_script_subdirs:
841 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
842 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
843 for fmode in files:
844 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
845 destname=fmode[0], chmod=fmode[1])
847 for t in etc_subdirs:
848 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
849 for fmode in files:
850 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
851 destname=fmode[0], chmod=fmode[1])
853 # If this is a direct install and there are no event scripts
854 # linked/enabled then enable some standard ones
855 if os.environ.get('DESTDIR') is None:
856 fmt = 'events/legacy/%s.script'
857 required_script = '00.ctdb'
858 required_path = os.path.join(bld.env.CTDB_ETCDIR,
859 fmt % (required_script))
860 if not os.path.islink(required_path) and \
861 not os.path.exists(required_path):
862 default_scripts = [ required_script,
863 '01.reclock',
864 '05.system',
865 '10.interface',
866 '95.database',
868 for t in default_scripts:
869 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
870 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
871 bld.symlink_as(name, tgt)
873 bld.SAMBA_GENERATOR('ctdb-functions',
874 source='config/functions',
875 target='functions',
876 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
877 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
879 etc_scripts = [
880 'ctdb-backup-persistent-tdbs.sh',
881 'ctdb-crash-cleanup.sh',
882 'debug-hung-script.sh',
883 'debug_locks.sh',
884 'nfs-linux-kernel-callout',
885 'notify.sh',
888 for t in etc_scripts:
889 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
890 destname=t, chmod=MODE_755)
892 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
893 'config/notification.README',
894 destname='README')
896 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
897 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
898 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
900 for d in ['volatile', 'persistent', 'state']:
901 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
904 # Test-only below this point
907 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
908 return
910 bld.SAMBA_BINARY('errcode',
911 source='tests/src/errcode.c',
912 deps='replace',
913 install_path='${CTDB_TEST_LIBEXECDIR}')
915 bld.SAMBA_BINARY('sigcode',
916 source='tests/src/sigcode.c',
917 deps='replace',
918 install_path='${CTDB_TEST_LIBEXECDIR}')
920 # Unit tests
921 ctdb_util_tests = [
922 'cmdline_test',
923 'comm_client_test',
924 'comm_server_test',
925 'comm_test',
926 'conf_test',
927 'db_hash_test',
928 'event_script_test',
929 'hash_count_test',
930 'pidfile_test',
931 'pkt_read_test',
932 'pkt_write_test',
933 'run_event_test',
934 'run_proc_test',
935 'sock_io_test',
936 'srvid_test',
937 'tunable_test',
940 for target in ctdb_util_tests:
941 src = 'tests/src/' + target + '.c'
943 bld.SAMBA_BINARY(target,
944 source=src,
945 deps='''ctdb-tests-backtrace
946 LIBASYNC_REQ
947 samba-util
948 sys_rw
949 tevent-util
950 talloc
951 tevent
953 popt
954 ''',
955 install_path='${CTDB_TEST_LIBEXECDIR}')
957 bld.SAMBA_BINARY('reqid_test',
958 source='tests/src/reqid_test.c',
959 deps='samba-util talloc',
960 install_path='${CTDB_TEST_LIBEXECDIR}')
962 bld.SAMBA_BINARY('rb_test',
963 source='tests/src/rb_test.c',
964 deps='samba-util talloc',
965 install_path='${CTDB_TEST_LIBEXECDIR}')
967 bld.SAMBA_BINARY('ctdb_packet_parse',
968 source='tests/src/ctdb_packet_parse.c',
969 deps='talloc tevent tdb ctdb-protocol',
970 install_path='${CTDB_TEST_LIBEXECDIR}')
972 bld.SAMBA_BINARY('system_socket_test',
973 source='tests/src/system_socket_test.c',
974 deps='''ctdb-tests-backtrace
975 talloc
976 ctdb-protocol-util
977 pcap
978 ''',
979 install_path='${CTDB_TEST_LIBEXECDIR}')
981 bld.SAMBA_BINARY('porting_tests',
982 source='tests/src/porting_tests.c',
983 deps='samba-util ctdb-system popt',
984 install_path='${CTDB_TEST_LIBEXECDIR}')
986 bld.SAMBA_BINARY('sock_daemon_test',
987 source='tests/src/sock_daemon_test.c',
988 deps='''ctdb-system talloc tevent tevent-util
989 LIBASYNC_REQ samba-util sys_rw''',
990 install_path='${CTDB_TEST_LIBEXECDIR}')
992 bld.SAMBA_BINARY('ctdb_io_test',
993 source='tests/src/ctdb_io_test.c',
994 deps='''talloc tevent tdb samba-util sys_rw''',
995 install_path='${CTDB_TEST_LIBEXECDIR}')
997 bld.SAMBA_BINARY('ctdb-db-test',
998 source='tests/src/db_test_tool.c',
999 cflags='-DCTDB_DB_TEST_TOOL',
1000 deps='''ctdb-client ctdb-protocol
1001 ctdb-util samba-util talloc tevent replace''',
1002 install_path='${CTDB_TEST_LIBEXECDIR}')
1004 for target in ['tmon_ping_test', 'tmon_test']:
1005 src = 'tests/src/' + target + '.c'
1007 bld.SAMBA_BINARY(target,
1008 source=src,
1009 deps='''ctdb-util
1010 ctdb-tests-backtrace
1011 LIBASYNC_REQ
1012 samba-util
1013 sys_rw
1014 tevent-util
1015 talloc
1016 tevent
1018 popt
1019 ''',
1020 install_path='${CTDB_TEST_LIBEXECDIR}')
1022 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1023 source=bld.SUBDIR('tests/src',
1024 'protocol_common_basic.c'),
1025 deps='samba-util replace talloc')
1027 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1028 source=bld.SUBDIR('tests/src',
1029 '''protocol_common.c
1030 protocol_common_ctdb.c
1031 '''),
1032 deps='ctdb-protocol-tests-basic replace talloc tdb')
1034 bld.SAMBA_BINARY('protocol_basic_test',
1035 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
1036 deps='ctdb-protocol-tests-basic talloc',
1037 install_path='${CTDB_TEST_LIBEXECDIR}')
1039 ctdb_protocol_tests = [
1040 'protocol_types_test',
1041 'protocol_ctdb_test',
1042 'protocol_util_test',
1043 'protocol_types_compat_test',
1044 'protocol_ctdb_compat_test',
1047 for target in ctdb_protocol_tests:
1048 src = 'tests/src/' + target + '.c'
1050 bld.SAMBA_BINARY(target,
1051 source=src,
1052 deps='''ctdb-protocol-tests-common
1053 samba-util talloc tdb''',
1054 install_path='${CTDB_TEST_LIBEXECDIR}')
1056 bld.SAMBA_BINARY('event_protocol_test',
1057 source='event/event_protocol_test.c',
1058 deps='''ctdb-protocol-tests-basic
1059 ctdb-protocol-basic talloc''',
1060 install_path='${CTDB_TEST_LIBEXECDIR}')
1062 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1063 source=bld.SUBDIR('tests/src',
1064 '''cluster_wait.c
1065 test_options.c
1066 '''),
1067 deps='''ctdb-client
1068 samba-util
1069 replace
1070 popt
1071 talloc
1072 tevent
1073 tdb''')
1075 bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1076 source=bld.SUBDIR('tests/src',
1077 'test_backtrace.c'),
1078 deps='''samba-util
1079 replace''')
1081 # Test binaries
1082 ctdb_tests = [
1083 'g_lock_loop',
1084 'message_ring',
1085 'fetch_ring',
1086 'fetch_loop',
1087 'fetch_loop_key',
1088 'fetch_readonly',
1089 'fetch_readonly_loop',
1090 'transaction_loop',
1091 'update_record',
1092 'update_record_persistent',
1093 'lock_tdb',
1094 'dummy_client',
1095 'tunnel_test',
1096 'tunnel_cmd',
1099 for target in ctdb_tests:
1100 src = 'tests/src/' + target + '.c'
1102 bld.SAMBA_BINARY(target,
1103 source=src,
1104 includes='include',
1105 deps='''ctdb-client ctdb-protocol ctdb-util
1106 samba-util ctdb-tests-common''',
1107 install_path='${CTDB_TEST_LIBEXECDIR}')
1109 bld.SAMBA_BINARY('ctdb_takeover_tests',
1110 source='''tests/src/ctdb_takeover_tests.c
1111 tests/src/ipalloc_read_known_ips.c''',
1112 deps='''replace popt tdb tevent talloc ctdb-system
1113 samba-util tdb-wrap talloc_report
1114 ctdb-ipalloc ctdb-protocol ctdb-util''',
1115 includes='include',
1116 install_path='${CTDB_TEST_LIBEXECDIR}')
1118 bld.SAMBA_BINARY('fake_ctdbd',
1119 source='''tests/src/fake_ctdbd.c
1120 tests/src/ipalloc_read_known_ips.c''',
1121 deps='''ctdb-conf-util
1122 ctdb-protocol
1123 ctdb-protocol-util
1124 ctdb-system
1125 ctdb-util
1126 popt
1127 samba-util
1128 tevent-util
1129 LIBASYNC_REQ''',
1130 install_path='${CTDB_TEST_LIBEXECDIR}')
1132 bld.SAMBA_BINARY('cluster_mutex_test',
1133 source='tests/src/cluster_mutex_test.c',
1134 deps='''ctdb-tests-backtrace
1135 samba-util
1136 talloc
1137 tevent
1138 ''',
1139 install_path='${CTDB_TEST_LIBEXECDIR}')
1141 if bld.env.HAVE_INFINIBAND:
1142 bld.SAMBA_BINARY('ibwrapper_test',
1143 source='ib/ibwrapper_test.c',
1144 includes='include',
1145 deps='replace talloc ctdb-common sys_rw' +
1146 ib_deps,
1147 install_path='${CTDB_TEST_LIBEXECDIR}')
1149 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1150 bld.SAMBA_BINARY('test_mutex_raw',
1151 source='tests/src/test_mutex_raw.c',
1152 deps='pthread',
1153 install_path='${CTDB_TEST_LIBEXECDIR}')
1155 test_subdirs = [
1156 'CLUSTER',
1157 'INTEGRATION',
1158 'UNIT',
1159 'etc-ctdb'
1162 if bld.env.standalone_ctdb:
1163 testdir = 'tests'
1164 else:
1165 testdir = 'ctdb/tests'
1167 for t in test_subdirs:
1168 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1169 for fmode in files:
1170 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1171 destname=fmode[0], chmod=fmode[1])
1173 # Install tests/scripts directory, excluding files that need munging
1174 test_scripts = [
1175 'cluster.bash',
1176 'common.sh',
1177 'integration.bash',
1178 'integration_local_daemons.bash',
1179 'integration_real_cluster.bash',
1180 'unit.sh'
1183 for t in test_scripts:
1184 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1185 os.path.join('tests/scripts', t),
1186 destname=os.path.join('scripts', t))
1188 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1189 'tests/scripts/test_wrap',
1190 destname='scripts/test_wrap',
1191 chmod=MODE_755)
1193 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1194 source='tests/scripts/script_install_paths.sh',
1195 target='script_install_paths.sh',
1196 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1197 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1198 'script_install_paths.sh',
1199 destname='script_install_paths.sh', chmod=MODE_644)
1201 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1202 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1203 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1204 bld.SAMBA_GENERATOR('ctdb-test-runner',
1205 source='tests/run_tests.sh',
1206 target='ctdb_run_tests.sh',
1207 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1208 sed_expr1, sed_expr2))
1209 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1210 destname='ctdb_run_tests', chmod=MODE_755)
1211 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1212 'ctdb_run_tests')
1214 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1215 source='tests/local_daemons.sh',
1216 target='ctdb_local_daemons.sh',
1217 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1218 sed_expr1, sed_expr2))
1219 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1220 destname='ctdb_local_daemons', chmod=MODE_755)
1223 def testonly(ctx):
1224 cmd = 'tests/run_tests.sh'
1225 ret = samba_utils.RUN_COMMAND(cmd)
1226 if ret != 0:
1227 print('tests exited with exit status %d' % ret)
1228 sys.exit(ret)
1231 def test(ctx):
1232 Options.commands.append('build')
1233 Options.commands.append('testonly')
1236 def autotest(ctx):
1237 env = samba_utils.LOAD_ENVIRONMENT()
1238 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1239 ret = samba_utils.RUN_COMMAND(cmd)
1240 if ret != 0:
1241 print('autotest exited with exit status %d' % ret)
1242 sys.exit(ret)
1245 def show_version(ctx):
1246 print(get_version_string())
1249 def manpages(ctx):
1250 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1251 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1252 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1253 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1254 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1255 for t in manpages:
1256 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1257 ret = samba_utils.RUN_COMMAND(cmd)
1258 if ret != 0:
1259 print('Command %s failed with exit status %d' % (cmd, ret))
1260 sys.exit(ret)
1262 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1263 ret = samba_utils.RUN_COMMAND(cmd)
1264 if ret != 0:
1265 print('Command %s failed with exit status %d' % (cmd, ret))
1266 sys.exit(ret)
1269 def distonly(ctx):
1270 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1272 t = 'ctdb.spec'
1273 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1274 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1275 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1276 sed_expr1, sed_expr2, t)
1277 ret = samba_utils.RUN_COMMAND(cmd)
1278 if ret != 0:
1279 print('Command "%s" failed with exit status %d' % (cmd, ret))
1280 sys.exit(ret)
1281 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1283 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1284 for t in manpages:
1285 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1286 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1287 extend=True)
1289 samba_dist.dist()
1292 def dist():
1293 Options.commands.append('manpages')
1294 Options.commands.append('distonly')
1297 def rpmonly(ctx):
1298 opts = os.getenv('RPM_OPTIONS') or ''
1299 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1300 (opts, get_version_string())
1301 ret = samba_utils.RUN_COMMAND(cmd)
1302 if ret != 0:
1303 print('rpmbuild exited with exit status %d' % ret)
1304 sys.exit(ret)
1307 def rpm(ctx):
1308 Options.commands.append('manpages')
1309 Options.commands.append('distonly')
1310 Options.commands.append('rpmonly')
1313 def ctags(ctx):
1314 "build 'tags' file using ctags"
1315 source_root = os.path.dirname(Context.g_module.root_path)
1316 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1317 print("Running: %s" % cmd)
1318 ret = samba_utils.RUN_COMMAND(cmd)
1319 if ret != 0:
1320 print('ctags failed with exit status %d' % ret)
1321 sys.exit(ret)