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 lib/socket_wrapper:lib/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
=True, version
=(2,5,0))
111 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=True)
113 if conf
.CHECK_FOR_THIRD_PARTY():
114 conf
.RECURSE('third_party/popt')
116 if not conf
.CHECK_POPT():
117 raise Utils
.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
119 conf
.define('USING_SYSTEM_POPT', 1)
121 conf
.RECURSE('lib/util')
123 conf
.RECURSE('lib/talloc')
124 conf
.RECURSE('lib/tevent')
125 conf
.RECURSE('lib/tdb')
126 if conf
.env
.standalone_ctdb
or conf
.CONFIG_GET('ENABLE_SELFTEST'):
127 conf
.RECURSE('lib/socket_wrapper')
128 conf
.env
.SOCKET_WRAPPER_SO_PATH
= conf
.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
130 conf
.CHECK_HEADERS('sched.h')
131 conf
.CHECK_HEADERS('procinfo.h')
132 if sys
.platform
.startswith('aix') and not conf
.CHECK_FUNCS('thread_setsched'):
133 Logs
.error('Need thread_setsched() on AIX')
135 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
136 Logs
.error('Need sched_setscheduler()')
138 conf
.CHECK_FUNCS('mlockall')
140 if not conf
.CHECK_VARIABLE('ETIME', headers
='errno.h'):
141 conf
.DEFINE('ETIME', 'ETIMEDOUT')
143 if sys
.platform
.startswith('linux'):
144 conf
.SET_TARGET_TYPE('pcap', 'EMPTY')
146 if not conf
.CHECK_HEADERS('pcap.h'):
147 Logs
.error('Need libpcap')
149 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
150 Logs
.error('Need libpcap')
153 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
154 checklibc
=True, headers
='execinfo.h'):
155 Logs
.error('backtrace support not available')
158 if Options
.options
.ctdb_pmda
:
161 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
164 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
166 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
171 Logs
.error("PMDA support not available")
174 Logs
.info('Building with PMDA support')
175 conf
.define('HAVE_PMDA', 1)
176 conf
.env
.CTDB_PMDADIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
,
177 'lib/pcp/pmdas/ctdb')
179 have_infiniband
= False
180 if Options
.options
.ctdb_infiniband
:
183 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
185 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
187 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
190 have_infiniband
= True
192 Logs
.error("Infiniband support not available")
195 Logs
.info('Building with Infiniband support')
196 conf
.define('HAVE_INFINIBAND', 1)
197 conf
.define('USE_INFINIBAND', 1)
199 have_etcd_reclock
= False
200 if Options
.options
.ctdb_etcd_reclock
:
202 conf
.check_python_module('etcd')
203 have_etcd_reclock
= True
205 Logs
.error('etcd support not available')
207 if have_etcd_reclock
:
208 Logs
.info('Building with etcd support')
209 conf
.env
.etcd_reclock
= have_etcd_reclock
211 if Options
.options
.ctdb_ceph_reclock
:
212 if (conf
.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
213 conf
.CHECK_LIB('rados', shlib
=True)):
214 Logs
.info('Building with Ceph librados recovery lock support')
215 conf
.define('HAVE_LIBRADOS', 1)
217 Logs
.error("Missing librados for Ceph recovery lock support")
220 conf
.env
.CTDB_BINDIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
, 'bin')
221 conf
.env
.CTDB_ETCDIR
= os
.path
.join(conf
.env
.SYSCONFDIR
, 'ctdb')
222 conf
.env
.CTDB_VARDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'lib/ctdb')
223 conf
.env
.CTDB_RUNDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'run/ctdb')
224 conf
.env
.CTDB_HELPER_BINDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb')
226 if Options
.options
.ctdb_logdir
:
227 conf
.env
.CTDB_LOGDIR
= Options
.options
.ctdb_logdir
229 conf
.env
.CTDB_LOGDIR
= os
.path
.join(conf
.env
.LOCALSTATEDIR
, 'log')
231 if Options
.options
.ctdb_sockpath
:
232 conf
.env
.CTDB_SOCKPATH
= Options
.options
.ctdb_sockpath
234 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
236 conf
.define('CTDB_SOCKET', conf
.env
.CTDB_SOCKPATH
)
238 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
242 -DCTDB_RUNDIR=\"%s\"''' % (
243 conf
.env
.CTDB_HELPER_BINDIR
,
244 conf
.env
.CTDB_LOGDIR
,
245 conf
.env
.CTDB_ETCDIR
,
246 conf
.env
.CTDB_VARDIR
,
247 conf
.env
.CTDB_RUNDIR
))
249 conf
.env
.CTDB_TEST_DATADIR
= os
.path
.join(conf
.env
.EXEC_PREFIX
,
251 conf
.env
.CTDB_TEST_LIBEXECDIR
= os
.path
.join(conf
.env
.LIBEXECDIR
, 'ctdb/tests')
253 # Allow unified compilation and separate compilation of utilities
255 if not conf
.env
.standalone_ctdb
:
256 conf
.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
259 # Building from tarball
260 conf
.ADD_EXTRA_INCLUDES('#include')
262 # Building standalone CTDB from within Samba tree
263 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
264 conf
.ADD_EXTRA_INCLUDES('#ctdb')
265 conf
.ADD_EXTRA_INCLUDES('#lib #lib/replace')
267 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
268 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
269 conf
.SAMBA_CONFIG_H()
271 if 'XSLTPROC_MANPAGES' in conf
.env
and conf
.env
['XSLTPROC_MANPAGES']:
272 conf
.env
.ctdb_generate_manpages
= True
274 conf
.env
.ctdb_generate_manpages
= False
276 Logs
.info("xsltproc unavailable, checking for pre-built manpages")
277 conf
.env
.ctdb_prebuilt_manpages
= []
278 manpages
= manpages_binary
+ manpages_misc
279 if conf
.env
.etcd_reclock
:
280 manpages
+= manpages_etcd
281 if conf
.env
.HAVE_LIBRADOS
:
282 manpages
+= manpages_ceph
284 if os
.path
.exists(os
.path
.join("doc", m
)):
285 Logs
.info(" %s: yes" % (m
))
286 conf
.env
.ctdb_prebuilt_manpages
.append(m
)
288 Logs
.info(" %s: no" % (m
))
291 if bld
.env
.standalone_ctdb
:
292 # enable building of public headers in the build tree
293 bld
.env
.build_public_headers
= 'include/public'
295 version_h
= samba_utils
.os_path_relpath(os
.path
.join(Options
.launch_dir
,
299 if bld
.env
.standalone_ctdb
:
300 ctdb_mkversion
= '../packaging/mkversion.sh'
301 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
302 target
='include/ctdb_version.h',
303 rule
='%s ${TGT} %s' % (ctdb_mkversion
, VERSION
),
304 dep_vars
=['VERSION'])
305 t
.env
.VERSION
= VERSION
307 t
= bld
.SAMBA_GENERATOR('ctdb-samba-version-header',
309 rule
='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}',
310 dep_vars
=['VERSION'])
311 t
.env
.VERSION
= VERSION
313 t
= bld
.SAMBA_GENERATOR('ctdb-samba-version-header',
314 target
='include/ctdb_version.h',
315 rule
='printf "#include \\"%s\\" \\n#define CTDB_VERSION_STRING SAMBA_VERSION_STRING\\n" > ${TGT}' % version_h
,
316 dep_vars
=['VERSION'])
317 t
.env
.VERSION
= VERSION
319 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
321 bld
.RECURSE('lib/replace')
322 if bld
.CHECK_FOR_THIRD_PARTY():
323 bld
.RECURSE('third_party/popt')
325 bld
.RECURSE('lib/tdb_wrap')
326 bld
.RECURSE('lib/util')
327 bld
.RECURSE('lib/async_req')
329 bld
.RECURSE('lib/talloc')
330 bld
.RECURSE('lib/tevent')
331 bld
.RECURSE('lib/tdb')
332 if bld
.env
.standalone_ctdb
or bld
.CONFIG_GET('SOCKET_WRAPPER'):
333 bld
.RECURSE('lib/socket_wrapper')
335 if bld
.env
.standalone_ctdb
:
336 # If a combined build is implemented, CTDB will want to
337 # build against samba-util rather than samba-util-core.
338 # Similarly, other Samba subsystems expect samba-util. So,
339 # for a standalone build, just define a fake samba-util
340 # subsystem that pulls in samba-util-core.
341 bld
.SAMBA_SUBSYSTEM('samba-util',
343 deps
='samba-util-core')
345 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
346 source
=bld
.SUBDIR('tcp',
347 'tcp_connect.c tcp_init.c tcp_io.c'),
349 deps
='replace tdb talloc tevent')
352 if bld
.env
.HAVE_INFINIBAND
:
353 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
354 source
=bld
.SUBDIR('ib',
355 '''ibwrapper.c ibw_ctdb.c
358 deps
='replace talloc tevent tdb')
359 ib_deps
= ' ctdb-ib rdmacm ibverbs'
361 if sys
.platform
.startswith('linux'):
362 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
363 elif sys
.platform
.startswith('aix'):
364 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
365 elif sys
.platform
.startswith('freebsd'):
366 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
367 elif sys
.platform
.startswith('gnukfreebsd'):
368 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
369 elif sys
.platform
== 'gnu':
370 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
372 Logs
.error("Platform %s not supported" % sys
.platform
)
374 bld
.SAMBA_SUBSYSTEM('ctdb-system',
375 source
=bld
.SUBDIR('common',
376 'system_common.c system_util.c') +
379 deps
='replace talloc tevent tdb pcap samba-util')
381 bld
.SAMBA_SUBSYSTEM('ctdb-common',
382 source
=bld
.SUBDIR('common',
383 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
386 deps
='replace popt talloc tevent tdb popt ctdb-system')
388 bld
.SAMBA_SUBSYSTEM('ctdb-util',
389 source
=bld
.SUBDIR('common',
390 '''db_hash.c srvid.c reqid.c
391 pkt_read.c pkt_write.c comm.c
392 logging.c rb_tree.c tunable.c
393 pidfile.c run_proc.c'''),
394 deps
='''samba-util sys_rw tevent-util
395 replace talloc tevent tdb''')
397 bld
.SAMBA_SUBSYSTEM('ctdb-protocol',
398 source
=bld
.SUBDIR('protocol',
399 '''protocol_header.c protocol_packet.c
400 protocol_types.c protocol_call.c
406 protocol_event.c'''),
408 deps
='replace talloc tdb')
410 bld
.SAMBA_SUBSYSTEM('ctdb-client',
411 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
413 deps
='''replace popt talloc tevent tdb
414 samba-util tdb-wrap ctdb-util''')
416 bld
.SAMBA_SUBSYSTEM('ctdb-client2',
417 source
=bld
.SUBDIR('client',
418 '''client_connect.c client_call.c
419 client_message.c client_control.c
420 client_message_sync.c
421 client_control_sync.c
422 client_db.c client_util.c
426 deps
='replace talloc tevent tdb tdb-wrap')
428 bld
.SAMBA_SUBSYSTEM('ctdb-server-util',
429 source
=bld
.SUBDIR('common',
430 '''sock_daemon.c'''),
431 deps
='''samba-util ctdb-util tevent-util
432 replace talloc tevent''')
434 bld
.SAMBA_SUBSYSTEM('ctdb-ipalloc',
435 source
=bld
.SUBDIR('server',
436 '''ipalloc_deterministic.c
437 ipalloc_nondeterministic.c
443 deps
='ctdb-protocol replace talloc tevent')
445 bld
.SAMBA_BINARY('ctdbd',
446 source
='server/ctdbd.c ' +
448 '''ctdb_daemon.c ctdb_recoverd.c
449 ctdb_recover.c ctdb_freeze.c
450 ctdb_tunables.c ctdb_monitor.c
451 ctdb_server.c ctdb_control.c
452 ctdb_call.c ctdb_ltdb_server.c
453 ctdb_traverse.c eventscript.c
455 ctdb_persistent.c ctdb_keepalive.c
459 ctdb_vacuum.c ctdb_banning.c
462 ctdb_lock.c ctdb_fork.c'''),
464 deps
='''ctdb-ipalloc ctdb-client ctdb-common ctdb-system
465 ctdb-tcp ctdb-util replace sys_rw popt
466 talloc tevent tdb talloc_report''' +
468 install_path
='${SBINDIR}',
471 bld
.SAMBA_BINARY('ctdb',
472 source
='tools/ctdb.c',
473 deps
='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
474 samba-util sys_rw popt''',
475 install_path
='${BINDIR}',
478 bld
.SAMBA_BINARY('ctdb_killtcp',
479 source
='tools/ctdb_killtcp.c',
480 deps
='''ctdb-protocol ctdb-util ctdb-system
481 samba-util replace''',
482 install_path
='${CTDB_HELPER_BINDIR}')
484 bld
.SAMBA_BINARY('ctdb_event',
485 source
='tools/ctdb_event.c',
486 deps
='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
487 samba-util replace''',
488 install_path
='${CTDB_HELPER_BINDIR}')
490 bld
.SAMBA_BINARY('ltdbtool',
491 source
='tools/ltdbtool.c',
494 install_path
='${BINDIR}',
495 manpages
='ltdbtool.1')
497 bld
.SAMBA_BINARY('ctdb_eventd',
498 source
='server/ctdb_eventd.c',
499 deps
='''ctdb-server-util ctdb-protocol ctdb-util
500 samba-util LIBASYNC_REQ replace popt''',
501 install_path
='${CTDB_HELPER_BINDIR}')
503 bld
.SAMBA_BINARY('ctdb_lock_helper',
504 source
='server/ctdb_lock_helper.c',
505 deps
='''samba-util sys_rw ctdb-system tevent-util
506 talloc tevent tdb''',
508 install_path
='${CTDB_HELPER_BINDIR}')
510 bld
.SAMBA_BINARY('ctdb_recovery_helper',
511 source
='server/ctdb_recovery_helper.c',
512 deps
='''ctdb-client2 ctdb-protocol ctdb-util
513 samba-util sys_rw replace tdb''',
514 install_path
='${CTDB_HELPER_BINDIR}')
516 bld
.SAMBA_BINARY('ctdb_takeover_helper',
517 source
='server/ctdb_takeover_helper.c',
518 deps
='''ctdb-client2 ctdb-protocol ctdb-util
519 samba-util sys_rw replace ctdb-ipalloc popt''',
520 install_path
='${CTDB_HELPER_BINDIR}')
522 bld
.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
523 source
='server/ctdb_mutex_fcntl_helper.c',
524 deps
='sys_rw ctdb-system',
526 install_path
='${CTDB_HELPER_BINDIR}')
528 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
529 source
='utils/smnotify/smnotify.x',
530 target
='utils/smnotify/smnotify.h',
531 rule
='rpcgen -h ${SRC} > ${TGT}')
533 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
535 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
536 source
='utils/smnotify/smnotify.x',
537 target
='utils/smnotify/gen_xdr.c',
538 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
540 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
541 source
='utils/smnotify/smnotify.x',
542 target
='utils/smnotify/gen_smnotify.c',
543 rule
='rpcgen -l ${SRC} > ${TGT}')
545 bld
.SAMBA_BINARY('smnotify',
546 source
=bld
.SUBDIR('utils/smnotify',
547 'smnotify.c gen_smnotify.c gen_xdr.c'),
548 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
549 includes
='utils utils/smnotify',
550 install_path
='${CTDB_HELPER_BINDIR}')
552 bld
.SAMBA_BINARY('ping_pong',
553 source
='utils/ping_pong/ping_pong.c',
555 install_path
='${BINDIR}',
556 manpages
='ping_pong.1')
558 if bld
.env
.HAVE_PMDA
:
559 bld
.SAMBA_BINARY('pmdactdb',
560 source
='utils/pmda/pmda_ctdb.c',
562 deps
='''ctdb-client2 ctdb-protocol ctdb-util
563 samba-util pcp_pmda pcp''',
564 install_path
='${CTDB_PMDADIR}')
565 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
567 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
569 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
571 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
573 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
575 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
578 if bld
.env
.HAVE_LIBRADOS
:
579 bld
.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
580 source
='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
581 deps
='talloc tevent rados',
583 install_path
='${CTDB_HELPER_BINDIR}')
585 sed_expr1
= 's|/usr/local/var/lib/ctdb|%s|g' % (bld
.env
.CTDB_VARDIR
)
586 sed_expr2
= 's|/usr/local/etc/ctdb|%s|g' % (bld
.env
.CTDB_ETCDIR
)
587 sed_expr3
= 's|/usr/local/var/log|%s|g' % (bld
.env
.CTDB_LOGDIR
)
588 sed_expr4
= 's|/usr/local/var/run/ctdb|%s|g' % (bld
.env
.CTDB_RUNDIR
)
589 sed_expr5
= 's|/usr/local/sbin|%s|g' % (bld
.env
.SBINDIR
)
590 sed_expr6
= 's|/usr/local/libexec/ctdb|%s|g' % (bld
.env
.CTDB_HELPER_BINDIR
)
591 sed_expr7
= 's|/usr/local/bin|%s|g' % (bld
.env
.BINDIR
)
592 sed_cmdline
= '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
593 (sed_expr1
, sed_expr2
, sed_expr3
, sed_expr4
, sed_expr5
,
594 sed_expr6
, sed_expr7
)
596 manpages_extra
= manpages_misc
597 if bld
.env
.etcd_reclock
:
598 manpages_extra
+= manpages_etcd
599 if bld
.env
.HAVE_LIBRADOS
:
600 manpages_extra
+= manpages_ceph
601 for f
in manpages_binary
+ manpages_extra
:
603 bld
.SAMBA_GENERATOR(x
,
604 source
=os
.path
.join('doc', x
),
606 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
608 if bld
.env
.ctdb_generate_manpages
:
609 bld
.MANPAGES(' '.join(manpages_extra
), True)
611 for m
in bld
.env
.ctdb_prebuilt_manpages
:
612 bld
.SAMBA_GENERATOR(m
,
613 source
=os
.path
.join("doc", m
),
615 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
616 bld
.INSTALL_FILES('${MANDIR}/man%s' % m
[-1], m
)
618 bld
.SAMBA_GENERATOR('ctdb-onnode',
619 source
='tools/onnode',
621 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
622 bld
.INSTALL_FILES('${BINDIR}', 'onnode',
623 destname
='onnode', chmod
=0755)
625 bld
.SAMBA_GENERATOR('ctdb-diagnostics',
626 source
='tools/ctdb_diagnostics',
627 target
='ctdb_diagnostics',
628 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
629 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
630 destname
='ctdb_diagnostics', chmod
=0755)
632 if bld
.env
.etcd_reclock
:
633 bld
.SAMBA_GENERATOR('ctdb-etcd-lock',
634 source
='utils/etcd/ctdb_etcd_lock',
635 target
='ctdb_etcd_lock',
636 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
637 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
638 destname
='ctdb_etcd_lock', chmod
=0744)
640 bld
.SAMBA_GENERATOR('ctdb-natgw',
641 source
='tools/ctdb_natgw',
643 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
644 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
645 destname
='ctdb_natgw', chmod
=0755)
647 bld
.SAMBA_GENERATOR('ctdb-lvs',
648 source
='tools/ctdb_lvs',
650 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
651 bld
.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
652 destname
='ctdb_lvs', chmod
=0755)
654 bld
.SAMBA_GENERATOR('ctdbd-wrapper',
655 source
='config/ctdbd_wrapper',
656 target
='ctdbd_wrapper',
657 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
658 bld
.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
659 destname
='ctdbd_wrapper', chmod
=0755)
661 def SUBDIR_MODE_callback(arg
, dirname
, fnames
):
663 fl
= os
.path
.join(dirname
, f
)
664 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
666 mode
= os
.lstat(fl
).st_mode
& 0777
668 fl
= samba_utils
.os_path_relpath(fl
, arg
['trim_path'])
669 arg
['file_list'].append([fl
, mode
])
671 def SUBDIR_MODE(path
, trim_path
=None):
672 pd
= {'trim_path': trim_path
, 'file_list': []}
673 os
.path
.walk(path
, SUBDIR_MODE_callback
, pd
)
674 return pd
['file_list']
681 if bld
.env
.standalone_ctdb
:
684 configdir
= 'ctdb/config'
686 for t
in etc_subdirs
:
687 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
689 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
690 destname
=fmode
[0], chmod
=fmode
[1])
692 bld
.SAMBA_GENERATOR('ctdb-functions',
693 source
='config/functions',
695 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
696 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'functions', destname
='functions')
699 'ctdb-crash-cleanup.sh',
700 'debug-hung-script.sh',
703 'nfs-linux-kernel-callout',
708 for t
in etc_scripts
:
709 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
710 destname
=t
, chmod
=0755)
712 bld
.SAMBA_GENERATOR('ctdb-sudoers',
713 source
='config/ctdb.sudoers',
714 target
='ctdb.sudoers',
715 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
716 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'ctdb.sudoers',
719 bld
.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
722 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
723 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
724 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
735 'protocol_types_test',
736 'protocol_client_test',
743 for target
in ctdb_unit_tests
:
744 src
= 'tests/src/' + target
+ '.c'
746 bld
.SAMBA_BINARY(target
,
748 deps
='''talloc tevent tdb tevent-util
749 LIBASYNC_REQ samba-util sys_rw''',
750 install_path
='${CTDB_TEST_LIBEXECDIR}')
752 bld
.SAMBA_BINARY('reqid_test',
753 source
='tests/src/reqid_test.c',
755 install_path
='${CTDB_TEST_LIBEXECDIR}')
757 bld
.SAMBA_BINARY('rb_test',
758 source
='tests/src/rb_test.c',
759 deps
='samba-util talloc',
760 install_path
='${CTDB_TEST_LIBEXECDIR}')
762 bld
.SAMBA_BINARY('ctdb_packet_parse',
763 source
='tests/src/ctdb_packet_parse.c',
764 deps
='talloc tevent tdb ctdb-protocol',
765 install_path
='${CTDB_TEST_LIBEXECDIR}')
767 bld
.SAMBA_BINARY('porting_tests',
768 source
='tests/src/porting_tests.c',
769 deps
='samba-util ctdb-system popt',
770 install_path
='${CTDB_TEST_LIBEXECDIR}')
773 bld
.SAMBA_SUBSYSTEM('ctdb-tests-common',
774 source
=bld
.SUBDIR('tests/src',
775 'cluster_wait.c test_options.c'),
777 deps
='replace popt talloc tevent tdb')
779 bld
.SAMBA_BINARY('protocol_util_test',
780 source
='tests/src/protocol_util_test.c',
781 deps
='talloc ctdb-protocol samba-util',
782 install_path
='${CTDB_TEST_LIBEXECDIR}')
792 'fetch_readonly_loop',
795 'update_record_persistent',
800 for target
in ctdb_tests
:
801 src
= 'tests/src/' + target
+ '.c'
803 bld
.SAMBA_BINARY(target
,
806 deps
='''ctdb-client2 ctdb-protocol ctdb-util
807 samba-util ctdb-tests-common''',
808 install_path
='${CTDB_TEST_LIBEXECDIR}')
810 bld
.SAMBA_BINARY('ctdb_takeover_tests',
811 source
='''tests/src/ctdb_takeover_tests.c
812 tests/src/ipalloc_read_known_ips.c''',
813 deps
='''replace popt tdb tevent talloc ctdb-system
814 samba-util tdb-wrap talloc_report
815 ctdb-ipalloc ctdb-protocol ctdb-util''',
817 install_path
='${CTDB_TEST_LIBEXECDIR}')
819 bld
.SAMBA_BINARY('fake_ctdbd',
820 source
='''tests/src/fake_ctdbd.c
821 tests/src/ipalloc_read_known_ips.c''',
822 deps
='''ctdb-util ctdb-protocol ctdb-system
823 samba-util tevent-util LIBASYNC_REQ popt''',
824 install_path
='${CTDB_TEST_LIBEXECDIR}')
826 if bld
.env
.HAVE_INFINIBAND
:
827 bld
.SAMBA_BINARY('ibwrapper_test',
828 source
='ib/ibwrapper_test.c',
830 deps
='replace talloc ctdb-client ctdb-common sys_rw' +
832 install_path
='${CTDB_TEST_LIBEXECDIR}')
834 if bld
.env
.HAVE_ROBUST_MUTEXES
:
835 bld
.SAMBA_BINARY('test_mutex_raw',
836 source
='tests/src/test_mutex_raw.c',
838 install_path
='${CTDB_TEST_LIBEXECDIR}')
854 if bld
.env
.standalone_ctdb
:
857 testdir
= 'ctdb/tests'
859 for t
in test_subdirs
:
860 files
= SUBDIR_MODE('%s/%s' % (testdir
, t
), trim_path
=testdir
)
862 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
863 destname
=fmode
[0], chmod
=fmode
[1])
865 # Install tests/scripts directory without test_wrap
872 for t
in test_scripts
:
873 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
874 os
.path
.join('tests/scripts', t
),
875 destname
=os
.path
.join('scripts', t
))
877 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
878 bld
.env
.CTDB_TEST_LIBEXECDIR
)
879 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
880 source
='tests/scripts/test_wrap',
882 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
883 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
884 destname
='test_wrap', chmod
=0755)
886 bld
.SAMBA_GENERATOR('ctdb-test-script-install-paths',
887 source
='tests/scripts/script_install_paths.sh',
888 target
='script_install_paths.sh',
889 rule
='sed %s ${SRC} > ${TGT}' % (sed_cmdline
))
890 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts",
891 'script_install_paths.sh',
892 destname
='script_install_paths.sh', chmod
=0644)
894 sed_expr1
= 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
895 bld
.env
.CTDB_TEST_DATADIR
, bld
.env
.CTDB_TEST_LIBEXECDIR
)
896 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
897 bld
.SAMBA_GENERATOR('ctdb-test-runner',
898 source
='tests/run_tests.sh',
899 target
='ctdb_run_tests.sh',
900 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
901 sed_expr1
, sed_expr2
))
902 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
903 destname
='ctdb_run_tests', chmod
=0755)
904 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
907 test_eventscript_links
= [
911 'nfs-linux-kernel-callout',
915 test_link_dir
= os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
,
916 'eventscripts/etc-ctdb')
917 for t
in test_eventscript_links
:
918 bld
.symlink_as(os
.path
.join(test_link_dir
, t
),
919 os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
921 # Tests that use onnode need to overwrite link to in-tree
922 # functions file when installed
923 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'onnode/functions'),
924 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'functions'))
925 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'simple/functions'),
926 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'functions'))
928 # Need a link to nodes file because $CTDB_BASE is overridden
929 bld
.symlink_as(os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
, 'simple/nodes'),
930 os
.path
.join(bld
.env
.CTDB_ETCDIR
, 'nodes'))
934 cmd
= 'tests/run_tests.sh -V tests/var'
935 ret
= samba_utils
.RUN_COMMAND(cmd
)
937 print('tests exited with exit status %d' % ret
)
943 Scripting
.commands
.append('build')
944 Scripting
.commands
.append('testonly')
948 env
= samba_utils
.LOAD_ENVIRONMENT()
949 ld
= 'LD_PRELOAD=%s' % env
.SOCKET_WRAPPER_SO_PATH
950 cmd
= '%s tests/run_tests.sh -e -S -C' % ld
951 ret
= samba_utils
.RUN_COMMAND(cmd
)
953 print('autotest exited with exit status %d' % ret
)
957 def show_version(ctx
):
962 BASE_URL
= 'http://docbook.sourceforge.net/release/xsl/current'
963 MAN_XSL
= '%s/manpages/docbook.xsl' % BASE_URL
964 HTML_XSL
= '%s/html/docbook.xsl' % BASE_URL
965 CMD_TEMPLATE
= 'xsltproc --xinclude -o %s --nonet %s %s'
966 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
968 cmd
= CMD_TEMPLATE
% ('doc/%s' % t
, MAN_XSL
, 'doc/%s.xml' % t
)
969 ret
= samba_utils
.RUN_COMMAND(cmd
)
971 print('Command %s failed with exit status %d' % (cmd
, ret
))
974 cmd
= CMD_TEMPLATE
% ('doc/%s.html' % t
, HTML_XSL
, 'doc/%s.xml' % t
)
975 ret
= samba_utils
.RUN_COMMAND(cmd
)
977 print('Command %s failed with exit status %d' % (cmd
, ret
))
982 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
984 t
= 'include/ctdb_version.h'
985 cmd
= 'packaging/mkversion.sh %s %s' % (t
, VERSION
)
986 ret
= samba_utils
.RUN_COMMAND(cmd
)
988 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
990 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
993 sed_expr1
= 's/@VERSION@/%s/g' % VERSION
994 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
995 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
996 sed_expr1
, sed_expr2
, t
)
997 ret
= samba_utils
.RUN_COMMAND(cmd
)
999 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
1001 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
1003 manpages
= manpages_binary
+ manpages_misc
+ manpages_etcd
+ manpages_ceph
1005 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
1006 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
1014 Scripting
.commands
.append('manpages')
1015 Scripting
.commands
.append('distonly')
1019 opts
= os
.getenv('RPM_OPTIONS') or ''
1020 cmd
= 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts
, VERSION
)
1021 ret
= samba_utils
.RUN_COMMAND(cmd
)
1023 print('rpmbuild exited with exit status %d' % ret
)
1029 Scripting
.commands
.append('manpages')
1030 Scripting
.commands
.append('distonly')
1031 Scripting
.commands
.append('rpmonly')
1035 "build 'tags' file using ctags"
1037 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1038 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
1039 print("Running: %s" % cmd
)
1040 ret
= samba_utils
.RUN_COMMAND(cmd
)
1042 print('ctags failed with exit status %d' % ret
)