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)
86 opt
.add_option('--enable-ceph-reclock',
87 help=("Enable Ceph CTDB recovery lock helper (default=no)"),
88 action
="store_true", dest
='ctdb_ceph_reclock', default
=False)
90 opt
.add_option('--with-logdir',
91 help=("Path to log directory"),
92 action
="store", dest
='ctdb_logdir', default
=None)
93 opt
.add_option('--with-socketpath',
94 help=("path to CTDB daemon socket"),
95 action
="store", dest
='ctdb_sockpath', default
=None)
100 # No need to build python bindings for talloc/tevent/tdb
101 if conf
.IN_LAUNCH_DIR():
102 conf
.env
.standalone_ctdb
= True
103 Options
.options
.disable_python
= True
105 conf
.RECURSE('lib/replace')
107 if conf
.env
.standalone_ctdb
:
108 conf
.SAMBA_CHECK_PERL(mandatory
=True)
110 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,5,0))
111 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
113 if conf
.CHECK_FOR_THIRD_PARTY():
114 conf
.RECURSE('third_party/popt')
115 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
116 conf
.RECURSE('third_party/socket_wrapper')
117 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
119 if not conf
.CHECK_POPT():
120 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
122 conf
.define('USING_SYSTEM_POPT', 1)
123 conf
.env
.SOCKET_WRAPPER_SO_PATH
= ''
126 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
127 if not conf
.CHECK_SOCKET_WRAPPER():
128 raise Utils
.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
130 conf
.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
131 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
133 conf
.RECURSE('lib/util')
135 conf
.RECURSE('lib/talloc')
136 conf
.RECURSE('lib/tevent')
137 conf
.RECURSE('lib/tdb')
139 conf
.CHECK_HEADERS('sched.h')
140 conf
.CHECK_HEADERS('procinfo.h')
141 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
142 Logs
.error('Need thread_setsched() on AIX')
144 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
145 Logs
.error('Need sched_setscheduler()')
147 conf
.CHECK_FUNCS('mlockall')
149 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
150 conf
.DEFINE('ETIME', 'ETIMEDOUT')
152 if sys
.platform
.startswith('linux'):
153 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
155 if not conf
.CHECK_HEADERS('pcap.h'):
156 Logs
.error('Need libpcap')
158 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
159 Logs
.error('Need libpcap')
162 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
163 checklibc
=True, headers
='execinfo.h'):
164 Logs
.error('backtrace support not available')
167 if Options
.options
.ctdb_pmda
:
170 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
173 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
175 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
180 Logs
.error("PMDA support not available")
183 Logs
.info('Building with PMDA support')
184 conf
.define('HAVE_PMDA', 1)
185 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
186 'lib/pcp/pmdas/ctdb')
188 have_infiniband
= False
189 if Options
.options
.ctdb_infiniband
:
192 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
194 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
196 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
199 have_infiniband
= True
201 Logs
.error("Infiniband support not available")
204 Logs
.info('Building with Infiniband support')
205 conf
.define('HAVE_INFINIBAND', 1)
206 conf
.define('USE_INFINIBAND', 1)
208 have_etcd_reclock
= False
209 if Options
.options
.ctdb_etcd_reclock
:
211 conf
.check_python_module('etcd')
212 have_etcd_reclock
= True
214 Logs
.error('etcd support not available')
216 if have_etcd_reclock
:
217 Logs
.info('Building with etcd support')
218 conf
.env
.etcd_reclock
= have_etcd_reclock
220 if Options
.options
.ctdb_ceph_reclock
:
221 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
222 conf
.CHECK_LIB('rados', shlib
=True)):
223 Logs
.info('Building with Ceph librados recovery lock support')
224 conf
.define('HAVE_LIBRADOS', 1)
226 Logs
.error("Missing librados for Ceph recovery lock support")
229 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
230 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
231 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
232 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
233 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
235 if Options
.options
.ctdb_logdir
:
236 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
238 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
240 if Options
.options
.ctdb_sockpath
:
241 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
243 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
245 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
247 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
251 -DCTDB_RUNDIR=\"%s\"''' % (
252 conf
.env
.CTDB_HELPER_BINDIR
,
253 conf
.env
.CTDB_LOGDIR
,
254 conf
.env
.CTDB_ETCDIR
,
255 conf
.env
.CTDB_VARDIR
,
256 conf
.env
.CTDB_RUNDIR
))
258 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
260 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
262 # Allow unified compilation and separate compilation of utilities
264 if not conf
.env
.standalone_ctdb
:
265 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
268 # Building from tarball
269 conf
.ADD_EXTRA_INCLUDES('#include')
271 # Building standalone CTDB from within Samba tree
272 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
273 conf
.ADD_EXTRA_INCLUDES('#ctdb')
274 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
276 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
277 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
278 conf
.SAMBA_CONFIG_H()
280 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
281 conf
.env
.ctdb_generate_manpages
= True
283 conf
.env
.ctdb_generate_manpages
= False
285 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
286 conf
.env
.ctdb_prebuilt_manpages
= []
287 manpages
= manpages_binary
+ manpages_misc
288 if conf
.env
.etcd_reclock
:
289 manpages
+= manpages_etcd
290 if conf
.env
.HAVE_LIBRADOS
:
291 manpages
+= manpages_ceph
293 if os
.path
.exists(os
.path
.join("doc", m
)):
294 Logs
.info(" %s: yes" % (m
))
295 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
297 Logs
.info(" %s: no" % (m
))
299 def gen_ctdb_version(task
):
300 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
301 fp
.write('/* This file is auto-generated from waf */\n')
302 fp
.write('#include "version.h"\n')
304 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
309 if bld
.env
.standalone_ctdb
:
310 # enable building of public headers in the build tree
311 bld
.env
.build_public_headers
= 'include/public'
313 if bld
.env
.standalone_ctdb
:
314 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
316 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
317 target
='include/ctdb_version.h',
318 rule
=gen_ctdb_version
,
319 dep_vars
=['VERSION'])
320 t
.env
.VERSION
= VERSION
322 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
324 bld
.RECURSE('lib/replace')
325 if bld
.CHECK_FOR_THIRD_PARTY():
326 bld
.RECURSE('third_party/popt')
327 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
328 bld
.RECURSE('third_party/socket_wrapper')
330 bld
.RECURSE('lib/tdb_wrap')
331 bld
.RECURSE('lib/util')
332 bld
.RECURSE('lib/async_req')
334 bld
.RECURSE('lib/talloc')
335 bld
.RECURSE('lib/tevent')
336 bld
.RECURSE('lib/tdb')
338 if bld
.env
.standalone_ctdb
:
339 # If a combined build is implemented, CTDB will want to
340 # build against samba-util rather than samba-util-core.
341 # Similarly, other Samba subsystems expect samba-util. So,
342 # for a standalone build, just define a fake samba-util
343 # subsystem that pulls in samba-util-core.
344 bld
.SAMBA_SUBSYSTEM('samba-util',
346 deps
='samba-util-core')
348 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
349 source
=bld
.SUBDIR('tcp',
350 'tcp_connect.c tcp_init.c tcp_io.c'),
352 deps
='replace tdb talloc tevent')
355 if bld
.env
.HAVE_INFINIBAND
:
356 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
357 source
=bld
.SUBDIR('ib',
358 '''ibwrapper.c ibw_ctdb.c
361 deps
='replace talloc tevent tdb')
362 ib_deps
= ' ctdb-ib rdmacm ibverbs'
364 if sys
.platform
.startswith('linux'):
365 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
366 elif sys
.platform
.startswith('aix'):
367 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
368 elif sys
.platform
.startswith('freebsd'):
369 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
370 elif sys
.platform
.startswith('gnukfreebsd'):
371 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
372 elif sys
.platform
== 'gnu':
373 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
375 Logs
.error("Platform %s not supported" % sys
.platform
)
377 bld
.SAMBA_SUBSYSTEM('ctdb-system',
378 source
=bld
.SUBDIR('common',
379 'system_common.c system_util.c') +
382 deps
='replace talloc tevent tdb pcap samba-util')
384 bld
.SAMBA_SUBSYSTEM('ctdb-common',
385 source
=bld
.SUBDIR('common',
386 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
389 deps
='''replace popt talloc tevent tdb popt ctdb-system
390 ctdb-protocol-util''')
392 bld
.SAMBA_SUBSYSTEM('ctdb-util',
393 source
=bld
.SUBDIR('common',
394 '''db_hash.c srvid.c reqid.c
395 pkt_read.c pkt_write.c comm.c
396 logging.c rb_tree.c tunable.c
398 hash_count.c run_event.c
399 sock_client.c version.c'''),
400 deps
='''samba-util sys_rw tevent-util
401 replace talloc tevent tdb''')
403 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
404 source
=bld
.SUBDIR('protocol',
405 '''protocol_header.c protocol_packet.c
406 protocol_basic.c protocol_types.c
417 deps
='replace talloc tdb')
419 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
420 source
='protocol/protocol_util.c',
421 deps
='replace talloc tdb')
423 bld
.SAMBA_SUBSYSTEM('ctdb-client',
424 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
426 deps
='''replace popt talloc tevent tdb
427 samba-util tdb-wrap ctdb-util''')
429 bld
.SAMBA_SUBSYSTEM('ctdb-client2',
430 source
=bld
.SUBDIR('client',
431 '''client_connect.c client_call.c
432 client_message.c client_control.c
433 client_message_sync.c
434 client_control_sync.c
435 client_db.c client_util.c
436 client_event.c client_tunnel.c
439 deps
='replace talloc tevent tdb tdb-wrap')
441 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
442 source
=bld
.SUBDIR('common',
443 '''sock_daemon.c'''),
444 deps
='''samba-util ctdb-util tevent-util
445 LIBASYNC_REQ replace talloc tevent''')
447 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
448 source
=bld
.SUBDIR('server',
449 '''ipalloc_deterministic.c
450 ipalloc_nondeterministic.c
456 deps
='ctdb-protocol-util replace talloc tevent')
458 bld
.SAMBA_BINARY('ctdbd',
459 source
='server/ctdbd.c ' +
461 '''ctdb_daemon.c ctdb_recoverd.c
462 ctdb_recover.c ctdb_freeze.c
463 ctdb_tunables.c ctdb_monitor.c
464 ctdb_server.c ctdb_control.c
465 ctdb_call.c ctdb_ltdb_server.c
466 ctdb_traverse.c eventscript.c
468 ctdb_persistent.c ctdb_keepalive.c
472 ctdb_vacuum.c ctdb_banning.c
475 ctdb_lock.c ctdb_fork.c
478 deps
='''ctdb-client ctdb-common ctdb-system ctdb-protocol
479 ctdb-tcp ctdb-util replace sys_rw popt
480 talloc tevent tdb talloc_report''' +
482 install_path
='${SBINDIR}',
485 bld
.SAMBA_BINARY('ctdb',
486 source
='tools/ctdb.c',
487 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
488 ctdb-util ctdb-system samba-util sys_rw popt''',
489 install_path
='${BINDIR}',
492 bld
.SAMBA_BINARY('ctdb_killtcp',
493 source
='tools/ctdb_killtcp.c',
494 deps
='''ctdb-protocol-util ctdb-util ctdb-system
495 samba-util replace''',
496 install_path
='${CTDB_HELPER_BINDIR}')
498 bld
.SAMBA_BINARY('ctdb_event',
499 source
='tools/ctdb_event.c',
500 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
501 ctdb-util ctdb-system samba-util replace''',
502 install_path
='${CTDB_HELPER_BINDIR}')
504 bld
.SAMBA_BINARY('ltdbtool',
505 source
='tools/ltdbtool.c',
508 install_path
='${BINDIR}',
509 manpages
='ltdbtool.1')
511 bld
.SAMBA_BINARY('ctdb_eventd',
512 source
='server/ctdb_eventd.c',
513 deps
='''ctdb-server-util ctdb-protocol ctdb-protocol-util
514 ctdb-util samba-util replace popt''',
515 install_path
='${CTDB_HELPER_BINDIR}')
517 bld
.SAMBA_BINARY('ctdb_lock_helper',
518 source
='server/ctdb_lock_helper.c',
519 deps
='''samba-util sys_rw ctdb-system tevent-util
520 talloc tevent tdb''',
522 install_path
='${CTDB_HELPER_BINDIR}')
524 bld
.SAMBA_BINARY('ctdb_recovery_helper',
525 source
='server/ctdb_recovery_helper.c',
526 deps
='''ctdb-client2 ctdb-protocol ctdb-util
527 samba-util sys_rw replace tdb''',
528 install_path
='${CTDB_HELPER_BINDIR}')
530 bld
.SAMBA_BINARY('ctdb_takeover_helper',
531 source
='server/ctdb_takeover_helper.c',
532 deps
='''ctdb-client2 ctdb-protocol ctdb-util
533 samba-util sys_rw replace ctdb-ipalloc popt''',
534 install_path
='${CTDB_HELPER_BINDIR}')
536 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
537 source
='server/ctdb_mutex_fcntl_helper.c',
538 deps
='sys_rw ctdb-system',
540 install_path
='${CTDB_HELPER_BINDIR}')
542 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
543 source
='utils/smnotify/smnotify.x',
544 target
='utils/smnotify/smnotify.h',
545 rule
='rpcgen -h ${SRC} > ${TGT}')
547 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
549 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
550 source
='utils/smnotify/smnotify.x',
551 target
='utils/smnotify/gen_xdr.c',
552 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
554 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
555 source
='utils/smnotify/smnotify.x',
556 target
='utils/smnotify/gen_smnotify.c',
557 rule
='rpcgen -l ${SRC} > ${TGT}')
559 bld
.SAMBA_BINARY('smnotify',
560 source
=bld
.SUBDIR('utils/smnotify',
561 'smnotify.c gen_smnotify.c gen_xdr.c'),
562 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
563 includes
='utils utils/smnotify',
564 install_path
='${CTDB_HELPER_BINDIR}')
566 bld
.SAMBA_BINARY('ping_pong',
567 source
='utils/ping_pong/ping_pong.c',
569 install_path
='${BINDIR}',
570 manpages
='ping_pong.1')
572 if bld
.env
.HAVE_PMDA
:
573 bld
.SAMBA_BINARY('pmdactdb',
574 source
='utils/pmda/pmda_ctdb.c',
576 deps
='''ctdb-client2 ctdb-protocol ctdb-util
577 samba-util pcp_pmda pcp''',
578 install_path
='${CTDB_PMDADIR}')
579 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
581 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
583 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
585 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
587 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
589 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
592 if bld
.env
.HAVE_LIBRADOS
:
593 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
594 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
595 deps
='talloc tevent rados',
597 install_path
='${CTDB_HELPER_BINDIR}')
599 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
600 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
601 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
602 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
603 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
604 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
605 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
606 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
607 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
608 sed_expr6
, sed_expr7
)
610 manpages_extra
= manpages_misc
611 if bld
.env
.etcd_reclock
:
612 manpages_extra
+= manpages_etcd
613 if bld
.env
.HAVE_LIBRADOS
:
614 manpages_extra
+= manpages_ceph
615 for f
in manpages_binary
+ manpages_extra
:
617 bld
.SAMBA_GENERATOR(x
,
618 source
=os
.path
.join('doc', x
),
620 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
622 if bld
.env
.ctdb_generate_manpages
:
623 bld
.MANPAGES(' '.join(manpages_extra
), True)
625 for m
in bld
.env
.ctdb_prebuilt_manpages
:
626 bld
.SAMBA_GENERATOR(m
,
627 source
=os
.path
.join("doc", m
),
629 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
630 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
632 bld
.SAMBA_GENERATOR('ctdb-onnode',
633 source
='tools/onnode',
635 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
636 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
637 destname
='onnode', chmod
=0755)
639 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
640 source
='tools/ctdb_diagnostics',
641 target
='ctdb_diagnostics',
642 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
643 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
644 destname
='ctdb_diagnostics', chmod
=0755)
646 if bld
.env
.etcd_reclock
:
647 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
648 source
='utils/etcd/ctdb_etcd_lock',
649 target
='ctdb_etcd_lock',
650 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
651 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
652 destname
='ctdb_etcd_lock', chmod
=0744)
654 bld
.SAMBA_GENERATOR('ctdb-natgw',
655 source
='tools/ctdb_natgw',
657 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
658 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
659 destname
='ctdb_natgw', chmod
=0755)
661 bld
.SAMBA_GENERATOR('ctdb-lvs',
662 source
='tools/ctdb_lvs',
664 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
665 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
666 destname
='ctdb_lvs', chmod
=0755)
668 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
669 source
='config/ctdbd_wrapper',
670 target
='ctdbd_wrapper',
671 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
672 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
673 destname
='ctdbd_wrapper', chmod
=0755)
675 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
677 fl
= os
.path
.join(dirname
, f
)
678 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
680 mode
= os
.lstat(fl
).st_mode
& 0777
682 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
683 arg
['file_list'].append([fl
, mode
])
685 def SUBDIR_MODE(path
, trim_path
=None):
686 pd
= {'trim_path': trim_path
, 'file_list': []}
687 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
688 return pd
['file_list']
695 if bld
.env
.standalone_ctdb
:
698 configdir
= 'ctdb/config'
700 for t
in etc_subdirs
:
701 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
703 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
704 destname
=fmode
[0], chmod
=fmode
[1])
706 bld
.SAMBA_GENERATOR('ctdb-functions',
707 source
='config/functions',
709 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
710 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
713 'ctdb-crash-cleanup.sh',
714 'debug-hung-script.sh',
717 'nfs-linux-kernel-callout',
722 for t
in etc_scripts
:
723 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
724 destname
=t
, chmod
=0755)
726 bld
.SAMBA_GENERATOR('ctdb-sudoers',
727 source
='config/ctdb.sudoers',
728 target
='ctdb.sudoers',
729 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
730 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
733 bld
.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
736 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
737 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
738 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
757 for target
in ctdb_unit_tests
:
758 src
= 'tests/src/' + target
+ '.c'
760 bld
.SAMBA_BINARY(target
,
762 deps
='''talloc tevent tdb tevent-util
763 LIBASYNC_REQ samba-util sys_rw''',
764 install_path
='${CTDB_TEST_LIBEXECDIR}')
766 bld
.SAMBA_BINARY('reqid_test',
767 source
='tests/src/reqid_test.c',
769 install_path
='${CTDB_TEST_LIBEXECDIR}')
771 bld
.SAMBA_BINARY('rb_test',
772 source
='tests/src/rb_test.c',
773 deps
='samba-util talloc',
774 install_path
='${CTDB_TEST_LIBEXECDIR}')
776 bld
.SAMBA_BINARY('ctdb_packet_parse',
777 source
='tests/src/ctdb_packet_parse.c',
778 deps
='talloc tevent tdb ctdb-protocol',
779 install_path
='${CTDB_TEST_LIBEXECDIR}')
781 bld
.SAMBA_BINARY('porting_tests',
782 source
='tests/src/porting_tests.c',
783 deps
='samba-util ctdb-system popt',
784 install_path
='${CTDB_TEST_LIBEXECDIR}')
786 bld
.SAMBA_SUBSYSTEM('protocol-tests-common',
787 source
=bld
.SUBDIR('tests/src',
789 protocol_common_ctdb.c
790 protocol_common_event.c
793 deps
='replace popt talloc tevent tdb')
795 ctdb_protocol_tests
= [
796 'protocol_basic_test',
797 'protocol_types_test',
798 'protocol_ctdb_test',
799 'protocol_event_test',
800 'protocol_util_test',
801 'protocol_types_compat_test',
802 'protocol_ctdb_compat_test',
805 for target
in ctdb_protocol_tests
:
806 src
= 'tests/src/' + target
+ '.c'
808 bld
.SAMBA_BINARY(target
,
810 deps
='''protocol-tests-common
811 samba-util talloc tdb''',
812 install_path
='${CTDB_TEST_LIBEXECDIR}')
814 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
815 source
=bld
.SUBDIR('tests/src',
816 'cluster_wait.c test_options.c'),
818 deps
='replace popt talloc tevent tdb')
828 'fetch_readonly_loop',
831 'update_record_persistent',
838 for target
in ctdb_tests
:
839 src
= 'tests/src/' + target
+ '.c'
841 bld
.SAMBA_BINARY(target
,
844 deps
='''ctdb-client2 ctdb-protocol ctdb-util
845 samba-util ctdb-tests-common''',
846 install_path
='${CTDB_TEST_LIBEXECDIR}')
848 bld
.SAMBA_BINARY('ctdb_takeover_tests',
849 source
='''tests/src/ctdb_takeover_tests.c
850 tests/src/ipalloc_read_known_ips.c''',
851 deps
='''replace popt tdb tevent talloc ctdb-system
852 samba-util tdb-wrap talloc_report
853 ctdb-ipalloc ctdb-protocol ctdb-util''',
855 install_path
='${CTDB_TEST_LIBEXECDIR}')
857 bld
.SAMBA_BINARY('fake_ctdbd',
858 source
='''tests/src/fake_ctdbd.c
859 tests/src/ipalloc_read_known_ips.c''',
860 deps
='''ctdb-util ctdb-protocol ctdb-protocol-util
861 ctdb-system samba-util tevent-util
862 LIBASYNC_REQ popt''',
863 install_path
='${CTDB_TEST_LIBEXECDIR}')
865 if bld
.env
.HAVE_INFINIBAND
:
866 bld
.SAMBA_BINARY('ibwrapper_test',
867 source
='ib/ibwrapper_test.c',
869 deps
='replace talloc ctdb-client ctdb-common sys_rw' +
871 install_path
='${CTDB_TEST_LIBEXECDIR}')
873 if bld
.env
.HAVE_ROBUST_MUTEXES
and sys
.platform
.startswith('linux'):
874 bld
.SAMBA_BINARY('test_mutex_raw',
875 source
='tests/src/test_mutex_raw.c',
877 install_path
='${CTDB_TEST_LIBEXECDIR}')
893 if bld
.env
.standalone_ctdb
:
896 testdir
= 'ctdb/tests'
898 for t
in test_subdirs
:
899 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
901 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
902 destname
=fmode
[0], chmod
=fmode
[1])
904 # Install tests/scripts directory without test_wrap
911 for t
in test_scripts
:
912 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
913 os
.path
.join('tests/scripts', t
),
914 destname
=os
.path
.join('scripts', t
))
916 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
917 bld
.env
.CTDB_TEST_LIBEXECDIR
)
918 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
919 source
='tests/scripts/test_wrap',
921 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
922 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
923 destname
='test_wrap', chmod
=0755)
925 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
926 source
='tests/scripts/script_install_paths.sh',
927 target
='script_install_paths.sh',
928 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
929 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
930 'script_install_paths.sh',
931 destname
='script_install_paths.sh', chmod
=0644)
933 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
934 'CTDB_TEST_DIR
', bld.env.CTDB_TEST_DATADIR,
935 'TEST_BIN_DIR
', bld.env.CTDB_TEST_LIBEXECDIR)
936 sed_expr2 = 's
@^\
(export CTDB_TESTS_ARE_INSTALLED\
)=false
@\\1=true
@'
937 bld.SAMBA_GENERATOR('ctdb
-test
-runner
',
938 source='tests
/run_tests
.sh
',
939 target='ctdb_run_tests
.sh
',
940 rule='sed
-e
"%s" -e
"%s" ${SRC}
> ${TGT}
' % (
941 sed_expr1, sed_expr2))
942 bld.INSTALL_FILES('${BINDIR}
', 'ctdb_run_tests
.sh
',
943 destname='ctdb_run_tests
', chmod=0755)
944 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests
'),
947 test_eventscript_links = [
951 'nfs
-linux
-kernel
-callout
',
955 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
956 'eventscripts
/etc
-ctdb
')
957 for t in test_eventscript_links:
958 bld.symlink_as(os.path.join(test_link_dir, t),
959 os.path.join(bld.env.CTDB_ETCDIR, t))
961 # Tests that use onnode need to overwrite link to in-tree
962 # functions file when installed
963 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'onnode
/functions
'),
964 os.path.join(bld.env.CTDB_ETCDIR, 'functions
'))
965 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple
/functions
'),
966 os.path.join(bld.env.CTDB_ETCDIR, 'functions
'))
968 # Need a link to nodes file because $CTDB_BASE is overridden
969 bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple
/nodes
'),
970 os.path.join(bld.env.CTDB_ETCDIR, 'nodes
'))
974 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
975 ret = samba_utils.RUN_COMMAND(cmd)
977 print('tests exited with exit status
%d' % ret)
983 Scripting.commands.append('build
')
984 Scripting.commands.append('testonly
')
988 env = samba_utils.LOAD_ENVIRONMENT()
989 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
990 ret = samba_utils.RUN_COMMAND(cmd)
992 print('autotest exited with exit status
%d' % ret)
996 def show_version(ctx):
1001 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
1002 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
1003 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
1004 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
1005 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1007 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
1008 ret = samba_utils.RUN_COMMAND(cmd)
1010 print('Command
%s failed with exit status
%d' % (cmd, ret))
1013 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
1014 ret = samba_utils.RUN_COMMAND(cmd)
1016 print('Command
%s failed with exit status
%d' % (cmd, ret))
1021 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
1023 distfile = file('.distversion
', 'w
')
1024 for field in version.vcs_fields:
1025 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1027 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1030 sed_expr1 = 's
/@VERSION@/%s/g
' % VERSION
1031 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1032 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1033 sed_expr1, sed_expr2, t)
1034 ret = samba_utils.RUN_COMMAND(cmd)
1036 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1038 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1040 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1042 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1043 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1051 Scripting.commands.append('manpages
')
1052 Scripting.commands.append('distonly
')
1056 opts = os.getenv('RPM_OPTIONS
') or ''
1057 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % (opts, VERSION)
1058 ret = samba_utils.RUN_COMMAND(cmd)
1060 print('rpmbuild exited with exit status
%d' % ret)
1066 Scripting.commands.append('manpages
')
1067 Scripting.commands.append('distonly
')
1068 Scripting.commands.append('rpmonly
')
1072 "build 'tags
' file using ctags"
1074 source_root = os.path.dirname(Utils.g_module.root_path)
1075 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1076 print("Running: %s" % cmd)
1077 ret = samba_utils.RUN_COMMAND(cmd)
1079 print('ctags failed with exit status
%d' % ret)