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