tests/krb5: Add tests for PAC buffer alignment
[Samba.git] / ctdb / wscript
bloba9fef9241aa9eb45ad5cc2038c84c0d8de1ac46d
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 'ctdbd_wrapper.1',
50 'onnode.1',
51 'ctdb.conf.5',
52 'ctdb-script.options.5',
53 'ctdb.sysconfig.5',
54 'ctdb.7',
55 'ctdb-statistics.7',
56 'ctdb-tunables.7',
59 manpages_etcd = [
60 'ctdb-etcd.7',
63 manpages_ceph = [
64 'ctdb_mutex_ceph_rados_helper.7',
67 VERSION = ''
69 def get_version():
70 import samba_version
71 env = samba_utils.LOAD_ENVIRONMENT()
73 return samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
75 def get_version_string():
76 if Context.g_module.VERSION:
77 return Context.g_module.VERSION
78 version = get_version()
79 Context.g_module.VERSION = version.STRING.replace('-', '.')
80 return Context.g_module.VERSION
82 def options(opt):
83 opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
85 opt.RECURSE('lib/replace')
87 opt.RECURSE('lib/util')
89 opt.RECURSE('lib/talloc')
90 opt.RECURSE('lib/tevent')
91 opt.RECURSE('lib/tdb')
93 opt.add_option('--enable-infiniband',
94 help=("Turn on infiniband support (default=no)"),
95 action="store_true", dest='ctdb_infiniband', default=False)
96 opt.add_option('--enable-pmda',
97 help=("Turn on PCP pmda support (default=no)"),
98 action="store_true", dest='ctdb_pmda', default=False)
99 opt.add_option('--enable-etcd-reclock',
100 help=("Enable etcd recovery lock helper (default=no)"),
101 action="store_true", dest='ctdb_etcd_reclock', default=False)
103 opt.add_option('--with-libcephfs',
104 help=("Directory under which libcephfs is installed"),
105 action="store", dest='libcephfs_dir', default=None)
106 opt.add_option('--enable-ceph-reclock',
107 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
108 action="store_true", dest='ctdb_ceph_reclock', default=False)
110 opt.add_option('--with-logdir',
111 help=("Path to log directory"),
112 action="store", dest='ctdb_logdir', default=None)
113 opt.add_option('--with-socketpath',
114 help=("path to CTDB daemon socket"),
115 action="store", dest='ctdb_sockpath', default=None)
118 def configure(conf):
119 # No need to build python bindings for talloc/tevent/tdb
120 if conf.IN_LAUNCH_DIR():
121 conf.env.standalone_ctdb = True
122 Options.options.disable_python = True
124 conf.RECURSE('lib/replace')
126 conf.CHECK_HEADERS(headers='''sys/socket.h
127 netinet/in.h
128 netinet/if_ether.h
129 netinet/ip.h
130 netinet/ip6.h
131 netinet/icmp6.h''',
132 together=True)
134 conf.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);',
135 define='HAVE_AF_PACKET',
136 headers='sys/socket.h linux/if_packet.h')
138 conf.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;',
139 define='HAVE_PACKETSOCKET',
140 headers='sys/socket.h linux/if_packet.h')
142 conf.CHECK_CODE('''pthread_mutex_t m;
143 int pid = 0;
144 m.__data.__owner = pid;
145 ''',
146 'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER',
147 headers='pthread.h',
148 msg='Checking for internal POSIX mutex owner field')
149 if not conf.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
150 # This is unsupported - please see note in debug_locks.sh
151 Logs.info('Building without unsupported mutex debugging hack')
153 if conf.env.standalone_ctdb:
154 conf.SAMBA_CHECK_PERL(mandatory=True)
156 # This is just for consistency and to check the version for the
157 # build system, see Options.options.disable_python = True above
158 conf.SAMBA_CHECK_PYTHON()
159 conf.SAMBA_CHECK_PYTHON_HEADERS()
161 # We just want gnutls_rnd for rand subsystem
162 conf.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls')
165 if conf.CHECK_FOR_THIRD_PARTY():
166 conf.RECURSE('third_party/popt')
167 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
168 conf.RECURSE('third_party/socket_wrapper')
169 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
170 else:
171 if not conf.CHECK_POPT():
172 raise Errors.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
173 else:
174 conf.define('USING_SYSTEM_POPT', 1)
175 conf.env.SOCKET_WRAPPER_SO_PATH = ''
178 if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
179 if not conf.CHECK_SOCKET_WRAPPER():
180 raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
181 else:
182 conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
183 conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
185 conf.RECURSE('lib/util')
187 conf.RECURSE('lib/talloc')
188 conf.RECURSE('lib/tevent')
189 conf.RECURSE('lib/tdb')
191 conf.CHECK_HEADERS('sched.h')
192 conf.CHECK_HEADERS('procinfo.h')
193 if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'):
194 Logs.error('Need thread_setsched() on AIX')
195 sys.exit(1)
196 elif not conf.CHECK_FUNCS('sched_setscheduler'):
197 Logs.error('Need sched_setscheduler()')
198 sys.exit(1)
199 conf.CHECK_FUNCS('mlockall')
200 conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
202 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
203 conf.DEFINE('ETIME', 'ETIMEDOUT')
205 if sys.platform.startswith('linux'):
206 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
207 else:
208 if not conf.CHECK_HEADERS('pcap.h'):
209 Logs.error('Need libpcap')
210 sys.exit(1)
211 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
212 Logs.error('Need libpcap')
213 sys.exit(1)
215 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
216 checklibc=True, headers='execinfo.h'):
217 Logs.error('backtrace support not available')
219 have_pmda = False
220 if Options.options.ctdb_pmda:
221 pmda_support = True
223 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
224 together=True):
225 pmda_support = False
226 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
227 pmda_support = False
228 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
229 pmda_support = False
230 if pmda_support:
231 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
232 have_pmda = True
233 else:
234 Logs.error("PMDA support not available")
235 sys.exit(1)
236 if have_pmda:
237 Logs.info('Building with PMDA support')
238 conf.define('HAVE_PMDA', 1)
239 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
240 'lib/pcp/pmdas/ctdb')
242 have_infiniband = False
243 if Options.options.ctdb_infiniband:
244 ib_support = True
246 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
247 ib_support = False
248 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
249 ib_support = False
250 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
251 ib_support = False
252 if ib_support:
253 have_infiniband = True
254 else:
255 Logs.error("Infiniband support not available")
256 sys.exit(1)
257 if have_infiniband:
258 Logs.info('Building with Infiniband support')
259 conf.define('HAVE_INFINIBAND', 1)
260 conf.define('USE_INFINIBAND', 1)
262 have_etcd_reclock = False
263 if Options.options.ctdb_etcd_reclock:
264 try:
265 conf.check_python_module('etcd')
266 have_etcd_reclock = True
267 except:
268 Logs.error('etcd support not available')
269 sys.exit(1)
270 if have_etcd_reclock:
271 Logs.info('Building with etcd support')
272 conf.env.etcd_reclock = have_etcd_reclock
274 if Options.options.libcephfs_dir:
275 Logs.error('''--with-libcephfs no longer supported, please use compiler
276 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
277 sys.exit(1)
279 if Options.options.ctdb_ceph_reclock:
280 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
281 conf.CHECK_LIB('rados', shlib=True)):
282 Logs.info('Building with Ceph librados recovery lock support')
283 conf.define('HAVE_LIBRADOS', 1)
284 else:
285 Logs.error("Missing librados for Ceph recovery lock support")
286 sys.exit(1)
288 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
289 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
290 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
291 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
292 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
293 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
295 if Options.options.ctdb_logdir:
296 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
297 else:
298 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
300 if Options.options.ctdb_sockpath:
301 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
302 else:
303 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
304 'ctdbd.socket')
305 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
307 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
308 -DLOGDIR=\"%s\"
309 -DCTDB_DATADIR=\"%s\"
310 -DCTDB_ETCDIR=\"%s\"
311 -DCTDB_VARDIR=\"%s\"
312 -DCTDB_RUNDIR=\"%s\"''' % (
313 conf.env.CTDB_HELPER_BINDIR,
314 conf.env.CTDB_LOGDIR,
315 conf.env.CTDB_DATADIR,
316 conf.env.CTDB_ETCDIR,
317 conf.env.CTDB_VARDIR,
318 conf.env.CTDB_RUNDIR))
320 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
321 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
323 # Allow unified compilation and separate compilation of utilities
324 # to find includes
325 if not conf.env.standalone_ctdb:
326 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
327 else:
328 if Context.g_module.top == '.':
329 # Building from tarball
330 conf.ADD_EXTRA_INCLUDES('#include')
331 else:
332 # Building standalone CTDB from within Samba tree
333 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
334 conf.ADD_EXTRA_INCLUDES('#ctdb')
335 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
337 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
338 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
339 conf.SAMBA_CONFIG_H()
341 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
342 conf.env.ctdb_generate_manpages = True
343 else:
344 conf.env.ctdb_generate_manpages = False
346 Logs.info("xsltproc unavailable, checking for pre-built manpages")
347 conf.env.ctdb_prebuilt_manpages = []
348 manpages = manpages_binary + manpages_misc
349 if conf.env.etcd_reclock:
350 manpages += manpages_etcd
351 if conf.env.HAVE_LIBRADOS:
352 manpages += manpages_ceph
353 for m in manpages:
354 if os.path.exists(os.path.join("doc", m)):
355 Logs.info(" %s: yes" % (m))
356 conf.env.ctdb_prebuilt_manpages.append(m)
357 else:
358 Logs.info(" %s: no" % (m))
360 def build(bld):
361 if bld.env.standalone_ctdb:
362 # enable building of public headers in the build tree
363 bld.env.build_public_headers = 'include/public'
365 if bld.env.standalone_ctdb:
366 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
368 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
370 bld.RECURSE('lib/replace')
371 if bld.CHECK_FOR_THIRD_PARTY():
372 bld.RECURSE('third_party/popt')
373 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
374 bld.RECURSE('third_party/socket_wrapper')
376 bld.RECURSE('lib/tdb_wrap')
377 bld.RECURSE('lib/util')
378 bld.RECURSE('lib/async_req')
379 bld.RECURSE('lib/pthreadpool')
380 bld.RECURSE('lib/messaging')
382 bld.RECURSE('lib/talloc')
383 bld.RECURSE('lib/tevent')
384 bld.RECURSE('lib/tdb')
386 if bld.env.standalone_ctdb:
387 # If a combined build is implemented, CTDB will want to
388 # build against samba-util rather than samba-util-core.
389 # Similarly, other Samba subsystems expect samba-util. So,
390 # for a standalone build, just define a fake samba-util
391 # subsystem that pulls in samba-util-core.
392 bld.SAMBA_SUBSYSTEM('samba-util',
393 source='',
394 deps='samba-util-core')
396 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
397 source=bld.SUBDIR('tcp',
398 'tcp_connect.c tcp_init.c tcp_io.c'),
399 includes='include',
400 deps='replace tdb talloc tevent')
402 ib_deps = ''
403 if bld.env.HAVE_INFINIBAND:
404 bld.SAMBA_SUBSYSTEM('ctdb-ib',
405 source=bld.SUBDIR('ib',
406 '''ibwrapper.c ibw_ctdb.c
407 ibw_ctdb_init.c'''),
408 includes='include',
409 deps='replace talloc tevent tdb')
410 ib_deps = ' ctdb-ib rdmacm ibverbs'
412 bld.SAMBA_SUBSYSTEM('ctdb-system',
413 source=bld.SUBDIR('common',
414 'system_socket.c system.c'),
415 includes='include',
416 deps='replace talloc tevent tdb pcap samba-util')
418 bld.SAMBA_SUBSYSTEM('ctdb-common',
419 source=bld.SUBDIR('common',
420 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
421 sock_io.c'''),
422 includes='include',
423 deps='''replace popt talloc tevent tdb popt ctdb-system
424 ctdb-protocol-util''')
426 bld.SAMBA_SUBSYSTEM('ctdb-util',
427 source=bld.SUBDIR('common',
428 '''db_hash.c srvid.c reqid.c
429 pkt_read.c pkt_write.c comm.c
430 logging.c rb_tree.c tunable.c
431 pidfile.c run_proc.c
432 hash_count.c
433 run_event.c event_script.c
434 sock_client.c
435 cmdline.c path.c conf.c line.c
436 '''),
437 deps='''samba-util sys_rw tevent-util
438 replace talloc tevent tdb popt''')
440 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
441 source='common/logging_conf.c',
442 deps='ctdb-util talloc')
444 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
445 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
446 deps='talloc tdb')
448 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
449 source=bld.SUBDIR('protocol',
450 '''protocol_header.c protocol_packet.c
451 protocol_types.c
452 protocol_call.c
453 protocol_message.c
454 protocol_control.c
455 protocol_keepalive.c
456 protocol_tunnel.c
457 protocol_client.c
458 protocol_debug.c
459 protocol_sock.c'''),
460 includes='include',
461 deps='ctdb-protocol-basic replace talloc tdb')
463 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
464 source='protocol/protocol_util.c',
465 deps='ctdb-util replace talloc tdb')
467 bld.SAMBA_SUBSYSTEM('ctdb-client',
468 source=bld.SUBDIR('client',
469 '''client_connect.c client_call.c
470 client_message.c client_control.c
471 client_message_sync.c
472 client_control_sync.c
473 client_db.c client_util.c
474 client_tunnel.c
475 '''),
476 includes='include',
477 deps='replace talloc tevent tdb tdb-wrap')
479 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
480 source=bld.SUBDIR('common',
481 '''sock_daemon.c'''),
482 deps='''samba-util ctdb-util ctdb-system tevent-util
483 LIBASYNC_REQ replace talloc tevent''')
485 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
486 source=bld.SUBDIR('server',
487 '''ipalloc_deterministic.c
488 ipalloc_nondeterministic.c
489 ipalloc_lcp2.c
490 ipalloc_common.c
491 ipalloc.c
492 '''),
493 includes='include',
494 deps='ctdb-protocol-util replace talloc tevent')
496 bld.SAMBA_BINARY('ctdb-path',
497 source='common/path_tool.c',
498 cflags='-DCTDB_PATH_TOOL',
499 deps='''ctdb-util samba-util talloc replace popt''',
500 install_path='${CTDB_HELPER_BINDIR}')
502 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
503 source='cluster/cluster_conf.c',
504 deps='ctdb-util')
506 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
507 source='database/database_conf.c',
508 deps='ctdb-util')
510 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
511 source='event/event_conf.c',
512 deps='ctdb-util')
514 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
515 source='failover/failover_conf.c',
516 deps='ctdb-util')
518 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
519 source='server/legacy_conf.c',
520 deps='ctdb-util')
522 bld.SAMBA_BINARY('ctdb-config',
523 source='common/conf_tool.c',
524 cflags='-DCTDB_CONF_TOOL',
525 deps='''ctdb-logging-conf
526 ctdb-event-conf
527 ctdb-cluster-conf
528 ctdb-database-conf
529 ctdb-failover-conf
530 ctdb-legacy-conf
531 ctdb-util samba-util talloc replace popt''',
532 install_path='${CTDB_HELPER_BINDIR}')
534 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
535 source=bld.SUBDIR('event',
536 '''event_protocol.c
537 event_protocol_util.c
538 '''),
539 deps='ctdb-protocol-basic')
541 bld.SAMBA_LIBRARY('ctdb-event-client',
542 source='event/event_client.c',
543 deps='ctdb-event-protocol ctdb-util tevent talloc',
544 private_library=True)
546 bld.SAMBA_BINARY('ctdb-eventd',
547 source=bld.SUBDIR('event',
548 '''event_cmd.c
549 event_config.c
550 event_context.c
551 event_daemon.c
552 event_request.c
553 '''),
554 deps='''ctdb-event-protocol
555 ctdb-event-conf ctdb-logging-conf
556 ctdb-server-util samba-util ctdb-util
557 talloc tevent replace popt''',
558 install_path='${CTDB_HELPER_BINDIR}')
560 bld.SAMBA_BINARY('ctdb-event',
561 source='event/event_tool.c',
562 cflags='-DCTDB_EVENT_TOOL',
563 deps='''ctdb-event-client ctdb-event-protocol
564 ctdb-util samba-util talloc replace''',
565 install_path='${CTDB_HELPER_BINDIR}')
567 bld.SAMBA_BINARY('ctdbd',
568 source='server/ctdbd.c ' +
569 bld.SUBDIR('server',
570 '''ctdb_daemon.c ctdb_recoverd.c
571 ctdb_recover.c ctdb_freeze.c
572 ctdb_tunables.c ctdb_monitor.c
573 ctdb_server.c ctdb_control.c
574 ctdb_call.c ctdb_ltdb_server.c
575 ctdb_traverse.c eventscript.c
576 ctdb_takeover.c
577 ctdb_persistent.c ctdb_keepalive.c
578 ctdb_cluster_mutex.c
579 ctdb_logging.c
580 ctdb_uptime.c
581 ctdb_vacuum.c ctdb_banning.c
582 ctdb_statistics.c
583 ctdb_update_record.c
584 ctdb_lock.c ctdb_fork.c
585 ctdb_tunnel.c ctdb_client.c
586 ctdb_config.c
587 '''),
588 includes='include',
589 deps='''ctdb-common ctdb-system ctdb-protocol
590 ctdb-tcp ctdb-util replace sys_rw popt
591 ctdb-logging-conf
592 ctdb-cluster-conf
593 ctdb-database-conf
594 ctdb-event-conf
595 ctdb-failover-conf
596 ctdb-legacy-conf
597 ctdb-event-protocol
598 talloc tevent tdb-wrap tdb talloc_report''' +
599 ib_deps,
600 install_path='${SBINDIR}',
601 manpages='ctdbd.1')
603 bld.SAMBA_BINARY('ctdb',
604 source='tools/ctdb.c',
605 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
606 ctdb-util ctdb-system samba-util sys_rw popt''',
607 install_path='${BINDIR}',
608 manpages='ctdb.1')
610 bld.SAMBA_BINARY('ctdb_killtcp',
611 source='tools/ctdb_killtcp.c',
612 deps='''ctdb-protocol-util ctdb-util ctdb-system
613 samba-util replace''',
614 install_path='${CTDB_HELPER_BINDIR}')
616 bld.SAMBA_BINARY('ltdbtool',
617 source='tools/ltdbtool.c',
618 includes='include',
619 deps='tdb',
620 install_path='${BINDIR}',
621 manpages='ltdbtool.1')
623 bld.SAMBA_BINARY('ctdb_lock_helper',
624 source='server/ctdb_lock_helper.c',
625 deps='''samba-util sys_rw ctdb-system tevent-util
626 talloc tevent tdb''',
627 includes='include',
628 install_path='${CTDB_HELPER_BINDIR}')
630 bld.SAMBA_BINARY('ctdb_recovery_helper',
631 source='server/ctdb_recovery_helper.c',
632 deps='''ctdb-client ctdb-protocol ctdb-util
633 samba-util sys_rw replace tdb''',
634 install_path='${CTDB_HELPER_BINDIR}')
636 bld.SAMBA_BINARY('ctdb_takeover_helper',
637 source='server/ctdb_takeover_helper.c',
638 deps='''ctdb-client ctdb-protocol ctdb-util
639 samba-util sys_rw replace ctdb-ipalloc popt''',
640 install_path='${CTDB_HELPER_BINDIR}')
642 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
643 source='server/ctdb_mutex_fcntl_helper.c',
644 deps='''sys_rw ctdb-system tevent-util
645 talloc tevent
646 ''',
647 includes='include',
648 install_path='${CTDB_HELPER_BINDIR}')
650 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
651 source='utils/smnotify/smnotify.x',
652 target='utils/smnotify/smnotify.h',
653 rule='rpcgen -h ${SRC} > ${TGT}')
655 xdr_buf_hack = 'grep -Fv "register int32_t *buf;"'
657 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
658 source='utils/smnotify/smnotify.x',
659 target='utils/smnotify/gen_xdr.c',
660 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
662 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
663 source='utils/smnotify/smnotify.x',
664 target='utils/smnotify/gen_smnotify.c',
665 rule='rpcgen -l ${SRC} > ${TGT}')
667 bld.SAMBA_BINARY('smnotify',
668 source=bld.SUBDIR('utils/smnotify',
669 'smnotify.c gen_smnotify.c gen_xdr.c'),
670 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
671 includes='utils utils/smnotify',
672 install_path='${CTDB_HELPER_BINDIR}')
674 bld.SAMBA_BINARY('ping_pong',
675 source='utils/ping_pong/ping_pong.c',
676 deps='',
677 install_path='${BINDIR}',
678 manpages='ping_pong.1')
680 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
681 bld.SAMBA_BINARY('tdb_mutex_check',
682 source='utils/tdb/tdb_mutex_check.c',
683 deps='tdb pthread',
684 install_path='${CTDB_HELPER_BINDIR}')
686 if bld.env.HAVE_PMDA:
687 bld.SAMBA_BINARY('pmdactdb',
688 source='utils/pmda/pmda_ctdb.c',
689 includes='include',
690 deps='''ctdb-client ctdb-protocol ctdb-util
691 samba-util pcp_pmda pcp''',
692 install_path='${CTDB_PMDADIR}')
693 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
694 destname='Install')
695 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
696 destname='Remove')
697 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
698 destname='pmns')
699 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
700 destname='domain.h')
701 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
702 destname='help')
703 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
704 destname='README')
706 if bld.env.HAVE_LIBRADOS:
707 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
708 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
709 deps='talloc tevent rados',
710 includes='include',
711 install_path='${CTDB_HELPER_BINDIR}')
713 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
714 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
715 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
716 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
717 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
718 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
719 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
720 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
721 sed_cmdline = '-e "%s" ' * 8 % \
722 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
723 sed_expr6, sed_expr7, sed_expr8)
725 manpages_extra = list(manpages_misc)
726 if bld.env.etcd_reclock:
727 manpages_extra += manpages_etcd
728 if bld.env.HAVE_LIBRADOS:
729 manpages_extra += manpages_ceph
730 for f in manpages_binary + manpages_extra:
731 x = '%s.xml' % (f)
732 bld.SAMBA_GENERATOR(x,
733 source=os.path.join('doc', x),
734 target=x,
735 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
737 if bld.env.ctdb_generate_manpages:
738 bld.MANPAGES(' '.join(manpages_extra), True)
739 else:
740 for m in bld.env.ctdb_prebuilt_manpages:
741 bld.SAMBA_GENERATOR(m,
742 source=os.path.join("doc", m),
743 target=m,
744 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
745 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
747 bld.SAMBA_GENERATOR('ctdb-onnode',
748 source='tools/onnode',
749 target='onnode',
750 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
751 bld.INSTALL_FILES('${BINDIR}', 'onnode',
752 destname='onnode', chmod=MODE_755)
754 bld.SAMBA_GENERATOR('ctdb-diagnostics',
755 source='tools/ctdb_diagnostics',
756 target='ctdb_diagnostics',
757 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
758 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
759 destname='ctdb_diagnostics', chmod=MODE_755)
761 if bld.env.etcd_reclock:
762 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
763 source='utils/etcd/ctdb_etcd_lock',
764 target='ctdb_etcd_lock',
765 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
766 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
767 destname='ctdb_etcd_lock', chmod=MODE_744)
769 bld.SAMBA_GENERATOR('ctdb-natgw',
770 source='tools/ctdb_natgw',
771 target='ctdb_natgw',
772 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
773 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
774 destname='ctdb_natgw', chmod=MODE_755)
776 bld.SAMBA_GENERATOR('ctdb-lvs',
777 source='tools/ctdb_lvs',
778 target='ctdb_lvs',
779 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
780 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
781 destname='ctdb_lvs', chmod=MODE_755)
783 bld.SAMBA_GENERATOR('ctdbd-wrapper',
784 source='config/ctdbd_wrapper',
785 target='ctdbd_wrapper',
786 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
787 bld.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
788 destname='ctdbd_wrapper', chmod=MODE_755)
790 def SUBDIR_MODE_callback(arg, dirname, fnames):
791 for f in fnames:
792 fl = os.path.join(dirname, f)
793 if os.path.isdir(fl) or os.path.islink(fl):
794 continue
795 mode = os.lstat(fl).st_mode & MODE_777
796 if arg['trim_path']:
797 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
798 arg['file_list'].append([fl, mode])
800 def SUBDIR_MODE(path, trim_path=None):
801 pd = {'trim_path': trim_path, 'file_list': []}
802 for dirname, _subdirs, fnames in os.walk(path):
803 SUBDIR_MODE_callback(pd, dirname, fnames)
804 return pd['file_list']
806 event_script_subdirs = [
807 'events/legacy',
810 etc_subdirs = [
811 'nfs-checks.d'
814 if bld.env.standalone_ctdb:
815 configdir = 'config'
816 else:
817 configdir = 'ctdb/config'
819 for t in event_script_subdirs:
820 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
821 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
822 for fmode in files:
823 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
824 destname=fmode[0], chmod=fmode[1])
826 for t in etc_subdirs:
827 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
828 for fmode in files:
829 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
830 destname=fmode[0], chmod=fmode[1])
832 # If this is a direct install and there are no event scripts
833 # linked/enabled then enable some standard ones
834 if os.environ.get('DESTDIR') is None:
835 fmt = 'events/legacy/%s.script'
836 required_script = '00.ctdb'
837 required_path = os.path.join(bld.env.CTDB_ETCDIR,
838 fmt % (required_script))
839 if not os.path.islink(required_path) and \
840 not os.path.exists(required_path):
841 default_scripts = [ required_script,
842 '01.reclock',
843 '05.system',
844 '10.interface',
846 for t in default_scripts:
847 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
848 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
849 bld.symlink_as(name, tgt)
851 bld.SAMBA_GENERATOR('ctdb-functions',
852 source='config/functions',
853 target='functions',
854 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
855 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
857 etc_scripts = [
858 'ctdb-crash-cleanup.sh',
859 'debug-hung-script.sh',
860 'debug_locks.sh',
861 'nfs-linux-kernel-callout',
862 'notify.sh',
863 'statd-callout'
866 for t in etc_scripts:
867 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
868 destname=t, chmod=MODE_755)
870 bld.SAMBA_GENERATOR('ctdb-sudoers',
871 source='config/ctdb.sudoers',
872 target='ctdb.sudoers',
873 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
874 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
875 destname='ctdb')
877 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
878 'config/notification.README',
879 destname='README')
881 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
882 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
883 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
885 for d in ['volatile', 'persistent', 'state']:
886 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
889 # Test-only below this point
892 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
893 return
895 bld.SAMBA_BINARY('errcode',
896 source='tests/src/errcode.c',
897 deps='replace',
898 install_path='${CTDB_TEST_LIBEXECDIR}')
900 bld.SAMBA_BINARY('sigcode',
901 source='tests/src/sigcode.c',
902 deps='replace',
903 install_path='${CTDB_TEST_LIBEXECDIR}')
905 # Unit tests
906 ctdb_unit_tests = [
907 'db_hash_test',
908 'srvid_test',
909 'pkt_read_test',
910 'pkt_write_test',
911 'comm_test',
912 'comm_server_test',
913 'comm_client_test',
914 'pidfile_test',
915 'run_proc_test',
916 'sock_io_test',
917 'hash_count_test',
918 'run_event_test',
919 'cmdline_test',
920 'conf_test',
921 'line_test',
922 'event_script_test',
925 for target in ctdb_unit_tests:
926 src = 'tests/src/' + target + '.c'
928 bld.SAMBA_BINARY(target,
929 source=src,
930 deps='''talloc tevent tdb tevent-util popt
931 LIBASYNC_REQ samba-util sys_rw''',
932 install_path='${CTDB_TEST_LIBEXECDIR}')
934 bld.SAMBA_BINARY('reqid_test',
935 source='tests/src/reqid_test.c',
936 deps='samba-util',
937 install_path='${CTDB_TEST_LIBEXECDIR}')
939 bld.SAMBA_BINARY('rb_test',
940 source='tests/src/rb_test.c',
941 deps='samba-util talloc',
942 install_path='${CTDB_TEST_LIBEXECDIR}')
944 bld.SAMBA_BINARY('ctdb_packet_parse',
945 source='tests/src/ctdb_packet_parse.c',
946 deps='talloc tevent tdb ctdb-protocol',
947 install_path='${CTDB_TEST_LIBEXECDIR}')
949 bld.SAMBA_BINARY('system_socket_test',
950 source='tests/src/system_socket_test.c',
951 deps='talloc ctdb-protocol-util pcap',
952 install_path='${CTDB_TEST_LIBEXECDIR}')
954 bld.SAMBA_BINARY('porting_tests',
955 source='tests/src/porting_tests.c',
956 deps='samba-util ctdb-system popt',
957 install_path='${CTDB_TEST_LIBEXECDIR}')
959 bld.SAMBA_BINARY('sock_daemon_test',
960 source='tests/src/sock_daemon_test.c',
961 deps='''ctdb-system talloc tevent tevent-util
962 LIBASYNC_REQ samba-util sys_rw''',
963 install_path='${CTDB_TEST_LIBEXECDIR}')
965 bld.SAMBA_BINARY('ctdb_io_test',
966 source='tests/src/ctdb_io_test.c',
967 deps='''talloc tevent tdb samba-util sys_rw''',
968 install_path='${CTDB_TEST_LIBEXECDIR}')
970 bld.SAMBA_BINARY('ctdb-db-test',
971 source='tests/src/db_test_tool.c',
972 cflags='-DCTDB_DB_TEST_TOOL',
973 deps='''ctdb-client ctdb-protocol
974 ctdb-util samba-util talloc tevent replace''',
975 install_path='${CTDB_TEST_LIBEXECDIR}')
977 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
978 source=bld.SUBDIR('tests/src',
979 'protocol_common_basic.c'),
980 deps='replace talloc')
982 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
983 source=bld.SUBDIR('tests/src',
984 '''protocol_common.c
985 protocol_common_ctdb.c
986 '''),
987 includes='include',
988 deps='ctdb-protocol-tests-basic replace talloc tdb')
990 bld.SAMBA_BINARY('protocol_basic_test',
991 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
992 deps='ctdb-protocol-tests-basic talloc',
993 install_path='${CTDB_TEST_LIBEXECDIR}')
995 ctdb_protocol_tests = [
996 'protocol_types_test',
997 'protocol_ctdb_test',
998 'protocol_util_test',
999 'protocol_types_compat_test',
1000 'protocol_ctdb_compat_test',
1003 for target in ctdb_protocol_tests:
1004 src = 'tests/src/' + target + '.c'
1006 bld.SAMBA_BINARY(target,
1007 source=src,
1008 deps='''ctdb-protocol-tests-common
1009 samba-util ctdb-util talloc tdb''',
1010 install_path='${CTDB_TEST_LIBEXECDIR}')
1012 bld.SAMBA_BINARY('event_protocol_test',
1013 source='event/event_protocol_test.c',
1014 deps='''ctdb-protocol-tests-basic
1015 ctdb-protocol-basic talloc''',
1016 install_path='${CTDB_TEST_LIBEXECDIR}')
1018 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1019 source=bld.SUBDIR('tests/src',
1020 'cluster_wait.c test_options.c'),
1021 includes='include',
1022 deps='samba-util replace popt talloc tevent tdb')
1024 # Test binaries
1025 ctdb_tests = [
1026 'g_lock_loop',
1027 'message_ring',
1028 'fetch_ring',
1029 'fetch_loop',
1030 'fetch_loop_key',
1031 'fetch_readonly',
1032 'fetch_readonly_loop',
1033 'transaction_loop',
1034 'update_record',
1035 'update_record_persistent',
1036 'lock_tdb',
1037 'dummy_client',
1038 'tunnel_test',
1039 'tunnel_cmd',
1042 for target in ctdb_tests:
1043 src = 'tests/src/' + target + '.c'
1045 bld.SAMBA_BINARY(target,
1046 source=src,
1047 includes='include',
1048 deps='''ctdb-client ctdb-protocol ctdb-util
1049 samba-util ctdb-tests-common''',
1050 install_path='${CTDB_TEST_LIBEXECDIR}')
1052 bld.SAMBA_BINARY('ctdb_takeover_tests',
1053 source='''tests/src/ctdb_takeover_tests.c
1054 tests/src/ipalloc_read_known_ips.c''',
1055 deps='''replace popt tdb tevent talloc ctdb-system
1056 samba-util tdb-wrap talloc_report
1057 ctdb-ipalloc ctdb-protocol ctdb-util''',
1058 includes='include',
1059 install_path='${CTDB_TEST_LIBEXECDIR}')
1061 bld.SAMBA_BINARY('fake_ctdbd',
1062 source='''tests/src/fake_ctdbd.c
1063 tests/src/ipalloc_read_known_ips.c''',
1064 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1065 ctdb-system samba-util tevent-util
1066 LIBASYNC_REQ popt''',
1067 install_path='${CTDB_TEST_LIBEXECDIR}')
1069 bld.SAMBA_BINARY('cluster_mutex_test',
1070 source='tests/src/cluster_mutex_test.c',
1071 deps='samba-util talloc tevent',
1072 install_path='${CTDB_TEST_LIBEXECDIR}')
1074 if bld.env.HAVE_INFINIBAND:
1075 bld.SAMBA_BINARY('ibwrapper_test',
1076 source='ib/ibwrapper_test.c',
1077 includes='include',
1078 deps='replace talloc ctdb-common sys_rw' +
1079 ib_deps,
1080 install_path='${CTDB_TEST_LIBEXECDIR}')
1082 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1083 bld.SAMBA_BINARY('test_mutex_raw',
1084 source='tests/src/test_mutex_raw.c',
1085 deps='pthread',
1086 install_path='${CTDB_TEST_LIBEXECDIR}')
1088 test_subdirs = [
1089 'CLUSTER',
1090 'INTEGRATION',
1091 'UNIT',
1092 'etc-ctdb'
1095 if bld.env.standalone_ctdb:
1096 testdir = 'tests'
1097 else:
1098 testdir = 'ctdb/tests'
1100 for t in test_subdirs:
1101 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1102 for fmode in files:
1103 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1104 destname=fmode[0], chmod=fmode[1])
1106 # Install tests/scripts directory, excluding files that need munging
1107 test_scripts = [
1108 'cluster.bash',
1109 'common.sh',
1110 'integration.bash',
1111 'integration_local_daemons.bash',
1112 'integration_real_cluster.bash',
1113 'unit.sh'
1116 for t in test_scripts:
1117 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1118 os.path.join('tests/scripts', t),
1119 destname=os.path.join('scripts', t))
1121 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1122 'tests/scripts/test_wrap',
1123 destname='scripts/test_wrap',
1124 chmod=MODE_755)
1126 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1127 source='tests/scripts/script_install_paths.sh',
1128 target='script_install_paths.sh',
1129 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1130 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1131 'script_install_paths.sh',
1132 destname='script_install_paths.sh', chmod=MODE_644)
1134 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1135 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1136 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1137 bld.SAMBA_GENERATOR('ctdb-test-runner',
1138 source='tests/run_tests.sh',
1139 target='ctdb_run_tests.sh',
1140 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1141 sed_expr1, sed_expr2))
1142 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1143 destname='ctdb_run_tests', chmod=MODE_755)
1144 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1145 'ctdb_run_tests')
1147 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1148 source='tests/local_daemons.sh',
1149 target='ctdb_local_daemons.sh',
1150 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1151 sed_expr1, sed_expr2))
1152 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1153 destname='ctdb_local_daemons', chmod=MODE_755)
1156 def testonly(ctx):
1157 cmd = 'tests/run_tests.sh'
1158 ret = samba_utils.RUN_COMMAND(cmd)
1159 if ret != 0:
1160 print('tests exited with exit status %d' % ret)
1161 sys.exit(ret)
1164 def test(ctx):
1165 Options.commands.append('build')
1166 Options.commands.append('testonly')
1169 def autotest(ctx):
1170 env = samba_utils.LOAD_ENVIRONMENT()
1171 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1172 ret = samba_utils.RUN_COMMAND(cmd)
1173 if ret != 0:
1174 print('autotest exited with exit status %d' % ret)
1175 sys.exit(ret)
1178 def show_version(ctx):
1179 print(get_version_string())
1182 def manpages(ctx):
1183 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1184 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1185 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1186 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1187 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1188 for t in manpages:
1189 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1190 ret = samba_utils.RUN_COMMAND(cmd)
1191 if ret != 0:
1192 print('Command %s failed with exit status %d' % (cmd, ret))
1193 sys.exit(ret)
1195 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1196 ret = samba_utils.RUN_COMMAND(cmd)
1197 if ret != 0:
1198 print('Command %s failed with exit status %d' % (cmd, ret))
1199 sys.exit(ret)
1202 def distonly(ctx):
1203 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1205 t = 'ctdb.spec'
1206 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1207 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1208 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1209 sed_expr1, sed_expr2, t)
1210 ret = samba_utils.RUN_COMMAND(cmd)
1211 if ret != 0:
1212 print('Command "%s" failed with exit status %d' % (cmd, ret))
1213 sys.exit(ret)
1214 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1216 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1217 for t in manpages:
1218 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1219 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1220 extend=True)
1222 samba_dist.dist()
1225 def dist():
1226 Options.commands.append('manpages')
1227 Options.commands.append('distonly')
1230 def rpmonly(ctx):
1231 opts = os.getenv('RPM_OPTIONS') or ''
1232 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1233 (opts, get_version_string())
1234 ret = samba_utils.RUN_COMMAND(cmd)
1235 if ret != 0:
1236 print('rpmbuild exited with exit status %d' % ret)
1237 sys.exit(ret)
1240 def rpm(ctx):
1241 Options.commands.append('manpages')
1242 Options.commands.append('distonly')
1243 Options.commands.append('rpmonly')
1246 def ctags(ctx):
1247 "build 'tags' file using ctags"
1248 source_root = os.path.dirname(Context.g_module.root_path)
1249 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1250 print("Running: %s" % cmd)
1251 ret = samba_utils.RUN_COMMAND(cmd)
1252 if ret != 0:
1253 print('ctags failed with exit status %d' % ret)
1254 sys.exit(ret)