s4:kdc: Add helper function to extract AES256 key and salt
[Samba.git] / ctdb / wscript
blobc3435c37eeb38485f012c87caaf25eaacb5bdde0
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)
102 opt.add_option('--with-libcephfs',
103 help=("Directory under which libcephfs is installed"),
104 action="store", dest='libcephfs_dir', default=None)
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 sys.platform.startswith('linux'):
205 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
206 else:
207 if not conf.CHECK_HEADERS('pcap.h'):
208 Logs.error('Need libpcap')
209 sys.exit(1)
210 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
211 Logs.error('Need libpcap')
212 sys.exit(1)
214 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
215 checklibc=True, headers='execinfo.h'):
216 Logs.error('backtrace support not available')
218 have_pmda = False
219 if Options.options.ctdb_pmda:
220 pmda_support = True
222 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
223 together=True):
224 pmda_support = False
225 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
226 pmda_support = False
227 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
228 pmda_support = False
229 if pmda_support:
230 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
231 have_pmda = True
232 else:
233 Logs.error("PMDA support not available")
234 sys.exit(1)
235 if have_pmda:
236 Logs.info('Building with PMDA support')
237 conf.define('HAVE_PMDA', 1)
238 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
239 'lib/pcp/pmdas/ctdb')
241 have_infiniband = False
242 if Options.options.ctdb_infiniband:
243 ib_support = True
245 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
246 ib_support = False
247 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
248 ib_support = False
249 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
250 ib_support = False
251 if ib_support:
252 have_infiniband = True
253 else:
254 Logs.error("Infiniband support not available")
255 sys.exit(1)
256 if have_infiniband:
257 Logs.info('Building with Infiniband support')
258 conf.define('HAVE_INFINIBAND', 1)
259 conf.define('USE_INFINIBAND', 1)
261 have_etcd_reclock = False
262 if Options.options.ctdb_etcd_reclock:
263 try:
264 conf.check_python_module('etcd')
265 have_etcd_reclock = True
266 except:
267 Logs.error('etcd support not available')
268 sys.exit(1)
269 if have_etcd_reclock:
270 Logs.info('Building with etcd support')
271 conf.env.etcd_reclock = have_etcd_reclock
273 if Options.options.libcephfs_dir:
274 Logs.error('''--with-libcephfs no longer supported, please use compiler
275 flags instead, e.g. GCC LIBRARY_PATH and C_INCLUDE_PATH''')
276 sys.exit(1)
278 if Options.options.ctdb_ceph_reclock:
279 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
280 conf.CHECK_LIB('rados', shlib=True)):
281 Logs.info('Building with Ceph librados recovery lock support')
282 conf.define('HAVE_LIBRADOS', 1)
283 else:
284 Logs.error("Missing librados for Ceph recovery lock support")
285 sys.exit(1)
287 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
288 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
289 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
290 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
291 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
292 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
294 if Options.options.ctdb_logdir:
295 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
296 else:
297 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
299 if Options.options.ctdb_sockpath:
300 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
301 else:
302 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
303 'ctdbd.socket')
304 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
306 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
307 -DLOGDIR=\"%s\"
308 -DCTDB_DATADIR=\"%s\"
309 -DCTDB_ETCDIR=\"%s\"
310 -DCTDB_VARDIR=\"%s\"
311 -DCTDB_RUNDIR=\"%s\"''' % (
312 conf.env.CTDB_HELPER_BINDIR,
313 conf.env.CTDB_LOGDIR,
314 conf.env.CTDB_DATADIR,
315 conf.env.CTDB_ETCDIR,
316 conf.env.CTDB_VARDIR,
317 conf.env.CTDB_RUNDIR))
319 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
320 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
322 # Allow unified compilation and separate compilation of utilities
323 # to find includes
324 if not conf.env.standalone_ctdb:
325 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
326 else:
327 if Context.g_module.top == '.':
328 # Building from tarball
329 conf.ADD_EXTRA_INCLUDES('#include')
330 else:
331 # Building standalone CTDB from within Samba tree
332 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
333 conf.ADD_EXTRA_INCLUDES('#ctdb')
334 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
336 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
337 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
338 conf.SAMBA_CONFIG_H()
340 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
341 conf.env.ctdb_generate_manpages = True
342 else:
343 conf.env.ctdb_generate_manpages = False
345 Logs.info("xsltproc unavailable, checking for pre-built manpages")
346 conf.env.ctdb_prebuilt_manpages = []
347 manpages = manpages_binary + manpages_misc
348 if conf.env.etcd_reclock:
349 manpages += manpages_etcd
350 if conf.env.HAVE_LIBRADOS:
351 manpages += manpages_ceph
352 for m in manpages:
353 if os.path.exists(os.path.join("doc", m)):
354 Logs.info(" %s: yes" % (m))
355 conf.env.ctdb_prebuilt_manpages.append(m)
356 else:
357 Logs.info(" %s: no" % (m))
359 def build(bld):
360 if bld.env.standalone_ctdb:
361 # enable building of public headers in the build tree
362 bld.env.build_public_headers = 'include/public'
364 if bld.env.standalone_ctdb:
365 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
367 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
369 bld.RECURSE('lib/replace')
370 if bld.CHECK_FOR_THIRD_PARTY():
371 bld.RECURSE('third_party/popt')
372 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
373 bld.RECURSE('third_party/socket_wrapper')
375 bld.RECURSE('lib/tdb_wrap')
376 bld.RECURSE('lib/util')
377 bld.RECURSE('lib/async_req')
378 bld.RECURSE('lib/pthreadpool')
379 bld.RECURSE('lib/messaging')
381 bld.RECURSE('lib/talloc')
382 bld.RECURSE('lib/tevent')
383 bld.RECURSE('lib/tdb')
385 if bld.env.standalone_ctdb:
386 # If a combined build is implemented, CTDB will want to
387 # build against samba-util rather than samba-util-core.
388 # Similarly, other Samba subsystems expect samba-util. So,
389 # for a standalone build, just define a fake samba-util
390 # subsystem that pulls in samba-util-core.
391 bld.SAMBA_SUBSYSTEM('samba-util',
392 source='',
393 deps='samba-util-core')
395 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
396 source=bld.SUBDIR('tcp',
397 'tcp_connect.c tcp_init.c tcp_io.c'),
398 includes='include',
399 deps='replace tdb talloc tevent')
401 ib_deps = ''
402 if bld.env.HAVE_INFINIBAND:
403 bld.SAMBA_SUBSYSTEM('ctdb-ib',
404 source=bld.SUBDIR('ib',
405 '''ibwrapper.c ibw_ctdb.c
406 ibw_ctdb_init.c'''),
407 includes='include',
408 deps='replace talloc tevent tdb')
409 ib_deps = ' ctdb-ib rdmacm ibverbs'
411 bld.SAMBA_SUBSYSTEM('ctdb-system',
412 source=bld.SUBDIR('common',
413 'system_socket.c system.c'),
414 deps='replace talloc tevent tdb pcap samba-util')
416 bld.SAMBA_SUBSYSTEM('ctdb-common',
417 source=bld.SUBDIR('common',
418 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
419 sock_io.c'''),
420 includes='include',
421 deps='''replace popt talloc tevent tdb popt ctdb-system
422 ctdb-protocol-util''')
424 bld.SAMBA_SUBSYSTEM('ctdb-util',
425 source=bld.SUBDIR('common',
426 '''db_hash.c srvid.c reqid.c
427 pkt_read.c pkt_write.c comm.c
428 logging.c rb_tree.c tunable.c
429 pidfile.c run_proc.c
430 hash_count.c
431 run_event.c event_script.c
432 sock_client.c
433 cmdline.c path.c conf.c line.c
434 '''),
435 deps='''samba-util sys_rw tevent-util
436 replace talloc tevent tdb popt''')
438 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
439 source='common/logging_conf.c',
440 deps='ctdb-util talloc')
442 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
443 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
444 deps='talloc tdb')
446 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
447 source=bld.SUBDIR('protocol',
448 '''protocol_header.c protocol_packet.c
449 protocol_types.c
450 protocol_call.c
451 protocol_message.c
452 protocol_control.c
453 protocol_keepalive.c
454 protocol_tunnel.c
455 protocol_client.c
456 protocol_debug.c
457 protocol_sock.c'''),
458 deps='ctdb-protocol-basic replace talloc tdb')
460 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
461 source='protocol/protocol_util.c',
462 deps='ctdb-util replace talloc tdb')
464 bld.SAMBA_SUBSYSTEM('ctdb-client',
465 source=bld.SUBDIR('client',
466 '''client_connect.c client_call.c
467 client_message.c client_control.c
468 client_message_sync.c
469 client_control_sync.c
470 client_db.c client_util.c
471 client_tunnel.c
472 '''),
473 deps='''ctdb-protocol
474 ctdb-util
475 samba-util
476 replace
477 talloc
478 tevent
480 tdb-wrap
481 ''')
483 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
484 source=bld.SUBDIR('common',
485 '''sock_daemon.c'''),
486 deps='''samba-util ctdb-util ctdb-system tevent-util
487 LIBASYNC_REQ replace talloc tevent''')
489 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
490 source=bld.SUBDIR('server',
491 '''ipalloc_deterministic.c
492 ipalloc_nondeterministic.c
493 ipalloc_lcp2.c
494 ipalloc_common.c
495 ipalloc.c
496 '''),
497 includes='include',
498 deps='ctdb-protocol-util replace talloc tevent')
500 bld.SAMBA_BINARY('ctdb-path',
501 source='common/path_tool.c',
502 cflags='-DCTDB_PATH_TOOL',
503 deps='''ctdb-util samba-util talloc replace popt''',
504 install_path='${CTDB_HELPER_BINDIR}')
506 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
507 source='cluster/cluster_conf.c',
508 deps='ctdb-util')
510 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
511 source='database/database_conf.c',
512 deps='ctdb-util')
514 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
515 source='event/event_conf.c',
516 deps='ctdb-util')
518 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
519 source='failover/failover_conf.c',
520 deps='ctdb-util')
522 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
523 source='server/legacy_conf.c',
524 deps='ctdb-util')
526 bld.SAMBA_BINARY('ctdb-config',
527 source='common/conf_tool.c',
528 cflags='-DCTDB_CONF_TOOL',
529 deps='''ctdb-logging-conf
530 ctdb-event-conf
531 ctdb-cluster-conf
532 ctdb-database-conf
533 ctdb-failover-conf
534 ctdb-legacy-conf
535 ctdb-util samba-util talloc replace popt''',
536 install_path='${CTDB_HELPER_BINDIR}')
538 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
539 source=bld.SUBDIR('event',
540 '''event_protocol.c
541 event_protocol_util.c
542 '''),
543 deps='ctdb-protocol-basic')
545 bld.SAMBA_LIBRARY('ctdb-event-client',
546 source='event/event_client.c',
547 deps='ctdb-event-protocol ctdb-util tevent talloc',
548 private_library=True)
550 bld.SAMBA_BINARY('ctdb-eventd',
551 source=bld.SUBDIR('event',
552 '''event_cmd.c
553 event_config.c
554 event_context.c
555 event_daemon.c
556 event_request.c
557 '''),
558 deps='''ctdb-event-protocol
559 ctdb-event-conf ctdb-logging-conf
560 ctdb-server-util samba-util ctdb-util
561 talloc tevent replace popt''',
562 install_path='${CTDB_HELPER_BINDIR}')
564 bld.SAMBA_BINARY('ctdb-event',
565 source='event/event_tool.c',
566 cflags='-DCTDB_EVENT_TOOL',
567 deps='''ctdb-event-client ctdb-event-protocol
568 ctdb-util samba-util talloc replace''',
569 install_path='${CTDB_HELPER_BINDIR}')
571 bld.SAMBA_BINARY('ctdbd',
572 source='server/ctdbd.c ' +
573 bld.SUBDIR('server',
574 '''ctdb_daemon.c ctdb_recoverd.c
575 ctdb_recover.c ctdb_freeze.c
576 ctdb_tunables.c ctdb_monitor.c
577 ctdb_server.c ctdb_control.c
578 ctdb_call.c ctdb_ltdb_server.c
579 ctdb_traverse.c eventscript.c
580 ctdb_takeover.c
581 ctdb_persistent.c ctdb_keepalive.c
582 ctdb_cluster_mutex.c
583 ctdb_logging.c
584 ctdb_uptime.c
585 ctdb_vacuum.c ctdb_banning.c
586 ctdb_statistics.c
587 ctdb_update_record.c
588 ctdb_lock.c ctdb_fork.c
589 ctdb_tunnel.c ctdb_client.c
590 ctdb_config.c
591 '''),
592 includes='include',
593 deps='''ctdb-common ctdb-system ctdb-protocol
594 ctdb-tcp ctdb-util replace sys_rw popt
595 ctdb-logging-conf
596 ctdb-cluster-conf
597 ctdb-database-conf
598 ctdb-event-conf
599 ctdb-failover-conf
600 ctdb-legacy-conf
601 ctdb-event-protocol
602 talloc tevent tdb-wrap tdb talloc_report''' +
603 ib_deps,
604 install_path='${SBINDIR}',
605 manpages='ctdbd.1')
607 bld.SAMBA_BINARY('ctdb',
608 source='tools/ctdb.c',
609 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
610 ctdb-util ctdb-system samba-util sys_rw popt''',
611 install_path='${BINDIR}',
612 manpages='ctdb.1')
614 bld.SAMBA_BINARY('ctdb_killtcp',
615 source='tools/ctdb_killtcp.c',
616 deps='''ctdb-protocol-util ctdb-util ctdb-system
617 samba-util replace''',
618 install_path='${CTDB_HELPER_BINDIR}')
620 bld.SAMBA_BINARY('ltdbtool',
621 source='tools/ltdbtool.c',
622 includes='include',
623 deps='tdb',
624 install_path='${BINDIR}',
625 manpages='ltdbtool.1')
627 bld.SAMBA_BINARY('ctdb_lock_helper',
628 source='server/ctdb_lock_helper.c',
629 deps='''samba-util sys_rw ctdb-system tevent-util
630 talloc tevent tdb''',
631 includes='include',
632 install_path='${CTDB_HELPER_BINDIR}')
634 bld.SAMBA_BINARY('ctdb_recovery_helper',
635 source='server/ctdb_recovery_helper.c',
636 deps='''ctdb-client ctdb-protocol ctdb-util
637 samba-util sys_rw replace tdb''',
638 install_path='${CTDB_HELPER_BINDIR}')
640 bld.SAMBA_BINARY('ctdb_takeover_helper',
641 source='server/ctdb_takeover_helper.c',
642 deps='''ctdb-client ctdb-protocol ctdb-util
643 samba-util sys_rw replace ctdb-ipalloc popt''',
644 install_path='${CTDB_HELPER_BINDIR}')
646 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
647 source='server/ctdb_mutex_fcntl_helper.c',
648 deps='''sys_rw ctdb-system tevent-util
649 talloc tevent
650 ''',
651 includes='include',
652 install_path='${CTDB_HELPER_BINDIR}')
654 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
655 source='utils/smnotify/smnotify.x',
656 target='utils/smnotify/smnotify.h',
657 rule='rpcgen -h ${SRC} > ${TGT}')
659 xdr_buf_hack = 'grep -Fv "register int32_t *buf;"'
661 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
662 source='utils/smnotify/smnotify.x',
663 target='utils/smnotify/gen_xdr.c',
664 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
666 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
667 source='utils/smnotify/smnotify.x',
668 target='utils/smnotify/gen_smnotify.c',
669 rule='rpcgen -l ${SRC} > ${TGT}')
671 bld.SAMBA_BINARY('smnotify',
672 source=bld.SUBDIR('utils/smnotify',
673 'smnotify.c gen_smnotify.c gen_xdr.c'),
674 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
675 includes='utils utils/smnotify',
676 install_path='${CTDB_HELPER_BINDIR}')
678 bld.SAMBA_BINARY('ping_pong',
679 source='utils/ping_pong/ping_pong.c',
680 deps='',
681 install_path='${BINDIR}',
682 manpages='ping_pong.1')
684 if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER:
685 bld.SAMBA_BINARY('tdb_mutex_check',
686 source='utils/tdb/tdb_mutex_check.c',
687 deps='tdb pthread',
688 install_path='${CTDB_HELPER_BINDIR}')
690 if bld.env.HAVE_PMDA:
691 bld.SAMBA_BINARY('pmdactdb',
692 source='utils/pmda/pmda_ctdb.c',
693 deps='''ctdb-client ctdb-protocol ctdb-util
694 samba-util pcp_pmda pcp''',
695 install_path='${CTDB_PMDADIR}')
696 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
697 destname='Install')
698 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
699 destname='Remove')
700 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
701 destname='pmns')
702 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
703 destname='domain.h')
704 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
705 destname='help')
706 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
707 destname='README')
709 if bld.env.HAVE_LIBRADOS:
710 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
711 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
712 deps='talloc tevent rados',
713 includes='include',
714 install_path='${CTDB_HELPER_BINDIR}')
716 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
717 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
718 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
719 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
720 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
721 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
722 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
723 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
724 sed_cmdline = '-e "%s" ' * 8 % \
725 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
726 sed_expr6, sed_expr7, sed_expr8)
728 manpages_extra = list(manpages_misc)
729 if bld.env.etcd_reclock:
730 manpages_extra += manpages_etcd
731 if bld.env.HAVE_LIBRADOS:
732 manpages_extra += manpages_ceph
733 for f in manpages_binary + manpages_extra:
734 x = '%s.xml' % (f)
735 bld.SAMBA_GENERATOR(x,
736 source=os.path.join('doc', x),
737 target=x,
738 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
740 if bld.env.ctdb_generate_manpages:
741 bld.MANPAGES(' '.join(manpages_extra), True)
742 else:
743 for m in bld.env.ctdb_prebuilt_manpages:
744 bld.SAMBA_GENERATOR(m,
745 source=os.path.join("doc", m),
746 target=m,
747 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
748 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
750 bld.SAMBA_GENERATOR('ctdb-onnode',
751 source='tools/onnode',
752 target='onnode',
753 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
754 bld.INSTALL_FILES('${BINDIR}', 'onnode',
755 destname='onnode', chmod=MODE_755)
757 bld.SAMBA_GENERATOR('ctdb-diagnostics',
758 source='tools/ctdb_diagnostics',
759 target='ctdb_diagnostics',
760 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
761 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
762 destname='ctdb_diagnostics', chmod=MODE_755)
764 if bld.env.etcd_reclock:
765 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
766 source='utils/etcd/ctdb_etcd_lock',
767 target='ctdb_etcd_lock',
768 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
769 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
770 destname='ctdb_etcd_lock', chmod=MODE_744)
772 bld.SAMBA_GENERATOR('ctdb-natgw',
773 source='tools/ctdb_natgw',
774 target='ctdb_natgw',
775 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
776 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
777 destname='ctdb_natgw', chmod=MODE_755)
779 bld.SAMBA_GENERATOR('ctdb-lvs',
780 source='tools/ctdb_lvs',
781 target='ctdb_lvs',
782 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
783 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
784 destname='ctdb_lvs', chmod=MODE_755)
786 def SUBDIR_MODE_callback(arg, dirname, fnames):
787 for f in fnames:
788 fl = os.path.join(dirname, f)
789 if os.path.isdir(fl) or os.path.islink(fl):
790 continue
791 mode = os.lstat(fl).st_mode & MODE_777
792 if arg['trim_path']:
793 fl = samba_utils.os.path.relpath(fl, arg['trim_path'])
794 arg['file_list'].append([fl, mode])
796 def SUBDIR_MODE(path, trim_path=None):
797 pd = {'trim_path': trim_path, 'file_list': []}
798 for dirname, _subdirs, fnames in os.walk(path):
799 SUBDIR_MODE_callback(pd, dirname, fnames)
800 return pd['file_list']
802 event_script_subdirs = [
803 'events/legacy',
806 etc_subdirs = [
807 'nfs-checks.d'
810 if bld.env.standalone_ctdb:
811 configdir = 'config'
812 else:
813 configdir = 'ctdb/config'
815 for t in event_script_subdirs:
816 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
817 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
818 for fmode in files:
819 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
820 destname=fmode[0], chmod=fmode[1])
822 for t in etc_subdirs:
823 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
824 for fmode in files:
825 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
826 destname=fmode[0], chmod=fmode[1])
828 # If this is a direct install and there are no event scripts
829 # linked/enabled then enable some standard ones
830 if os.environ.get('DESTDIR') is None:
831 fmt = 'events/legacy/%s.script'
832 required_script = '00.ctdb'
833 required_path = os.path.join(bld.env.CTDB_ETCDIR,
834 fmt % (required_script))
835 if not os.path.islink(required_path) and \
836 not os.path.exists(required_path):
837 default_scripts = [ required_script,
838 '01.reclock',
839 '05.system',
840 '10.interface',
842 for t in default_scripts:
843 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
844 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
845 bld.symlink_as(name, tgt)
847 bld.SAMBA_GENERATOR('ctdb-functions',
848 source='config/functions',
849 target='functions',
850 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
851 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
853 etc_scripts = [
854 'ctdb-crash-cleanup.sh',
855 'debug-hung-script.sh',
856 'debug_locks.sh',
857 'nfs-linux-kernel-callout',
858 'notify.sh',
859 'statd-callout'
862 for t in etc_scripts:
863 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
864 destname=t, chmod=MODE_755)
866 bld.SAMBA_GENERATOR('ctdb-sudoers',
867 source='config/ctdb.sudoers',
868 target='ctdb.sudoers',
869 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
870 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
871 destname='ctdb')
873 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
874 'config/notification.README',
875 destname='README')
877 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
878 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
879 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
881 for d in ['volatile', 'persistent', 'state']:
882 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
885 # Test-only below this point
888 if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'):
889 return
891 bld.SAMBA_BINARY('errcode',
892 source='tests/src/errcode.c',
893 deps='replace',
894 install_path='${CTDB_TEST_LIBEXECDIR}')
896 bld.SAMBA_BINARY('sigcode',
897 source='tests/src/sigcode.c',
898 deps='replace',
899 install_path='${CTDB_TEST_LIBEXECDIR}')
901 # Unit tests
902 ctdb_unit_tests = [
903 'db_hash_test',
904 'srvid_test',
905 'pkt_read_test',
906 'pkt_write_test',
907 'comm_test',
908 'comm_server_test',
909 'comm_client_test',
910 'pidfile_test',
911 'run_proc_test',
912 'sock_io_test',
913 'hash_count_test',
914 'run_event_test',
915 'cmdline_test',
916 'conf_test',
917 'line_test',
918 'event_script_test',
919 'tunable_test',
922 for target in ctdb_unit_tests:
923 src = 'tests/src/' + target + '.c'
925 bld.SAMBA_BINARY(target,
926 source=src,
927 deps='''talloc tevent tdb tevent-util popt
928 LIBASYNC_REQ samba-util sys_rw''',
929 install_path='${CTDB_TEST_LIBEXECDIR}')
931 bld.SAMBA_BINARY('reqid_test',
932 source='tests/src/reqid_test.c',
933 deps='samba-util',
934 install_path='${CTDB_TEST_LIBEXECDIR}')
936 bld.SAMBA_BINARY('rb_test',
937 source='tests/src/rb_test.c',
938 deps='samba-util talloc',
939 install_path='${CTDB_TEST_LIBEXECDIR}')
941 bld.SAMBA_BINARY('ctdb_packet_parse',
942 source='tests/src/ctdb_packet_parse.c',
943 deps='talloc tevent tdb ctdb-protocol',
944 install_path='${CTDB_TEST_LIBEXECDIR}')
946 bld.SAMBA_BINARY('system_socket_test',
947 source='tests/src/system_socket_test.c',
948 deps='''ctdb-tests-common
949 talloc
950 ctdb-protocol-util
951 pcap
952 ''',
953 install_path='${CTDB_TEST_LIBEXECDIR}')
955 bld.SAMBA_BINARY('porting_tests',
956 source='tests/src/porting_tests.c',
957 deps='samba-util ctdb-system popt',
958 install_path='${CTDB_TEST_LIBEXECDIR}')
960 bld.SAMBA_BINARY('sock_daemon_test',
961 source='tests/src/sock_daemon_test.c',
962 deps='''ctdb-system talloc tevent tevent-util
963 LIBASYNC_REQ samba-util sys_rw''',
964 install_path='${CTDB_TEST_LIBEXECDIR}')
966 bld.SAMBA_BINARY('ctdb_io_test',
967 source='tests/src/ctdb_io_test.c',
968 deps='''talloc tevent tdb samba-util sys_rw''',
969 install_path='${CTDB_TEST_LIBEXECDIR}')
971 bld.SAMBA_BINARY('ctdb-db-test',
972 source='tests/src/db_test_tool.c',
973 cflags='-DCTDB_DB_TEST_TOOL',
974 deps='''ctdb-client ctdb-protocol
975 ctdb-util samba-util talloc tevent replace''',
976 install_path='${CTDB_TEST_LIBEXECDIR}')
978 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
979 source=bld.SUBDIR('tests/src',
980 'protocol_common_basic.c'),
981 deps='samba-util replace talloc')
983 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
984 source=bld.SUBDIR('tests/src',
985 '''protocol_common.c
986 protocol_common_ctdb.c
987 '''),
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
1021 test_options.c
1022 test_backtrace.c
1023 '''),
1024 deps='''ctdb-client
1025 samba-util
1026 replace
1027 popt
1028 talloc
1029 tevent
1030 tdb''')
1032 # Test binaries
1033 ctdb_tests = [
1034 'g_lock_loop',
1035 'message_ring',
1036 'fetch_ring',
1037 'fetch_loop',
1038 'fetch_loop_key',
1039 'fetch_readonly',
1040 'fetch_readonly_loop',
1041 'transaction_loop',
1042 'update_record',
1043 'update_record_persistent',
1044 'lock_tdb',
1045 'dummy_client',
1046 'tunnel_test',
1047 'tunnel_cmd',
1050 for target in ctdb_tests:
1051 src = 'tests/src/' + target + '.c'
1053 bld.SAMBA_BINARY(target,
1054 source=src,
1055 includes='include',
1056 deps='''ctdb-client ctdb-protocol ctdb-util
1057 samba-util ctdb-tests-common''',
1058 install_path='${CTDB_TEST_LIBEXECDIR}')
1060 bld.SAMBA_BINARY('ctdb_takeover_tests',
1061 source='''tests/src/ctdb_takeover_tests.c
1062 tests/src/ipalloc_read_known_ips.c''',
1063 deps='''replace popt tdb tevent talloc ctdb-system
1064 samba-util tdb-wrap talloc_report
1065 ctdb-ipalloc ctdb-protocol ctdb-util''',
1066 includes='include',
1067 install_path='${CTDB_TEST_LIBEXECDIR}')
1069 bld.SAMBA_BINARY('fake_ctdbd',
1070 source='''tests/src/fake_ctdbd.c
1071 tests/src/ipalloc_read_known_ips.c''',
1072 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1073 ctdb-system samba-util tevent-util
1074 LIBASYNC_REQ popt''',
1075 install_path='${CTDB_TEST_LIBEXECDIR}')
1077 bld.SAMBA_BINARY('cluster_mutex_test',
1078 source='tests/src/cluster_mutex_test.c',
1079 deps='''ctdb-tests-common
1080 samba-util
1081 talloc
1082 tevent
1083 ''',
1084 install_path='${CTDB_TEST_LIBEXECDIR}')
1086 if bld.env.HAVE_INFINIBAND:
1087 bld.SAMBA_BINARY('ibwrapper_test',
1088 source='ib/ibwrapper_test.c',
1089 includes='include',
1090 deps='replace talloc ctdb-common sys_rw' +
1091 ib_deps,
1092 install_path='${CTDB_TEST_LIBEXECDIR}')
1094 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER:
1095 bld.SAMBA_BINARY('test_mutex_raw',
1096 source='tests/src/test_mutex_raw.c',
1097 deps='pthread',
1098 install_path='${CTDB_TEST_LIBEXECDIR}')
1100 test_subdirs = [
1101 'CLUSTER',
1102 'INTEGRATION',
1103 'UNIT',
1104 'etc-ctdb'
1107 if bld.env.standalone_ctdb:
1108 testdir = 'tests'
1109 else:
1110 testdir = 'ctdb/tests'
1112 for t in test_subdirs:
1113 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1114 for fmode in files:
1115 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1116 destname=fmode[0], chmod=fmode[1])
1118 # Install tests/scripts directory, excluding files that need munging
1119 test_scripts = [
1120 'cluster.bash',
1121 'common.sh',
1122 'integration.bash',
1123 'integration_local_daemons.bash',
1124 'integration_real_cluster.bash',
1125 'unit.sh'
1128 for t in test_scripts:
1129 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1130 os.path.join('tests/scripts', t),
1131 destname=os.path.join('scripts', t))
1133 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1134 'tests/scripts/test_wrap',
1135 destname='scripts/test_wrap',
1136 chmod=MODE_755)
1138 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1139 source='tests/scripts/script_install_paths.sh',
1140 target='script_install_paths.sh',
1141 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1142 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1143 'script_install_paths.sh',
1144 destname='script_install_paths.sh', chmod=MODE_644)
1146 sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % (
1147 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1148 sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@'
1149 bld.SAMBA_GENERATOR('ctdb-test-runner',
1150 source='tests/run_tests.sh',
1151 target='ctdb_run_tests.sh',
1152 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1153 sed_expr1, sed_expr2))
1154 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1155 destname='ctdb_run_tests', chmod=MODE_755)
1156 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1157 'ctdb_run_tests')
1159 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1160 source='tests/local_daemons.sh',
1161 target='ctdb_local_daemons.sh',
1162 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1163 sed_expr1, sed_expr2))
1164 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1165 destname='ctdb_local_daemons', chmod=MODE_755)
1168 def testonly(ctx):
1169 cmd = 'tests/run_tests.sh'
1170 ret = samba_utils.RUN_COMMAND(cmd)
1171 if ret != 0:
1172 print('tests exited with exit status %d' % ret)
1173 sys.exit(ret)
1176 def test(ctx):
1177 Options.commands.append('build')
1178 Options.commands.append('testonly')
1181 def autotest(ctx):
1182 env = samba_utils.LOAD_ENVIRONMENT()
1183 cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH
1184 ret = samba_utils.RUN_COMMAND(cmd)
1185 if ret != 0:
1186 print('autotest exited with exit status %d' % ret)
1187 sys.exit(ret)
1190 def show_version(ctx):
1191 print(get_version_string())
1194 def manpages(ctx):
1195 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1196 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1197 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1198 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1199 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1200 for t in manpages:
1201 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1202 ret = samba_utils.RUN_COMMAND(cmd)
1203 if ret != 0:
1204 print('Command %s failed with exit status %d' % (cmd, ret))
1205 sys.exit(ret)
1207 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1208 ret = samba_utils.RUN_COMMAND(cmd)
1209 if ret != 0:
1210 print('Command %s failed with exit status %d' % (cmd, ret))
1211 sys.exit(ret)
1214 def distonly(ctx):
1215 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1217 t = 'ctdb.spec'
1218 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1219 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1220 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1221 sed_expr1, sed_expr2, t)
1222 ret = samba_utils.RUN_COMMAND(cmd)
1223 if ret != 0:
1224 print('Command "%s" failed with exit status %d' % (cmd, ret))
1225 sys.exit(ret)
1226 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1228 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1229 for t in manpages:
1230 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1231 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1232 extend=True)
1234 samba_dist.dist()
1237 def dist():
1238 Options.commands.append('manpages')
1239 Options.commands.append('distonly')
1242 def rpmonly(ctx):
1243 opts = os.getenv('RPM_OPTIONS') or ''
1244 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1245 (opts, get_version_string())
1246 ret = samba_utils.RUN_COMMAND(cmd)
1247 if ret != 0:
1248 print('rpmbuild exited with exit status %d' % ret)
1249 sys.exit(ret)
1252 def rpm(ctx):
1253 Options.commands.append('manpages')
1254 Options.commands.append('distonly')
1255 Options.commands.append('rpmonly')
1258 def ctags(ctx):
1259 "build 'tags' file using ctags"
1260 source_root = os.path.dirname(Context.g_module.root_path)
1261 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1262 print("Running: %s" % cmd)
1263 ret = samba_utils.RUN_COMMAND(cmd)
1264 if ret != 0:
1265 print('ctags failed with exit status %d' % ret)
1266 sys.exit(ret)