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''')
62 'ctdb_mutex_ceph_rados_helper.7',
67 opt
.PRIVATE_EXTENSION_DEFAULT('ctdb')
69 opt
.RECURSE('lib/replace')
71 opt
.RECURSE('lib/util')
73 opt
.RECURSE('lib/talloc')
74 opt
.RECURSE('lib/tevent')
75 opt
.RECURSE('lib/tdb')
77 opt
.add_option('--enable-infiniband',
78 help=("Turn on infiniband support (default=no)"),
79 action
="store_true", dest
='ctdb_infiniband', default
=False)
80 opt
.add_option('--enable-pmda',
81 help=("Turn on PCP pmda support (default=no)"),
82 action
="store_true", dest
='ctdb_pmda', default
=False)
83 opt
.add_option('--enable-etcd-reclock',
84 help=("Enable etcd recovery lock helper (default=no)"),
85 action
="store_true", dest
='ctdb_etcd_reclock', default
=False)
87 opt
.add_option('--with-libcephfs',
88 help=("Directory under which libcephfs is installed"),
89 action
="store", dest
='libcephfs_dir', default
=None)
90 opt
.add_option('--enable-ceph-reclock',
91 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
92 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
94 opt
.add_option('--with-logdir',
95 help=("Path to log directory"),
96 action
="store", dest
='ctdb_logdir', default
=None)
97 opt
.add_option('--with-socketpath',
98 help=("path to CTDB daemon socket"),
99 action
="store", dest
='ctdb_sockpath', default
=None)
104 # No need to build python bindings for talloc/tevent/tdb
105 if conf
.IN_LAUNCH_DIR():
106 conf
.env
.standalone_ctdb
= True
107 Options
.options
.disable_python
= True
109 conf
.RECURSE('lib/replace')
111 if conf
.env
.standalone_ctdb
:
112 conf
.SAMBA_CHECK_PERL(mandatory
=True)
114 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
115 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
117 if conf
.CHECK_FOR_THIRD_PARTY():
118 conf
.RECURSE('third_party/popt')
119 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
120 conf
.RECURSE('third_party/socket_wrapper')
121 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
123 if not conf
.CHECK_POPT():
124 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
126 conf
.define('USING_SYSTEM_POPT', 1)
127 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
130 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
131 if not conf
.CHECK_SOCKET_WRAPPER():
132 raise Utils
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
134 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
135 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
137 conf
.RECURSE('lib/util')
139 conf
.RECURSE('lib/talloc')
140 conf
.RECURSE('lib/tevent')
141 conf
.RECURSE('lib/tdb')
143 conf
.CHECK_HEADERS('sched.h')
144 conf
.CHECK_HEADERS('procinfo.h')
145 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
146 Logs
.error('Need thread_setsched() on AIX')
148 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
149 Logs
.error('Need sched_setscheduler()')
151 conf
.CHECK_FUNCS('mlockall')
153 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
154 conf
.DEFINE('ETIME', 'ETIMEDOUT')
156 if sys
.platform
.startswith('linux'):
157 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
159 if not conf
.CHECK_HEADERS('pcap.h'):
160 Logs
.error('Need libpcap')
162 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
163 Logs
.error('Need libpcap')
166 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
167 checklibc
=True, headers
='execinfo.h'):
168 Logs
.error('backtrace support not available')
171 if Options
.options
.ctdb_pmda
:
174 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
177 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
179 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
182 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
185 Logs
.error("PMDA support not available")
188 Logs
.info('Building with PMDA support')
189 conf
.define('HAVE_PMDA', 1)
190 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
191 'lib/pcp/pmdas/ctdb')
193 have_infiniband
= False
194 if Options
.options
.ctdb_infiniband
:
197 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
199 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
201 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
204 have_infiniband
= True
206 Logs
.error("Infiniband support not available")
209 Logs
.info('Building with Infiniband support')
210 conf
.define('HAVE_INFINIBAND', 1)
211 conf
.define('USE_INFINIBAND', 1)
213 have_etcd_reclock
= False
214 if Options
.options
.ctdb_etcd_reclock
:
216 conf
.check_python_module('etcd')
217 have_etcd_reclock
= True
219 Logs
.error('etcd support not available')
221 if have_etcd_reclock
:
222 Logs
.info('Building with etcd support')
223 conf
.env
.etcd_reclock
= have_etcd_reclock
225 if Options
.options
.ctdb_ceph_reclock
:
226 # Use custom libcephfs library path if provided. XXX The top level build
227 # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
228 if Options
.options
.libcephfs_dir
:
229 conf
.env
['CPPPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/include'
230 conf
.env
['LIBPATH_RADOS'] = Options
.options
.libcephfs_dir
+ '/lib'
231 conf
.env
['LIBPATH_CEPH-COMMON'] = conf
.env
['LIBPATH_RADOS'] + '/ceph'
233 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
234 conf
.CHECK_LIB('rados', shlib
=True)):
235 conf
.CHECK_LIB('ceph-common', shlib
=True)
236 Logs
.info('Building with Ceph librados recovery lock support')
237 conf
.define('HAVE_LIBRADOS', 1)
239 Logs
.error("Missing librados for Ceph recovery lock support")
242 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
243 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
244 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
245 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
246 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
248 if Options
.options
.ctdb_logdir
:
249 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
251 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
253 if Options
.options
.ctdb_sockpath
:
254 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
256 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
258 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
260 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
264 -DCTDB_RUNDIR=\"%s\"''' % (
265 conf
.env
.CTDB_HELPER_BINDIR
,
266 conf
.env
.CTDB_LOGDIR
,
267 conf
.env
.CTDB_ETCDIR
,
268 conf
.env
.CTDB_VARDIR
,
269 conf
.env
.CTDB_RUNDIR
))
271 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
273 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
275 # Allow unified compilation and separate compilation of utilities
277 if not conf
.env
.standalone_ctdb
:
278 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
281 # Building from tarball
282 conf
.ADD_EXTRA_INCLUDES('#include')
284 # Building standalone CTDB from within Samba tree
285 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
286 conf
.ADD_EXTRA_INCLUDES('#ctdb')
287 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
289 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
290 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
291 conf
.SAMBA_CONFIG_H()
293 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
294 conf
.env
.ctdb_generate_manpages
= True
296 conf
.env
.ctdb_generate_manpages
= False
298 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
299 conf
.env
.ctdb_prebuilt_manpages
= []
300 manpages
= manpages_binary
+ manpages_misc
301 if conf
.env
.etcd_reclock
:
302 manpages
+= manpages_etcd
303 if conf
.env
.HAVE_LIBRADOS
:
304 manpages
+= manpages_ceph
306 if os
.path
.exists(os
.path
.join("doc", m
)):
307 Logs
.info(" %s: yes" % (m
))
308 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
310 Logs
.info(" %s: no" % (m
))
312 def gen_ctdb_version(task
):
313 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
314 fp
.write('/* This file is auto-generated from waf */\n')
315 fp
.write('#include "version.h"\n')
317 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
322 if bld
.env
.standalone_ctdb
:
323 # enable building of public headers in the build tree
324 bld
.env
.build_public_headers
= 'include/public'
326 if bld
.env
.standalone_ctdb
:
327 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
329 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
330 target
='include/ctdb_version.h',
331 rule
=gen_ctdb_version
,
332 dep_vars
=['VERSION'])
333 t
.env
.VERSION
= VERSION
335 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
337 bld
.RECURSE('lib/replace')
338 if bld
.CHECK_FOR_THIRD_PARTY():
339 bld
.RECURSE('third_party/popt')
340 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
341 bld
.RECURSE('third_party/socket_wrapper')
343 bld
.RECURSE('lib/tdb_wrap')
344 bld
.RECURSE('lib/util')
345 bld
.RECURSE('lib/async_req')
347 bld
.RECURSE('lib/talloc')
348 bld
.RECURSE('lib/tevent')
349 bld
.RECURSE('lib/tdb')
351 if bld
.env
.standalone_ctdb
:
352 # If a combined build is implemented, CTDB will want to
353 # build against samba-util rather than samba-util-core.
354 # Similarly, other Samba subsystems expect samba-util. So,
355 # for a standalone build, just define a fake samba-util
356 # subsystem that pulls in samba-util-core.
357 bld
.SAMBA_SUBSYSTEM('samba-util',
359 deps
='samba-util-core')
361 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
362 source
=bld
.SUBDIR('tcp',
363 'tcp_connect.c tcp_init.c tcp_io.c'),
365 deps
='replace tdb talloc tevent')
368 if bld
.env
.HAVE_INFINIBAND
:
369 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
370 source
=bld
.SUBDIR('ib',
371 '''ibwrapper.c ibw_ctdb.c
374 deps
='replace talloc tevent tdb')
375 ib_deps
= ' ctdb-ib rdmacm ibverbs'
377 if sys
.platform
.startswith('linux'):
378 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
379 elif sys
.platform
.startswith('aix'):
380 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
381 elif sys
.platform
.startswith('freebsd'):
382 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
383 elif sys
.platform
.startswith('gnukfreebsd'):
384 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
385 elif sys
.platform
== 'gnu':
386 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
388 Logs
.error("Platform %s not supported" % sys
.platform
)
390 bld
.SAMBA_SUBSYSTEM('ctdb-system',
391 source
=bld
.SUBDIR('common',
392 'system_common.c system_util.c') +
395 deps
='replace talloc tevent tdb pcap samba-util')
397 bld
.SAMBA_SUBSYSTEM('ctdb-common',
398 source
=bld
.SUBDIR('common',
399 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
402 deps
='''replace popt talloc tevent tdb popt ctdb-system
403 ctdb-protocol-util''')
405 bld
.SAMBA_SUBSYSTEM('ctdb-util',
406 source
=bld
.SUBDIR('common',
407 '''db_hash.c srvid.c reqid.c
408 pkt_read.c pkt_write.c comm.c
409 logging.c rb_tree.c tunable.c
411 hash_count.c run_event.c
412 sock_client.c version.c
415 deps
='''samba-util sys_rw tevent-util
416 replace talloc tevent tdb''')
418 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
419 source
=bld
.SUBDIR('protocol',
420 '''protocol_header.c protocol_packet.c
421 protocol_basic.c protocol_types.c
432 deps
='replace talloc tdb')
434 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
435 source
='protocol/protocol_util.c',
436 deps
='ctdb-util replace talloc tdb')
438 bld
.SAMBA_SUBSYSTEM('ctdb-client',
439 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
441 deps
='''replace popt talloc tevent tdb
442 samba-util tdb-wrap ctdb-util''')
444 bld
.SAMBA_SUBSYSTEM('ctdb-client2',
445 source
=bld
.SUBDIR('client',
446 '''client_connect.c client_call.c
447 client_message.c client_control.c
448 client_message_sync.c
449 client_control_sync.c
450 client_db.c client_util.c
451 client_event.c client_tunnel.c
454 deps
='replace talloc tevent tdb tdb-wrap')
456 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
457 source
=bld
.SUBDIR('common',
458 '''sock_daemon.c'''),
459 deps
='''samba-util ctdb-util tevent-util
460 LIBASYNC_REQ replace talloc tevent''')
462 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
463 source
=bld
.SUBDIR('server',
464 '''ipalloc_deterministic.c
465 ipalloc_nondeterministic.c
471 deps
='ctdb-protocol-util replace talloc tevent')
473 bld
.SAMBA_BINARY('ctdbd',
474 source
='server/ctdbd.c ' +
476 '''ctdb_daemon.c ctdb_recoverd.c
477 ctdb_recover.c ctdb_freeze.c
478 ctdb_tunables.c ctdb_monitor.c
479 ctdb_server.c ctdb_control.c
480 ctdb_call.c ctdb_ltdb_server.c
481 ctdb_traverse.c eventscript.c
483 ctdb_persistent.c ctdb_keepalive.c
487 ctdb_vacuum.c ctdb_banning.c
490 ctdb_lock.c ctdb_fork.c
493 deps
='''ctdb-client ctdb-common ctdb-system ctdb-protocol
494 ctdb-tcp ctdb-util replace sys_rw popt
495 talloc tevent tdb talloc_report''' +
497 install_path
='${SBINDIR}',
500 bld
.SAMBA_BINARY('ctdb',
501 source
='tools/ctdb.c',
502 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
503 ctdb-util ctdb-system samba-util sys_rw popt''',
504 install_path
='${BINDIR}',
507 bld
.SAMBA_BINARY('ctdb_killtcp',
508 source
='tools/ctdb_killtcp.c',
509 deps
='''ctdb-protocol-util ctdb-util ctdb-system
510 samba-util replace''',
511 install_path
='${CTDB_HELPER_BINDIR}')
513 bld
.SAMBA_BINARY('ctdb_event',
514 source
='tools/ctdb_event.c',
515 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
516 ctdb-util ctdb-system samba-util replace''',
517 install_path
='${CTDB_HELPER_BINDIR}')
519 bld
.SAMBA_BINARY('ltdbtool',
520 source
='tools/ltdbtool.c',
523 install_path
='${BINDIR}',
524 manpages
='ltdbtool.1')
526 bld
.SAMBA_BINARY('ctdb_eventd',
527 source
='server/ctdb_eventd.c',
528 deps
='''ctdb-server-util ctdb-protocol ctdb-protocol-util
529 ctdb-util samba-util replace popt''',
530 install_path
='${CTDB_HELPER_BINDIR}')
532 bld
.SAMBA_BINARY('ctdb_lock_helper',
533 source
='server/ctdb_lock_helper.c',
534 deps
='''samba-util sys_rw ctdb-system tevent-util
535 talloc tevent tdb''',
537 install_path
='${CTDB_HELPER_BINDIR}')
539 bld
.SAMBA_BINARY('ctdb_recovery_helper',
540 source
='server/ctdb_recovery_helper.c',
541 deps
='''ctdb-client2 ctdb-protocol ctdb-util
542 samba-util sys_rw replace tdb''',
543 install_path
='${CTDB_HELPER_BINDIR}')
545 bld
.SAMBA_BINARY('ctdb_takeover_helper',
546 source
='server/ctdb_takeover_helper.c',
547 deps
='''ctdb-client2 ctdb-protocol ctdb-util
548 samba-util sys_rw replace ctdb-ipalloc popt''',
549 install_path
='${CTDB_HELPER_BINDIR}')
551 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
552 source
='server/ctdb_mutex_fcntl_helper.c',
553 deps
='sys_rw ctdb-system',
555 install_path
='${CTDB_HELPER_BINDIR}')
557 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
558 source
='utils/smnotify/smnotify.x',
559 target
='utils/smnotify/smnotify.h',
560 rule
='rpcgen -h ${SRC} > ${TGT}')
562 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
564 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
565 source
='utils/smnotify/smnotify.x',
566 target
='utils/smnotify/gen_xdr.c',
567 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
569 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
570 source
='utils/smnotify/smnotify.x',
571 target
='utils/smnotify/gen_smnotify.c',
572 rule
='rpcgen -l ${SRC} > ${TGT}')
574 bld
.SAMBA_BINARY('smnotify',
575 source
=bld
.SUBDIR('utils/smnotify',
576 'smnotify.c gen_smnotify.c gen_xdr.c'),
577 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
578 includes
='utils utils/smnotify',
579 install_path
='${CTDB_HELPER_BINDIR}')
581 bld
.SAMBA_BINARY('ping_pong',
582 source
='utils/ping_pong/ping_pong.c',
584 install_path
='${BINDIR}',
585 manpages
='ping_pong.1')
587 if bld
.env
.HAVE_PMDA
:
588 bld
.SAMBA_BINARY('pmdactdb',
589 source
='utils/pmda/pmda_ctdb.c',
591 deps
='''ctdb-client2 ctdb-protocol ctdb-util
592 samba-util pcp_pmda pcp''',
593 install_path
='${CTDB_PMDADIR}')
594 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
596 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
598 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
600 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
602 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
604 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
607 if bld
.env
.HAVE_LIBRADOS
:
608 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
609 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
610 deps
='talloc tevent rados ceph-common',
612 install_path
='${CTDB_HELPER_BINDIR}')
614 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
615 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
616 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
617 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
618 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
619 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
620 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
621 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
622 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
623 sed_expr6
, sed_expr7
)
625 manpages_extra
= manpages_misc
626 if bld
.env
.etcd_reclock
:
627 manpages_extra
+= manpages_etcd
628 if bld
.env
.HAVE_LIBRADOS
:
629 manpages_extra
+= manpages_ceph
630 for f
in manpages_binary
+ manpages_extra
:
632 bld
.SAMBA_GENERATOR(x
,
633 source
=os
.path
.join('doc', x
),
635 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
637 if bld
.env
.ctdb_generate_manpages
:
638 bld
.MANPAGES(' '.join(manpages_extra
), True)
640 for m
in bld
.env
.ctdb_prebuilt_manpages
:
641 bld
.SAMBA_GENERATOR(m
,
642 source
=os
.path
.join("doc", m
),
644 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
645 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
647 bld
.SAMBA_GENERATOR('ctdb-onnode',
648 source
='tools/onnode',
650 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
651 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
652 destname
='onnode', chmod
=0755)
654 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
655 source
='tools/ctdb_diagnostics',
656 target
='ctdb_diagnostics',
657 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
658 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
659 destname
='ctdb_diagnostics', chmod
=0755)
661 if bld
.env
.etcd_reclock
:
662 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
663 source
='utils/etcd/ctdb_etcd_lock',
664 target
='ctdb_etcd_lock',
665 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
666 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
667 destname
='ctdb_etcd_lock', chmod
=0744)
669 bld
.SAMBA_GENERATOR('ctdb-natgw',
670 source
='tools/ctdb_natgw',
672 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
673 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
674 destname
='ctdb_natgw', chmod
=0755)
676 bld
.SAMBA_GENERATOR('ctdb-lvs',
677 source
='tools/ctdb_lvs',
679 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
680 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
681 destname
='ctdb_lvs', chmod
=0755)
683 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
684 source
='config/ctdbd_wrapper',
685 target
='ctdbd_wrapper',
686 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
687 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
688 destname
='ctdbd_wrapper', chmod
=0755)
690 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
692 fl
= os
.path
.join(dirname
, f
)
693 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
695 mode
= os
.lstat(fl
).st_mode
& 0777
697 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
698 arg
['file_list'].append([fl
, mode
])
700 def SUBDIR_MODE(path
, trim_path
=None):
701 pd
= {'trim_path': trim_path
, 'file_list': []}
702 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
703 return pd
['file_list']
710 if bld
.env
.standalone_ctdb
:
713 configdir
= 'ctdb/config'
715 for t
in etc_subdirs
:
716 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
718 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
719 destname
=fmode
[0], chmod
=fmode
[1])
721 bld
.SAMBA_GENERATOR('ctdb-functions',
722 source
='config/functions',
724 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
725 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
728 'ctdb-crash-cleanup.sh',
729 '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
)
773 for target
in ctdb_unit_tests
:
774 src
= 'tests/src/' + target
+ '.c'
776 bld
.SAMBA_BINARY(target
,
778 deps
='''talloc tevent tdb tevent-util
779 LIBASYNC_REQ samba-util sys_rw''',
780 install_path
='${CTDB_TEST_LIBEXECDIR}')
782 bld
.SAMBA_BINARY('reqid_test',
783 source
='tests/src/reqid_test.c',
785 install_path
='${CTDB_TEST_LIBEXECDIR}')
787 bld
.SAMBA_BINARY('rb_test',
788 source
='tests/src/rb_test.c',
789 deps
='samba-util talloc',
790 install_path
='${CTDB_TEST_LIBEXECDIR}')
792 bld
.SAMBA_BINARY('ctdb_packet_parse',
793 source
='tests/src/ctdb_packet_parse.c',
794 deps
='talloc tevent tdb ctdb-protocol',
795 install_path
='${CTDB_TEST_LIBEXECDIR}')
797 bld
.SAMBA_BINARY('porting_tests',
798 source
='tests/src/porting_tests.c',
799 deps
='samba-util ctdb-system popt',
800 install_path
='${CTDB_TEST_LIBEXECDIR}')
802 bld
.SAMBA_SUBSYSTEM('protocol-tests-common',
803 source
=bld
.SUBDIR('tests/src',
805 protocol_common_ctdb.c
806 protocol_common_event.c
809 deps
='replace popt talloc tevent tdb')
811 ctdb_protocol_tests
= [
812 'protocol_basic_test',
813 'protocol_types_test',
814 'protocol_ctdb_test',
815 'protocol_event_test',
816 'protocol_util_test',
817 'protocol_types_compat_test',
818 'protocol_ctdb_compat_test',
821 for target
in ctdb_protocol_tests
:
822 src
= 'tests/src/' + target
+ '.c'
824 bld
.SAMBA_BINARY(target
,
826 deps
='''protocol-tests-common
827 samba-util ctdb-util talloc tdb''',
828 install_path
='${CTDB_TEST_LIBEXECDIR}')
830 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
831 source
=bld
.SUBDIR('tests/src',
832 'cluster_wait.c test_options.c'),
834 deps
='samba-util replace popt talloc tevent tdb')
844 'fetch_readonly_loop',
847 'update_record_persistent',
854 for target
in ctdb_tests
:
855 src
= 'tests/src/' + target
+ '.c'
857 bld
.SAMBA_BINARY(target
,
860 deps
='''ctdb-client2 ctdb-protocol ctdb-util
861 samba-util ctdb-tests-common''',
862 install_path
='${CTDB_TEST_LIBEXECDIR}')
864 bld
.SAMBA_BINARY('ctdb_takeover_tests',
865 source
='''tests/src/ctdb_takeover_tests.c
866 tests/src/ipalloc_read_known_ips.c''',
867 deps
='''replace popt tdb tevent talloc ctdb-system
868 samba-util tdb-wrap talloc_report
869 ctdb-ipalloc ctdb-protocol ctdb-util''',
871 install_path
='${CTDB_TEST_LIBEXECDIR}')
873 bld
.SAMBA_BINARY('fake_ctdbd',
874 source
='''tests/src/fake_ctdbd.c
875 tests/src/ipalloc_read_known_ips.c''',
876 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
877 ctdb-system samba-util tevent-util
878 LIBASYNC_REQ popt''',
879 install_path
='${CTDB_TEST_LIBEXECDIR}')
881 if bld
.env
.HAVE_INFINIBAND
:
882 bld
.SAMBA_BINARY('ibwrapper_test',
883 source
='ib/ibwrapper_test.c',
885 deps
='replace talloc ctdb-client ctdb-common sys_rw' +
887 install_path
='${CTDB_TEST_LIBEXECDIR}')
889 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
890 bld
.SAMBA_BINARY('test_mutex_raw',
891 source
='tests/src/test_mutex_raw.c',
893 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
'),
963 test_eventscript_links = [
967 'nfs
-linux
-kernel
-callout
',
971 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
972 'eventscripts
/etc
-ctdb
')
973 for t in test_eventscript_links:
974 bld.symlink_as(os.path.join(test_link_dir, t),
975 os.path.join(bld.env.CTDB_ETCDIR, t))
977 # Tests that use onnode need to overwrite link to in-tree
978 # functions file when installed
979 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'onnode
/functions
'),
980 os.path.join(bld.env.CTDB_ETCDIR, 'functions
'))
981 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple
/functions
'),
982 os.path.join(bld.env.CTDB_ETCDIR, 'functions
'))
984 # Need a link to nodes file because $CTDB_BASE is overridden
985 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple
/nodes
'),
986 os.path.join(bld.env.CTDB_ETCDIR, 'nodes
'))
990 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
991 ret = samba_utils.RUN_COMMAND(cmd)
993 print('tests exited with exit status
%d' % ret)
999 Scripting.commands.append('build
')
1000 Scripting.commands.append('testonly
')
1004 env = samba_utils.LOAD_ENVIRONMENT()
1005 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
1006 ret = samba_utils.RUN_COMMAND(cmd)
1008 print('autotest exited with exit status
%d' % ret)
1012 def show_version(ctx):
1017 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
1018 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
1019 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
1020 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
1021 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1023 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
1024 ret = samba_utils.RUN_COMMAND(cmd)
1026 print('Command
%s failed with exit status
%d' % (cmd, ret))
1029 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
1030 ret = samba_utils.RUN_COMMAND(cmd)
1032 print('Command
%s failed with exit status
%d' % (cmd, ret))
1037 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
1039 distfile = file('.distversion
', 'w
')
1040 for field in version.vcs_fields:
1041 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1043 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1046 sed_expr1 = 's
/@VERSION@/%s/g
' % VERSION
1047 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1048 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1049 sed_expr1, sed_expr2, t)
1050 ret = samba_utils.RUN_COMMAND(cmd)
1052 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1054 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1056 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1058 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1059 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1067 Scripting.commands.append('manpages
')
1068 Scripting.commands.append('distonly
')
1072 opts = os.getenv('RPM_OPTIONS
') or ''
1073 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % (opts, VERSION)
1074 ret = samba_utils.RUN_COMMAND(cmd)
1076 print('rpmbuild exited with exit status
%d' % ret)
1082 Scripting.commands.append('manpages
')
1083 Scripting.commands.append('distonly
')
1084 Scripting.commands.append('rpmonly
')
1088 "build 'tags
' file using ctags"
1090 source_root = os.path.dirname(Utils.g_module.root_path)
1091 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1092 print("Running: %s" % cmd)
1093 ret = samba_utils.RUN_COMMAND(cmd)
1095 print('ctags failed with exit status
%d' % ret)