APPNAME = 'ctdb'
-blddir = 'bin'
-
import sys, os
# find the buildtools directory
-srcdir = '.'
-while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
- srcdir = srcdir + '/..'
-sys.path.insert(0, srcdir + '/buildtools/wafsamba')
+top = '.'
+while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
+ top = top + '/..'
+sys.path.insert(0, top + '/buildtools/wafsamba')
+
+out = 'bin'
-import wafsamba, samba_dist, Options, Logs, Utils
-import samba_utils, samba_version
+from waflib import Options, Logs, Errors, Context
+import wafsamba
+from wafsamba import samba_dist, samba_utils
+from samba_utils import MODE_644, MODE_744, MODE_755, MODE_777
-env = samba_utils.LOAD_ENVIRONMENT()
if os.path.isfile('./VERSION'):
vdir = '.'
elif os.path.isfile('../VERSION'):
else:
Logs.error("VERSION file not found")
-version = samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
-VERSION = version.STRING.replace('-', '.')
-
default_prefix = Options.default_prefix = '/usr/local'
samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
'ctdb_mutex_ceph_rados_helper.7',
]
+VERSION = ''
+
+def get_version():
+ import samba_version
+ env = samba_utils.LOAD_ENVIRONMENT()
+
+ return samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env)
-def set_options(opt):
+def get_version_string():
+ if Context.g_module.VERSION:
+ return Context.g_module.VERSION
+ version = get_version()
+ Context.g_module.VERSION = version.STRING.replace('-', '.')
+ return Context.g_module.VERSION
+
+def options(opt):
opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
opt.RECURSE('lib/replace')
opt.add_option('--enable-etcd-reclock',
help=("Enable etcd recovery lock helper (default=no)"),
action="store_true", dest='ctdb_etcd_reclock', default=False)
+
+ opt.add_option('--with-libcephfs',
+ help=("Directory under which libcephfs is installed"),
+ action="store", dest='libcephfs_dir', default=None)
opt.add_option('--enable-ceph-reclock',
help=("Enable Ceph CTDB recovery lock helper (default=no)"),
action="store_true", dest='ctdb_ceph_reclock', default=False)
def configure(conf):
-
# No need to build python bindings for talloc/tevent/tdb
if conf.IN_LAUNCH_DIR():
conf.env.standalone_ctdb = True
if conf.env.standalone_ctdb:
conf.SAMBA_CHECK_PERL(mandatory=True)
- conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,5,0))
- conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
+ # This is just for consistency and to check the version for the
+ # build system, see Options.options.disable_python = True above
+ conf.SAMBA_CHECK_PYTHON()
+ conf.SAMBA_CHECK_PYTHON_HEADERS()
if conf.CHECK_FOR_THIRD_PARTY():
conf.RECURSE('third_party/popt')
conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
else:
if not conf.CHECK_POPT():
- raise Utils.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
+ raise Errors.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
else:
conf.define('USING_SYSTEM_POPT', 1)
conf.env.SOCKET_WRAPPER_SO_PATH = ''
if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
if not conf.CHECK_SOCKET_WRAPPER():
- raise Utils.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
+ raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
else:
conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
conf.env.etcd_reclock = have_etcd_reclock
if Options.options.ctdb_ceph_reclock:
+ # Use custom libcephfs library path if provided. XXX The top level build
+ # explicitly sets LIBPATH_CEPH-COMMON when libcephfs_dir isn't provided.
+ if Options.options.libcephfs_dir:
+ conf.env['CPPPATH_RADOS'] = Options.options.libcephfs_dir + '/include'
+ conf.env['LIBPATH_RADOS'] = Options.options.libcephfs_dir + '/lib'
+ conf.env['LIBPATH_CEPH-COMMON'] = conf.env['LIBPATH_RADOS'] + '/ceph'
+
if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and
conf.CHECK_LIB('rados', shlib=True)):
+ conf.CHECK_LIB('ceph-common', shlib=True)
Logs.info('Building with Ceph librados recovery lock support')
conf.define('HAVE_LIBRADOS', 1)
else:
if not conf.env.standalone_ctdb:
conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb')
else:
- if srcdir == '.':
+ if Context.g_module.top == '.':
# Building from tarball
conf.ADD_EXTRA_INCLUDES('#include')
else:
else:
Logs.info(" %s: no" % (m))
-def gen_ctdb_version(task):
- fp = file(task.outputs[0].bldpath(task.env), 'w')
- fp.write('/* This file is auto-generated from waf */\n')
- fp.write('#include "version.h"\n')
- fp.write('\n')
- fp.write('#define CTDB_VERSION_STRING "%s"\n' % VERSION)
- fp.close()
-
-
def build(bld):
if bld.env.standalone_ctdb:
# enable building of public headers in the build tree
if bld.env.standalone_ctdb:
bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir)
- t = bld.SAMBA_GENERATOR('ctdb-version-header',
- target='include/ctdb_version.h',
- rule=gen_ctdb_version,
- dep_vars=['VERSION'])
- t.env.VERSION = VERSION
-
bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
bld.RECURSE('lib/replace')
pkt_read.c pkt_write.c comm.c
logging.c rb_tree.c tunable.c
pidfile.c run_proc.c
- hash_count.c run_event.c
- sock_client.c version.c
- cmdline.c path.c conf.c
+ hash_count.c
+ run_event.c event_script.c
+ sock_client.c
+ cmdline.c path.c conf.c line.c
'''),
deps='''samba-util sys_rw tevent-util
replace talloc tevent tdb popt''')
bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
source='protocol/protocol_util.c',
- deps='replace talloc tdb')
+ deps='ctdb-util replace talloc tdb')
bld.SAMBA_SUBSYSTEM('ctdb-client',
source=bld.SUBDIR('client',
source='event/event_conf.c',
deps='ctdb-util')
+ bld.SAMBA_SUBSYSTEM('ctdb-failover-conf',
+ source='failover/failover_conf.c',
+ deps='ctdb-util')
+
bld.SAMBA_SUBSYSTEM('ctdb-legacy-conf',
source='server/legacy_conf.c',
deps='ctdb-util')
ctdb-event-conf
ctdb-cluster-conf
ctdb-database-conf
+ ctdb-failover-conf
ctdb-legacy-conf
ctdb-util samba-util talloc replace popt''',
install_path='${CTDB_HELPER_BINDIR}')
ctdb-cluster-conf
ctdb-database-conf
ctdb-event-conf
+ ctdb-failover-conf
ctdb-legacy-conf
ctdb-event-protocol
talloc tevent tdb-wrap tdb talloc_report''' +
if bld.env.HAVE_LIBRADOS:
bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper',
source='utils/ceph/ctdb_mutex_ceph_rados_helper.c',
- deps='talloc tevent rados',
+ deps='talloc tevent rados ceph-common',
includes='include',
install_path='${CTDB_HELPER_BINDIR}')
target='onnode',
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
bld.INSTALL_FILES('${BINDIR}', 'onnode',
- destname='onnode', chmod=0755)
+ destname='onnode', chmod=MODE_755)
bld.SAMBA_GENERATOR('ctdb-diagnostics',
source='tools/ctdb_diagnostics',
target='ctdb_diagnostics',
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics',
- destname='ctdb_diagnostics', chmod=0755)
+ destname='ctdb_diagnostics', chmod=MODE_755)
if bld.env.etcd_reclock:
bld.SAMBA_GENERATOR('ctdb-etcd-lock',
target='ctdb_etcd_lock',
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock',
- destname='ctdb_etcd_lock', chmod=0744)
+ destname='ctdb_etcd_lock', chmod=MODE_744)
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)
+ destname='ctdb_natgw', chmod=MODE_755)
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)
+ destname='ctdb_lvs', chmod=MODE_755)
bld.SAMBA_GENERATOR('ctdbd-wrapper',
source='config/ctdbd_wrapper',
target='ctdbd_wrapper',
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
bld.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
- destname='ctdbd_wrapper', chmod=0755)
+ destname='ctdbd_wrapper', chmod=MODE_755)
def SUBDIR_MODE_callback(arg, dirname, fnames):
for f in fnames:
fl = os.path.join(dirname, f)
if os.path.isdir(fl) or os.path.islink(fl):
continue
- mode = os.lstat(fl).st_mode & 0777
+ mode = os.lstat(fl).st_mode & MODE_777
if arg['trim_path']:
fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
arg['file_list'].append([fl, mode])
def SUBDIR_MODE(path, trim_path=None):
pd = {'trim_path': trim_path, 'file_list': []}
- os.path.walk(path, SUBDIR_MODE_callback, pd)
+ for dirname, _subdirs, fnames in os.walk(path):
+ SUBDIR_MODE_callback(pd, dirname, fnames)
return pd['file_list']
event_script_subdirs = [
for t in etc_scripts:
bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t,
- destname=t, chmod=0755)
+ destname=t, chmod=MODE_755)
bld.SAMBA_GENERATOR('ctdb-sudoers',
source='config/ctdb.sudoers',
'config/notification.README',
destname='README')
- bld.install_dir(bld.env.CTDB_LOGDIR)
- bld.install_dir(bld.env.CTDB_RUNDIR)
- bld.install_dir(bld.env.CTDB_VARDIR)
+ bld.INSTALL_DIR(bld.env.CTDB_LOGDIR)
+ bld.INSTALL_DIR(bld.env.CTDB_RUNDIR)
+ bld.INSTALL_DIR(bld.env.CTDB_VARDIR)
for d in ['volatile', 'persistent', 'state']:
- bld.install_dir(os.path.join(bld.env.CTDB_VARDIR, d))
+ bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d))
bld.SAMBA_BINARY('errcode',
source='tests/src/errcode.c',
'run_event_test',
'cmdline_test',
'conf_test',
+ 'line_test',
+ 'event_script_test',
]
for target in ctdb_unit_tests:
deps='talloc tevent tdb ctdb-protocol',
install_path='${CTDB_TEST_LIBEXECDIR}')
+ bld.SAMBA_BINARY('system_socket_test',
+ source='tests/src/system_socket_test.c',
+ deps='talloc ctdb-protocol-util pcap',
+ install_path='${CTDB_TEST_LIBEXECDIR}')
+
bld.SAMBA_BINARY('porting_tests',
source='tests/src/porting_tests.c',
deps='samba-util ctdb-system popt',
LIBASYNC_REQ samba-util sys_rw''',
install_path='${CTDB_TEST_LIBEXECDIR}')
+ bld.SAMBA_BINARY('ctdb_io_test',
+ source='tests/src/ctdb_io_test.c',
+ deps='''talloc tevent tdb samba-util sys_rw''',
+ install_path='${CTDB_TEST_LIBEXECDIR}')
+
+
bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic',
source=bld.SUBDIR('tests/src',
'protocol_common_basic.c'),
bld.SAMBA_BINARY(target,
source=src,
deps='''ctdb-protocol-tests-common
- samba-util talloc tdb''',
+ samba-util ctdb-util talloc tdb''',
install_path='${CTDB_TEST_LIBEXECDIR}')
bld.SAMBA_BINARY('event_protocol_test',
'complex',
'ctdb_eventd',
'cunit',
+ 'etc-ctdb',
'eventd',
'eventscripts',
'onnode',
target='test_wrap',
rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
- destname='test_wrap', chmod=0755)
+ destname='test_wrap', chmod=MODE_755)
bld.SAMBA_GENERATOR('ctdb-test-script-install-paths',
source='tests/scripts/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)
+ destname='script_install_paths.sh', chmod=MODE_644)
- sed_expr1 = 's@^\(export %s\)=.*@\\1=%s\\nexport %s=\"%s\"@''' % (
- 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR,
- 'TEST_BIN_DIR', bld.env.CTDB_TEST_LIBEXECDIR)
+ sed_expr1 = 's@^\(export %s\)=.*@\\1=%s@' % (
+ 'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR)
sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
bld.SAMBA_GENERATOR('ctdb-test-runner',
source='tests/run_tests.sh',
rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
sed_expr1, sed_expr2))
bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
- destname='ctdb_run_tests', chmod=0755)
+ destname='ctdb_run_tests', chmod=MODE_755)
bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
'ctdb_run_tests')
+ bld.SAMBA_GENERATOR('ctdb-local-daemons',
+ source='tests/local_daemons.sh',
+ target='ctdb_local_daemons.sh',
+ rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
+ sed_expr1, sed_expr2))
+ bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh',
+ destname='ctdb_local_daemons', chmod=MODE_755)
+
def testonly(ctx):
cmd = 'tests/run_tests.sh -V tests/var'
def test(ctx):
- import Scripting
- Scripting.commands.append('build')
- Scripting.commands.append('testonly')
+ Options.commands.append('build')
+ Options.commands.append('testonly')
def autotest(ctx):
def show_version(ctx):
- print VERSION
+ print(get_version_string())
def manpages(ctx):
def distonly(ctx):
samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
- distfile = file('.distversion', 'w')
- for field in version.vcs_fields:
- distfile.write('%s=%s\n' % (field, str(version.vcs_fields[field])))
- distfile.close()
- samba_dist.DIST_FILES('ctdb/.distversion:.distversion', extend=True)
-
t = 'ctdb.spec'
- sed_expr1 = 's/@VERSION@/%s/g' % VERSION
+ sed_expr1 = 's/@VERSION@/%s/g' % get_version_string()
sed_expr2 = 's/@RELEASE@/%s/g' % '1'
cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
sed_expr1, sed_expr2, t)
def dist():
- import Scripting
- Scripting.commands.append('manpages')
- Scripting.commands.append('distonly')
+ Options.commands.append('manpages')
+ Options.commands.append('distonly')
def rpmonly(ctx):
opts = os.getenv('RPM_OPTIONS') or ''
- cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % (opts, VERSION)
+ cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \
+ (opts, get_version_string())
ret = samba_utils.RUN_COMMAND(cmd)
if ret != 0:
print('rpmbuild exited with exit status %d' % ret)
def rpm(ctx):
- import Scripting
- Scripting.commands.append('manpages')
- Scripting.commands.append('distonly')
- Scripting.commands.append('rpmonly')
+ Options.commands.append('manpages')
+ Options.commands.append('distonly')
+ Options.commands.append('rpmonly')
def ctags(ctx):
"build 'tags' file using ctags"
- import Utils
- source_root = os.path.dirname(Utils.g_module.root_path)
+ source_root = os.path.dirname(Context.g_module.root_path)
cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
print("Running: %s" % cmd)
ret = samba_utils.RUN_COMMAND(cmd)