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'):
178 conf
.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
181 Logs
.error("PMDA support not available")
184 Logs
.info('Building with PMDA support')
185 conf
.define('HAVE_PMDA', 1)
186 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
187 'lib/pcp/pmdas/ctdb')
189 have_infiniband
= False
190 if Options
.options
.ctdb_infiniband
:
193 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
195 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
197 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
200 have_infiniband
= True
202 Logs
.error("Infiniband support not available")
205 Logs
.info('Building with Infiniband support')
206 conf
.define('HAVE_INFINIBAND', 1)
207 conf
.define('USE_INFINIBAND', 1)
209 have_etcd_reclock
= False
210 if Options
.options
.ctdb_etcd_reclock
:
212 conf
.check_python_module('etcd')
213 have_etcd_reclock
= True
215 Logs
.error('etcd support not available')
217 if have_etcd_reclock
:
218 Logs
.info('Building with etcd support')
219 conf
.env
.etcd_reclock
= have_etcd_reclock
221 if Options
.options
.ctdb_ceph_reclock
:
222 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
223 conf
.CHECK_LIB('rados', shlib
=True)):
224 Logs
.info('Building with Ceph librados recovery lock support')
225 conf
.define('HAVE_LIBRADOS', 1)
227 Logs
.error("Missing librados for Ceph recovery lock support")
230 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
231 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
232 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
233 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
234 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
236 if Options
.options
.ctdb_logdir
:
237 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
239 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
241 if Options
.options
.ctdb_sockpath
:
242 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
244 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
246 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
248 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
252 -DCTDB_RUNDIR=\"%s\"''' % (
253 conf
.env
.CTDB_HELPER_BINDIR
,
254 conf
.env
.CTDB_LOGDIR
,
255 conf
.env
.CTDB_ETCDIR
,
256 conf
.env
.CTDB_VARDIR
,
257 conf
.env
.CTDB_RUNDIR
))
259 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
261 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
263 # Allow unified compilation and separate compilation of utilities
265 if not conf
.env
.standalone_ctdb
:
266 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
269 # Building from tarball
270 conf
.ADD_EXTRA_INCLUDES('#include')
272 # Building standalone CTDB from within Samba tree
273 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
274 conf
.ADD_EXTRA_INCLUDES('#ctdb')
275 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
277 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
278 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
279 conf
.SAMBA_CONFIG_H()
281 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
282 conf
.env
.ctdb_generate_manpages
= True
284 conf
.env
.ctdb_generate_manpages
= False
286 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
287 conf
.env
.ctdb_prebuilt_manpages
= []
288 manpages
= manpages_binary
+ manpages_misc
289 if conf
.env
.etcd_reclock
:
290 manpages
+= manpages_etcd
291 if conf
.env
.HAVE_LIBRADOS
:
292 manpages
+= manpages_ceph
294 if os
.path
.exists(os
.path
.join("doc", m
)):
295 Logs
.info(" %s: yes" % (m
))
296 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
298 Logs
.info(" %s: no" % (m
))
300 def gen_ctdb_version(task
):
301 fp
= file(task
.outputs
[0].bldpath(task
.env
), 'w')
302 fp
.write('/* This file is auto-generated from waf */\n')
303 fp
.write('#include "version.h"\n')
305 fp
.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION
)
310 if bld
.env
.standalone_ctdb
:
311 # enable building of public headers in the build tree
312 bld
.env
.build_public_headers
= 'include/public'
314 if bld
.env
.standalone_ctdb
:
315 bld
.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir
)
317 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
318 target
='include/ctdb_version.h',
319 rule
=gen_ctdb_version
,
320 dep_vars
=['VERSION'])
321 t
.env
.VERSION
= VERSION
323 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
325 bld
.RECURSE('lib/replace')
326 if bld
.CHECK_FOR_THIRD_PARTY():
327 bld
.RECURSE('third_party/popt')
328 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
329 bld
.RECURSE('third_party/socket_wrapper')
331 bld
.RECURSE('lib/tdb_wrap')
332 bld
.RECURSE('lib/util')
333 bld
.RECURSE('lib/async_req')
335 bld
.RECURSE('lib/talloc')
336 bld
.RECURSE('lib/tevent')
337 bld
.RECURSE('lib/tdb')
339 if bld
.env
.standalone_ctdb
:
340 # If a combined build is implemented, CTDB will want to
341 # build against samba-util rather than samba-util-core.
342 # Similarly, other Samba subsystems expect samba-util. So,
343 # for a standalone build, just define a fake samba-util
344 # subsystem that pulls in samba-util-core.
345 bld
.SAMBA_SUBSYSTEM('samba-util',
347 deps
='samba-util-core')
349 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
350 source
=bld
.SUBDIR('tcp',
351 'tcp_connect.c tcp_init.c tcp_io.c'),
353 deps
='replace tdb talloc tevent')
356 if bld
.env
.HAVE_INFINIBAND
:
357 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
358 source
=bld
.SUBDIR('ib',
359 '''ibwrapper.c ibw_ctdb.c
362 deps
='replace talloc tevent tdb')
363 ib_deps
= ' ctdb-ib rdmacm ibverbs'
365 if sys
.platform
.startswith('linux'):
366 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
367 elif sys
.platform
.startswith('aix'):
368 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
369 elif sys
.platform
.startswith('freebsd'):
370 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
371 elif sys
.platform
.startswith('gnukfreebsd'):
372 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
373 elif sys
.platform
== 'gnu':
374 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
376 Logs
.error("Platform %s not supported" % sys
.platform
)
378 bld
.SAMBA_SUBSYSTEM('ctdb-system',
379 source
=bld
.SUBDIR('common',
380 'system_common.c system_util.c') +
383 deps
='replace talloc tevent tdb pcap samba-util')
385 bld
.SAMBA_SUBSYSTEM('ctdb-common',
386 source
=bld
.SUBDIR('common',
387 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
390 deps
='''replace popt talloc tevent tdb popt ctdb-system
391 ctdb-protocol-util''')
393 bld
.SAMBA_SUBSYSTEM('ctdb-util',
394 source
=bld
.SUBDIR('common',
395 '''db_hash.c srvid.c reqid.c
396 pkt_read.c pkt_write.c comm.c
397 logging.c rb_tree.c tunable.c
399 hash_count.c run_event.c
400 sock_client.c version.c'''),
401 deps
='''samba-util sys_rw tevent-util
402 replace talloc tevent tdb''')
404 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
405 source
=bld
.SUBDIR('protocol',
406 '''protocol_header.c protocol_packet.c
407 protocol_basic.c protocol_types.c
418 deps
='replace talloc tdb')
420 bld
.SAMBA_SUBSYSTEM('ctdb-protocol-util',
421 source
='protocol/protocol_util.c',
422 deps
='replace talloc tdb')
424 bld
.SAMBA_SUBSYSTEM('ctdb-client',
425 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
427 deps
='''replace popt talloc tevent tdb
428 samba-util tdb-wrap ctdb-util''')
430 bld
.SAMBA_SUBSYSTEM('ctdb-client2',
431 source
=bld
.SUBDIR('client',
432 '''client_connect.c client_call.c
433 client_message.c client_control.c
434 client_message_sync.c
435 client_control_sync.c
436 client_db.c client_util.c
437 client_event.c client_tunnel.c
440 deps
='replace talloc tevent tdb tdb-wrap')
442 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
443 source
=bld
.SUBDIR('common',
444 '''sock_daemon.c'''),
445 deps
='''samba-util ctdb-util tevent-util
446 LIBASYNC_REQ replace talloc tevent''')
448 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
449 source
=bld
.SUBDIR('server',
450 '''ipalloc_deterministic.c
451 ipalloc_nondeterministic.c
457 deps
='ctdb-protocol-util replace talloc tevent')
459 bld
.SAMBA_BINARY('ctdbd',
460 source
='server/ctdbd.c ' +
462 '''ctdb_daemon.c ctdb_recoverd.c
463 ctdb_recover.c ctdb_freeze.c
464 ctdb_tunables.c ctdb_monitor.c
465 ctdb_server.c ctdb_control.c
466 ctdb_call.c ctdb_ltdb_server.c
467 ctdb_traverse.c eventscript.c
469 ctdb_persistent.c ctdb_keepalive.c
473 ctdb_vacuum.c ctdb_banning.c
476 ctdb_lock.c ctdb_fork.c
479 deps
='''ctdb-client ctdb-common ctdb-system ctdb-protocol
480 ctdb-tcp ctdb-util replace sys_rw popt
481 talloc tevent tdb talloc_report''' +
483 install_path
='${SBINDIR}',
486 bld
.SAMBA_BINARY('ctdb',
487 source
='tools/ctdb.c',
488 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
489 ctdb-util ctdb-system samba-util sys_rw popt''',
490 install_path
='${BINDIR}',
493 bld
.SAMBA_BINARY('ctdb_killtcp',
494 source
='tools/ctdb_killtcp.c',
495 deps
='''ctdb-protocol-util ctdb-util ctdb-system
496 samba-util replace''',
497 install_path
='${CTDB_HELPER_BINDIR}')
499 bld
.SAMBA_BINARY('ctdb_event',
500 source
='tools/ctdb_event.c',
501 deps
='''ctdb-client2 ctdb-protocol ctdb-protocol-util
502 ctdb-util ctdb-system samba-util replace''',
503 install_path
='${CTDB_HELPER_BINDIR}')
505 bld
.SAMBA_BINARY('ltdbtool',
506 source
='tools/ltdbtool.c',
509 install_path
='${BINDIR}',
510 manpages
='ltdbtool.1')
512 bld
.SAMBA_BINARY('ctdb_eventd',
513 source
='server/ctdb_eventd.c',
514 deps
='''ctdb-server-util ctdb-protocol ctdb-protocol-util
515 ctdb-util samba-util replace popt''',
516 install_path
='${CTDB_HELPER_BINDIR}')
518 bld
.SAMBA_BINARY('ctdb_lock_helper',
519 source
='server/ctdb_lock_helper.c',
520 deps
='''samba-util sys_rw ctdb-system tevent-util
521 talloc tevent tdb''',
523 install_path
='${CTDB_HELPER_BINDIR}')
525 bld
.SAMBA_BINARY('ctdb_recovery_helper',
526 source
='server/ctdb_recovery_helper.c',
527 deps
='''ctdb-client2 ctdb-protocol ctdb-util
528 samba-util sys_rw replace tdb''',
529 install_path
='${CTDB_HELPER_BINDIR}')
531 bld
.SAMBA_BINARY('ctdb_takeover_helper',
532 source
='server/ctdb_takeover_helper.c',
533 deps
='''ctdb-client2 ctdb-protocol ctdb-util
534 samba-util sys_rw replace ctdb-ipalloc popt''',
535 install_path
='${CTDB_HELPER_BINDIR}')
537 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
538 source
='server/ctdb_mutex_fcntl_helper.c',
539 deps
='sys_rw ctdb-system',
541 install_path
='${CTDB_HELPER_BINDIR}')
543 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
544 source
='utils/smnotify/smnotify.x',
545 target
='utils/smnotify/smnotify.h',
546 rule
='rpcgen -h ${SRC} > ${TGT}')
548 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
550 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
551 source
='utils/smnotify/smnotify.x',
552 target
='utils/smnotify/gen_xdr.c',
553 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
555 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
556 source
='utils/smnotify/smnotify.x',
557 target
='utils/smnotify/gen_smnotify.c',
558 rule
='rpcgen -l ${SRC} > ${TGT}')
560 bld
.SAMBA_BINARY('smnotify',
561 source
=bld
.SUBDIR('utils/smnotify',
562 'smnotify.c gen_smnotify.c gen_xdr.c'),
563 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
564 includes
='utils utils/smnotify',
565 install_path
='${CTDB_HELPER_BINDIR}')
567 bld
.SAMBA_BINARY('ping_pong',
568 source
='utils/ping_pong/ping_pong.c',
570 install_path
='${BINDIR}',
571 manpages
='ping_pong.1')
573 if bld
.env
.HAVE_PMDA
:
574 bld
.SAMBA_BINARY('pmdactdb',
575 source
='utils/pmda/pmda_ctdb.c',
577 deps
='''ctdb-client2 ctdb-protocol ctdb-util
578 samba-util pcp_pmda pcp''',
579 install_path
='${CTDB_PMDADIR}')
580 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
582 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
584 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
586 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
588 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
590 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
593 if bld
.env
.HAVE_LIBRADOS
:
594 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
595 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
596 deps
='talloc tevent rados',
598 install_path
='${CTDB_HELPER_BINDIR}')
600 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
601 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
602 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
603 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
604 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
605 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
606 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
607 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
608 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
609 sed_expr6
, sed_expr7
)
611 manpages_extra
= manpages_misc
612 if bld
.env
.etcd_reclock
:
613 manpages_extra
+= manpages_etcd
614 if bld
.env
.HAVE_LIBRADOS
:
615 manpages_extra
+= manpages_ceph
616 for f
in manpages_binary
+ manpages_extra
:
618 bld
.SAMBA_GENERATOR(x
,
619 source
=os
.path
.join('doc', x
),
621 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
623 if bld
.env
.ctdb_generate_manpages
:
624 bld
.MANPAGES(' '.join(manpages_extra
), True)
626 for m
in bld
.env
.ctdb_prebuilt_manpages
:
627 bld
.SAMBA_GENERATOR(m
,
628 source
=os
.path
.join("doc", m
),
630 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
631 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
633 bld
.SAMBA_GENERATOR('ctdb-onnode',
634 source
='tools/onnode',
636 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
637 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
638 destname
='onnode', chmod
=0755)
640 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
641 source
='tools/ctdb_diagnostics',
642 target
='ctdb_diagnostics',
643 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
644 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
645 destname
='ctdb_diagnostics', chmod
=0755)
647 if bld
.env
.etcd_reclock
:
648 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
649 source
='utils/etcd/ctdb_etcd_lock',
650 target
='ctdb_etcd_lock',
651 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
652 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
653 destname
='ctdb_etcd_lock', chmod
=0744)
655 bld
.SAMBA_GENERATOR('ctdb-natgw',
656 source
='tools/ctdb_natgw',
658 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
659 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
660 destname
='ctdb_natgw', chmod
=0755)
662 bld
.SAMBA_GENERATOR('ctdb-lvs',
663 source
='tools/ctdb_lvs',
665 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
666 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
667 destname
='ctdb_lvs', chmod
=0755)
669 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
670 source
='config/ctdbd_wrapper',
671 target
='ctdbd_wrapper',
672 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
673 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
674 destname
='ctdbd_wrapper', chmod
=0755)
676 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
678 fl
= os
.path
.join(dirname
, f
)
679 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
681 mode
= os
.lstat(fl
).st_mode
& 0777
683 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
684 arg
['file_list'].append([fl
, mode
])
686 def SUBDIR_MODE(path
, trim_path
=None):
687 pd
= {'trim_path': trim_path
, 'file_list': []}
688 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
689 return pd
['file_list']
696 if bld
.env
.standalone_ctdb
:
699 configdir
= 'ctdb/config'
701 for t
in etc_subdirs
:
702 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
704 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
705 destname
=fmode
[0], chmod
=fmode
[1])
707 bld
.SAMBA_GENERATOR('ctdb-functions',
708 source
='config/functions',
710 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
711 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
714 'ctdb-crash-cleanup.sh',
715 '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}')
892 if bld
.env
.standalone_ctdb
:
895 testdir
= 'ctdb/tests'
897 for t
in test_subdirs
:
898 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
900 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
901 destname
=fmode
[0], chmod
=fmode
[1])
903 # Install tests/scripts directory without test_wrap
910 for t
in test_scripts
:
911 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
912 os
.path
.join('tests/scripts', t
),
913 destname
=os
.path
.join('scripts', t
))
915 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
916 bld
.env
.CTDB_TEST_LIBEXECDIR
)
917 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
918 source
='tests/scripts/test_wrap',
920 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
921 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
922 destname
='test_wrap', chmod
=0755)
924 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
925 source
='tests/scripts/script_install_paths.sh',
926 target
='script_install_paths.sh',
927 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
928 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
929 'script_install_paths.sh',
930 destname
='script_install_paths.sh', chmod
=0644)
932 sed_expr1
= 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
933 'CTDB_TEST_DIR
', bld.env.CTDB_TEST_DATADIR,
934 'TEST_BIN_DIR
', bld.env.CTDB_TEST_LIBEXECDIR)
935 sed_expr2 = 's
@^\
(export CTDB_TESTS_ARE_INSTALLED\
)=false
@\\1=true
@'
936 bld.SAMBA_GENERATOR('ctdb
-test
-runner
',
937 source='tests
/run_tests
.sh
',
938 target='ctdb_run_tests
.sh
',
939 rule='sed
-e
"%s" -e
"%s" ${SRC}
> ${TGT}
' % (
940 sed_expr1, sed_expr2))
941 bld.INSTALL_FILES('${BINDIR}
', 'ctdb_run_tests
.sh
',
942 destname='ctdb_run_tests
', chmod=0755)
943 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests
'),
948 cmd = 'tests
/run_tests
.sh
-V tests
/var
'
949 ret = samba_utils.RUN_COMMAND(cmd)
951 print('tests exited with exit status
%d' % ret)
957 Scripting.commands.append('build
')
958 Scripting.commands.append('testonly
')
962 env = samba_utils.LOAD_ENVIRONMENT()
963 cmd = 'tests
/run_tests
.sh
-e
-S
%s -C
' % env.SOCKET_WRAPPER_SO_PATH
964 ret = samba_utils.RUN_COMMAND(cmd)
966 print('autotest exited with exit status
%d' % ret)
970 def show_version(ctx):
975 BASE_URL = 'http
://docbook
.sourceforge
.net
/release
/xsl
/current
'
976 MAN_XSL = '%s/manpages
/docbook
.xsl
' % BASE_URL
977 HTML_XSL = '%s/html
/docbook
.xsl
' % BASE_URL
978 CMD_TEMPLATE = 'xsltproc
--xinclude
-o
%s --nonet
%s %s'
979 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
981 cmd = CMD_TEMPLATE % ('doc
/%s' % t, MAN_XSL, 'doc
/%s.xml
' % t)
982 ret = samba_utils.RUN_COMMAND(cmd)
984 print('Command
%s failed with exit status
%d' % (cmd, ret))
987 cmd = CMD_TEMPLATE % ('doc
/%s.html
' % t, HTML_XSL, 'doc
/%s.xml
' % t)
988 ret = samba_utils.RUN_COMMAND(cmd)
990 print('Command
%s failed with exit status
%d' % (cmd, ret))
995 samba_dist.DIST_FILES('VERSION
:VERSION
', extend=True)
997 distfile = file('.distversion
', 'w
')
998 for field in version.vcs_fields:
999 distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
1001 samba_dist.DIST_FILES('ctdb
/.distversion
:.distversion
', extend=True)
1004 sed_expr1 = 's
/@VERSION@/%s/g
' % VERSION
1005 sed_expr2 = 's
/@RELEASE@/%s/g
' % '1'
1006 cmd = 'sed
-e
"%s" -e
"%s" packaging
/RPM
/ctdb
.spec
.in > %s' % (
1007 sed_expr1, sed_expr2, t)
1008 ret = samba_utils.RUN_COMMAND(cmd)
1010 print('Command
"%s" failed with exit status
%d' % (cmd, ret))
1012 samba_dist.DIST_FILES('ctdb
/%s:%s' % (t, t), extend=True)
1014 manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph
1016 samba_dist.DIST_FILES('ctdb
/doc
/%s:doc
/%s' % (t, t), extend=True)
1017 samba_dist.DIST_FILES('ctdb
/doc
/%s.html
:doc
/%s.html
' % (t, t),
1025 Scripting.commands.append('manpages
')
1026 Scripting.commands.append('distonly
')
1030 opts = os.getenv('RPM_OPTIONS
') or ''
1031 cmd = 'rpmbuild
-ta
--clean
--rmsource
%s ctdb
-%s.tar
.gz
' % (opts, VERSION)
1032 ret = samba_utils.RUN_COMMAND(cmd)
1034 print('rpmbuild exited with exit status
%d' % ret)
1040 Scripting.commands.append('manpages
')
1041 Scripting.commands.append('distonly
')
1042 Scripting.commands.append('rpmonly
')
1046 "build 'tags
' file using ctags"
1048 source_root = os.path.dirname(Utils.g_module.root_path)
1049 cmd = 'ctags $
(find
%s -name
"*.[ch]")' % source_root
1050 print("Running: %s" % cmd)
1051 ret = samba_utils.RUN_COMMAND(cmd)
1053 print('ctags failed with exit status
%d' % ret)