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