third_party/popt:third_party/popt
lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
lib/ccan:lib/ccan libcli/util:libcli/util
+ lib/async_req:lib/async_req
buildtools:buildtools third_party/waf:third_party/waf''')
manpages = [
def configure(conf):
- # CTDB relies on nested event loops
- conf.env.TEVENT_DEPRECATED = 1
-
# No need to build python bindings for talloc/tevent/tdb
if conf.IN_LAUNCH_DIR():
conf.env.standalone_ctdb = True
conf.RECURSE('lib/tdb')
if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
conf.RECURSE('lib/socket_wrapper')
+ conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
conf.CHECK_HEADERS('sched.h')
conf.CHECK_HEADERS('procinfo.h')
have_pmda = True
else:
Logs.error("PMDA support not available")
+ sys.exit(1)
if have_pmda:
Logs.info('Building with PMDA support')
conf.define('HAVE_PMDA', 1)
have_infiniband = True
else:
Logs.error("Infiniband support not available")
+ sys.exit(1)
if have_infiniband:
Logs.info('Building with Infiniband support')
conf.define('HAVE_INFINIBAND', 1)
conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
+ conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb')
if Options.options.ctdb_logdir:
conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
else:
conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
'ctdbd.socket')
+ conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH)
conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
-DLOGDIR=\"%s\"
- -DSOCKPATH=\"%s\"
-DCTDB_ETCDIR=\"%s\"
-DCTDB_VARDIR=\"%s\"
-DCTDB_RUNDIR=\"%s\"''' % (
- conf.env.CTDB_BINDIR,
+ conf.env.CTDB_HELPER_BINDIR,
conf.env.CTDB_LOGDIR,
- conf.env.CTDB_SOCKPATH,
conf.env.CTDB_ETCDIR,
conf.env.CTDB_VARDIR,
conf.env.CTDB_RUNDIR))
# Allow unified compilation and separate compilation of utilities
# to find includes
if not conf.env.standalone_ctdb:
- conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include')
+ conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
else:
if srcdir == '.':
# Building from tarball
conf.ADD_EXTRA_INCLUDES('#include')
- conf.ADD_EXTRA_INCLUDES('#include/internal')
else:
# Building standalone CTDB from within Samba tree
conf.ADD_EXTRA_INCLUDES('#ctdb/include')
- conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal')
conf.ADD_EXTRA_INCLUDES('#ctdb')
conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
conf.SAMBA_CONFIG_H()
+ if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']:
+ conf.env.ctdb_generate_manpages = True
+ else:
+ conf.env.ctdb_generate_manpages = False
+
+ Logs.info("xsltproc unavailable, checking for pre-built manpages")
+ conf.env.ctdb_prebuilt_manpages = []
+ for m in manpages:
+ if os.path.exists(os.path.join("doc", m)):
+ Logs.info(" %s: yes" % (m))
+ conf.env.ctdb_prebuilt_manpages.append(m)
+ else:
+ Logs.info(" %s: no" % (m))
def build(bld):
if bld.env.standalone_ctdb:
bld.RECURSE('lib/tdb_wrap')
bld.RECURSE('lib/util')
+ bld.RECURSE('lib/async_req')
bld.RECURSE('lib/talloc')
bld.RECURSE('lib/tevent')
bld.SAMBA_SUBSYSTEM('ctdb-tcp',
source=bld.SUBDIR('tcp',
'tcp_connect.c tcp_init.c tcp_io.c'),
- includes='include include/internal',
+ includes='include',
deps='replace tdb talloc tevent')
ib_deps = ''
source=bld.SUBDIR('ib',
'''ibwrapper.c ibw_ctdb.c
ibw_ctdb_init.c'''),
- includes='include include/internal',
- deps='replace')
+ includes='include',
+ deps='replace talloc tevent tdb')
ib_deps = ' ctdb-ib rdmacm ibverbs'
if sys.platform.startswith('linux'):
CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_aix.c')
elif sys.platform.startswith('freebsd'):
CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_freebsd.c')
- elif sys.platform == 'kfreebsd':
+ elif sys.platform.startswith('gnukfreebsd'):
CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_kfreebsd.c')
elif sys.platform == 'gnu':
CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_gnu.c')
Logs.error("Platform %s not supported" % sys.platform)
bld.SAMBA_SUBSYSTEM('ctdb-system',
- source='common/system_common.c ' + CTDB_SYSTEM_SRC,
- includes='include include/internal',
- deps='replace talloc tevent tdb pcap')
+ source=bld.SUBDIR('common',
+ 'system_common.c system_util.c') +
+ CTDB_SYSTEM_SRC,
+ includes='include',
+ deps='replace talloc tevent tdb pcap samba-util')
bld.SAMBA_SUBSYSTEM('ctdb-common',
source=bld.SUBDIR('common',
'''ctdb_io.c ctdb_util.c ctdb_ltdb.c
- cmdline.c rb_tree.c
- ctdb_fork.c'''),
- includes='include include/internal common .',
+ cmdline.c'''),
+ includes='include',
deps='replace popt talloc tevent tdb popt ctdb-system')
- bld.SAMBA_SUBSYSTEM('ctdb-common-util',
- source=bld.SUBDIR('common',
- 'system_util.c ctdb_logging.c'),
- includes='include include/internal',
- deps='replace tevent tdb')
-
bld.SAMBA_SUBSYSTEM('ctdb-util',
source=bld.SUBDIR('common',
'''db_hash.c srvid.c reqid.c
pkt_read.c pkt_write.c comm.c
- logging.c'''),
- deps='replace talloc tevent tdb tevent-unix-util')
+ logging.c rb_tree.c'''),
+ deps='replace talloc tevent tdb tevent-util')
bld.SAMBA_SUBSYSTEM('ctdb-protocol',
source=bld.SUBDIR('protocol',
protocol_message.c
protocol_control.c
protocol_client.c
+ protocol_debug.c
protocol_util.c'''),
includes='include',
deps='replace talloc tdb')
bld.SAMBA_SUBSYSTEM('ctdb-client',
source=bld.SUBDIR('client', 'ctdb_client.c'),
- includes='include include/internal',
+ includes='include',
deps='''replace popt talloc tevent tdb
samba-util tdb-wrap ctdb-util''')
client_control_sync.c
client_db.c client_util.c
'''),
- includes='include include/internal',
+ includes='include',
deps='replace talloc tevent tdb tdb-wrap')
+ bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
+ source=bld.SUBDIR('server',
+ '''ipalloc_deterministic.c
+ ipalloc_nondeterministic.c
+ ipalloc_lcp2.c
+ ipalloc_common.c
+ ipalloc.c
+ '''),
+ includes='include',
+ deps='ctdb-protocol replace talloc tevent')
+
bld.SAMBA_SUBSYSTEM('ctdb-server',
source='server/ctdbd.c ' +
bld.SUBDIR('server',
ctdb_server.c ctdb_control.c
ctdb_call.c ctdb_ltdb_server.c
ctdb_traverse.c eventscript.c
- ctdb_takeover.c ctdb_serverids.c
+ ctdb_takeover.c
ctdb_persistent.c ctdb_keepalive.c
+ ctdb_cluster_mutex.c
ctdb_logging.c
ctdb_logging_syslog.c
ctdb_logging_file.c
ctdb_vacuum.c ctdb_banning.c
ctdb_statistics.c
ctdb_update_record.c
- ctdb_lock.c'''),
- includes='include include/internal',
- deps='replace popt talloc tevent tdb talloc_report')
+ ctdb_lock.c ctdb_fork.c'''),
+ includes='include',
+ deps='ctdb-ipalloc replace popt talloc tevent tdb talloc_report')
bld.SAMBA_BINARY('ctdbd',
source='',
deps='''ctdb-server ctdb-client ctdb-common
- ctdb-common-util ctdb-tcp ctdb-util''' +
+ ctdb-system ctdb-tcp ctdb-util''' +
ib_deps,
install_path='${SBINDIR}',
manpages='ctdbd.1')
bld.SAMBA_BINARY('ctdb',
- source='tools/ctdb.c tools/ctdb_vacuum.c',
- deps='''ctdb-client ctdb-common ctdb-common-util
- ctdb-util''',
- includes='include include/internal',
+ source='tools/ctdb.c',
+ deps='ctdb-client ctdb-common ctdb-system ctdb-util',
+ includes='include',
install_path='${BINDIR}',
manpages='ctdb.1')
+ bld.SAMBA_BINARY('ctdb_killtcp',
+ source='tools/ctdb_killtcp.c',
+ deps='''ctdb-protocol ctdb-util ctdb-system
+ samba-util replace''',
+ install_path='${CTDB_HELPER_BINDIR}')
+
bld.SAMBA_BINARY('ltdbtool',
source='tools/ltdbtool.c',
includes='include',
bld.SAMBA_BINARY('ctdb_lock_helper',
source='server/ctdb_lock_helper.c',
- deps='samba-util ctdb-common-util talloc tdb',
- includes='include include/internal',
- install_path='${BINDIR}')
+ deps='samba-util ctdb-system talloc tdb',
+ includes='include',
+ install_path='${CTDB_HELPER_BINDIR}')
bld.SAMBA_BINARY('ctdb_event_helper',
source='server/ctdb_event_helper.c',
- includes='include include/internal',
- deps='samba-util ctdb-common-util replace tdb',
- install_path='${BINDIR}')
+ includes='include',
+ deps='samba-util ctdb-system replace tdb',
+ install_path='${CTDB_HELPER_BINDIR}')
bld.SAMBA_BINARY('ctdb_recovery_helper',
source='server/ctdb_recovery_helper.c',
deps='''ctdb-client2 ctdb-protocol ctdb-util
samba-util replace tdb''',
- install_path='${BINDIR}')
+ install_path='${CTDB_HELPER_BINDIR}')
+
+ bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper',
+ source='server/ctdb_mutex_fcntl_helper.c',
+ deps='ctdb-system',
+ includes='include',
+ install_path='${CTDB_HELPER_BINDIR}')
bld.SAMBA_GENERATOR('ctdb-smnotify-h',
source='utils/smnotify/smnotify.x',
'smnotify.c gen_smnotify.c gen_xdr.c'),
deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
includes='utils utils/smnotify',
- install_path='${BINDIR}')
+ install_path='${CTDB_HELPER_BINDIR}')
bld.SAMBA_BINARY('ping_pong',
source='utils/ping_pong/ping_pong.c',
if bld.env.HAVE_PMDA:
bld.SAMBA_BINARY('pmdactdb',
source='utils/pmda/pmda_ctdb.c',
- includes='include include/internal',
- deps='''ctdb-client ctdb-common
- ctdb-common-util pcp_pmda pcp''',
+ includes='include',
+ deps='ctdb-client ctdb-common pcp_pmda pcp',
install_path='${CTDB_PMDADIR}')
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
destname='Install')
sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR)
sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR)
sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR)
- sed_cmdline = '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
- (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5)
+ sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR)
+ sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR)
+ sed_cmdline = '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
+ (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
+ sed_expr6, sed_expr7)
for f in manpages:
x = '%s.xml' % (f)
target=x,
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
- if 'XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']:
+ if bld.env.ctdb_generate_manpages:
bld.MANPAGES('''onnode.1 ctdbd_wrapper.1 ctdbd.conf.5
ctdb.7 ctdb-statistics.7 ctdb-tunables.7''',
True)
else:
- for m in manpages:
+ for m in bld.env.ctdb_prebuilt_manpages:
bld.SAMBA_GENERATOR(m,
source=os.path.join("doc", m),
target=m,
bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
destname='ctdb_diagnostics', chmod=0755)
+ bld.SAMBA_GENERATOR('ctdb-natgw',
+ source='tools/ctdb_natgw',
+ target='ctdb_natgw',
+ rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+ bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw',
+ destname='ctdb_natgw', chmod=0755)
+
+ bld.SAMBA_GENERATOR('ctdb-lvs',
+ source='tools/ctdb_lvs',
+ target='ctdb_lvs',
+ rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+ bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs',
+ destname='ctdb_lvs', chmod=0755)
+
bld.SAMBA_GENERATOR('ctdbd-wrapper',
source='config/ctdbd_wrapper',
target='ctdbd_wrapper',
bld.install_dir(bld.env.CTDB_RUNDIR)
bld.install_dir(bld.env.CTDB_VARDIR)
- sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
- t = bld.SAMBA_GENERATOR('ctdb-pc',
- source='ctdb.pc.in',
- target='ctdb.pc',
- rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr,
- dep_vars=['VERSION'])
- t.env.VERSION = VERSION
- bld.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
-
# Unit tests
ctdb_unit_tests = [
'db_hash_test',
bld.SAMBA_BINARY(target,
source=src,
- deps='talloc tevent tdb tevent-unix-util',
+ deps='''talloc tevent tdb tevent-util
+ LIBASYNC_REQ samba-util''',
install_path='${CTDB_TEST_LIBDIR}')
bld.SAMBA_BINARY('reqid_test',
deps='samba-util',
install_path='${CTDB_TEST_LIBDIR}')
+ bld.SAMBA_BINARY('rb_test',
+ source='tests/src/rb_test.c',
+ deps='samba-util talloc',
+ install_path='${CTDB_TEST_LIBDIR}')
+
+ bld.SAMBA_BINARY('ctdb_packet_parse',
+ source='tests/src/ctdb_packet_parse.c',
+ deps='talloc tevent tdb ctdb-protocol',
+ install_path='${CTDB_TEST_LIBDIR}')
+
# Test binaries
ctdb_tests = [
- 'rb_test',
- 'ctdb_bench',
- 'ctdb_fetch',
- 'ctdb_fetch_one',
- 'ctdb_fetch_readonly_once',
- 'ctdb_fetch_readonly_loop',
'ctdb_trackingdb_test',
- 'ctdb_update_record',
- 'ctdb_update_record_persistent',
'ctdb_store',
'ctdb_traverse',
'ctdb_randrec',
'ctdb_persistent',
'ctdb_porting_tests',
- 'ctdb_transaction',
'ctdb_lock_tdb'
]
bld.SAMBA_BINARY(target,
source=src,
- includes='include include/internal',
- deps='''ctdb-client ctdb-common ctdb-common-util
- ctdb-util''',
+ includes='include',
+ deps='ctdb-client ctdb-common ctdb-util',
+ install_path='${CTDB_TEST_LIBDIR}')
+
+ bld.SAMBA_SUBSYSTEM('ctdb-tests-common',
+ source=bld.SUBDIR('tests/src',
+ 'cluster_wait.c test_options.c'),
+ includes='include',
+ deps='replace popt talloc tevent tdb')
+
+ ctdb_tests = [
+ 'g_lock_loop',
+ 'message_ring',
+ 'fetch_ring',
+ 'fetch_loop',
+ 'fetch_readonly',
+ 'fetch_readonly_loop',
+ 'transaction_loop',
+ 'update_record',
+ 'update_record_persistent'
+ ]
+
+ for target in ctdb_tests:
+ src = 'tests/src/' + target + '.c'
+
+ bld.SAMBA_BINARY(target,
+ source=src,
+ includes='include',
+ deps='''ctdb-client2 ctdb-protocol ctdb-util
+ samba-util ctdb-tests-common''',
install_path='${CTDB_TEST_LIBDIR}')
bld.SAMBA_BINARY('ctdb_takeover_tests',
source='tests/src/ctdb_takeover_tests.c',
deps='''replace popt tdb tevent talloc ctdb-system
- samba-util tdb-wrap talloc_report''' +
- ib_deps,
- includes='include include/internal',
- install_path='${CTDB_TEST_LIBDIR}')
-
- bld.SAMBA_BINARY('ctdb_functest',
- source='tests/src/ctdb_functest.c',
- deps='''replace tdb tevent talloc popt ctdb-system
- samba-util tdb-wrap''',
- includes='include include/internal',
+ samba-util tdb-wrap talloc_report
+ ctdb-ipalloc ctdb-protocol ctdb-util''',
+ includes='include',
install_path='${CTDB_TEST_LIBDIR}')
- bld.SAMBA_BINARY('ctdb_stubtest',
- source='tests/src/ctdb_test.c',
- deps='''replace tdb tevent talloc popt ctdb-system
- samba-util tdb-wrap''',
- includes='include include/internal',
+ bld.SAMBA_BINARY('fake_ctdbd',
+ source='tests/src/fake_ctdbd.c',
+ deps='''ctdb-util ctdb-protocol ctdb-system
+ samba-util tevent-util LIBASYNC_REQ popt''',
install_path='${CTDB_TEST_LIBDIR}')
if bld.env.HAVE_INFINIBAND:
bld.SAMBA_BINARY('ibwrapper_test',
source='ib/ibwrapper_test.c',
- includes='include include/internal',
- deps='replace talloc ctdb-client ctdb-common ' +
+ includes='include',
+ deps='replace talloc ctdb-client ctdb-common' +
ib_deps,
install_path='${CTDB_TEST_LIBDIR}')
'events.d',
'eventscripts',
'onnode',
+ 'shellcheck',
'simple',
'takeover',
'tool'
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
destname='test_wrap', chmod=0755)
+ bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
+ source='tests/scripts/script_install_paths.sh',
+ target='script_install_paths.sh',
+ rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+ bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts",
+ 'script_install_paths.sh',
+ destname='script_install_paths.sh', chmod=0644)
+
sed_expr1 = 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
bld.env.CTDB_TEST_DATADIR, bld.env.CTDB_TEST_LIBDIR)
sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
def autotest(ctx):
- ld = 'LD_PRELOAD=%s/bin/shared/libsocket-wrapper.so' % os.getcwd()
+ env = samba_utils.LOAD_ENVIRONMENT()
+ ld = 'LD_PRELOAD=%s' % env.SOCKET_WRAPPER_SO_PATH
cmd = '%s tests/run_tests.sh -e -S -C' % ld
ret = samba_utils.RUN_COMMAND(cmd)
if ret != 0: