s3: libsmbclient: Fix smbc_getxattr() to return 0 on success.
[Samba.git] / ctdb / wscript
blob88e42439f5a93bd50d4b56b41edd9ab7e920da39
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)
225 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
226 checklibc=True, headers='execinfo.h'):
227 Logs.error('backtrace support not available')
229 have_pmda = False
230 if Options.options.ctdb_pmda:
231 pmda_support = True
233 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
234 together=True):
235 pmda_support = False
236 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
237 pmda_support = False
238 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
239 pmda_support = False
240 if pmda_support:
241 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
242 have_pmda = True
243 else:
244 Logs.error("PMDA support not available")
245 sys.exit(1)
246 if have_pmda:
247 Logs.info('Building with PMDA support')
248 conf.define('HAVE_PMDA', 1)
249 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
250 'lib/pcp/pmdas/ctdb')
252 have_infiniband = False
253 if Options.options.ctdb_infiniband:
254 ib_support = True
256 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
257 ib_support = False
258 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
259 ib_support = False
260 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
261 ib_support = False
262 if ib_support:
263 have_infiniband = True
264 else:
265 Logs.error("Infiniband support not available")
266 sys.exit(1)
267 if have_infiniband:
268 Logs.info('Building with Infiniband support')
269 conf.define('HAVE_INFINIBAND', 1)
270 conf.define('USE_INFINIBAND', 1)
272 have_etcd_reclock = False
273 if Options.options.ctdb_etcd_reclock:
274 try:
275 conf.check_python_module('etcd')
276 have_etcd_reclock = True
277 except:
278 Logs.error('etcd support not available')
279 sys.exit(1)
280 if have_etcd_reclock:
281 Logs.info('Building with etcd support')
282 conf.env.etcd_reclock = have_etcd_reclock
284 if Options.options.libcephfs_dir:
285 Logs.error('''--with-libcephfs no longer supported, please use compiler
286 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
287 sys.exit(1)
289 if Options.options.ctdb_ceph_reclock:
290 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
291 conf.CHECK_LIB('rados', shlib=True)):
292 Logs.info('Building with Ceph librados recovery lock support')
293 conf.define('HAVE_LIBRADOS', 1)
294 else:
295 Logs.error("Missing librados for Ceph recovery lock support")
296 sys.exit(1)
298 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
299 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
300 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
301 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
302 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
303 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
305 if Options.options.ctdb_logdir:
306 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
307 else:
308 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
310 if Options.options.ctdb_sockpath:
311 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
312 else:
313 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
314 'ctdbd.socket')
315 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
317 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
318 -DLOGDIR=\"%s\"
319 -DCTDB_DATADIR=\"%s\"
320 -DCTDB_ETCDIR=\"%s\"
321 -DCTDB_VARDIR=\"%s\"
322 -DCTDB_RUNDIR=\"%s\"''' % (
323 conf.env.CTDB_HELPER_BINDIR,
324 conf.env.CTDB_LOGDIR,
325 conf.env.CTDB_DATADIR,
326 conf.env.CTDB_ETCDIR,
327 conf.env.CTDB_VARDIR,
328 conf.env.CTDB_RUNDIR))
330 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
331 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
333 # Allow unified compilation and separate compilation of utilities
334 # to find includes
335 if not conf.env.standalone_ctdb:
336 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
337 else:
338 if Context.g_module.top == '.':
339 # Building from tarball
340 conf.ADD_EXTRA_INCLUDES('#include')
341 else:
342 # Building standalone CTDB from within Samba tree
343 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
344 conf.ADD_EXTRA_INCLUDES('#ctdb')
345 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
347 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
348 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
349 conf.SAMBA_CONFIG_H()
351 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
352 conf.env.ctdb_generate_manpages = True
353 else:
354 conf.env.ctdb_generate_manpages = False
356 Logs.info("xsltproc unavailable, checking for pre-built manpages")
357 conf.env.ctdb_prebuilt_manpages = []
358 manpages = manpages_binary + manpages_misc
359 if conf.env.etcd_reclock:
360 manpages += manpages_etcd
361 if conf.env.HAVE_LIBRADOS:
362 manpages += manpages_ceph
363 for m in manpages:
364 if os.path.exists(os.path.join("doc", m)):
365 Logs.info(" %s: yes" % (m))
366 conf.env.ctdb_prebuilt_manpages.append(m)
367 else:
368 Logs.info(" %s: no" % (m))
370 def build(bld):
371 if bld.env.standalone_ctdb:
372 # enable building of public headers in the build tree
373 bld.env.build_public_headers = 'include/public'
375 if bld.env.standalone_ctdb:
376 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
378 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
380 bld.RECURSE('lib/replace')
381 if bld.CHECK_FOR_THIRD_PARTY():
382 bld.RECURSE('third_party/popt')
383 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
384 bld.RECURSE('third_party/socket_wrapper')
386 bld.RECURSE('lib/tdb_wrap')
387 bld.RECURSE('lib/util')
388 bld.RECURSE('lib/async_req')
389 bld.RECURSE('lib/pthreadpool')
390 bld.RECURSE('lib/messaging')
392 bld.RECURSE('lib/talloc')
393 bld.RECURSE('lib/tevent')
394 bld.RECURSE('lib/tdb')
396 if bld.env.standalone_ctdb:
397 # If a combined build is implemented, CTDB will want to
398 # build against samba-util rather than samba-util-core.
399 # Similarly, other Samba subsystems expect samba-util. So,
400 # for a standalone build, just define a fake samba-util
401 # subsystem that pulls in samba-util-core.
402 bld.SAMBA_SUBSYSTEM('samba-util',
403 source='',
404 deps='samba-util-core')
406 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
407 source=bld.SUBDIR('tcp',
408 'tcp_connect.c tcp_init.c tcp_io.c'),
409 includes='include',
410 deps='replace tdb talloc tevent')
412 ib_deps = ''
413 if bld.env.HAVE_INFINIBAND:
414 bld.SAMBA_SUBSYSTEM('ctdb-ib',
415 source=bld.SUBDIR('ib',
416 '''ibwrapper.c ibw_ctdb.c
417 ibw_ctdb_init.c'''),
418 includes='include',
419 deps='replace talloc tevent tdb')
420 ib_deps = ' ctdb-ib rdmacm ibverbs'
422 bld.SAMBA_SUBSYSTEM('ctdb-system',
423 source=bld.SUBDIR('common',
424 'system_socket.c system.c'),
425 deps='replace talloc tevent tdb pcap samba-util')
427 bld.SAMBA_SUBSYSTEM('ctdb-common',
428 source=bld.SUBDIR('common',
429 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
430 sock_io.c'''),
431 includes='include',
432 deps='''replace popt talloc tevent tdb popt ctdb-system
433 ctdb-protocol-util''')
435 bld.SAMBA_SUBSYSTEM('ctdb-util',
436 source=bld.SUBDIR('common',
437 '''cmdline.c
438 comm.c
439 conf.c
440 db_hash.c
441 event_script.c
442 hash_count.c
443 line.c
444 logging.c
445 path.c
446 pidfile.c
447 pkt_read.c
448 pkt_write.c
449 rb_tree.c
450 reqid.c
451 run_event.c
452 run_proc.c
453 sock_client.c
454 srvid.c
455 tmon.c
456 tunable.c
457 '''),
458 deps='''samba-util
459 LIBASYNC_REQ
460 sys_rw
461 tevent-util
462 replace
463 talloc
464 tevent
466 popt
467 ''')
469 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
470 source='common/logging_conf.c',
471 deps='ctdb-util talloc')
473 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
474 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
475 deps='talloc tdb')
477 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
478 source=bld.SUBDIR('protocol',
479 '''protocol_header.c protocol_packet.c
480 protocol_types.c
481 protocol_call.c
482 protocol_message.c
483 protocol_control.c
484 protocol_keepalive.c
485 protocol_tunnel.c
486 protocol_client.c
487 protocol_debug.c
488 protocol_sock.c'''),
489 deps='ctdb-protocol-basic replace talloc tdb')
491 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
492 source='protocol/protocol_util.c',
493 deps='ctdb-util replace talloc tdb')
495 bld.SAMBA_SUBSYSTEM('ctdb-client',
496 source=bld.SUBDIR('client',
497 '''client_connect.c client_call.c
498 client_message.c client_control.c
499 client_message_sync.c
500 client_control_sync.c
501 client_db.c client_util.c
502 client_tunnel.c
503 '''),
504 deps='''ctdb-protocol
505 ctdb-util
506 samba-util
507 replace
508 talloc
509 tevent
511 tdb-wrap
512 ''')
514 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
515 source=bld.SUBDIR('common',
516 '''sock_daemon.c'''),
517 deps='''samba-util ctdb-util ctdb-system tevent-util
518 LIBASYNC_REQ replace talloc tevent''')
520 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
521 source=bld.SUBDIR('server',
522 '''ipalloc_deterministic.c
523 ipalloc_nondeterministic.c
524 ipalloc_lcp2.c
525 ipalloc_common.c
526 ipalloc.c
527 '''),
528 includes='include',
529 deps='ctdb-protocol-util replace talloc tevent')
531 bld.SAMBA_BINARY('ctdb-path',
532 source='common/path_tool.c',
533 cflags='-DCTDB_PATH_TOOL',
534 deps='''ctdb-util samba-util talloc replace popt''',
535 install_path='${CTDB_HELPER_BINDIR}')
537 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
538 source='cluster/cluster_conf.c',
539 deps='ctdb-util')
541 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
542 source='database/database_conf.c',
543 deps='ctdb-util')
545 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
546 source='event/event_conf.c',
547 deps='ctdb-util')
549 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
550 source='failover/failover_conf.c',
551 deps='ctdb-util')
553 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
554 source='server/legacy_conf.c',
555 deps='ctdb-util')
557 bld.SAMBA_BINARY('ctdb-config',
558 source='common/conf_tool.c',
559 cflags='-DCTDB_CONF_TOOL',
560 deps='''ctdb-logging-conf
561 ctdb-event-conf
562 ctdb-cluster-conf
563 ctdb-database-conf
564 ctdb-failover-conf
565 ctdb-legacy-conf
566 ctdb-util samba-util talloc replace popt''',
567 install_path='${CTDB_HELPER_BINDIR}')
569 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
570 source=bld.SUBDIR('event',
571 '''event_protocol.c
572 event_protocol_util.c
573 '''),
574 deps='ctdb-protocol-basic')
576 bld.SAMBA_LIBRARY('ctdb-event-client',
577 source='event/event_client.c',
578 deps='ctdb-event-protocol ctdb-util tevent talloc',
579 private_library=True)
581 bld.SAMBA_BINARY('ctdb-eventd',
582 source=bld.SUBDIR('event',
583 '''event_cmd.c
584 event_config.c
585 event_context.c
586 event_daemon.c
587 event_request.c
588 '''),
589 deps='''ctdb-event-protocol
590 ctdb-event-conf ctdb-logging-conf
591 ctdb-server-util samba-util ctdb-util
592 talloc tevent replace popt''',
593 install_path='${CTDB_HELPER_BINDIR}')
595 bld.SAMBA_BINARY('ctdb-event',
596 source='event/event_tool.c',
597 cflags='-DCTDB_EVENT_TOOL',
598 deps='''ctdb-event-client ctdb-event-protocol
599 ctdb-util samba-util talloc replace''',
600 install_path='${CTDB_HELPER_BINDIR}')
602 bld.SAMBA_BINARY('ctdbd',
603 source='server/ctdbd.c ' +
604 bld.SUBDIR('server',
605 '''ctdb_daemon.c ctdb_recoverd.c
606 ctdb_recover.c ctdb_freeze.c
607 ctdb_tunables.c ctdb_monitor.c
608 ctdb_server.c ctdb_control.c
609 ctdb_call.c ctdb_ltdb_server.c
610 ctdb_traverse.c eventscript.c
611 ctdb_takeover.c
612 ctdb_persistent.c ctdb_keepalive.c
613 ctdb_cluster_mutex.c
614 ctdb_logging.c
615 ctdb_uptime.c
616 ctdb_vacuum.c ctdb_banning.c
617 ctdb_statistics.c
618 ctdb_update_record.c
619 ctdb_lock.c ctdb_fork.c
620 ctdb_tunnel.c ctdb_client.c
621 ctdb_config.c
622 '''),
623 includes='include',
624 deps='''ctdb-common ctdb-system ctdb-protocol
625 ctdb-tcp ctdb-util replace sys_rw popt
626 ctdb-logging-conf
627 ctdb-cluster-conf
628 ctdb-database-conf
629 ctdb-event-conf
630 ctdb-failover-conf
631 ctdb-legacy-conf
632 ctdb-event-protocol
633 talloc tevent tdb-wrap tdb talloc_report''' +
634 ib_deps,
635 install_path='${SBINDIR}',
636 manpages='ctdbd.1')
638 bld.SAMBA_BINARY('ctdb',
639 source='tools/ctdb.c',
640 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
641 ctdb-util ctdb-system samba-util sys_rw popt''',
642 install_path='${BINDIR}',
643 manpages='ctdb.1')
645 bld.SAMBA_BINARY('ctdb_killtcp',
646 source='tools/ctdb_killtcp.c',
647 deps='''ctdb-protocol-util ctdb-util ctdb-system
648 samba-util replace''',
649 install_path='${CTDB_HELPER_BINDIR}')
651 bld.SAMBA_BINARY('ltdbtool',
652 source='tools/ltdbtool.c',
653 includes='include',
654 deps='tdb',
655 install_path='${BINDIR}',
656 manpages='ltdbtool.1')
658 bld.SAMBA_BINARY('ctdb_lock_helper',
659 source='server/ctdb_lock_helper.c',
660 deps='''samba-util sys_rw ctdb-system tevent-util
661 talloc tevent tdb''',
662 includes='include',
663 install_path='${CTDB_HELPER_BINDIR}')
665 bld.SAMBA_BINARY('ctdb_recovery_helper',
666 source='server/ctdb_recovery_helper.c',
667 deps='''ctdb-client ctdb-protocol ctdb-util
668 samba-util sys_rw replace tdb''',
669 install_path='${CTDB_HELPER_BINDIR}')
671 bld.SAMBA_BINARY('ctdb_takeover_helper',
672 source='server/ctdb_takeover_helper.c',
673 deps='''ctdb-client ctdb-protocol ctdb-util
674 samba-util sys_rw replace ctdb-ipalloc popt''',
675 install_path='${CTDB_HELPER_BINDIR}')
677 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
678 source='server/ctdb_mutex_fcntl_helper.c',
679 deps='''sys_rw ctdb-system tevent-util ctdb-util
680 talloc tevent
681 ''',
682 includes='include',
683 install_path='${CTDB_HELPER_BINDIR}')
685 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
686 source='utils/smnotify/smnotify.x',
687 target='utils/smnotify/smnotify.h',
688 rule='rpcgen -h ${SRC} > ${TGT}')
690 xdr_buf_hack = 'grep -Fv "register int32_t *buf;"'
692 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
693 source='utils/smnotify/smnotify.x',
694 target='utils/smnotify/gen_xdr.c',
695 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
697 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
698 source='utils/smnotify/smnotify.x',
699 target='utils/smnotify/gen_smnotify.c',
700 rule='rpcgen -l ${SRC} > ${TGT}')
702 bld.SAMBA_BINARY('smnotify',
703 source=bld.SUBDIR('utils/smnotify',
704 'smnotify.c gen_smnotify.c gen_xdr.c'),
705 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
706 includes='utils utils/smnotify',
707 install_path='${CTDB_HELPER_BINDIR}')
709 bld.SAMBA_BINARY('ping_pong',
710 source='utils/ping_pong/ping_pong.c',
711 deps='',
712 install_path='${BINDIR}',
713 manpages='ping_pong.1')
715 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
716 bld.SAMBA_BINARY('tdb_mutex_check',
717 source='utils/tdb/tdb_mutex_check.c',
718 deps='tdb pthread',
719 install_path='${CTDB_HELPER_BINDIR}')
721 if bld.env.HAVE_PMDA:
722 bld.SAMBA_BINARY('pmdactdb',
723 source='utils/pmda/pmda_ctdb.c',
724 deps='''ctdb-client ctdb-protocol ctdb-util
725 samba-util pcp_pmda pcp''',
726 install_path='${CTDB_PMDADIR}')
727 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
728 destname='Install')
729 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
730 destname='Remove')
731 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
732 destname='pmns')
733 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
734 destname='domain.h')
735 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
736 destname='help')
737 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
738 destname='README')
740 if bld.env.HAVE_LIBRADOS:
741 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
742 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
743 deps='talloc tevent rados',
744 includes='include',
745 install_path='${CTDB_HELPER_BINDIR}')
747 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
748 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
749 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
750 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
751 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
752 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
753 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
754 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
755 sed_cmdline = '-e "%s" ' * 8 % \
756 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
757 sed_expr6, sed_expr7, sed_expr8)
759 manpages_extra = list(manpages_misc)
760 if bld.env.etcd_reclock:
761 manpages_extra += manpages_etcd
762 if bld.env.HAVE_LIBRADOS:
763 manpages_extra += manpages_ceph
764 for f in manpages_binary + manpages_extra:
765 x = '%s.xml' % (f)
766 bld.SAMBA_GENERATOR(x,
767 source=os.path.join('doc', x),
768 target=x,
769 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
771 if bld.env.ctdb_generate_manpages:
772 bld.MANPAGES(' '.join(manpages_extra), True)
773 else:
774 for m in bld.env.ctdb_prebuilt_manpages:
775 bld.SAMBA_GENERATOR(m,
776 source=os.path.join("doc", m),
777 target=m,
778 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
779 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
781 bld.SAMBA_GENERATOR('ctdb-onnode',
782 source='tools/onnode',
783 target='onnode',
784 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
785 bld.INSTALL_FILES('${BINDIR}', 'onnode',
786 destname='onnode', chmod=MODE_755)
788 bld.SAMBA_GENERATOR('ctdb-diagnostics',
789 source='tools/ctdb_diagnostics',
790 target='ctdb_diagnostics',
791 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
792 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
793 destname='ctdb_diagnostics', chmod=MODE_755)
795 if bld.env.etcd_reclock:
796 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
797 source='utils/etcd/ctdb_etcd_lock',
798 target='ctdb_etcd_lock',
799 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
800 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
801 destname='ctdb_etcd_lock', chmod=MODE_744)
803 bld.SAMBA_GENERATOR('ctdb-natgw',
804 source='tools/ctdb_natgw',
805 target='ctdb_natgw',
806 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
807 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
808 destname='ctdb_natgw', chmod=MODE_755)
810 bld.SAMBA_GENERATOR('ctdb-lvs',
811 source='tools/ctdb_lvs',
812 target='ctdb_lvs',
813 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
814 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
815 destname='ctdb_lvs', chmod=MODE_755)
817 def SUBDIR_MODE_callback(arg, dirname, fnames):
818 for f in fnames:
819 fl = os.path.join(dirname, f)
820 if os.path.isdir(fl) or os.path.islink(fl):
821 continue
822 mode = os.lstat(fl).st_mode & MODE_777
823 if arg['trim_path']:
824 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
825 arg['file_list'].append([fl, mode])
827 def SUBDIR_MODE(path, trim_path=None):
828 pd = {'trim_path': trim_path, 'file_list': []}
829 for dirname, _subdirs, fnames in os.walk(path):
830 SUBDIR_MODE_callback(pd, dirname, fnames)
831 return pd['file_list']
833 event_script_subdirs = [
834 'events/legacy',
837 etc_subdirs = [
838 'nfs-checks.d'
841 if bld.env.standalone_ctdb:
842 configdir = 'config'
843 else:
844 configdir = 'ctdb/config'
846 for t in event_script_subdirs:
847 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
848 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
849 for fmode in files:
850 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
851 destname=fmode[0], chmod=fmode[1])
853 for t in etc_subdirs:
854 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
855 for fmode in files:
856 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
857 destname=fmode[0], chmod=fmode[1])
859 # If this is a direct install and there are no event scripts
860 # linked/enabled then enable some standard ones
861 if os.environ.get('DESTDIR') is None:
862 fmt = 'events/legacy/%s.script'
863 required_script = '00.ctdb'
864 required_path = os.path.join(bld.env.CTDB_ETCDIR,
865 fmt % (required_script))
866 if not os.path.islink(required_path) and \
867 not os.path.exists(required_path):
868 default_scripts = [ required_script,
869 '01.reclock',
870 '05.system',
871 '10.interface',
873 for t in default_scripts:
874 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
875 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
876 bld.symlink_as(name, tgt)
878 bld.SAMBA_GENERATOR('ctdb-functions',
879 source='config/functions',
880 target='functions',
881 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
882 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
884 etc_scripts = [
885 'ctdb-crash-cleanup.sh',
886 'debug-hung-script.sh',
887 'debug_locks.sh',
888 'nfs-linux-kernel-callout',
889 'notify.sh',
890 'statd-callout'
893 for t in etc_scripts:
894 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
895 destname=t, chmod=MODE_755)
897 bld.SAMBA_GENERATOR('ctdb-sudoers',
898 source='config/ctdb.sudoers',
899 target='ctdb.sudoers',
900 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
901 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
902 destname='ctdb')
904 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
905 'config/notification.README',
906 destname='README')
908 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
909 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
910 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
912 for d in ['volatile', 'persistent', 'state']:
913 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
916 # Test-only below this point
919 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
920 return
922 bld.SAMBA_BINARY('errcode',
923 source='tests/src/errcode.c',
924 deps='replace',
925 install_path='${CTDB_TEST_LIBEXECDIR}')
927 bld.SAMBA_BINARY('sigcode',
928 source='tests/src/sigcode.c',
929 deps='replace',
930 install_path='${CTDB_TEST_LIBEXECDIR}')
932 # Unit tests
933 ctdb_util_tests = [
934 'cmdline_test',
935 'comm_client_test',
936 'comm_server_test',
937 'comm_test',
938 'conf_test',
939 'db_hash_test',
940 'event_script_test',
941 'hash_count_test',
942 'line_test',
943 'pidfile_test',
944 'pkt_read_test',
945 'pkt_write_test',
946 'run_event_test',
947 'run_proc_test',
948 'sock_io_test',
949 'srvid_test',
950 'tunable_test',
953 for target in ctdb_util_tests:
954 src = 'tests/src/' + target + '.c'
956 bld.SAMBA_BINARY(target,
957 source=src,
958 deps='''ctdb-tests-backtrace
959 LIBASYNC_REQ
960 samba-util
961 sys_rw
962 tevent-util
963 talloc
964 tevent
966 popt
967 ''',
968 install_path='${CTDB_TEST_LIBEXECDIR}')
970 bld.SAMBA_BINARY('reqid_test',
971 source='tests/src/reqid_test.c',
972 deps='samba-util talloc',
973 install_path='${CTDB_TEST_LIBEXECDIR}')
975 bld.SAMBA_BINARY('rb_test',
976 source='tests/src/rb_test.c',
977 deps='samba-util talloc',
978 install_path='${CTDB_TEST_LIBEXECDIR}')
980 bld.SAMBA_BINARY('ctdb_packet_parse',
981 source='tests/src/ctdb_packet_parse.c',
982 deps='talloc tevent tdb ctdb-protocol',
983 install_path='${CTDB_TEST_LIBEXECDIR}')
985 bld.SAMBA_BINARY('system_socket_test',
986 source='tests/src/system_socket_test.c',
987 deps='''ctdb-tests-backtrace
988 talloc
989 ctdb-protocol-util
990 pcap
991 ''',
992 install_path='${CTDB_TEST_LIBEXECDIR}')
994 bld.SAMBA_BINARY('porting_tests',
995 source='tests/src/porting_tests.c',
996 deps='samba-util ctdb-system popt',
997 install_path='${CTDB_TEST_LIBEXECDIR}')
999 bld.SAMBA_BINARY('sock_daemon_test',
1000 source='tests/src/sock_daemon_test.c',
1001 deps='''ctdb-system talloc tevent tevent-util
1002 LIBASYNC_REQ samba-util sys_rw''',
1003 install_path='${CTDB_TEST_LIBEXECDIR}')
1005 bld.SAMBA_BINARY('ctdb_io_test',
1006 source='tests/src/ctdb_io_test.c',
1007 deps='''talloc tevent tdb samba-util sys_rw''',
1008 install_path='${CTDB_TEST_LIBEXECDIR}')
1010 bld.SAMBA_BINARY('ctdb-db-test',
1011 source='tests/src/db_test_tool.c',
1012 cflags='-DCTDB_DB_TEST_TOOL',
1013 deps='''ctdb-client ctdb-protocol
1014 ctdb-util samba-util talloc tevent replace''',
1015 install_path='${CTDB_TEST_LIBEXECDIR}')
1017 for target in ['tmon_ping_test', 'tmon_test']:
1018 src = 'tests/src/' + target + '.c'
1020 bld.SAMBA_BINARY(target,
1021 source=src,
1022 deps='''ctdb-util
1023 ctdb-tests-backtrace
1024 LIBASYNC_REQ
1025 samba-util
1026 sys_rw
1027 tevent-util
1028 talloc
1029 tevent
1031 popt
1032 ''',
1033 install_path='${CTDB_TEST_LIBEXECDIR}')
1035 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
1036 source=bld.SUBDIR('tests/src',
1037 'protocol_common_basic.c'),
1038 deps='samba-util replace talloc')
1040 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
1041 source=bld.SUBDIR('tests/src',
1042 '''protocol_common.c
1043 protocol_common_ctdb.c
1044 '''),
1045 deps='ctdb-protocol-tests-basic replace talloc tdb')
1047 bld.SAMBA_BINARY('protocol_basic_test',
1048 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
1049 deps='ctdb-protocol-tests-basic talloc',
1050 install_path='${CTDB_TEST_LIBEXECDIR}')
1052 ctdb_protocol_tests = [
1053 'protocol_types_test',
1054 'protocol_ctdb_test',
1055 'protocol_util_test',
1056 'protocol_types_compat_test',
1057 'protocol_ctdb_compat_test',
1060 for target in ctdb_protocol_tests:
1061 src = 'tests/src/' + target + '.c'
1063 bld.SAMBA_BINARY(target,
1064 source=src,
1065 deps='''ctdb-protocol-tests-common
1066 samba-util ctdb-util talloc tdb''',
1067 install_path='${CTDB_TEST_LIBEXECDIR}')
1069 bld.SAMBA_BINARY('event_protocol_test',
1070 source='event/event_protocol_test.c',
1071 deps='''ctdb-protocol-tests-basic
1072 ctdb-protocol-basic talloc''',
1073 install_path='${CTDB_TEST_LIBEXECDIR}')
1075 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
1076 source=bld.SUBDIR('tests/src',
1077 '''cluster_wait.c
1078 test_options.c
1079 '''),
1080 deps='''ctdb-client
1081 samba-util
1082 replace
1083 popt
1084 talloc
1085 tevent
1086 tdb''')
1088 bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace',
1089 source=bld.SUBDIR('tests/src',
1090 'test_backtrace.c'),
1091 deps='''samba-util
1092 replace''')
1094 # Test binaries
1095 ctdb_tests = [
1096 'g_lock_loop',
1097 'message_ring',
1098 'fetch_ring',
1099 'fetch_loop',
1100 'fetch_loop_key',
1101 'fetch_readonly',
1102 'fetch_readonly_loop',
1103 'transaction_loop',
1104 'update_record',
1105 'update_record_persistent',
1106 'lock_tdb',
1107 'dummy_client',
1108 'tunnel_test',
1109 'tunnel_cmd',
1112 for target in ctdb_tests:
1113 src = 'tests/src/' + target + '.c'
1115 bld.SAMBA_BINARY(target,
1116 source=src,
1117 includes='include',
1118 deps='''ctdb-client ctdb-protocol ctdb-util
1119 samba-util ctdb-tests-common''',
1120 install_path='${CTDB_TEST_LIBEXECDIR}')
1122 bld.SAMBA_BINARY('ctdb_takeover_tests',
1123 source='''tests/src/ctdb_takeover_tests.c
1124 tests/src/ipalloc_read_known_ips.c''',
1125 deps='''replace popt tdb tevent talloc ctdb-system
1126 samba-util tdb-wrap talloc_report
1127 ctdb-ipalloc ctdb-protocol ctdb-util''',
1128 includes='include',
1129 install_path='${CTDB_TEST_LIBEXECDIR}')
1131 bld.SAMBA_BINARY('fake_ctdbd',
1132 source='''tests/src/fake_ctdbd.c
1133 tests/src/ipalloc_read_known_ips.c''',
1134 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1135 ctdb-system samba-util tevent-util
1136 LIBASYNC_REQ popt''',
1137 install_path='${CTDB_TEST_LIBEXECDIR}')
1139 bld.SAMBA_BINARY('cluster_mutex_test',
1140 source='tests/src/cluster_mutex_test.c',
1141 deps='''ctdb-tests-backtrace
1142 samba-util
1143 talloc
1144 tevent
1145 ''',
1146 install_path='${CTDB_TEST_LIBEXECDIR}')
1148 if bld.env.HAVE_INFINIBAND:
1149 bld.SAMBA_BINARY('ibwrapper_test',
1150 source='ib/ibwrapper_test.c',
1151 includes='include',
1152 deps='replace talloc ctdb-common sys_rw' +
1153 ib_deps,
1154 install_path='${CTDB_TEST_LIBEXECDIR}')
1156 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1157 bld.SAMBA_BINARY('test_mutex_raw',
1158 source='tests/src/test_mutex_raw.c',
1159 deps='pthread',
1160 install_path='${CTDB_TEST_LIBEXECDIR}')
1162 test_subdirs = [
1163 'CLUSTER',
1164 'INTEGRATION',
1165 'UNIT',
1166 'etc-ctdb'
1169 if bld.env.standalone_ctdb:
1170 testdir = 'tests'
1171 else:
1172 testdir = 'ctdb/tests'
1174 for t in test_subdirs:
1175 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1176 for fmode in files:
1177 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1178 destname=fmode[0], chmod=fmode[1])
1180 # Install tests/scripts directory, excluding files that need munging
1181 test_scripts = [
1182 'cluster.bash',
1183 'common.sh',
1184 'integration.bash',
1185 'integration_local_daemons.bash',
1186 'integration_real_cluster.bash',
1187 'unit.sh'
1190 for t in test_scripts:
1191 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1192 os.path.join('tests/scripts', t),
1193 destname=os.path.join('scripts', t))
1195 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1196 'tests/scripts/test_wrap',
1197 destname='scripts/test_wrap',
1198 chmod=MODE_755)
1200 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1201 source='tests/scripts/script_install_paths.sh',
1202 target='script_install_paths.sh',
1203 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1204 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1205 'script_install_paths.sh',
1206 destname='script_install_paths.sh', chmod=MODE_644)
1208 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1209 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1210 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1211 bld.SAMBA_GENERATOR('ctdb-test-runner',
1212 source='tests/run_tests.sh',
1213 target='ctdb_run_tests.sh',
1214 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1215 sed_expr1, sed_expr2))
1216 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1217 destname='ctdb_run_tests', chmod=MODE_755)
1218 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1219 'ctdb_run_tests')
1221 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1222 source='tests/local_daemons.sh',
1223 target='ctdb_local_daemons.sh',
1224 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1225 sed_expr1, sed_expr2))
1226 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1227 destname='ctdb_local_daemons', chmod=MODE_755)
1230 def testonly(ctx):
1231 cmd = 'tests/run_tests.sh'
1232 ret = samba_utils.RUN_COMMAND(cmd)
1233 if ret != 0:
1234 print('tests exited with exit status %d' % ret)
1235 sys.exit(ret)
1238 def test(ctx):
1239 Options.commands.append('build')
1240 Options.commands.append('testonly')
1243 def autotest(ctx):
1244 env = samba_utils.LOAD_ENVIRONMENT()
1245 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1246 ret = samba_utils.RUN_COMMAND(cmd)
1247 if ret != 0:
1248 print('autotest exited with exit status %d' % ret)
1249 sys.exit(ret)
1252 def show_version(ctx):
1253 print(get_version_string())
1256 def manpages(ctx):
1257 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1258 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1259 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1260 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1261 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1262 for t in manpages:
1263 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1264 ret = samba_utils.RUN_COMMAND(cmd)
1265 if ret != 0:
1266 print('Command %s failed with exit status %d' % (cmd, ret))
1267 sys.exit(ret)
1269 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1270 ret = samba_utils.RUN_COMMAND(cmd)
1271 if ret != 0:
1272 print('Command %s failed with exit status %d' % (cmd, ret))
1273 sys.exit(ret)
1276 def distonly(ctx):
1277 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1279 t = 'ctdb.spec'
1280 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1281 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1282 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1283 sed_expr1, sed_expr2, t)
1284 ret = samba_utils.RUN_COMMAND(cmd)
1285 if ret != 0:
1286 print('Command "%s" failed with exit status %d' % (cmd, ret))
1287 sys.exit(ret)
1288 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1290 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1291 for t in manpages:
1292 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1293 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1294 extend=True)
1296 samba_dist.dist()
1299 def dist():
1300 Options.commands.append('manpages')
1301 Options.commands.append('distonly')
1304 def rpmonly(ctx):
1305 opts = os.getenv('RPM_OPTIONS') or ''
1306 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1307 (opts, get_version_string())
1308 ret = samba_utils.RUN_COMMAND(cmd)
1309 if ret != 0:
1310 print('rpmbuild exited with exit status %d' % ret)
1311 sys.exit(ret)
1314 def rpm(ctx):
1315 Options.commands.append('manpages')
1316 Options.commands.append('distonly')
1317 Options.commands.append('rpmonly')
1320 def ctags(ctx):
1321 "build 'tags' file using ctags"
1322 source_root = os.path.dirname(Context.g_module.root_path)
1323 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1324 print("Running: %s" % cmd)
1325 ret = samba_utils.RUN_COMMAND(cmd)
1326 if ret != 0:
1327 print('ctags failed with exit status %d' % ret)
1328 sys.exit(ret)