9 # find the buildtools directory
11 while not os
.path
.exists(srcdir
+'/buildtools') and len(srcdir
.split('/')) < 5:
12 srcdir
= srcdir
+ '/..'
13 sys
.path
.insert(0, srcdir
+ '/buildtools/wafsamba')
15 import wafsamba
, samba_dist
, Options
, Logs
, Utils
16 import samba_utils
, samba_version
18 env
= samba_utils
.LOAD_ENVIRONMENT()
19 if os
.path
.isfile('./VERSION'):
21 elif os
.path
.isfile('../VERSION'):
24 Logs
.error("VERSION file not found")
26 version
= samba_version
.samba_version_file('%s/VERSION' % vdir
, vdir
, env
)
27 VERSION
= version
.STRING
.replace('-', '.')
29 default_prefix
= Options
.default_prefix
= '/usr/local'
31 samba_dist
.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
32 lib/tevent:lib/tevent lib/tdb:lib/tdb
33 third_party/socket_wrapper:third_party/socket_wrapper
34 third_party/popt:third_party/popt
35 lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
36 lib/ccan:lib/ccan libcli/util:libcli/util
37 lib/async_req:lib/async_req
38 buildtools:buildtools third_party/waf:third_party/waf''')
51 'ctdb-script.options.5',
64 'ctdb_mutex_ceph_rados_helper.7',
69 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
71 opt
.RECURSE('lib/replace')
73 opt
.RECURSE('lib/util')
75 opt
.RECURSE('lib/talloc')
76 opt
.RECURSE('lib/tevent')
77 opt
.RECURSE('lib/tdb')
79 opt
.add_option('--enable-infiniband',
80 help=("Turn on infiniband support (default=no)"),
81 action
="store_true", dest
='ctdb_infiniband', default
=False)
82 opt
.add_option('--enable-pmda',
83 help=("Turn on PCP pmda support (default=no)"),
84 action
="store_true", dest
='ctdb_pmda', default
=False)
85 opt
.add_option('--enable-etcd-reclock',
86 help=("Enable etcd recovery lock helper (default=no)"),
87 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
88 opt
.add_option('--enable-ceph-reclock',
89 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
90 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
92 opt
.add_option('--with-logdir',
93 help=("Path to log directory"),
94 action
="store", dest
='ctdb_logdir', default
=None)
95 opt
.add_option('--with-socketpath',
96 help=("path to CTDB daemon socket"),
97 action
="store", dest
='ctdb_sockpath', default
=None)
102 # No need to build python bindings for talloc/tevent/tdb
103 if conf
.IN_LAUNCH_DIR():
104 conf
.env
.standalone_ctdb
= True
105 Options
.options
.disable_python
= True
107 conf
.RECURSE('lib/replace')
109 if conf
.env
.standalone_ctdb
:
110 conf
.SAMBA_CHECK_PERL(mandatory
=True)
112 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
113 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
115 if conf
.CHECK_FOR_THIRD_PARTY():
116 conf
.RECURSE('third_party/popt')
117 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
118 conf
.RECURSE('third_party/socket_wrapper')
119 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
121 if not conf
.CHECK_POPT():
122 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
124 conf
.define('USING_SYSTEM_POPT', 1)
125 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
128 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
129 if not conf
.CHECK_SOCKET_WRAPPER():
130 raise Utils
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
132 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
133 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
135 conf
.RECURSE('lib/util')
137 conf
.RECURSE('lib/talloc')
138 conf
.RECURSE('lib/tevent')
139 conf
.RECURSE('lib/tdb')
141 conf
.CHECK_HEADERS('sched.h')
142 conf
.CHECK_HEADERS('procinfo.h')
143 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
144 Logs
.error('Need thread_setsched() on AIX')
146 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
147 Logs
.error('Need sched_setscheduler()')
149 conf
.CHECK_FUNCS('mlockall')
151 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
152 conf
.DEFINE('ETIME', 'ETIMEDOUT')
154 if sys
.platform
.startswith('linux'):
155 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
157 if not conf
.CHECK_HEADERS('pcap.h'):
158 Logs
.error('Need libpcap')
160 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
161 Logs
.error('Need libpcap')
164 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
165 checklibc
=True, headers
='execinfo.h'):
166 Logs
.error('backtrace support not available')
169 if Options
.options
.ctdb_pmda
:
172 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
175 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
177 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
180 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
183 Logs
.error("PMDA support not available")
186 Logs
.info('Building with PMDA support')
187 conf
.define('HAVE_PMDA', 1)
188 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
189 'lib/pcp/pmdas/ctdb')
191 have_infiniband
= False
192 if Options
.options
.ctdb_infiniband
:
195 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
197 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
199 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
202 have_infiniband
= True
204 Logs
.error("Infiniband support not available")
207 Logs
.info('Building with Infiniband support')
208 conf
.define('HAVE_INFINIBAND', 1)
209 conf
.define('USE_INFINIBAND', 1)
211 have_etcd_reclock
= False
212 if Options
.options
.ctdb_etcd_reclock
:
214 conf
.check_python_module('etcd')
215 have_etcd_reclock
= True
217 Logs
.error('etcd support not available')
219 if have_etcd_reclock
:
220 Logs
.info('Building with etcd support')
221 conf
.env
.etcd_reclock
= have_etcd_reclock
223 if Options
.options
.ctdb_ceph_reclock
:
224 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
225 conf
.CHECK_LIB('rados', shlib
=True)):
226 Logs
.info('Building with Ceph librados recovery lock support')
227 conf
.define('HAVE_LIBRADOS', 1)
229 Logs
.error("Missing librados for Ceph recovery lock support")
232 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
233 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
234 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
235 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
236 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
238 if Options
.options
.ctdb_logdir
:
239 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
241 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
243 if Options
.options
.ctdb_sockpath
:
244 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
246 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
248 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
250 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
254 -DCTDB_RUNDIR=\"%s\"''' % (
255 conf
.env
.CTDB_HELPER_BINDIR
,
256 conf
.env
.CTDB_LOGDIR
,
257 conf
.env
.CTDB_ETCDIR
,
258 conf
.env
.CTDB_VARDIR
,
259 conf
.env
.CTDB_RUNDIR
))
261 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
263 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
265 # Allow unified compilation and separate compilation of utilities
267 if not conf
.env
.standalone_ctdb
:
268 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
271 # Building from tarball
272 conf
.ADD_EXTRA_INCLUDES('#include')
274 # Building standalone CTDB from within Samba tree
275 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
276 conf
.ADD_EXTRA_INCLUDES('#ctdb')
277 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
279 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
280 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
281 conf
.SAMBA_CONFIG_H()
283 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
284 conf
.env
.ctdb_generate_manpages
= True
286 conf
.env
.ctdb_generate_manpages
= False
288 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
289 conf
.env
.ctdb_prebuilt_manpages
= []
290 manpages
= manpages_binary
+ manpages_misc
291 if conf
.env
.etcd_reclock
:
292 manpages
+= manpages_etcd
293 if conf
.env
.HAVE_LIBRADOS
:
294 manpages
+= manpages_ceph
296 if os
.path
.exists(os
.path
.join("doc", m
)):
297 Logs
.info(" %s: yes" % (m
))
298 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
300 Logs
.info(" %s: no" % (m
))
302 def gen_ctdb_version(task
):
303 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
304 fp
.write('/* This file is auto-generated from waf */\n')
305 fp
.write('#include "version.h"\n')
307 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
312 if bld
.env
.standalone_ctdb
:
313 # enable building of public headers in the build tree
314 bld
.env
.build_public_headers
= 'include/public'
316 if bld
.env
.standalone_ctdb
:
317 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
319 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
320 target
='include/ctdb_version.h',
321 rule
=gen_ctdb_version
,
322 dep_vars
=['VERSION'])
323 t
.env
.VERSION
= VERSION
325 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
327 bld
.RECURSE('lib/replace')
328 if bld
.CHECK_FOR_THIRD_PARTY():
329 bld
.RECURSE('third_party/popt')
330 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
331 bld
.RECURSE('third_party/socket_wrapper')
333 bld
.RECURSE('lib/tdb_wrap')
334 bld
.RECURSE('lib/util')
335 bld
.RECURSE('lib/async_req')
337 bld
.RECURSE('lib/talloc')
338 bld
.RECURSE('lib/tevent')
339 bld
.RECURSE('lib/tdb')
341 if bld
.env
.standalone_ctdb
:
342 # If a combined build is implemented, CTDB will want to
343 # build against samba-util rather than samba-util-core.
344 # Similarly, other Samba subsystems expect samba-util. So,
345 # for a standalone build, just define a fake samba-util
346 # subsystem that pulls in samba-util-core.
347 bld
.SAMBA_SUBSYSTEM('samba-util',
349 deps
='samba-util-core')
351 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
352 source
=bld
.SUBDIR('tcp',
353 'tcp_connect.c tcp_init.c tcp_io.c'),
355 deps
='replace tdb talloc tevent')
358 if bld
.env
.HAVE_INFINIBAND
:
359 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
360 source
=bld
.SUBDIR('ib',
361 '''ibwrapper.c ibw_ctdb.c
364 deps
='replace talloc tevent tdb')
365 ib_deps
= ' ctdb-ib rdmacm ibverbs'
367 if sys
.platform
.startswith('linux'):
368 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
369 elif sys
.platform
.startswith('aix'):
370 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
371 elif sys
.platform
.startswith('freebsd'):
372 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
373 elif sys
.platform
.startswith('gnukfreebsd'):
374 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
375 elif sys
.platform
== 'gnu':
376 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
378 Logs
.error("Platform %s not supported" % sys
.platform
)
380 bld
.SAMBA_SUBSYSTEM('ctdb-system',
381 source
=bld
.SUBDIR('common',
382 'system_common.c system_util.c') +
385 deps
='replace talloc tevent tdb pcap samba-util')
387 bld
.SAMBA_SUBSYSTEM('ctdb-common',
388 source
=bld
.SUBDIR('common',
389 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
392 deps
='''replace popt talloc tevent tdb popt ctdb-system
393 ctdb-protocol-util''')
395 bld
.SAMBA_SUBSYSTEM('ctdb-util',
396 source
=bld
.SUBDIR('common',
397 '''db_hash.c srvid.c reqid.c
398 pkt_read.c pkt_write.c comm.c
399 logging.c rb_tree.c tunable.c
401 hash_count.c run_event.c
402 sock_client.c version.c
403 cmdline.c path.c conf.c
405 deps
='''samba-util sys_rw tevent-util
406 replace talloc tevent tdb popt''')
408 bld
.SAMBA_SUBSYSTEM('ctdb-logging-conf',
409 source
='common/logging_conf.c',
410 deps
='ctdb-util talloc')
412 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
413 source
=bld
.SUBDIR('protocol',
414 '''protocol_header.c protocol_packet.c
415 protocol_basic.c protocol_types.c
426 deps
='replace talloc tdb')
428 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
429 source
='protocol/protocol_util.c',
430 deps
='replace talloc tdb')
432 bld
.SAMBA_SUBSYSTEM('ctdb-client',
433 source
=bld
.SUBDIR('client',
434 '''client_connect.c client_call.c
435 client_message.c client_control.c
436 client_message_sync.c
437 client_control_sync.c
438 client_db.c client_util.c
439 client_event.c client_tunnel.c
442 deps
='replace talloc tevent tdb tdb-wrap')
444 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
445 source
=bld
.SUBDIR('common',
446 '''sock_daemon.c'''),
447 deps
='''samba-util ctdb-util tevent-util
448 LIBASYNC_REQ replace talloc tevent''')
450 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
451 source
=bld
.SUBDIR('server',
452 '''ipalloc_deterministic.c
453 ipalloc_nondeterministic.c
459 deps
='ctdb-protocol-util replace talloc tevent')
461 bld
.SAMBA_BINARY('ctdb-path',
462 source
='common/path_tool.c',
463 cflags
='-DCTDB_PATH_TOOL',
464 deps
='''ctdb-util samba-util talloc replace popt''',
465 install_path
='${CTDB_HELPER_BINDIR}')
467 bld
.SAMBA_BINARY('ctdb-config',
468 source
='common/conf_tool.c',
469 cflags
='-DCTDB_CONF_TOOL',
470 deps
='''ctdb-logging-conf
471 ctdb-util samba-util talloc replace popt''',
472 install_path
='${CTDB_HELPER_BINDIR}')
474 bld
.SAMBA_BINARY('ctdbd',
475 source
='server/ctdbd.c ' +
477 '''ctdb_daemon.c ctdb_recoverd.c
478 ctdb_recover.c ctdb_freeze.c
479 ctdb_tunables.c ctdb_monitor.c
480 ctdb_server.c ctdb_control.c
481 ctdb_call.c ctdb_ltdb_server.c
482 ctdb_traverse.c eventscript.c
484 ctdb_persistent.c ctdb_keepalive.c
488 ctdb_vacuum.c ctdb_banning.c
491 ctdb_lock.c ctdb_fork.c
492 ctdb_tunnel.c ctdb_client.c'''),
494 deps
='''ctdb-common ctdb-system ctdb-protocol
495 ctdb-tcp ctdb-util replace sys_rw popt
496 talloc tevent tdb-wrap tdb talloc_report''' +
498 install_path
='${SBINDIR}',
501 bld
.SAMBA_BINARY('ctdb',
502 source
='tools/ctdb.c',
503 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
504 ctdb-util ctdb-system samba-util sys_rw popt''',
505 install_path
='${BINDIR}',
508 bld
.SAMBA_BINARY('ctdb_killtcp',
509 source
='tools/ctdb_killtcp.c',
510 deps
='''ctdb-protocol-util ctdb-util ctdb-system
511 samba-util replace''',
512 install_path
='${CTDB_HELPER_BINDIR}')
514 bld
.SAMBA_BINARY('ctdb_event',
515 source
='tools/ctdb_event.c',
516 deps
='''ctdb-client ctdb-protocol ctdb-protocol-util
517 ctdb-util ctdb-system samba-util replace''',
518 install_path
='${CTDB_HELPER_BINDIR}')
520 bld
.SAMBA_BINARY('ltdbtool',
521 source
='tools/ltdbtool.c',
524 install_path
='${BINDIR}',
525 manpages
='ltdbtool.1')
527 bld
.SAMBA_BINARY('ctdb_eventd',
528 source
='server/ctdb_eventd.c',
529 deps
='''ctdb-server-util ctdb-protocol ctdb-protocol-util
530 ctdb-util samba-util replace popt''',
531 install_path
='${CTDB_HELPER_BINDIR}')
533 bld
.SAMBA_BINARY('ctdb_lock_helper',
534 source
='server/ctdb_lock_helper.c',
535 deps
='''samba-util sys_rw ctdb-system tevent-util
536 talloc tevent tdb''',
538 install_path
='${CTDB_HELPER_BINDIR}')
540 bld
.SAMBA_BINARY('ctdb_recovery_helper',
541 source
='server/ctdb_recovery_helper.c',
542 deps
='''ctdb-client ctdb-protocol ctdb-util
543 samba-util sys_rw replace tdb''',
544 install_path
='${CTDB_HELPER_BINDIR}')
546 bld
.SAMBA_BINARY('ctdb_takeover_helper',
547 source
='server/ctdb_takeover_helper.c',
548 deps
='''ctdb-client ctdb-protocol ctdb-util
549 samba-util sys_rw replace ctdb-ipalloc popt''',
550 install_path
='${CTDB_HELPER_BINDIR}')
552 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
553 source
='server/ctdb_mutex_fcntl_helper.c',
554 deps
='sys_rw ctdb-system',
556 install_path
='${CTDB_HELPER_BINDIR}')
558 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
559 source
='utils/smnotify/smnotify.x',
560 target
='utils/smnotify/smnotify.h',
561 rule
='rpcgen -h ${SRC} > ${TGT}')
563 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
565 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
566 source
='utils/smnotify/smnotify.x',
567 target
='utils/smnotify/gen_xdr.c',
568 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
570 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
571 source
='utils/smnotify/smnotify.x',
572 target
='utils/smnotify/gen_smnotify.c',
573 rule
='rpcgen -l ${SRC} > ${TGT}')
575 bld
.SAMBA_BINARY('smnotify',
576 source
=bld
.SUBDIR('utils/smnotify',
577 'smnotify.c gen_smnotify.c gen_xdr.c'),
578 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
579 includes
='utils utils/smnotify',
580 install_path
='${CTDB_HELPER_BINDIR}')
582 bld
.SAMBA_BINARY('ping_pong',
583 source
='utils/ping_pong/ping_pong.c',
585 install_path
='${BINDIR}',
586 manpages
='ping_pong.1')
588 if bld
.env
.HAVE_PMDA
:
589 bld
.SAMBA_BINARY('pmdactdb',
590 source
='utils/pmda/pmda_ctdb.c',
592 deps
='''ctdb-client ctdb-protocol ctdb-util
593 samba-util pcp_pmda pcp''',
594 install_path
='${CTDB_PMDADIR}')
595 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
597 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
599 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
601 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
603 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
605 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
608 if bld
.env
.HAVE_LIBRADOS
:
609 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
610 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
611 deps
='talloc tevent rados',
613 install_path
='${CTDB_HELPER_BINDIR}')
615 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
616 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
617 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
618 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
619 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
620 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
621 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
622 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
623 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
624 sed_expr6
, sed_expr7
)
626 manpages_extra
= manpages_misc
627 if bld
.env
.etcd_reclock
:
628 manpages_extra
+= manpages_etcd
629 if bld
.env
.HAVE_LIBRADOS
:
630 manpages_extra
+= manpages_ceph
631 for f
in manpages_binary
+ manpages_extra
:
633 bld
.SAMBA_GENERATOR(x
,
634 source
=os
.path
.join('doc', x
),
636 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
638 if bld
.env
.ctdb_generate_manpages
:
639 bld
.MANPAGES(' '.join(manpages_extra
), True)
641 for m
in bld
.env
.ctdb_prebuilt_manpages
:
642 bld
.SAMBA_GENERATOR(m
,
643 source
=os
.path
.join("doc", m
),
645 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
646 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
648 bld
.SAMBA_GENERATOR('ctdb-onnode',
649 source
='tools/onnode',
651 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
652 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
653 destname
='onnode', chmod
=0755)
655 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
656 source
='tools/ctdb_diagnostics',
657 target
='ctdb_diagnostics',
658 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
659 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
660 destname
='ctdb_diagnostics', chmod
=0755)
662 if bld
.env
.etcd_reclock
:
663 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
664 source
='utils/etcd/ctdb_etcd_lock',
665 target
='ctdb_etcd_lock',
666 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
667 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
668 destname
='ctdb_etcd_lock', chmod
=0744)
670 bld
.SAMBA_GENERATOR('ctdb-natgw',
671 source
='tools/ctdb_natgw',
673 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
674 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
675 destname
='ctdb_natgw', chmod
=0755)
677 bld
.SAMBA_GENERATOR('ctdb-lvs',
678 source
='tools/ctdb_lvs',
680 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
681 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
682 destname
='ctdb_lvs', chmod
=0755)
684 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
685 source
='config/ctdbd_wrapper',
686 target
='ctdbd_wrapper',
687 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
688 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
689 destname
='ctdbd_wrapper', chmod
=0755)
691 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
693 fl
= os
.path
.join(dirname
, f
)
694 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
696 mode
= os
.lstat(fl
).st_mode
& 0777
698 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
699 arg
['file_list'].append([fl
, mode
])
701 def SUBDIR_MODE(path
, trim_path
=None):
702 pd
= {'trim_path': trim_path
, 'file_list': []}
703 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
704 return pd
['file_list']
711 if bld
.env
.standalone_ctdb
:
714 configdir
= 'ctdb/config'
716 for t
in etc_subdirs
:
717 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
719 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
720 destname
=fmode
[0], chmod
=fmode
[1])
722 bld
.SAMBA_GENERATOR('ctdb-functions',
723 source
='config/functions',
725 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
726 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
729 'ctdb-crash-cleanup.sh',
730 'debug-hung-script.sh',
732 'nfs-linux-kernel-callout',
737 for t
in etc_scripts
:
738 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
739 destname
=t
, chmod
=0755)
741 bld
.SAMBA_GENERATOR('ctdb-sudoers',
742 source
='config/ctdb.sudoers',
743 target
='ctdb.sudoers',
744 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
745 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
748 bld
.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
751 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
752 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
753 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
774 for target
in ctdb_unit_tests
:
775 src
= 'tests/src/' + target
+ '.c'
777 bld
.SAMBA_BINARY(target
,
779 deps
='''talloc tevent tdb tevent-util popt
780 LIBASYNC_REQ samba-util sys_rw''',
781 install_path
='${CTDB_TEST_LIBEXECDIR}')
783 bld
.SAMBA_BINARY('reqid_test',
784 source
='tests/src/reqid_test.c',
786 install_path
='${CTDB_TEST_LIBEXECDIR}')
788 bld
.SAMBA_BINARY('rb_test',
789 source
='tests/src/rb_test.c',
790 deps
='samba-util talloc',
791 install_path
='${CTDB_TEST_LIBEXECDIR}')
793 bld
.SAMBA_BINARY('ctdb_packet_parse',
794 source
='tests/src/ctdb_packet_parse.c',
795 deps
='talloc tevent tdb ctdb-protocol',
796 install_path
='${CTDB_TEST_LIBEXECDIR}')
798 bld
.SAMBA_BINARY('porting_tests',
799 source
='tests/src/porting_tests.c',
800 deps
='samba-util ctdb-system popt',
801 install_path
='${CTDB_TEST_LIBEXECDIR}')
803 bld
.SAMBA_SUBSYSTEM('protocol-tests-common',
804 source
=bld
.SUBDIR('tests/src',
806 protocol_common_ctdb.c
807 protocol_common_event.c
810 deps
='replace popt talloc tevent tdb')
812 ctdb_protocol_tests
= [
813 'protocol_basic_test',
814 'protocol_types_test',
815 'protocol_ctdb_test',
816 'protocol_event_test',
817 'protocol_util_test',
818 'protocol_types_compat_test',
819 'protocol_ctdb_compat_test',
822 for target
in ctdb_protocol_tests
:
823 src
= 'tests/src/' + target
+ '.c'
825 bld
.SAMBA_BINARY(target
,
827 deps
='''protocol-tests-common
828 samba-util talloc tdb''',
829 install_path
='${CTDB_TEST_LIBEXECDIR}')
831 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
832 source
=bld
.SUBDIR('tests/src',
833 'cluster_wait.c test_options.c'),
835 deps
='replace popt talloc tevent tdb')
845 'fetch_readonly_loop',
848 'update_record_persistent',
855 for target
in ctdb_tests
:
856 src
= 'tests/src/' + target
+ '.c'
858 bld
.SAMBA_BINARY(target
,
861 deps
='''ctdb-client ctdb-protocol ctdb-util
862 samba-util ctdb-tests-common''',
863 install_path
='${CTDB_TEST_LIBEXECDIR}')
865 bld
.SAMBA_BINARY('ctdb_takeover_tests',
866 source
='''tests/src/ctdb_takeover_tests.c
867 tests/src/ipalloc_read_known_ips.c''',
868 deps
='''replace popt tdb tevent talloc ctdb-system
869 samba-util tdb-wrap talloc_report
870 ctdb-ipalloc ctdb-protocol ctdb-util''',
872 install_path
='${CTDB_TEST_LIBEXECDIR}')
874 bld
.SAMBA_BINARY('fake_ctdbd',
875 source
='''tests/src/fake_ctdbd.c
876 tests/src/ipalloc_read_known_ips.c''',
877 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
878 ctdb-system samba-util tevent-util
879 LIBASYNC_REQ popt''',
880 install_path
='${CTDB_TEST_LIBEXECDIR}')
882 if bld
.env
.HAVE_INFINIBAND
:
883 bld
.SAMBA_BINARY('ibwrapper_test',
884 source
='ib/ibwrapper_test.c',
886 deps
='replace talloc ctdb-common sys_rw' +
888 install_path
='${CTDB_TEST_LIBEXECDIR}')
890 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
891 bld
.SAMBA_BINARY('test_mutex_raw',
892 source
='tests/src/test_mutex_raw.c',
894 install_path
='${CTDB_TEST_LIBEXECDIR}')
909 if bld
.env
.standalone_ctdb
:
912 testdir
= 'ctdb/tests'
914 for t
in test_subdirs
:
915 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
917 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
918 destname
=fmode
[0], chmod
=fmode
[1])
920 # Install tests/scripts directory without test_wrap
927 for t
in test_scripts
:
928 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
929 os
.path
.join('tests/scripts', t
),
930 destname
=os
.path
.join('scripts', t
))
932 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
933 bld
.env
.CTDB_TEST_LIBEXECDIR
)
934 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
935 source
='tests/scripts/test_wrap',
937 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
938 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
939 destname
='test_wrap', chmod
=0755)
941 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
942 source
='tests/scripts/script_install_paths.sh',
943 target
='script_install_paths.sh',
944 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
945 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
946 'script_install_paths.sh',
947 destname
='script_install_paths.sh', chmod
=0644)
949 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
950 'CTDB_TEST_DIR
', bld.env.CTDB_TEST_DATADIR,
951 'TEST_BIN_DIR
', bld.env.CTDB_TEST_LIBEXECDIR)
952 sed_expr2 = 's
@^\
(export CTDB_TESTS_ARE_INSTALLED\
)=false
@\\1=true
@'
953 bld.SAMBA_GENERATOR('ctdb
-test
-runner
',
954 source='tests
/run_tests
.sh
',
955 target='ctdb_run_tests
.sh
',
956 rule='sed
-e
"%s" -e
"%s" ${SRC}
> ${TGT}
' % (
957 sed_expr1, sed_expr2))
958 bld.INSTALL_FILES('${BINDIR}
', 'ctdb_run_tests
.sh
',
959 destname='ctdb_run_tests
', chmod=0755)
960 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests
'),
965 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
966 ret = samba_utils.RUN_COMMAND(cmd)
968 print('tests exited with exit status
%d' % ret)
974 Scripting.commands.append('build
')
975 Scripting.commands.append('testonly
')
979 env = samba_utils.LOAD_ENVIRONMENT()
980 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
981 ret = samba_utils.RUN_COMMAND(cmd)
983 print('autotest exited with exit status
%d' % ret)
987 def show_version(ctx):
992 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
993 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
994 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
995 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
996 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
998 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
999 ret = samba_utils.RUN_COMMAND(cmd)
1001 print('Command
%s failed with exit status
%d' % (cmd, ret))
1004 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
1005 ret = samba_utils.RUN_COMMAND(cmd)
1007 print('Command
%s failed with exit status
%d' % (cmd, ret))
1012 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
1014 distfile = file('.distversion
', 'w
')
1015 for field in version.vcs_fields:
1016 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1018 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1021 sed_expr1 = 's
/@VERSION@/%s/g
' % VERSION
1022 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1023 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1024 sed_expr1, sed_expr2, t)
1025 ret = samba_utils.RUN_COMMAND(cmd)
1027 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1029 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1031 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1033 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1034 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1042 Scripting.commands.append('manpages
')
1043 Scripting.commands.append('distonly
')
1047 opts = os.getenv('RPM_OPTIONS
') or ''
1048 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % (opts, VERSION)
1049 ret = samba_utils.RUN_COMMAND(cmd)
1051 print('rpmbuild exited with exit status
%d' % ret)
1057 Scripting.commands.append('manpages
')
1058 Scripting.commands.append('distonly
')
1059 Scripting.commands.append('rpmonly
')
1063 "build 'tags
' file using ctags"
1065 source_root = os.path.dirname(Utils.g_module.root_path)
1066 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1067 print("Running: %s" % cmd)
1068 ret = samba_utils.RUN_COMMAND(cmd)
1070 print('ctags failed with exit status
%d' % ret)