s4:torture/smb2: test_notify_tcp_dis trigger idle event every 0.25s
[Samba.git] / ctdb / wscript
blob3fa525b564da837b3b82429236129d2d3d2aaf6c
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')
184 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
185 conf.DEFINE('ETIME', 'ETIMEDOUT')
187 if sys.platform.startswith('linux'):
188 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
189 else:
190 if not conf.CHECK_HEADERS('pcap.h'):
191 Logs.error('Need libpcap')
192 sys.exit(1)
193 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
194 Logs.error('Need libpcap')
195 sys.exit(1)
197 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
198 checklibc=True, headers='execinfo.h'):
199 Logs.error('backtrace support not available')
201 have_pmda = False
202 if Options.options.ctdb_pmda:
203 pmda_support = True
205 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
206 together=True):
207 pmda_support = False
208 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
209 pmda_support = False
210 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
211 pmda_support = False
212 if pmda_support:
213 conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
214 have_pmda = True
215 else:
216 Logs.error("PMDA support not available")
217 sys.exit(1)
218 if have_pmda:
219 Logs.info('Building with PMDA support')
220 conf.define('HAVE_PMDA', 1)
221 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
222 'lib/pcp/pmdas/ctdb')
224 have_infiniband = False
225 if Options.options.ctdb_infiniband:
226 ib_support = True
228 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
229 ib_support = False
230 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
231 ib_support = False
232 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
233 ib_support = False
234 if ib_support:
235 have_infiniband = True
236 else:
237 Logs.error("Infiniband support not available")
238 sys.exit(1)
239 if have_infiniband:
240 Logs.info('Building with Infiniband support')
241 conf.define('HAVE_INFINIBAND', 1)
242 conf.define('USE_INFINIBAND', 1)
244 have_etcd_reclock = False
245 if Options.options.ctdb_etcd_reclock:
246 try:
247 conf.check_python_module('etcd')
248 have_etcd_reclock = True
249 except:
250 Logs.error('etcd support not available')
251 sys.exit(1)
252 if have_etcd_reclock:
253 Logs.info('Building with etcd support')
254 conf.env.etcd_reclock = have_etcd_reclock
256 if Options.options.ctdb_ceph_reclock:
257 # Use custom libcephfs library path if provided. XXX The top level build
258 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
259 if Options.options.libcephfs_dir:
260 conf.env['CPPPATH_RADOS'] = Options.options.libcephfs_dir + '/include'
261 conf.env['LIBPATH_RADOS'] = Options.options.libcephfs_dir + '/lib'
262 conf.env['LIBPATH_CEPH-COMMON'] = conf.env['LIBPATH_RADOS'] + '/ceph'
264 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
265 conf.CHECK_LIB('rados', shlib=True)):
266 conf.CHECK_LIB('ceph-common', shlib=True)
267 Logs.info('Building with Ceph librados recovery lock support')
268 conf.define('HAVE_LIBRADOS', 1)
269 else:
270 Logs.error("Missing librados for Ceph recovery lock support")
271 sys.exit(1)
273 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
274 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
275 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
276 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
277 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
278 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
280 if Options.options.ctdb_logdir:
281 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
282 else:
283 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
285 if Options.options.ctdb_sockpath:
286 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
287 else:
288 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
289 'ctdbd.socket')
290 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
292 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
293 -DLOGDIR=\"%s\"
294 -DCTDB_DATADIR=\"%s\"
295 -DCTDB_ETCDIR=\"%s\"
296 -DCTDB_VARDIR=\"%s\"
297 -DCTDB_RUNDIR=\"%s\"''' % (
298 conf.env.CTDB_HELPER_BINDIR,
299 conf.env.CTDB_LOGDIR,
300 conf.env.CTDB_DATADIR,
301 conf.env.CTDB_ETCDIR,
302 conf.env.CTDB_VARDIR,
303 conf.env.CTDB_RUNDIR))
305 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
306 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
308 # Allow unified compilation and separate compilation of utilities
309 # to find includes
310 if not conf.env.standalone_ctdb:
311 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
312 else:
313 if Context.g_module.top == '.':
314 # Building from tarball
315 conf.ADD_EXTRA_INCLUDES('#include')
316 else:
317 # Building standalone CTDB from within Samba tree
318 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
319 conf.ADD_EXTRA_INCLUDES('#ctdb')
320 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
322 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
323 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
324 conf.SAMBA_CONFIG_H()
326 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
327 conf.env.ctdb_generate_manpages = True
328 else:
329 conf.env.ctdb_generate_manpages = False
331 Logs.info("xsltproc unavailable, checking for pre-built manpages")
332 conf.env.ctdb_prebuilt_manpages = []
333 manpages = manpages_binary + manpages_misc
334 if conf.env.etcd_reclock:
335 manpages += manpages_etcd
336 if conf.env.HAVE_LIBRADOS:
337 manpages += manpages_ceph
338 for m in manpages:
339 if os.path.exists(os.path.join("doc", m)):
340 Logs.info(" %s: yes" % (m))
341 conf.env.ctdb_prebuilt_manpages.append(m)
342 else:
343 Logs.info(" %s: no" % (m))
345 def build(bld):
346 if bld.env.standalone_ctdb:
347 # enable building of public headers in the build tree
348 bld.env.build_public_headers = 'include/public'
350 if bld.env.standalone_ctdb:
351 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
353 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
355 bld.RECURSE('lib/replace')
356 if bld.CHECK_FOR_THIRD_PARTY():
357 bld.RECURSE('third_party/popt')
358 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
359 bld.RECURSE('third_party/socket_wrapper')
361 bld.RECURSE('lib/tdb_wrap')
362 bld.RECURSE('lib/util')
363 bld.RECURSE('lib/async_req')
365 bld.RECURSE('lib/talloc')
366 bld.RECURSE('lib/tevent')
367 bld.RECURSE('lib/tdb')
369 if bld.env.standalone_ctdb:
370 # If a combined build is implemented, CTDB will want to
371 # build against samba-util rather than samba-util-core.
372 # Similarly, other Samba subsystems expect samba-util. So,
373 # for a standalone build, just define a fake samba-util
374 # subsystem that pulls in samba-util-core.
375 bld.SAMBA_SUBSYSTEM('samba-util',
376 source='',
377 deps='samba-util-core')
379 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
380 source=bld.SUBDIR('tcp',
381 'tcp_connect.c tcp_init.c tcp_io.c'),
382 includes='include',
383 deps='replace tdb talloc tevent')
385 ib_deps = ''
386 if bld.env.HAVE_INFINIBAND:
387 bld.SAMBA_SUBSYSTEM('ctdb-ib',
388 source=bld.SUBDIR('ib',
389 '''ibwrapper.c ibw_ctdb.c
390 ibw_ctdb_init.c'''),
391 includes='include',
392 deps='replace talloc tevent tdb')
393 ib_deps = ' ctdb-ib rdmacm ibverbs'
395 bld.SAMBA_SUBSYSTEM('ctdb-system',
396 source=bld.SUBDIR('common',
397 'system_socket.c system.c'),
398 includes='include',
399 deps='replace talloc tevent tdb pcap samba-util')
401 bld.SAMBA_SUBSYSTEM('ctdb-common',
402 source=bld.SUBDIR('common',
403 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
404 sock_io.c'''),
405 includes='include',
406 deps='''replace popt talloc tevent tdb popt ctdb-system
407 ctdb-protocol-util''')
409 bld.SAMBA_SUBSYSTEM('ctdb-util',
410 source=bld.SUBDIR('common',
411 '''db_hash.c srvid.c reqid.c
412 pkt_read.c pkt_write.c comm.c
413 logging.c rb_tree.c tunable.c
414 pidfile.c run_proc.c
415 hash_count.c
416 run_event.c event_script.c
417 sock_client.c
418 cmdline.c path.c conf.c line.c
419 '''),
420 deps='''samba-util sys_rw tevent-util
421 replace talloc tevent tdb popt''')
423 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
424 source='common/logging_conf.c',
425 deps='ctdb-util talloc')
427 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
428 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
429 deps='talloc tdb')
431 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
432 source=bld.SUBDIR('protocol',
433 '''protocol_header.c protocol_packet.c
434 protocol_types.c
435 protocol_call.c
436 protocol_message.c
437 protocol_control.c
438 protocol_keepalive.c
439 protocol_tunnel.c
440 protocol_client.c
441 protocol_debug.c
442 protocol_sock.c'''),
443 includes='include',
444 deps='ctdb-protocol-basic replace talloc tdb')
446 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
447 source='protocol/protocol_util.c',
448 deps='ctdb-util replace talloc tdb')
450 bld.SAMBA_SUBSYSTEM('ctdb-client',
451 source=bld.SUBDIR('client',
452 '''client_connect.c client_call.c
453 client_message.c client_control.c
454 client_message_sync.c
455 client_control_sync.c
456 client_db.c client_util.c
457 client_tunnel.c
458 '''),
459 includes='include',
460 deps='replace talloc tevent tdb tdb-wrap')
462 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
463 source=bld.SUBDIR('common',
464 '''sock_daemon.c'''),
465 deps='''samba-util ctdb-util ctdb-system tevent-util
466 LIBASYNC_REQ replace talloc tevent''')
468 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
469 source=bld.SUBDIR('server',
470 '''ipalloc_deterministic.c
471 ipalloc_nondeterministic.c
472 ipalloc_lcp2.c
473 ipalloc_common.c
474 ipalloc.c
475 '''),
476 includes='include',
477 deps='ctdb-protocol-util replace talloc tevent')
479 bld.SAMBA_BINARY('ctdb-path',
480 source='common/path_tool.c',
481 cflags='-DCTDB_PATH_TOOL',
482 deps='''ctdb-util samba-util talloc replace popt''',
483 install_path='${CTDB_HELPER_BINDIR}')
485 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
486 source='cluster/cluster_conf.c',
487 deps='ctdb-util')
489 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
490 source='database/database_conf.c',
491 deps='ctdb-util')
493 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
494 source='event/event_conf.c',
495 deps='ctdb-util')
497 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
498 source='failover/failover_conf.c',
499 deps='ctdb-util')
501 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
502 source='server/legacy_conf.c',
503 deps='ctdb-util')
505 bld.SAMBA_BINARY('ctdb-config',
506 source='common/conf_tool.c',
507 cflags='-DCTDB_CONF_TOOL',
508 deps='''ctdb-logging-conf
509 ctdb-event-conf
510 ctdb-cluster-conf
511 ctdb-database-conf
512 ctdb-failover-conf
513 ctdb-legacy-conf
514 ctdb-util samba-util talloc replace popt''',
515 install_path='${CTDB_HELPER_BINDIR}')
517 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
518 source=bld.SUBDIR('event',
519 '''event_protocol.c
520 event_protocol_util.c
521 '''),
522 deps='ctdb-protocol-basic')
524 bld.SAMBA_LIBRARY('ctdb-event-client',
525 source='event/event_client.c',
526 deps='ctdb-event-protocol ctdb-util tevent talloc',
527 private_library=True)
529 bld.SAMBA_BINARY('ctdb-eventd',
530 source=bld.SUBDIR('event',
531 '''event_cmd.c
532 event_config.c
533 event_context.c
534 event_daemon.c
535 event_request.c
536 '''),
537 deps='''ctdb-event-protocol
538 ctdb-event-conf ctdb-logging-conf
539 ctdb-server-util samba-util ctdb-util
540 talloc tevent replace popt''',
541 install_path='${CTDB_HELPER_BINDIR}')
543 bld.SAMBA_BINARY('ctdb-event',
544 source='event/event_tool.c',
545 cflags='-DCTDB_EVENT_TOOL',
546 deps='''ctdb-event-client ctdb-event-protocol
547 ctdb-util samba-util talloc replace''',
548 install_path='${CTDB_HELPER_BINDIR}')
550 bld.SAMBA_BINARY('ctdbd',
551 source='server/ctdbd.c ' +
552 bld.SUBDIR('server',
553 '''ctdb_daemon.c ctdb_recoverd.c
554 ctdb_recover.c ctdb_freeze.c
555 ctdb_tunables.c ctdb_monitor.c
556 ctdb_server.c ctdb_control.c
557 ctdb_call.c ctdb_ltdb_server.c
558 ctdb_traverse.c eventscript.c
559 ctdb_takeover.c
560 ctdb_persistent.c ctdb_keepalive.c
561 ctdb_cluster_mutex.c
562 ctdb_logging.c
563 ctdb_uptime.c
564 ctdb_vacuum.c ctdb_banning.c
565 ctdb_statistics.c
566 ctdb_update_record.c
567 ctdb_lock.c ctdb_fork.c
568 ctdb_tunnel.c ctdb_client.c
569 ctdb_config.c
570 '''),
571 includes='include',
572 deps='''ctdb-common ctdb-system ctdb-protocol
573 ctdb-tcp ctdb-util replace sys_rw popt
574 ctdb-logging-conf
575 ctdb-cluster-conf
576 ctdb-database-conf
577 ctdb-event-conf
578 ctdb-failover-conf
579 ctdb-legacy-conf
580 ctdb-event-protocol
581 talloc tevent tdb-wrap tdb talloc_report''' +
582 ib_deps,
583 install_path='${SBINDIR}',
584 manpages='ctdbd.1')
586 bld.SAMBA_BINARY('ctdb',
587 source='tools/ctdb.c',
588 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
589 ctdb-util ctdb-system samba-util sys_rw popt''',
590 install_path='${BINDIR}',
591 manpages='ctdb.1')
593 bld.SAMBA_BINARY('ctdb_killtcp',
594 source='tools/ctdb_killtcp.c',
595 deps='''ctdb-protocol-util ctdb-util ctdb-system
596 samba-util replace''',
597 install_path='${CTDB_HELPER_BINDIR}')
599 bld.SAMBA_BINARY('ltdbtool',
600 source='tools/ltdbtool.c',
601 includes='include',
602 deps='tdb',
603 install_path='${BINDIR}',
604 manpages='ltdbtool.1')
606 bld.SAMBA_BINARY('ctdb_lock_helper',
607 source='server/ctdb_lock_helper.c',
608 deps='''samba-util sys_rw ctdb-system tevent-util
609 talloc tevent tdb''',
610 includes='include',
611 install_path='${CTDB_HELPER_BINDIR}')
613 bld.SAMBA_BINARY('ctdb_recovery_helper',
614 source='server/ctdb_recovery_helper.c',
615 deps='''ctdb-client ctdb-protocol ctdb-util
616 samba-util sys_rw replace tdb''',
617 install_path='${CTDB_HELPER_BINDIR}')
619 bld.SAMBA_BINARY('ctdb_takeover_helper',
620 source='server/ctdb_takeover_helper.c',
621 deps='''ctdb-client ctdb-protocol ctdb-util
622 samba-util sys_rw replace ctdb-ipalloc popt''',
623 install_path='${CTDB_HELPER_BINDIR}')
625 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
626 source='server/ctdb_mutex_fcntl_helper.c',
627 deps='sys_rw ctdb-system',
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 = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = 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 ceph-common',
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}')
939 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
940 source=bld.SUBDIR('tests/src',
941 'protocol_common_basic.c'),
942 deps='replace talloc')
944 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
945 source=bld.SUBDIR('tests/src',
946 '''protocol_common.c
947 protocol_common_ctdb.c
948 '''),
949 includes='include',
950 deps='ctdb-protocol-tests-basic replace talloc tdb')
952 bld.SAMBA_BINARY('protocol_basic_test',
953 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
954 deps='ctdb-protocol-tests-basic talloc',
955 install_path='${CTDB_TEST_LIBEXECDIR}')
957 ctdb_protocol_tests = [
958 'protocol_types_test',
959 'protocol_ctdb_test',
960 'protocol_util_test',
961 'protocol_types_compat_test',
962 'protocol_ctdb_compat_test',
965 for target in ctdb_protocol_tests:
966 src = 'tests/src/' + target + '.c'
968 bld.SAMBA_BINARY(target,
969 source=src,
970 deps='''ctdb-protocol-tests-common
971 samba-util ctdb-util talloc tdb''',
972 install_path='${CTDB_TEST_LIBEXECDIR}')
974 bld.SAMBA_BINARY('event_protocol_test',
975 source='event/event_protocol_test.c',
976 deps='''ctdb-protocol-tests-basic
977 ctdb-protocol-basic talloc''',
978 install_path='${CTDB_TEST_LIBEXECDIR}')
980 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
981 source=bld.SUBDIR('tests/src',
982 'cluster_wait.c test_options.c'),
983 includes='include',
984 deps='samba-util replace popt talloc tevent tdb')
986 # Test binaries
987 ctdb_tests = [
988 'g_lock_loop',
989 'message_ring',
990 'fetch_ring',
991 'fetch_loop',
992 'fetch_loop_key',
993 'fetch_readonly',
994 'fetch_readonly_loop',
995 'transaction_loop',
996 'update_record',
997 'update_record_persistent',
998 'lock_tdb',
999 'dummy_client',
1000 'tunnel_test',
1001 'tunnel_cmd',
1004 for target in ctdb_tests:
1005 src = 'tests/src/' + target + '.c'
1007 bld.SAMBA_BINARY(target,
1008 source=src,
1009 includes='include',
1010 deps='''ctdb-client ctdb-protocol ctdb-util
1011 samba-util ctdb-tests-common''',
1012 install_path='${CTDB_TEST_LIBEXECDIR}')
1014 bld.SAMBA_BINARY('ctdb_takeover_tests',
1015 source='''tests/src/ctdb_takeover_tests.c
1016 tests/src/ipalloc_read_known_ips.c''',
1017 deps='''replace popt tdb tevent talloc ctdb-system
1018 samba-util tdb-wrap talloc_report
1019 ctdb-ipalloc ctdb-protocol ctdb-util''',
1020 includes='include',
1021 install_path='${CTDB_TEST_LIBEXECDIR}')
1023 bld.SAMBA_BINARY('fake_ctdbd',
1024 source='''tests/src/fake_ctdbd.c
1025 tests/src/ipalloc_read_known_ips.c''',
1026 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1027 ctdb-system samba-util tevent-util
1028 LIBASYNC_REQ popt''',
1029 install_path='${CTDB_TEST_LIBEXECDIR}')
1031 if bld.env.HAVE_INFINIBAND:
1032 bld.SAMBA_BINARY('ibwrapper_test',
1033 source='ib/ibwrapper_test.c',
1034 includes='include',
1035 deps='replace talloc ctdb-common sys_rw' +
1036 ib_deps,
1037 install_path='${CTDB_TEST_LIBEXECDIR}')
1039 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux'):
1040 bld.SAMBA_BINARY('test_mutex_raw',
1041 source='tests/src/test_mutex_raw.c',
1042 deps='pthread',
1043 install_path='${CTDB_TEST_LIBEXECDIR}')
1045 test_subdirs = [
1046 'complex',
1047 'ctdb_eventd',
1048 'cunit',
1049 'etc-ctdb',
1050 'eventd',
1051 'eventscripts',
1052 'onnode',
1053 'shellcheck',
1054 'simple',
1055 'takeover',
1056 'takeover_helper',
1057 'tool'
1060 if bld.env.standalone_ctdb:
1061 testdir = 'tests'
1062 else:
1063 testdir = 'ctdb/tests'
1065 for t in test_subdirs:
1066 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1067 for fmode in files:
1068 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1069 destname=fmode[0], chmod=fmode[1])
1071 # Install tests/scripts directory without test_wrap
1072 test_scripts = [
1073 'common.sh',
1074 'integration.bash',
1075 'unit.sh'
1078 for t in test_scripts:
1079 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1080 os.path.join('tests/scripts', t),
1081 destname=os.path.join('scripts', t))
1083 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1084 bld.env.CTDB_TEST_LIBEXECDIR)
1085 bld.SAMBA_GENERATOR('ctdb-test-wrap',
1086 source='tests/scripts/test_wrap',
1087 target='test_wrap',
1088 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
1089 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
1090 destname='test_wrap', chmod=MODE_755)
1092 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1093 source='tests/scripts/script_install_paths.sh',
1094 target='script_install_paths.sh',
1095 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1096 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1097 'script_install_paths.sh',
1098 destname='script_install_paths.sh', chmod=MODE_644)
1100 sed_expr1 = 's@^\(export %s\)=.*@\\1=%s@' % (
1101 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1102 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1103 bld.SAMBA_GENERATOR('ctdb-test-runner',
1104 source='tests/run_tests.sh',
1105 target='ctdb_run_tests.sh',
1106 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1107 sed_expr1, sed_expr2))
1108 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1109 destname='ctdb_run_tests', chmod=MODE_755)
1110 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1111 'ctdb_run_tests')
1113 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1114 source='tests/local_daemons.sh',
1115 target='ctdb_local_daemons.sh',
1116 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1117 sed_expr1, sed_expr2))
1118 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1119 destname='ctdb_local_daemons', chmod=MODE_755)
1122 def testonly(ctx):
1123 cmd = 'tests/run_tests.sh -V tests/var'
1124 ret = samba_utils.RUN_COMMAND(cmd)
1125 if ret != 0:
1126 print('tests exited with exit status %d' % ret)
1127 sys.exit(ret)
1130 def test(ctx):
1131 Options.commands.append('build')
1132 Options.commands.append('testonly')
1135 def autotest(ctx):
1136 env = samba_utils.LOAD_ENVIRONMENT()
1137 cmd = 'tests/run_tests.sh -e -S %s -C' % env.SOCKET_WRAPPER_SO_PATH
1138 ret = samba_utils.RUN_COMMAND(cmd)
1139 if ret != 0:
1140 print('autotest exited with exit status %d' % ret)
1141 sys.exit(ret)
1144 def show_version(ctx):
1145 print(get_version_string())
1148 def manpages(ctx):
1149 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1150 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1151 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1152 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1153 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1154 for t in manpages:
1155 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1156 ret = samba_utils.RUN_COMMAND(cmd)
1157 if ret != 0:
1158 print('Command %s failed with exit status %d' % (cmd, ret))
1159 sys.exit(ret)
1161 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1162 ret = samba_utils.RUN_COMMAND(cmd)
1163 if ret != 0:
1164 print('Command %s failed with exit status %d' % (cmd, ret))
1165 sys.exit(ret)
1168 def distonly(ctx):
1169 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1171 t = 'ctdb.spec'
1172 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1173 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1174 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1175 sed_expr1, sed_expr2, t)
1176 ret = samba_utils.RUN_COMMAND(cmd)
1177 if ret != 0:
1178 print('Command "%s" failed with exit status %d' % (cmd, ret))
1179 sys.exit(ret)
1180 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1182 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1183 for t in manpages:
1184 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1185 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1186 extend=True)
1188 samba_dist.dist()
1191 def dist():
1192 Options.commands.append('manpages')
1193 Options.commands.append('distonly')
1196 def rpmonly(ctx):
1197 opts = os.getenv('RPM_OPTIONS') or ''
1198 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1199 (opts, get_version_string())
1200 ret = samba_utils.RUN_COMMAND(cmd)
1201 if ret != 0:
1202 print('rpmbuild exited with exit status %d' % ret)
1203 sys.exit(ret)
1206 def rpm(ctx):
1207 Options.commands.append('manpages')
1208 Options.commands.append('distonly')
1209 Options.commands.append('rpmonly')
1212 def ctags(ctx):
1213 "build 'tags' file using ctags"
1214 source_root = os.path.dirname(Context.g_module.root_path)
1215 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1216 print("Running: %s" % cmd)
1217 ret = samba_utils.RUN_COMMAND(cmd)
1218 if ret != 0:
1219 print('ctags failed with exit status %d' % ret)
1220 sys.exit(ret)