s3:winbind: Add support for storing KRB5 credential in KCM
[Samba.git] / ctdb / wscript
blob614e042bd70fc6cc1fbc7d0747c97a89e59b560b
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.ctdb_ceph_reclock:
258 # Use custom libcephfs library path if provided. XXX The top level build
259 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
260 if Options.options.libcephfs_dir:
261 conf.env['CPPPATH_RADOS'] = Options.options.libcephfs_dir + '/include'
262 conf.env['LIBPATH_RADOS'] = Options.options.libcephfs_dir + '/lib'
263 conf.env['LIBPATH_CEPH-COMMON'] = conf.env['LIBPATH_RADOS'] + '/ceph'
265 if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
266 conf.CHECK_LIB('rados', shlib=True)):
267 conf.CHECK_LIB('ceph-common', shlib=True)
268 Logs.info('Building with Ceph librados recovery lock support')
269 conf.define('HAVE_LIBRADOS', 1)
270 else:
271 Logs.error("Missing librados for Ceph recovery lock support")
272 sys.exit(1)
274 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
275 conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb')
276 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
277 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
278 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
279 conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
281 if Options.options.ctdb_logdir:
282 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
283 else:
284 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
286 if Options.options.ctdb_sockpath:
287 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
288 else:
289 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
290 'ctdbd.socket')
291 conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
293 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
294 -DLOGDIR=\"%s\"
295 -DCTDB_DATADIR=\"%s\"
296 -DCTDB_ETCDIR=\"%s\"
297 -DCTDB_VARDIR=\"%s\"
298 -DCTDB_RUNDIR=\"%s\"''' % (
299 conf.env.CTDB_HELPER_BINDIR,
300 conf.env.CTDB_LOGDIR,
301 conf.env.CTDB_DATADIR,
302 conf.env.CTDB_ETCDIR,
303 conf.env.CTDB_VARDIR,
304 conf.env.CTDB_RUNDIR))
306 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests')
307 conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests')
309 # Allow unified compilation and separate compilation of utilities
310 # to find includes
311 if not conf.env.standalone_ctdb:
312 conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
313 else:
314 if Context.g_module.top == '.':
315 # Building from tarball
316 conf.ADD_EXTRA_INCLUDES('#include')
317 else:
318 # Building standalone CTDB from within Samba tree
319 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
320 conf.ADD_EXTRA_INCLUDES('#ctdb')
321 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
323 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
324 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
325 conf.SAMBA_CONFIG_H()
327 if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
328 conf.env.ctdb_generate_manpages = True
329 else:
330 conf.env.ctdb_generate_manpages = False
332 Logs.info("xsltproc unavailable, checking for pre-built manpages")
333 conf.env.ctdb_prebuilt_manpages = []
334 manpages = manpages_binary + manpages_misc
335 if conf.env.etcd_reclock:
336 manpages += manpages_etcd
337 if conf.env.HAVE_LIBRADOS:
338 manpages += manpages_ceph
339 for m in manpages:
340 if os.path.exists(os.path.join("doc", m)):
341 Logs.info(" %s: yes" % (m))
342 conf.env.ctdb_prebuilt_manpages.append(m)
343 else:
344 Logs.info(" %s: no" % (m))
346 def build(bld):
347 if bld.env.standalone_ctdb:
348 # enable building of public headers in the build tree
349 bld.env.build_public_headers = 'include/public'
351 if bld.env.standalone_ctdb:
352 bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
354 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
356 bld.RECURSE('lib/replace')
357 if bld.CHECK_FOR_THIRD_PARTY():
358 bld.RECURSE('third_party/popt')
359 if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
360 bld.RECURSE('third_party/socket_wrapper')
362 bld.RECURSE('lib/tdb_wrap')
363 bld.RECURSE('lib/util')
364 bld.RECURSE('lib/async_req')
366 bld.RECURSE('lib/talloc')
367 bld.RECURSE('lib/tevent')
368 bld.RECURSE('lib/tdb')
370 if bld.env.standalone_ctdb:
371 # If a combined build is implemented, CTDB will want to
372 # build against samba-util rather than samba-util-core.
373 # Similarly, other Samba subsystems expect samba-util. So,
374 # for a standalone build, just define a fake samba-util
375 # subsystem that pulls in samba-util-core.
376 bld.SAMBA_SUBSYSTEM('samba-util',
377 source='',
378 deps='samba-util-core')
380 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
381 source=bld.SUBDIR('tcp',
382 'tcp_connect.c tcp_init.c tcp_io.c'),
383 includes='include',
384 deps='replace tdb talloc tevent')
386 ib_deps = ''
387 if bld.env.HAVE_INFINIBAND:
388 bld.SAMBA_SUBSYSTEM('ctdb-ib',
389 source=bld.SUBDIR('ib',
390 '''ibwrapper.c ibw_ctdb.c
391 ibw_ctdb_init.c'''),
392 includes='include',
393 deps='replace talloc tevent tdb')
394 ib_deps = ' ctdb-ib rdmacm ibverbs'
396 bld.SAMBA_SUBSYSTEM('ctdb-system',
397 source=bld.SUBDIR('common',
398 'system_socket.c system.c'),
399 includes='include',
400 deps='replace talloc tevent tdb pcap samba-util')
402 bld.SAMBA_SUBSYSTEM('ctdb-common',
403 source=bld.SUBDIR('common',
404 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
405 sock_io.c'''),
406 includes='include',
407 deps='''replace popt talloc tevent tdb popt ctdb-system
408 ctdb-protocol-util''')
410 bld.SAMBA_SUBSYSTEM('ctdb-util',
411 source=bld.SUBDIR('common',
412 '''db_hash.c srvid.c reqid.c
413 pkt_read.c pkt_write.c comm.c
414 logging.c rb_tree.c tunable.c
415 pidfile.c run_proc.c
416 hash_count.c
417 run_event.c event_script.c
418 sock_client.c
419 cmdline.c path.c conf.c line.c
420 '''),
421 deps='''samba-util sys_rw tevent-util
422 replace talloc tevent tdb popt''')
424 bld.SAMBA_SUBSYSTEM('ctdb-logging-conf',
425 source='common/logging_conf.c',
426 deps='ctdb-util talloc')
428 bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic',
429 source=bld.SUBDIR('protocol', 'protocol_basic.c'),
430 deps='talloc tdb')
432 bld.SAMBA_SUBSYSTEM('ctdb-protocol',
433 source=bld.SUBDIR('protocol',
434 '''protocol_header.c protocol_packet.c
435 protocol_types.c
436 protocol_call.c
437 protocol_message.c
438 protocol_control.c
439 protocol_keepalive.c
440 protocol_tunnel.c
441 protocol_client.c
442 protocol_debug.c
443 protocol_sock.c'''),
444 includes='include',
445 deps='ctdb-protocol-basic replace talloc tdb')
447 bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
448 source='protocol/protocol_util.c',
449 deps='ctdb-util replace talloc tdb')
451 bld.SAMBA_SUBSYSTEM('ctdb-client',
452 source=bld.SUBDIR('client',
453 '''client_connect.c client_call.c
454 client_message.c client_control.c
455 client_message_sync.c
456 client_control_sync.c
457 client_db.c client_util.c
458 client_tunnel.c
459 '''),
460 includes='include',
461 deps='replace talloc tevent tdb tdb-wrap')
463 bld.SAMBA_SUBSYSTEM('ctdb-server-util',
464 source=bld.SUBDIR('common',
465 '''sock_daemon.c'''),
466 deps='''samba-util ctdb-util ctdb-system tevent-util
467 LIBASYNC_REQ replace talloc tevent''')
469 bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
470 source=bld.SUBDIR('server',
471 '''ipalloc_deterministic.c
472 ipalloc_nondeterministic.c
473 ipalloc_lcp2.c
474 ipalloc_common.c
475 ipalloc.c
476 '''),
477 includes='include',
478 deps='ctdb-protocol-util replace talloc tevent')
480 bld.SAMBA_BINARY('ctdb-path',
481 source='common/path_tool.c',
482 cflags='-DCTDB_PATH_TOOL',
483 deps='''ctdb-util samba-util talloc replace popt''',
484 install_path='${CTDB_HELPER_BINDIR}')
486 bld.SAMBA_SUBSYSTEM('ctdb-cluster-conf',
487 source='cluster/cluster_conf.c',
488 deps='ctdb-util')
490 bld.SAMBA_SUBSYSTEM('ctdb-database-conf',
491 source='database/database_conf.c',
492 deps='ctdb-util')
494 bld.SAMBA_SUBSYSTEM('ctdb-event-conf',
495 source='event/event_conf.c',
496 deps='ctdb-util')
498 bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
499 source='failover/failover_conf.c',
500 deps='ctdb-util')
502 bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
503 source='server/legacy_conf.c',
504 deps='ctdb-util')
506 bld.SAMBA_BINARY('ctdb-config',
507 source='common/conf_tool.c',
508 cflags='-DCTDB_CONF_TOOL',
509 deps='''ctdb-logging-conf
510 ctdb-event-conf
511 ctdb-cluster-conf
512 ctdb-database-conf
513 ctdb-failover-conf
514 ctdb-legacy-conf
515 ctdb-util samba-util talloc replace popt''',
516 install_path='${CTDB_HELPER_BINDIR}')
518 bld.SAMBA_SUBSYSTEM('ctdb-event-protocol',
519 source=bld.SUBDIR('event',
520 '''event_protocol.c
521 event_protocol_util.c
522 '''),
523 deps='ctdb-protocol-basic')
525 bld.SAMBA_LIBRARY('ctdb-event-client',
526 source='event/event_client.c',
527 deps='ctdb-event-protocol ctdb-util tevent talloc',
528 private_library=True)
530 bld.SAMBA_BINARY('ctdb-eventd',
531 source=bld.SUBDIR('event',
532 '''event_cmd.c
533 event_config.c
534 event_context.c
535 event_daemon.c
536 event_request.c
537 '''),
538 deps='''ctdb-event-protocol
539 ctdb-event-conf ctdb-logging-conf
540 ctdb-server-util samba-util ctdb-util
541 talloc tevent replace popt''',
542 install_path='${CTDB_HELPER_BINDIR}')
544 bld.SAMBA_BINARY('ctdb-event',
545 source='event/event_tool.c',
546 cflags='-DCTDB_EVENT_TOOL',
547 deps='''ctdb-event-client ctdb-event-protocol
548 ctdb-util samba-util talloc replace''',
549 install_path='${CTDB_HELPER_BINDIR}')
551 bld.SAMBA_BINARY('ctdbd',
552 source='server/ctdbd.c ' +
553 bld.SUBDIR('server',
554 '''ctdb_daemon.c ctdb_recoverd.c
555 ctdb_recover.c ctdb_freeze.c
556 ctdb_tunables.c ctdb_monitor.c
557 ctdb_server.c ctdb_control.c
558 ctdb_call.c ctdb_ltdb_server.c
559 ctdb_traverse.c eventscript.c
560 ctdb_takeover.c
561 ctdb_persistent.c ctdb_keepalive.c
562 ctdb_cluster_mutex.c
563 ctdb_logging.c
564 ctdb_uptime.c
565 ctdb_vacuum.c ctdb_banning.c
566 ctdb_statistics.c
567 ctdb_update_record.c
568 ctdb_lock.c ctdb_fork.c
569 ctdb_tunnel.c ctdb_client.c
570 ctdb_config.c
571 '''),
572 includes='include',
573 deps='''ctdb-common ctdb-system ctdb-protocol
574 ctdb-tcp ctdb-util replace sys_rw popt
575 ctdb-logging-conf
576 ctdb-cluster-conf
577 ctdb-database-conf
578 ctdb-event-conf
579 ctdb-failover-conf
580 ctdb-legacy-conf
581 ctdb-event-protocol
582 talloc tevent tdb-wrap tdb talloc_report''' +
583 ib_deps,
584 install_path='${SBINDIR}',
585 manpages='ctdbd.1')
587 bld.SAMBA_BINARY('ctdb',
588 source='tools/ctdb.c',
589 deps='''ctdb-client ctdb-protocol ctdb-protocol-util
590 ctdb-util ctdb-system samba-util sys_rw popt''',
591 install_path='${BINDIR}',
592 manpages='ctdb.1')
594 bld.SAMBA_BINARY('ctdb_killtcp',
595 source='tools/ctdb_killtcp.c',
596 deps='''ctdb-protocol-util ctdb-util ctdb-system
597 samba-util replace''',
598 install_path='${CTDB_HELPER_BINDIR}')
600 bld.SAMBA_BINARY('ltdbtool',
601 source='tools/ltdbtool.c',
602 includes='include',
603 deps='tdb',
604 install_path='${BINDIR}',
605 manpages='ltdbtool.1')
607 bld.SAMBA_BINARY('ctdb_lock_helper',
608 source='server/ctdb_lock_helper.c',
609 deps='''samba-util sys_rw ctdb-system tevent-util
610 talloc tevent tdb''',
611 includes='include',
612 install_path='${CTDB_HELPER_BINDIR}')
614 bld.SAMBA_BINARY('ctdb_recovery_helper',
615 source='server/ctdb_recovery_helper.c',
616 deps='''ctdb-client ctdb-protocol ctdb-util
617 samba-util sys_rw replace tdb''',
618 install_path='${CTDB_HELPER_BINDIR}')
620 bld.SAMBA_BINARY('ctdb_takeover_helper',
621 source='server/ctdb_takeover_helper.c',
622 deps='''ctdb-client ctdb-protocol ctdb-util
623 samba-util sys_rw replace ctdb-ipalloc popt''',
624 install_path='${CTDB_HELPER_BINDIR}')
626 bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
627 source='server/ctdb_mutex_fcntl_helper.c',
628 deps='sys_rw ctdb-system',
629 includes='include',
630 install_path='${CTDB_HELPER_BINDIR}')
632 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
633 source='utils/smnotify/smnotify.x',
634 target='utils/smnotify/smnotify.h',
635 rule='rpcgen -h ${SRC} > ${TGT}')
637 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
639 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
640 source='utils/smnotify/smnotify.x',
641 target='utils/smnotify/gen_xdr.c',
642 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
644 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
645 source='utils/smnotify/smnotify.x',
646 target='utils/smnotify/gen_smnotify.c',
647 rule='rpcgen -l ${SRC} > ${TGT}')
649 bld.SAMBA_BINARY('smnotify',
650 source=bld.SUBDIR('utils/smnotify',
651 'smnotify.c gen_smnotify.c gen_xdr.c'),
652 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
653 includes='utils utils/smnotify',
654 install_path='${CTDB_HELPER_BINDIR}')
656 bld.SAMBA_BINARY('ping_pong',
657 source='utils/ping_pong/ping_pong.c',
658 deps='',
659 install_path='${BINDIR}',
660 manpages='ping_pong.1')
662 if bld.env.HAVE_PMDA:
663 bld.SAMBA_BINARY('pmdactdb',
664 source='utils/pmda/pmda_ctdb.c',
665 includes='include',
666 deps='''ctdb-client ctdb-protocol ctdb-util
667 samba-util pcp_pmda pcp''',
668 install_path='${CTDB_PMDADIR}')
669 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
670 destname='Install')
671 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
672 destname='Remove')
673 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
674 destname='pmns')
675 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
676 destname='domain.h')
677 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
678 destname='help')
679 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
680 destname='README')
682 if bld.env.HAVE_LIBRADOS:
683 rados_inc = ' include'
684 if bld.CONFIG_GET('CPPPATH_RADOS') is not None:
685 rados_inc = bld.CONFIG_GET('CPPPATH_RADOS') + rados_inc
686 bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
687 source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
688 deps='talloc tevent rados ceph-common',
689 includes=rados_inc,
690 install_path='${CTDB_HELPER_BINDIR}')
692 sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR)
693 sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR)
694 sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
695 sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
696 sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
697 sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
698 sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
699 sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR)
700 sed_cmdline = '-e "%s" ' * 8 % \
701 (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
702 sed_expr6, sed_expr7, sed_expr8)
704 manpages_extra = manpages_misc
705 if bld.env.etcd_reclock:
706 manpages_extra += manpages_etcd
707 if bld.env.HAVE_LIBRADOS:
708 manpages_extra += manpages_ceph
709 for f in manpages_binary + manpages_extra:
710 x = '%s.xml' % (f)
711 bld.SAMBA_GENERATOR(x,
712 source=os.path.join('doc', x),
713 target=x,
714 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
716 if bld.env.ctdb_generate_manpages:
717 bld.MANPAGES(' '.join(manpages_extra), True)
718 else:
719 for m in bld.env.ctdb_prebuilt_manpages:
720 bld.SAMBA_GENERATOR(m,
721 source=os.path.join("doc", m),
722 target=m,
723 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
724 bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m)
726 bld.SAMBA_GENERATOR('ctdb-onnode',
727 source='tools/onnode',
728 target='onnode',
729 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
730 bld.INSTALL_FILES('${BINDIR}', 'onnode',
731 destname='onnode', chmod=MODE_755)
733 bld.SAMBA_GENERATOR('ctdb-diagnostics',
734 source='tools/ctdb_diagnostics',
735 target='ctdb_diagnostics',
736 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
737 bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
738 destname='ctdb_diagnostics', chmod=MODE_755)
740 if bld.env.etcd_reclock:
741 bld.SAMBA_GENERATOR('ctdb-etcd-lock',
742 source='utils/etcd/ctdb_etcd_lock',
743 target='ctdb_etcd_lock',
744 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
745 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
746 destname='ctdb_etcd_lock', chmod=MODE_744)
748 bld.SAMBA_GENERATOR('ctdb-natgw',
749 source='tools/ctdb_natgw',
750 target='ctdb_natgw',
751 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
752 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
753 destname='ctdb_natgw', chmod=MODE_755)
755 bld.SAMBA_GENERATOR('ctdb-lvs',
756 source='tools/ctdb_lvs',
757 target='ctdb_lvs',
758 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
759 bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
760 destname='ctdb_lvs', chmod=MODE_755)
762 bld.SAMBA_GENERATOR('ctdbd-wrapper',
763 source='config/ctdbd_wrapper',
764 target='ctdbd_wrapper',
765 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
766 bld.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
767 destname='ctdbd_wrapper', chmod=MODE_755)
769 def SUBDIR_MODE_callback(arg, dirname, fnames):
770 for f in fnames:
771 fl = os.path.join(dirname, f)
772 if os.path.isdir(fl) or os.path.islink(fl):
773 continue
774 mode = os.lstat(fl).st_mode & MODE_777
775 if arg['trim_path']:
776 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
777 arg['file_list'].append([fl, mode])
779 def SUBDIR_MODE(path, trim_path=None):
780 pd = {'trim_path': trim_path, 'file_list': []}
781 for dirname, _subdirs, fnames in os.walk(path):
782 SUBDIR_MODE_callback(pd, dirname, fnames)
783 return pd['file_list']
785 event_script_subdirs = [
786 'events/legacy',
789 etc_subdirs = [
790 'nfs-checks.d'
793 if bld.env.standalone_ctdb:
794 configdir = 'config'
795 else:
796 configdir = 'ctdb/config'
798 for t in event_script_subdirs:
799 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t))
800 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
801 for fmode in files:
802 bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0],
803 destname=fmode[0], chmod=fmode[1])
805 for t in etc_subdirs:
806 files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir)
807 for fmode in files:
808 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
809 destname=fmode[0], chmod=fmode[1])
811 # If this is a direct install and there are no event scripts
812 # linked/enabled then enable some standard ones
813 if os.environ.get('DESTDIR') is None:
814 fmt = 'events/legacy/%s.script'
815 required_script = '00.ctdb'
816 required_path = os.path.join(bld.env.CTDB_ETCDIR,
817 fmt % (required_script))
818 if not os.path.islink(required_path) and \
819 not os.path.exists(required_path):
820 default_scripts = [ required_script,
821 '01.reclock',
822 '05.system',
823 '10.interface',
825 for t in default_scripts:
826 tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t))
827 name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t))
828 bld.symlink_as(name, tgt)
830 bld.SAMBA_GENERATOR('ctdb-functions',
831 source='config/functions',
832 target='functions',
833 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
834 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions')
836 etc_scripts = [
837 'ctdb-crash-cleanup.sh',
838 'debug-hung-script.sh',
839 'debug_locks.sh',
840 'nfs-linux-kernel-callout',
841 'notify.sh',
842 'statd-callout'
845 for t in etc_scripts:
846 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
847 destname=t, chmod=MODE_755)
849 bld.SAMBA_GENERATOR('ctdb-sudoers',
850 source='config/ctdb.sudoers',
851 target='ctdb.sudoers',
852 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
853 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
854 destname='ctdb')
856 bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification',
857 'config/notification.README',
858 destname='README')
860 bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
861 bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
862 bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
864 for d in ['volatile', 'persistent', 'state']:
865 bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
867 bld.SAMBA_BINARY('errcode',
868 source='tests/src/errcode.c',
869 deps='replace',
870 install_path='${CTDB_TEST_LIBEXECDIR}')
872 bld.SAMBA_BINARY('sigcode',
873 source='tests/src/sigcode.c',
874 deps='replace',
875 install_path='${CTDB_TEST_LIBEXECDIR}')
877 # Unit tests
878 ctdb_unit_tests = [
879 'db_hash_test',
880 'srvid_test',
881 'pkt_read_test',
882 'pkt_write_test',
883 'comm_test',
884 'comm_server_test',
885 'comm_client_test',
886 'pidfile_test',
887 'run_proc_test',
888 'sock_io_test',
889 'hash_count_test',
890 'run_event_test',
891 'cmdline_test',
892 'conf_test',
893 'line_test',
894 'event_script_test',
897 for target in ctdb_unit_tests:
898 src = 'tests/src/' + target + '.c'
900 bld.SAMBA_BINARY(target,
901 source=src,
902 deps='''talloc tevent tdb tevent-util popt
903 LIBASYNC_REQ samba-util sys_rw''',
904 install_path='${CTDB_TEST_LIBEXECDIR}')
906 bld.SAMBA_BINARY('reqid_test',
907 source='tests/src/reqid_test.c',
908 deps='samba-util',
909 install_path='${CTDB_TEST_LIBEXECDIR}')
911 bld.SAMBA_BINARY('rb_test',
912 source='tests/src/rb_test.c',
913 deps='samba-util talloc',
914 install_path='${CTDB_TEST_LIBEXECDIR}')
916 bld.SAMBA_BINARY('ctdb_packet_parse',
917 source='tests/src/ctdb_packet_parse.c',
918 deps='talloc tevent tdb ctdb-protocol',
919 install_path='${CTDB_TEST_LIBEXECDIR}')
921 bld.SAMBA_BINARY('system_socket_test',
922 source='tests/src/system_socket_test.c',
923 deps='talloc ctdb-protocol-util pcap',
924 install_path='${CTDB_TEST_LIBEXECDIR}')
926 bld.SAMBA_BINARY('porting_tests',
927 source='tests/src/porting_tests.c',
928 deps='samba-util ctdb-system popt',
929 install_path='${CTDB_TEST_LIBEXECDIR}')
931 bld.SAMBA_BINARY('sock_daemon_test',
932 source='tests/src/sock_daemon_test.c',
933 deps='''ctdb-system talloc tevent tevent-util
934 LIBASYNC_REQ samba-util sys_rw''',
935 install_path='${CTDB_TEST_LIBEXECDIR}')
937 bld.SAMBA_BINARY('ctdb_io_test',
938 source='tests/src/ctdb_io_test.c',
939 deps='''talloc tevent tdb samba-util sys_rw''',
940 install_path='${CTDB_TEST_LIBEXECDIR}')
943 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
944 source=bld.SUBDIR('tests/src',
945 'protocol_common_basic.c'),
946 deps='replace talloc')
948 bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common',
949 source=bld.SUBDIR('tests/src',
950 '''protocol_common.c
951 protocol_common_ctdb.c
952 '''),
953 includes='include',
954 deps='ctdb-protocol-tests-basic replace talloc tdb')
956 bld.SAMBA_BINARY('protocol_basic_test',
957 source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'),
958 deps='ctdb-protocol-tests-basic talloc',
959 install_path='${CTDB_TEST_LIBEXECDIR}')
961 ctdb_protocol_tests = [
962 'protocol_types_test',
963 'protocol_ctdb_test',
964 'protocol_util_test',
965 'protocol_types_compat_test',
966 'protocol_ctdb_compat_test',
969 for target in ctdb_protocol_tests:
970 src = 'tests/src/' + target + '.c'
972 bld.SAMBA_BINARY(target,
973 source=src,
974 deps='''ctdb-protocol-tests-common
975 samba-util ctdb-util talloc tdb''',
976 install_path='${CTDB_TEST_LIBEXECDIR}')
978 bld.SAMBA_BINARY('event_protocol_test',
979 source='event/event_protocol_test.c',
980 deps='''ctdb-protocol-tests-basic
981 ctdb-protocol-basic talloc''',
982 install_path='${CTDB_TEST_LIBEXECDIR}')
984 bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
985 source=bld.SUBDIR('tests/src',
986 'cluster_wait.c test_options.c'),
987 includes='include',
988 deps='samba-util replace popt talloc tevent tdb')
990 # Test binaries
991 ctdb_tests = [
992 'g_lock_loop',
993 'message_ring',
994 'fetch_ring',
995 'fetch_loop',
996 'fetch_loop_key',
997 'fetch_readonly',
998 'fetch_readonly_loop',
999 'transaction_loop',
1000 'update_record',
1001 'update_record_persistent',
1002 'lock_tdb',
1003 'dummy_client',
1004 'tunnel_test',
1005 'tunnel_cmd',
1008 for target in ctdb_tests:
1009 src = 'tests/src/' + target + '.c'
1011 bld.SAMBA_BINARY(target,
1012 source=src,
1013 includes='include',
1014 deps='''ctdb-client ctdb-protocol ctdb-util
1015 samba-util ctdb-tests-common''',
1016 install_path='${CTDB_TEST_LIBEXECDIR}')
1018 bld.SAMBA_BINARY('ctdb_takeover_tests',
1019 source='''tests/src/ctdb_takeover_tests.c
1020 tests/src/ipalloc_read_known_ips.c''',
1021 deps='''replace popt tdb tevent talloc ctdb-system
1022 samba-util tdb-wrap talloc_report
1023 ctdb-ipalloc ctdb-protocol ctdb-util''',
1024 includes='include',
1025 install_path='${CTDB_TEST_LIBEXECDIR}')
1027 bld.SAMBA_BINARY('fake_ctdbd',
1028 source='''tests/src/fake_ctdbd.c
1029 tests/src/ipalloc_read_known_ips.c''',
1030 deps='''ctdb-util ctdb-protocol ctdb-protocol-util
1031 ctdb-system samba-util tevent-util
1032 LIBASYNC_REQ popt''',
1033 install_path='${CTDB_TEST_LIBEXECDIR}')
1035 if bld.env.HAVE_INFINIBAND:
1036 bld.SAMBA_BINARY('ibwrapper_test',
1037 source='ib/ibwrapper_test.c',
1038 includes='include',
1039 deps='replace talloc ctdb-common sys_rw' +
1040 ib_deps,
1041 install_path='${CTDB_TEST_LIBEXECDIR}')
1043 if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux'):
1044 bld.SAMBA_BINARY('test_mutex_raw',
1045 source='tests/src/test_mutex_raw.c',
1046 deps='pthread',
1047 install_path='${CTDB_TEST_LIBEXECDIR}')
1049 test_subdirs = [
1050 'complex',
1051 'ctdb_eventd',
1052 'cunit',
1053 'etc-ctdb',
1054 'eventd',
1055 'eventscripts',
1056 'onnode',
1057 'shellcheck',
1058 'simple',
1059 'takeover',
1060 'takeover_helper',
1061 'tool'
1064 if bld.env.standalone_ctdb:
1065 testdir = 'tests'
1066 else:
1067 testdir = 'ctdb/tests'
1069 for t in test_subdirs:
1070 files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir)
1071 for fmode in files:
1072 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
1073 destname=fmode[0], chmod=fmode[1])
1075 # Install tests/scripts directory without test_wrap
1076 test_scripts = [
1077 'common.sh',
1078 'integration.bash',
1079 'unit.sh'
1082 for t in test_scripts:
1083 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
1084 os.path.join('tests/scripts', t),
1085 destname=os.path.join('scripts', t))
1087 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
1088 bld.env.CTDB_TEST_LIBEXECDIR)
1089 bld.SAMBA_GENERATOR('ctdb-test-wrap',
1090 source='tests/scripts/test_wrap',
1091 target='test_wrap',
1092 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
1093 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
1094 destname='test_wrap', chmod=MODE_755)
1096 bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
1097 source='tests/scripts/script_install_paths.sh',
1098 target='script_install_paths.sh',
1099 rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
1100 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
1101 'script_install_paths.sh',
1102 destname='script_install_paths.sh', chmod=MODE_644)
1104 sed_expr1 = 's@^\(export %s\)=.*@\\1=%s@' % (
1105 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
1106 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
1107 bld.SAMBA_GENERATOR('ctdb-test-runner',
1108 source='tests/run_tests.sh',
1109 target='ctdb_run_tests.sh',
1110 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1111 sed_expr1, sed_expr2))
1112 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
1113 destname='ctdb_run_tests', chmod=MODE_755)
1114 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
1115 'ctdb_run_tests')
1117 bld.SAMBA_GENERATOR('ctdb-local-daemons',
1118 source='tests/local_daemons.sh',
1119 target='ctdb_local_daemons.sh',
1120 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
1121 sed_expr1, sed_expr2))
1122 bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
1123 destname='ctdb_local_daemons', chmod=MODE_755)
1126 def testonly(ctx):
1127 cmd = 'tests/run_tests.sh -V tests/var'
1128 ret = samba_utils.RUN_COMMAND(cmd)
1129 if ret != 0:
1130 print('tests exited with exit status %d' % ret)
1131 sys.exit(ret)
1134 def test(ctx):
1135 Options.commands.append('build')
1136 Options.commands.append('testonly')
1139 def autotest(ctx):
1140 env = samba_utils.LOAD_ENVIRONMENT()
1141 cmd = 'tests/run_tests.sh -e -S %s' % env.SOCKET_WRAPPER_SO_PATH
1142 ret = samba_utils.RUN_COMMAND(cmd)
1143 if ret != 0:
1144 print('autotest exited with exit status %d' % ret)
1145 sys.exit(ret)
1148 def show_version(ctx):
1149 print(get_version_string())
1152 def manpages(ctx):
1153 BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current'
1154 MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL
1155 HTML_XSL = '%s/html/docbook.xsl' % BASE_URL
1156 CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s'
1157 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1158 for t in manpages:
1159 cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t)
1160 ret = samba_utils.RUN_COMMAND(cmd)
1161 if ret != 0:
1162 print('Command %s failed with exit status %d' % (cmd, ret))
1163 sys.exit(ret)
1165 cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t)
1166 ret = samba_utils.RUN_COMMAND(cmd)
1167 if ret != 0:
1168 print('Command %s failed with exit status %d' % (cmd, ret))
1169 sys.exit(ret)
1172 def distonly(ctx):
1173 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
1175 t = 'ctdb.spec'
1176 sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
1177 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
1178 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
1179 sed_expr1, sed_expr2, t)
1180 ret = samba_utils.RUN_COMMAND(cmd)
1181 if ret != 0:
1182 print('Command "%s" failed with exit status %d' % (cmd, ret))
1183 sys.exit(ret)
1184 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
1186 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1187 for t in manpages:
1188 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
1189 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
1190 extend=True)
1192 samba_dist.dist()
1195 def dist():
1196 Options.commands.append('manpages')
1197 Options.commands.append('distonly')
1200 def rpmonly(ctx):
1201 opts = os.getenv('RPM_OPTIONS') or ''
1202 cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
1203 (opts, get_version_string())
1204 ret = samba_utils.RUN_COMMAND(cmd)
1205 if ret != 0:
1206 print('rpmbuild exited with exit status %d' % ret)
1207 sys.exit(ret)
1210 def rpm(ctx):
1211 Options.commands.append('manpages')
1212 Options.commands.append('distonly')
1213 Options.commands.append('rpmonly')
1216 def ctags(ctx):
1217 "build 'tags' file using ctags"
1218 source_root = os.path.dirname(Context.g_module.root_path)
1219 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
1220 print("Running: %s" % cmd)
1221 ret = samba_utils.RUN_COMMAND(cmd)
1222 if ret != 0:
1223 print('ctags failed with exit status %d' % ret)
1224 sys.exit(ret)