| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
APPNAME = 'ctdb' |
| 4 |
|
| 5 |
import sys, os |
| 6 |
|
| 7 |
# find the buildtools directory |
| 8 |
top = '.' |
| 9 |
while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5: |
| 10 |
top = top + '/..' |
| 11 |
sys.path.insert(0, top + '/buildtools/wafsamba') |
| 12 |
|
| 13 |
out = 'bin' |
| 14 |
|
| 15 |
from waflib import Options, Logs, Errors, Context |
| 16 |
import wafsamba |
| 17 |
from wafsamba import samba_dist, samba_utils |
| 18 |
from samba_utils import MODE_644, MODE_744, MODE_755, MODE_777 |
| 19 |
|
| 20 |
if os.path.isfile('./VERSION'): |
| 21 |
vdir = '.' |
| 22 |
elif os.path.isfile('../VERSION'): |
| 23 |
vdir = '..' |
| 24 |
else: |
| 25 |
Logs.error("VERSION file not found") |
| 26 |
|
| 27 |
default_prefix = Options.default_prefix = '/usr/local' |
| 28 |
|
| 29 |
samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc |
| 30 |
lib/tevent:lib/tevent lib/tdb:lib/tdb |
| 31 |
third_party/socket_wrapper:third_party/socket_wrapper |
| 32 |
third_party/popt:third_party/popt |
| 33 |
lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap |
| 34 |
lib/ccan:lib/ccan libcli/util:libcli/util |
| 35 |
lib/async_req:lib/async_req |
| 36 |
lib/pthreadpool:lib/pthreadpool |
| 37 |
lib/messaging:lib/messaging |
| 38 |
buildtools:buildtools third_party/waf:third_party/waf''') |
| 39 |
|
| 40 |
manpages_binary = [ |
| 41 |
'ctdb.1', |
| 42 |
'ctdbd.1', |
| 43 |
'ltdbtool.1', |
| 44 |
'ping_pong.1' |
| 45 |
] |
| 46 |
|
| 47 |
manpages_misc = [ |
| 48 |
'ctdb_diagnostics.1', |
| 49 |
'onnode.1', |
| 50 |
'ctdb.conf.5', |
| 51 |
'ctdb-script.options.5', |
| 52 |
'ctdb.sysconfig.5', |
| 53 |
'ctdb.7', |
| 54 |
'ctdb-statistics.7', |
| 55 |
'ctdb-tunables.7', |
| 56 |
] |
| 57 |
|
| 58 |
manpages_etcd = [ |
| 59 |
'ctdb-etcd.7', |
| 60 |
] |
| 61 |
|
| 62 |
manpages_ceph = [ |
| 63 |
'ctdb_mutex_ceph_rados_helper.7', |
| 64 |
] |
| 65 |
|
| 66 |
VERSION = '' |
| 67 |
|
| 68 |
def get_version(): |
| 69 |
import samba_version |
| 70 |
env = samba_utils.LOAD_ENVIRONMENT() |
| 71 |
|
| 72 |
return samba_version.samba_version_file('%s/VERSION' % vdir, vdir, env) |
| 73 |
|
| 74 |
def get_version_string(): |
| 75 |
if Context.g_module.VERSION: |
| 76 |
return Context.g_module.VERSION |
| 77 |
version = get_version() |
| 78 |
Context.g_module.VERSION = version.STRING.replace('-', '.') |
| 79 |
return Context.g_module.VERSION |
| 80 |
|
| 81 |
def options(opt): |
| 82 |
opt.PRIVATE_EXTENSION_DEFAULT('ctdb') |
| 83 |
|
| 84 |
opt.RECURSE('lib/replace') |
| 85 |
|
| 86 |
opt.RECURSE('lib/util') |
| 87 |
|
| 88 |
opt.RECURSE('lib/talloc') |
| 89 |
opt.RECURSE('lib/tevent') |
| 90 |
opt.RECURSE('lib/tdb') |
| 91 |
|
| 92 |
opt.add_option('--enable-infiniband', |
| 93 |
help=("Turn on infiniband support (default=no)"), |
| 94 |
action="store_true", dest='ctdb_infiniband', default=False) |
| 95 |
opt.add_option('--enable-pmda', |
| 96 |
help=("Turn on PCP pmda support (default=no)"), |
| 97 |
action="store_true", dest='ctdb_pmda', default=False) |
| 98 |
opt.add_option('--enable-etcd-reclock', |
| 99 |
help=("Enable etcd recovery lock helper (default=no)"), |
| 100 |
action="store_true", dest='ctdb_etcd_reclock', default=False) |
| 101 |
opt.add_option('--enable-pcap', |
| 102 |
help=("Use pcap for packet capture (default=no)"), |
| 103 |
action="store_true", dest='ctdb_pcap', default=False) |
| 104 |
|
| 105 |
opt.add_option('--enable-ceph-reclock', |
| 106 |
help=("Enable Ceph CTDB recovery lock helper (default=no)"), |
| 107 |
action="store_true", dest='ctdb_ceph_reclock', default=False) |
| 108 |
|
| 109 |
opt.add_option('--with-logdir', |
| 110 |
help=("Path to log directory"), |
| 111 |
action="store", dest='ctdb_logdir', default=None) |
| 112 |
opt.add_option('--with-socketpath', |
| 113 |
help=("path to CTDB daemon socket"), |
| 114 |
action="store", dest='ctdb_sockpath', default=None) |
| 115 |
|
| 116 |
|
| 117 |
def configure(conf): |
| 118 |
# No need to build python bindings for talloc/tevent/tdb |
| 119 |
if conf.IN_LAUNCH_DIR(): |
| 120 |
conf.env.standalone_ctdb = True |
| 121 |
Options.options.disable_python = True |
| 122 |
|
| 123 |
conf.RECURSE('lib/replace') |
| 124 |
|
| 125 |
conf.CHECK_HEADERS(headers='''sys/socket.h |
| 126 |
netinet/in.h |
| 127 |
netinet/if_ether.h |
| 128 |
netinet/ip.h |
| 129 |
netinet/ip6.h |
| 130 |
netinet/icmp6.h''', |
| 131 |
together=True) |
| 132 |
|
| 133 |
conf.CHECK_CODE('int s = socket(AF_PACKET, SOCK_RAW, 0);', |
| 134 |
define='HAVE_AF_PACKET', |
| 135 |
headers='sys/socket.h linux/if_packet.h') |
| 136 |
|
| 137 |
conf.CHECK_CODE('struct sockaddr_ll sall; sall.sll_family = AF_PACKET;', |
| 138 |
define='HAVE_PACKETSOCKET', |
| 139 |
headers='sys/socket.h linux/if_packet.h') |
| 140 |
|
| 141 |
conf.CHECK_CODE('''pthread_mutex_t m; |
| 142 |
int pid = 0; |
| 143 |
m.__data.__owner = pid; |
| 144 |
''', |
| 145 |
'HAVE_PTHREAD_INTERNAL_MUTEX_OWNER', |
| 146 |
headers='pthread.h', |
| 147 |
msg='Checking for internal POSIX mutex owner field') |
| 148 |
if not conf.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER: |
| 149 |
# This is unsupported - please see note in debug_locks.sh |
| 150 |
Logs.info('Building without unsupported mutex debugging hack') |
| 151 |
|
| 152 |
if conf.env.standalone_ctdb: |
| 153 |
conf.SAMBA_CHECK_PERL(mandatory=True) |
| 154 |
|
| 155 |
# This is just for consistency and to check the version for the |
| 156 |
# build system, see Options.options.disable_python = True above |
| 157 |
conf.SAMBA_CHECK_PYTHON() |
| 158 |
conf.SAMBA_CHECK_PYTHON_HEADERS() |
| 159 |
|
| 160 |
# We just want gnutls_rnd for rand subsystem |
| 161 |
conf.CHECK_FUNCS_IN('gnutls_rnd', 'gnutls') |
| 162 |
|
| 163 |
|
| 164 |
if conf.CHECK_FOR_THIRD_PARTY(): |
| 165 |
conf.RECURSE('third_party/popt') |
| 166 |
if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'): |
| 167 |
conf.RECURSE('third_party/socket_wrapper') |
| 168 |
conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH') |
| 169 |
else: |
| 170 |
if not conf.CHECK_POPT(): |
| 171 |
raise Errors.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.') |
| 172 |
else: |
| 173 |
conf.define('USING_SYSTEM_POPT', 1) |
| 174 |
conf.env.SOCKET_WRAPPER_SO_PATH = '' |
| 175 |
|
| 176 |
|
| 177 |
if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'): |
| 178 |
if not conf.CHECK_SOCKET_WRAPPER(): |
| 179 |
raise Errors.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.') |
| 180 |
else: |
| 181 |
conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1) |
| 182 |
conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH') |
| 183 |
|
| 184 |
conf.RECURSE('lib/util') |
| 185 |
|
| 186 |
conf.RECURSE('lib/talloc') |
| 187 |
conf.RECURSE('lib/tevent') |
| 188 |
conf.RECURSE('lib/tdb') |
| 189 |
|
| 190 |
conf.CHECK_HEADERS('sched.h') |
| 191 |
conf.CHECK_HEADERS('procinfo.h') |
| 192 |
if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'): |
| 193 |
Logs.error('Need thread_setsched() on AIX') |
| 194 |
sys.exit(1) |
| 195 |
elif not conf.CHECK_FUNCS('sched_setscheduler'): |
| 196 |
Logs.error('Need sched_setscheduler()') |
| 197 |
sys.exit(1) |
| 198 |
conf.CHECK_FUNCS('mlockall') |
| 199 |
conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h") |
| 200 |
|
| 201 |
if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'): |
| 202 |
conf.DEFINE('ETIME', 'ETIMEDOUT') |
| 203 |
|
| 204 |
if Options.options.ctdb_pcap or not sys.platform.startswith('linux'): |
| 205 |
conf.DEFINE('ENABLE_PCAP', 1) |
| 206 |
if not conf.env.ENABLE_PCAP: |
| 207 |
conf.SET_TARGET_TYPE('pcap', 'EMPTY') |
| 208 |
else: |
| 209 |
conf.find_program('pcap-config', var='PCAP_CONFIG') |
| 210 |
if conf.env.PCAP_CONFIG: |
| 211 |
conf.CHECK_CFG(path=conf.env.PCAP_CONFIG, |
| 212 |
args="--cflags --libs", |
| 213 |
package="", |
| 214 |
uselib_store="PCAP") |
| 215 |
if not conf.CHECK_HEADERS('pcap.h'): |
| 216 |
Logs.error('Need libpcap') |
| 217 |
sys.exit(1) |
| 218 |
if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'): |
| 219 |
Logs.error('Need libpcap') |
| 220 |
sys.exit(1) |
| 221 |
conf.CHECK_FUNCS_IN('pcap_set_immediate_mode', 'pcap', headers='pcap.h') |
| 222 |
|
| 223 |
if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', |
| 224 |
checklibc=True, headers='execinfo.h'): |
| 225 |
Logs.error('backtrace support not available') |
| 226 |
|
| 227 |
have_pmda = False |
| 228 |
if Options.options.ctdb_pmda: |
| 229 |
checks = [conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h', |
| 230 |
together=True), |
| 231 |
conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda')] |
| 232 |
|
| 233 |
have_progname = [conf.CHECK_FUNCS_IN('pmProgname', 'pcp'), |
| 234 |
conf.CHECK_FUNCS_IN('pmGetProgname', 'pcp'), |
| 235 |
conf.CHECK_FUNCS_IN('pmSetProgname', 'pcp')] |
| 236 |
|
| 237 |
conf.CHECK_TYPE_IN('struct pmResult', 'pcp/pmapi.h') |
| 238 |
|
| 239 |
if all(checks) and any(have_progname): |
| 240 |
conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h') |
| 241 |
have_pmda = True |
| 242 |
else: |
| 243 |
Logs.error("PMDA support not available") |
| 244 |
sys.exit(1) |
| 245 |
if have_pmda: |
| 246 |
Logs.info('Building with PMDA support') |
| 247 |
conf.define('HAVE_PMDA', 1) |
| 248 |
conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR, |
| 249 |
'lib/pcp/pmdas/ctdb') |
| 250 |
|
| 251 |
have_infiniband = False |
| 252 |
if Options.options.ctdb_infiniband: |
| 253 |
ib_support = True |
| 254 |
|
| 255 |
if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'): |
| 256 |
ib_support = False |
| 257 |
if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'): |
| 258 |
ib_support = False |
| 259 |
if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'): |
| 260 |
ib_support = False |
| 261 |
if ib_support: |
| 262 |
have_infiniband = True |
| 263 |
else: |
| 264 |
Logs.error("Infiniband support not available") |
| 265 |
sys.exit(1) |
| 266 |
if have_infiniband: |
| 267 |
Logs.info('Building with Infiniband support') |
| 268 |
conf.define('HAVE_INFINIBAND', 1) |
| 269 |
conf.define('USE_INFINIBAND', 1) |
| 270 |
|
| 271 |
have_etcd_reclock = False |
| 272 |
if Options.options.ctdb_etcd_reclock: |
| 273 |
try: |
| 274 |
conf.check_python_module('etcd') |
| 275 |
have_etcd_reclock = True |
| 276 |
except: |
| 277 |
Logs.error('etcd support not available') |
| 278 |
sys.exit(1) |
| 279 |
if have_etcd_reclock: |
| 280 |
Logs.info('Building with etcd support') |
| 281 |
conf.env.etcd_reclock = have_etcd_reclock |
| 282 |
|
| 283 |
if Options.options.ctdb_ceph_reclock: |
| 284 |
if (conf.CHECK_HEADERS('rados/librados.h', False, False, 'rados') and |
| 285 |
conf.CHECK_LIB('rados', shlib=True)): |
| 286 |
Logs.info('Building with Ceph librados recovery lock support') |
| 287 |
conf.define('HAVE_LIBRADOS', 1) |
| 288 |
else: |
| 289 |
Logs.error("Missing librados for Ceph recovery lock support") |
| 290 |
sys.exit(1) |
| 291 |
|
| 292 |
conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin') |
| 293 |
conf.env.CTDB_DATADIR = os.path.join(conf.env.EXEC_PREFIX, 'share/ctdb') |
| 294 |
conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb') |
| 295 |
conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb') |
| 296 |
conf.env.CTDB_RUNDIR = '/run/ctdb' |
| 297 |
conf.env.CTDB_HELPER_BINDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb') |
| 298 |
|
| 299 |
if Options.options.ctdb_logdir: |
| 300 |
conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir |
| 301 |
else: |
| 302 |
conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log') |
| 303 |
|
| 304 |
if Options.options.ctdb_sockpath: |
| 305 |
conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath |
| 306 |
else: |
| 307 |
conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR, |
| 308 |
'ctdbd.socket') |
| 309 |
conf.define('CTDB_SOCKET', conf.env.CTDB_SOCKPATH) |
| 310 |
|
| 311 |
conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\" |
| 312 |
-DLOGDIR=\"%s\" |
| 313 |
-DCTDB_DATADIR=\"%s\" |
| 314 |
-DCTDB_ETCDIR=\"%s\" |
| 315 |
-DCTDB_VARDIR=\"%s\" |
| 316 |
-DCTDB_RUNDIR=\"%s\"''' % ( |
| 317 |
conf.env.CTDB_HELPER_BINDIR, |
| 318 |
conf.env.CTDB_LOGDIR, |
| 319 |
conf.env.CTDB_DATADIR, |
| 320 |
conf.env.CTDB_ETCDIR, |
| 321 |
conf.env.CTDB_VARDIR, |
| 322 |
conf.env.CTDB_RUNDIR)) |
| 323 |
|
| 324 |
conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.CTDB_DATADIR, 'tests') |
| 325 |
conf.env.CTDB_TEST_LIBEXECDIR = os.path.join(conf.env.LIBEXECDIR, 'ctdb/tests') |
| 326 |
|
| 327 |
# Allow unified compilation and separate compilation of utilities |
| 328 |
# to find includes |
| 329 |
if not conf.env.standalone_ctdb: |
| 330 |
conf.ADD_EXTRA_INCLUDES('#include/public #ctdb/include #ctdb') |
| 331 |
else: |
| 332 |
if Context.g_module.top == '.': |
| 333 |
# Building from tarball |
| 334 |
conf.ADD_EXTRA_INCLUDES('#include') |
| 335 |
else: |
| 336 |
# Building standalone CTDB from within Samba tree |
| 337 |
conf.ADD_EXTRA_INCLUDES('#ctdb/include') |
| 338 |
conf.ADD_EXTRA_INCLUDES('#ctdb') |
| 339 |
conf.ADD_EXTRA_INCLUDES('#lib #lib/replace') |
| 340 |
|
| 341 |
conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True) |
| 342 |
conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True) |
| 343 |
conf.SAMBA_CONFIG_H() |
| 344 |
|
| 345 |
if 'XSLTPROC_MANPAGES' in conf.env and conf.env['XSLTPROC_MANPAGES']: |
| 346 |
conf.env.ctdb_generate_manpages = True |
| 347 |
else: |
| 348 |
conf.env.ctdb_generate_manpages = False |
| 349 |
|
| 350 |
Logs.info("xsltproc unavailable, checking for pre-built manpages") |
| 351 |
conf.env.ctdb_prebuilt_manpages = [] |
| 352 |
manpages = manpages_binary + manpages_misc |
| 353 |
if conf.env.etcd_reclock: |
| 354 |
manpages += manpages_etcd |
| 355 |
if conf.env.HAVE_LIBRADOS: |
| 356 |
manpages += manpages_ceph |
| 357 |
for m in manpages: |
| 358 |
if os.path.exists(os.path.join("doc", m)): |
| 359 |
Logs.info(" %s: yes" % (m)) |
| 360 |
conf.env.ctdb_prebuilt_manpages.append(m) |
| 361 |
else: |
| 362 |
Logs.info(" %s: no" % (m)) |
| 363 |
|
| 364 |
def build(bld): |
| 365 |
if bld.env.standalone_ctdb: |
| 366 |
# enable building of public headers in the build tree |
| 367 |
bld.env.build_public_headers = 'include/public' |
| 368 |
|
| 369 |
if bld.env.standalone_ctdb: |
| 370 |
bld.SAMBA_MKVERSION('version.h', '%s/VERSION' % vdir) |
| 371 |
|
| 372 |
bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig' |
| 373 |
|
| 374 |
bld.RECURSE('lib/replace') |
| 375 |
if bld.CHECK_FOR_THIRD_PARTY(): |
| 376 |
bld.RECURSE('third_party/popt') |
| 377 |
if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'): |
| 378 |
bld.RECURSE('third_party/socket_wrapper') |
| 379 |
|
| 380 |
bld.RECURSE('lib/tdb_wrap') |
| 381 |
bld.RECURSE('lib/util') |
| 382 |
bld.RECURSE('lib/async_req') |
| 383 |
bld.RECURSE('lib/pthreadpool') |
| 384 |
bld.RECURSE('lib/messaging') |
| 385 |
|
| 386 |
bld.RECURSE('lib/talloc') |
| 387 |
bld.RECURSE('lib/tevent') |
| 388 |
bld.RECURSE('lib/tdb') |
| 389 |
|
| 390 |
if bld.env.standalone_ctdb: |
| 391 |
# If a combined build is implemented, CTDB will want to |
| 392 |
# build against samba-util rather than samba-util-core. |
| 393 |
# Similarly, other Samba subsystems expect samba-util. So, |
| 394 |
# for a standalone build, just define a fake samba-util |
| 395 |
# subsystem that pulls in samba-util-core. |
| 396 |
bld.SAMBA_SUBSYSTEM('samba-util', |
| 397 |
source='', |
| 398 |
deps='samba-util-core') |
| 399 |
|
| 400 |
bld.SAMBA_SUBSYSTEM('ctdb-tcp', |
| 401 |
source=bld.SUBDIR('tcp', |
| 402 |
'tcp_connect.c tcp_init.c tcp_io.c'), |
| 403 |
includes='include', |
| 404 |
deps='''ctdb-protocol-util |
| 405 |
ctdb-system |
| 406 |
ctdb-util |
| 407 |
replace |
| 408 |
talloc |
| 409 |
tdb |
| 410 |
tevent |
| 411 |
''') |
| 412 |
|
| 413 |
ib_deps = '' |
| 414 |
if bld.env.HAVE_INFINIBAND: |
| 415 |
bld.SAMBA_SUBSYSTEM('ctdb-ib', |
| 416 |
source=bld.SUBDIR('ib', |
| 417 |
'''ibwrapper.c ibw_ctdb.c |
| 418 |
ibw_ctdb_init.c'''), |
| 419 |
includes='include', |
| 420 |
deps='replace talloc tevent tdb') |
| 421 |
ib_deps = ' ctdb-ib rdmacm ibverbs' |
| 422 |
|
| 423 |
bld.SAMBA_SUBSYSTEM('ctdb-system', |
| 424 |
source=bld.SUBDIR('common', |
| 425 |
'system_socket.c system.c'), |
| 426 |
deps='''ctdb-protocol |
| 427 |
ctdb-protocol-util |
| 428 |
pcap |
| 429 |
replace |
| 430 |
samba-util |
| 431 |
talloc |
| 432 |
tdb |
| 433 |
tevent |
| 434 |
''') |
| 435 |
|
| 436 |
bld.SAMBA_SUBSYSTEM('ctdb-common', |
| 437 |
source=bld.SUBDIR('common', |
| 438 |
'''ctdb_io.c ctdb_util.c ctdb_ltdb.c |
| 439 |
sock_io.c'''), |
| 440 |
includes='include', |
| 441 |
deps='''replace popt talloc tevent tdb popt ctdb-system |
| 442 |
ctdb-protocol-util''') |
| 443 |
|
| 444 |
bld.SAMBA_SUBSYSTEM('ctdb-util', |
| 445 |
source=bld.SUBDIR('common', |
| 446 |
'''cmdline.c |
| 447 |
comm.c |
| 448 |
db_hash.c |
| 449 |
event_script.c |
| 450 |
hash_count.c |
| 451 |
logging.c |
| 452 |
path.c |
| 453 |
pidfile.c |
| 454 |
pkt_read.c |
| 455 |
pkt_write.c |
| 456 |
rb_tree.c |
| 457 |
reqid.c |
| 458 |
run_event.c |
| 459 |
run_proc.c |
| 460 |
sock_client.c |
| 461 |
srvid.c |
| 462 |
tmon.c |
| 463 |
tunable.c |
| 464 |
'''), |
| 465 |
deps='''samba-util |
| 466 |
LIBASYNC_REQ |
| 467 |
sys_rw |
| 468 |
tevent-util |
| 469 |
replace |
| 470 |
talloc |
| 471 |
tevent |
| 472 |
tdb |
| 473 |
popt |
| 474 |
''') |
| 475 |
|
| 476 |
bld.SAMBA_SUBSYSTEM('ctdb-protocol-basic', |
| 477 |
source=bld.SUBDIR('protocol', 'protocol_basic.c'), |
| 478 |
deps='talloc tdb') |
| 479 |
|
| 480 |
bld.SAMBA_SUBSYSTEM('ctdb-protocol', |
| 481 |
source=bld.SUBDIR('protocol', |
| 482 |
'''protocol_header.c protocol_packet.c |
| 483 |
protocol_types.c |
| 484 |
protocol_call.c |
| 485 |
protocol_message.c |
| 486 |
protocol_control.c |
| 487 |
protocol_keepalive.c |
| 488 |
protocol_tunnel.c |
| 489 |
protocol_client.c |
| 490 |
protocol_debug.c |
| 491 |
protocol_sock.c'''), |
| 492 |
deps='ctdb-protocol-basic replace talloc tdb') |
| 493 |
|
| 494 |
bld.SAMBA_SUBSYSTEM('ctdb-protocol-util', |
| 495 |
source='protocol/protocol_util.c', |
| 496 |
deps='replace talloc tdb') |
| 497 |
|
| 498 |
bld.SAMBA_SUBSYSTEM('ctdb-client', |
| 499 |
source=bld.SUBDIR('client', |
| 500 |
'''client_connect.c client_call.c |
| 501 |
client_message.c client_control.c |
| 502 |
client_message_sync.c |
| 503 |
client_control_sync.c |
| 504 |
client_db.c client_util.c |
| 505 |
client_tunnel.c |
| 506 |
'''), |
| 507 |
deps='''ctdb-protocol |
| 508 |
ctdb-util |
| 509 |
samba-util |
| 510 |
replace |
| 511 |
talloc |
| 512 |
tevent |
| 513 |
tdb |
| 514 |
tdb-wrap |
| 515 |
''') |
| 516 |
|
| 517 |
bld.SAMBA_SUBSYSTEM('ctdb-server-util', |
| 518 |
source=bld.SUBDIR('common', |
| 519 |
'''sock_daemon.c'''), |
| 520 |
deps='''samba-util ctdb-util ctdb-system tevent-util |
| 521 |
LIBASYNC_REQ replace talloc tevent''') |
| 522 |
|
| 523 |
bld.SAMBA_SUBSYSTEM('ctdb-ipalloc', |
| 524 |
source=bld.SUBDIR('server', |
| 525 |
'''ipalloc_deterministic.c |
| 526 |
ipalloc_nondeterministic.c |
| 527 |
ipalloc_lcp2.c |
| 528 |
ipalloc_common.c |
| 529 |
ipalloc.c |
| 530 |
'''), |
| 531 |
includes='include', |
| 532 |
deps='ctdb-protocol-util replace talloc tevent') |
| 533 |
|
| 534 |
bld.SAMBA_BINARY('ctdb-path', |
| 535 |
source='common/path_tool.c', |
| 536 |
cflags='-DCTDB_PATH_TOOL', |
| 537 |
deps='''ctdb-util samba-util talloc replace popt''', |
| 538 |
install_path='${CTDB_HELPER_BINDIR}') |
| 539 |
|
| 540 |
bld.SAMBA_SUBSYSTEM('ctdb-conf', |
| 541 |
source='''conf/conf.c |
| 542 |
conf/logging_conf.c |
| 543 |
conf/cluster_conf.c |
| 544 |
conf/database_conf.c |
| 545 |
conf/event_conf.c |
| 546 |
conf/failover_conf.c |
| 547 |
conf/legacy_conf.c |
| 548 |
conf/ctdb_config.c |
| 549 |
''', |
| 550 |
deps='''ctdb-util talloc replace''') |
| 551 |
|
| 552 |
bld.SAMBA_SUBSYSTEM('ctdb-conf-util', |
| 553 |
source='''conf/node.c |
| 554 |
''', |
| 555 |
deps='''ctdb-protocol |
| 556 |
ctdb-protocol-util |
| 557 |
replace |
| 558 |
samba-util |
| 559 |
talloc |
| 560 |
''') |
| 561 |
|
| 562 |
bld.SAMBA_BINARY('ctdb-config', |
| 563 |
source='conf/conf_tool.c', |
| 564 |
cflags='-DCTDB_CONF_TOOL', |
| 565 |
deps='''ctdb-conf |
| 566 |
ctdb-util samba-util talloc replace popt''', |
| 567 |
install_path='${CTDB_HELPER_BINDIR}') |
| 568 |
|
| 569 |
bld.SAMBA_SUBSYSTEM('ctdb-event-protocol', |
| 570 |
source=bld.SUBDIR('event', |
| 571 |
'''event_protocol.c |
| 572 |
event_protocol_util.c |
| 573 |
'''), |
| 574 |
deps='ctdb-protocol-basic') |
| 575 |
|
| 576 |
bld.SAMBA_LIBRARY('ctdb-event-client', |
| 577 |
source='event/event_client.c', |
| 578 |
deps='ctdb-event-protocol ctdb-util tevent talloc', |
| 579 |
private_library=True) |
| 580 |
|
| 581 |
bld.SAMBA_BINARY('ctdb-eventd', |
| 582 |
source=bld.SUBDIR('event', |
| 583 |
'''event_cmd.c |
| 584 |
event_config.c |
| 585 |
event_context.c |
| 586 |
event_daemon.c |
| 587 |
event_request.c |
| 588 |
'''), |
| 589 |
deps='''ctdb-event-protocol |
| 590 |
ctdb-conf |
| 591 |
ctdb-server-util samba-util ctdb-util |
| 592 |
talloc tevent replace popt''', |
| 593 |
install_path='${CTDB_HELPER_BINDIR}') |
| 594 |
|
| 595 |
bld.SAMBA_BINARY('ctdb-event', |
| 596 |
source='event/event_tool.c', |
| 597 |
cflags='-DCTDB_EVENT_TOOL', |
| 598 |
deps='''ctdb-event-client ctdb-event-protocol |
| 599 |
ctdb-util samba-util talloc replace''', |
| 600 |
install_path='${CTDB_HELPER_BINDIR}') |
| 601 |
|
| 602 |
bld.SAMBA_BINARY('ctdbd', |
| 603 |
source='server/ctdbd.c ' + |
| 604 |
bld.SUBDIR('server', |
| 605 |
'''ctdb_daemon.c ctdb_recoverd.c |
| 606 |
ctdb_recover.c ctdb_freeze.c |
| 607 |
ctdb_tunables.c ctdb_monitor.c |
| 608 |
ctdb_server.c ctdb_control.c |
| 609 |
ctdb_call.c ctdb_ltdb_server.c |
| 610 |
ctdb_traverse.c eventscript.c |
| 611 |
ctdb_takeover.c |
| 612 |
ctdb_persistent.c ctdb_keepalive.c |
| 613 |
ctdb_cluster_mutex.c |
| 614 |
ctdb_logging.c |
| 615 |
ctdb_uptime.c |
| 616 |
ctdb_vacuum.c ctdb_banning.c |
| 617 |
ctdb_statistics.c |
| 618 |
ctdb_update_record.c |
| 619 |
ctdb_lock.c ctdb_fork.c |
| 620 |
ctdb_tunnel.c ctdb_client.c |
| 621 |
'''), |
| 622 |
includes='include', |
| 623 |
deps='''ctdb-common |
| 624 |
ctdb-conf |
| 625 |
ctdb-conf-util |
| 626 |
ctdb-event-protocol |
| 627 |
ctdb-protocol |
| 628 |
ctdb-system |
| 629 |
ctdb-tcp |
| 630 |
ctdb-util |
| 631 |
popt |
| 632 |
replace |
| 633 |
sys_rw |
| 634 |
talloc |
| 635 |
talloc_report |
| 636 |
tdb |
| 637 |
tdb-wrap |
| 638 |
tevent |
| 639 |
''' + |
| 640 |
ib_deps, |
| 641 |
install_path='${SBINDIR}', |
| 642 |
manpages='ctdbd.1') |
| 643 |
|
| 644 |
bld.SAMBA_BINARY('ctdb', |
| 645 |
source='tools/ctdb.c', |
| 646 |
deps='''ctdb-client |
| 647 |
ctdb-conf |
| 648 |
ctdb-conf-util |
| 649 |
ctdb-protocol |
| 650 |
ctdb-protocol-util |
| 651 |
ctdb-system |
| 652 |
ctdb-util |
| 653 |
popt |
| 654 |
samba-util |
| 655 |
sys_rw |
| 656 |
''', |
| 657 |
install_path='${BINDIR}', |
| 658 |
manpages='ctdb.1') |
| 659 |
|
| 660 |
bld.SAMBA_BINARY('ctdb_killtcp', |
| 661 |
source='tools/ctdb_killtcp.c', |
| 662 |
deps='''ctdb-protocol-util ctdb-util ctdb-system |
| 663 |
samba-util replace''', |
| 664 |
install_path='${CTDB_HELPER_BINDIR}') |
| 665 |
|
| 666 |
bld.SAMBA_BINARY('ltdbtool', |
| 667 |
source='tools/ltdbtool.c', |
| 668 |
includes='include', |
| 669 |
deps='tdb', |
| 670 |
install_path='${BINDIR}', |
| 671 |
manpages='ltdbtool.1') |
| 672 |
|
| 673 |
bld.SAMBA_BINARY('ctdb_lock_helper', |
| 674 |
source='server/ctdb_lock_helper.c', |
| 675 |
deps='''samba-util sys_rw ctdb-system tevent-util |
| 676 |
talloc tevent tdb''', |
| 677 |
includes='include', |
| 678 |
install_path='${CTDB_HELPER_BINDIR}') |
| 679 |
|
| 680 |
bld.SAMBA_BINARY('ctdb_recovery_helper', |
| 681 |
source='server/ctdb_recovery_helper.c', |
| 682 |
deps='''ctdb-client ctdb-protocol ctdb-util |
| 683 |
samba-util sys_rw replace tdb''', |
| 684 |
install_path='${CTDB_HELPER_BINDIR}') |
| 685 |
|
| 686 |
bld.SAMBA_BINARY("statd_callout", |
| 687 |
source="failover/statd_callout.c", |
| 688 |
install_path="${CTDB_HELPER_BINDIR}") |
| 689 |
|
| 690 |
bld.SAMBA_BINARY('ctdb_takeover_helper', |
| 691 |
source='server/ctdb_takeover_helper.c', |
| 692 |
deps='''ctdb-client ctdb-protocol ctdb-util |
| 693 |
samba-util sys_rw replace ctdb-ipalloc popt''', |
| 694 |
install_path='${CTDB_HELPER_BINDIR}') |
| 695 |
|
| 696 |
bld.SAMBA_BINARY('ctdb_mutex_fcntl_helper', |
| 697 |
source='server/ctdb_mutex_fcntl_helper.c', |
| 698 |
deps='''sys_rw ctdb-system tevent-util ctdb-util |
| 699 |
talloc tevent |
| 700 |
''', |
| 701 |
includes='include', |
| 702 |
install_path='${CTDB_HELPER_BINDIR}') |
| 703 |
|
| 704 |
bld.SAMBA_BINARY('ctdb_smnotify_helper', |
| 705 |
source=('failover/smnotify_helper.c'), |
| 706 |
deps='sys_rw replace', |
| 707 |
install_path='${CTDB_HELPER_BINDIR}') |
| 708 |
|
| 709 |
bld.SAMBA_BINARY('ping_pong', |
| 710 |
source='utils/ping_pong/ping_pong.c', |
| 711 |
deps='', |
| 712 |
install_path='${BINDIR}', |
| 713 |
manpages='ping_pong.1') |
| 714 |
|
| 715 |
if bld.env.HAVE_PTHREAD_INTERNAL_MUTEX_OWNER: |
| 716 |
bld.SAMBA_BINARY('tdb_mutex_check', |
| 717 |
source='utils/tdb/tdb_mutex_check.c', |
| 718 |
deps='tdb pthread', |
| 719 |
install_path='${CTDB_HELPER_BINDIR}') |
| 720 |
|
| 721 |
if bld.env.HAVE_PMDA: |
| 722 |
bld.SAMBA_BINARY('pmdactdb', |
| 723 |
source='utils/pmda/pmda_ctdb.c', |
| 724 |
deps='''ctdb-client ctdb-protocol ctdb-util |
| 725 |
samba-util pcp_pmda pcp''', |
| 726 |
install_path='${CTDB_PMDADIR}') |
| 727 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install', |
| 728 |
destname='Install') |
| 729 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove', |
| 730 |
destname='Remove') |
| 731 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns', |
| 732 |
destname='pmns') |
| 733 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h', |
| 734 |
destname='domain.h') |
| 735 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help', |
| 736 |
destname='help') |
| 737 |
bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README', |
| 738 |
destname='README') |
| 739 |
|
| 740 |
if bld.env.HAVE_LIBRADOS: |
| 741 |
bld.SAMBA_BINARY('ctdb_mutex_ceph_rados_helper', |
| 742 |
source='utils/ceph/ctdb_mutex_ceph_rados_helper.c', |
| 743 |
deps='talloc tevent rados', |
| 744 |
includes='include', |
| 745 |
install_path='${CTDB_HELPER_BINDIR}') |
| 746 |
|
| 747 |
sed_expr1 = 's|/usr/local/var/lib/ctdb|%s|g' % (bld.env.CTDB_VARDIR) |
| 748 |
sed_expr2 = 's|/usr/local/etc/ctdb|%s|g' % (bld.env.CTDB_ETCDIR) |
| 749 |
sed_expr3 = 's|/usr/local/var/log|%s|g' % (bld.env.CTDB_LOGDIR) |
| 750 |
sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g' % (bld.env.CTDB_RUNDIR) |
| 751 |
sed_expr5 = 's|/usr/local/sbin|%s|g' % (bld.env.SBINDIR) |
| 752 |
sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g' % (bld.env.CTDB_HELPER_BINDIR) |
| 753 |
sed_expr7 = 's|/usr/local/bin|%s|g' % (bld.env.BINDIR) |
| 754 |
sed_expr8 = 's|/usr/local/share/ctdb|%s|g' % (bld.env.CTDB_DATADIR) |
| 755 |
sed_cmdline = '-e "%s" ' * 8 % \ |
| 756 |
(sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5, |
| 757 |
sed_expr6, sed_expr7, sed_expr8) |
| 758 |
|
| 759 |
manpages_extra = list(manpages_misc) |
| 760 |
if bld.env.etcd_reclock: |
| 761 |
manpages_extra += manpages_etcd |
| 762 |
if bld.env.HAVE_LIBRADOS: |
| 763 |
manpages_extra += manpages_ceph |
| 764 |
for f in manpages_binary + manpages_extra: |
| 765 |
x = '%s.xml' % (f) |
| 766 |
bld.SAMBA_GENERATOR(x, |
| 767 |
source=os.path.join('doc', x), |
| 768 |
target=x, |
| 769 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 770 |
|
| 771 |
if bld.env.ctdb_generate_manpages: |
| 772 |
bld.MANPAGES(' '.join(manpages_extra), True) |
| 773 |
else: |
| 774 |
for m in bld.env.ctdb_prebuilt_manpages: |
| 775 |
bld.SAMBA_GENERATOR(m, |
| 776 |
source=os.path.join("doc", m), |
| 777 |
target=m, |
| 778 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 779 |
bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m) |
| 780 |
|
| 781 |
bld.SAMBA_GENERATOR('ctdb-onnode', |
| 782 |
source='tools/onnode', |
| 783 |
target='onnode', |
| 784 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 785 |
bld.INSTALL_FILES('${BINDIR}', 'onnode', |
| 786 |
destname='onnode', chmod=MODE_755) |
| 787 |
|
| 788 |
bld.SAMBA_GENERATOR('ctdb-diagnostics', |
| 789 |
source='tools/ctdb_diagnostics', |
| 790 |
target='ctdb_diagnostics', |
| 791 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 792 |
bld.INSTALL_FILES('${BINDIR}', 'ctdb_diagnostics', |
| 793 |
destname='ctdb_diagnostics', chmod=MODE_755) |
| 794 |
|
| 795 |
if bld.env.etcd_reclock: |
| 796 |
bld.SAMBA_GENERATOR('ctdb-etcd-lock', |
| 797 |
source='utils/etcd/ctdb_etcd_lock', |
| 798 |
target='ctdb_etcd_lock', |
| 799 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 800 |
bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_etcd_lock', |
| 801 |
destname='ctdb_etcd_lock', chmod=MODE_744) |
| 802 |
|
| 803 |
bld.SAMBA_GENERATOR('ctdb-natgw', |
| 804 |
source='tools/ctdb_natgw', |
| 805 |
target='ctdb_natgw', |
| 806 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 807 |
bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_natgw', |
| 808 |
destname='ctdb_natgw', chmod=MODE_755) |
| 809 |
|
| 810 |
bld.SAMBA_GENERATOR('ctdb-lvs', |
| 811 |
source='tools/ctdb_lvs', |
| 812 |
target='ctdb_lvs', |
| 813 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 814 |
bld.INSTALL_FILES('${CTDB_HELPER_BINDIR}', 'ctdb_lvs', |
| 815 |
destname='ctdb_lvs', chmod=MODE_755) |
| 816 |
|
| 817 |
bld.SAMBA_GENERATOR("ctdb-statd-callout-helper", |
| 818 |
source="tools/statd_callout_helper", |
| 819 |
target="statd_callout_helper", |
| 820 |
rule=f"sed {sed_cmdline} ${{SRC}} > ${{TGT}}") |
| 821 |
bld.INSTALL_FILES("${CTDB_HELPER_BINDIR}", "statd_callout_helper", |
| 822 |
destname="statd_callout_helper", chmod=MODE_755) |
| 823 |
|
| 824 |
bld.symlink_as(os.path.join(bld.env.CTDB_ETCDIR, "statd-callout"), |
| 825 |
os.path.join(bld.env.CTDB_HELPER_BINDIR, "statd_callout")) |
| 826 |
|
| 827 |
def SUBDIR_MODE_callback(arg, dirname, fnames): |
| 828 |
for f in fnames: |
| 829 |
fl = os.path.join(dirname, f) |
| 830 |
if os.path.isdir(fl) or os.path.islink(fl): |
| 831 |
continue |
| 832 |
mode = os.lstat(fl).st_mode & MODE_777 |
| 833 |
if arg['trim_path']: |
| 834 |
fl = samba_utils.os.path.relpath(fl, arg['trim_path']) |
| 835 |
arg['file_list'].append([fl, mode]) |
| 836 |
|
| 837 |
def SUBDIR_MODE(path, trim_path=None): |
| 838 |
pd = {'trim_path': trim_path, 'file_list': []} |
| 839 |
for dirname, _subdirs, fnames in os.walk(path): |
| 840 |
SUBDIR_MODE_callback(pd, dirname, fnames) |
| 841 |
return pd['file_list'] |
| 842 |
|
| 843 |
event_script_subdirs = [ |
| 844 |
'events/legacy', |
| 845 |
] |
| 846 |
|
| 847 |
etc_subdirs = [ |
| 848 |
'nfs-checks.d' |
| 849 |
] |
| 850 |
|
| 851 |
if bld.env.standalone_ctdb: |
| 852 |
configdir = 'config' |
| 853 |
else: |
| 854 |
configdir = 'ctdb/config' |
| 855 |
|
| 856 |
for t in event_script_subdirs: |
| 857 |
bld.INSTALL_DIR(os.path.join(bld.env.CTDB_ETCDIR, t)) |
| 858 |
files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir) |
| 859 |
for fmode in files: |
| 860 |
bld.INSTALL_FILES(bld.env.CTDB_DATADIR, 'config/%s' % fmode[0], |
| 861 |
destname=fmode[0], chmod=fmode[1]) |
| 862 |
|
| 863 |
for t in etc_subdirs: |
| 864 |
files = SUBDIR_MODE('%s/%s' % (configdir, t), trim_path=configdir) |
| 865 |
for fmode in files: |
| 866 |
bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0], |
| 867 |
destname=fmode[0], chmod=fmode[1]) |
| 868 |
|
| 869 |
# If this is a direct install and there are no event scripts |
| 870 |
# linked/enabled then enable some standard ones |
| 871 |
if os.environ.get('DESTDIR') is None: |
| 872 |
fmt = 'events/legacy/%s.script' |
| 873 |
required_script = '00.ctdb' |
| 874 |
required_path = os.path.join(bld.env.CTDB_ETCDIR, |
| 875 |
fmt % (required_script)) |
| 876 |
if not os.path.islink(required_path) and \ |
| 877 |
not os.path.exists(required_path): |
| 878 |
default_scripts = [ required_script, |
| 879 |
'01.reclock', |
| 880 |
'05.system', |
| 881 |
'10.interface', |
| 882 |
'95.database', |
| 883 |
] |
| 884 |
for t in default_scripts: |
| 885 |
tgt = os.path.join(bld.env.CTDB_DATADIR, fmt % (t)) |
| 886 |
name = os.path.join(bld.env.CTDB_ETCDIR, fmt % (t)) |
| 887 |
bld.symlink_as(name, tgt) |
| 888 |
|
| 889 |
bld.SAMBA_GENERATOR('ctdb-functions', |
| 890 |
source='config/functions', |
| 891 |
target='functions', |
| 892 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 893 |
bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'functions', destname='functions') |
| 894 |
|
| 895 |
etc_scripts = [ |
| 896 |
'ctdb-backup-persistent-tdbs.sh', |
| 897 |
'ctdb-crash-cleanup.sh', |
| 898 |
'debug-hung-script.sh', |
| 899 |
'debug_locks.sh', |
| 900 |
'nfs-linux-kernel-callout', |
| 901 |
'notify.sh', |
| 902 |
] |
| 903 |
|
| 904 |
for t in etc_scripts: |
| 905 |
bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % t, |
| 906 |
destname=t, chmod=MODE_755) |
| 907 |
|
| 908 |
bld.INSTALL_FILES('${CTDB_ETCDIR}/events/notification', |
| 909 |
'config/notification.README', |
| 910 |
destname='README') |
| 911 |
|
| 912 |
bld.INSTALL_DIR(bld.env.CTDB_LOGDIR) |
| 913 |
bld.INSTALL_DIR(bld.env.CTDB_RUNDIR) |
| 914 |
bld.INSTALL_DIR(bld.env.CTDB_VARDIR) |
| 915 |
|
| 916 |
for d in ['volatile', 'persistent', 'state']: |
| 917 |
bld.INSTALL_DIR(os.path.join(bld.env.CTDB_VARDIR, d)) |
| 918 |
|
| 919 |
# |
| 920 |
# Test-only below this point |
| 921 |
# |
| 922 |
|
| 923 |
if not bld.env.standalone_ctdb and not bld.CONFIG_GET('ENABLE_SELFTEST'): |
| 924 |
return |
| 925 |
|
| 926 |
bld.SAMBA_BINARY('errcode', |
| 927 |
source='tests/src/errcode.c', |
| 928 |
deps='replace', |
| 929 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 930 |
|
| 931 |
bld.SAMBA_BINARY('sigcode', |
| 932 |
source='tests/src/sigcode.c', |
| 933 |
deps='replace', |
| 934 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 935 |
|
| 936 |
# Unit tests |
| 937 |
ctdb_util_tests = [ |
| 938 |
'cmdline_test', |
| 939 |
'comm_client_test', |
| 940 |
'comm_server_test', |
| 941 |
'comm_test', |
| 942 |
'conf_test', |
| 943 |
'db_hash_test', |
| 944 |
'event_script_test', |
| 945 |
'hash_count_test', |
| 946 |
'pidfile_test', |
| 947 |
'pkt_read_test', |
| 948 |
'pkt_write_test', |
| 949 |
'run_event_test', |
| 950 |
'run_proc_test', |
| 951 |
'sock_io_test', |
| 952 |
'srvid_test', |
| 953 |
'tunable_test', |
| 954 |
] |
| 955 |
|
| 956 |
for target in ctdb_util_tests: |
| 957 |
src = 'tests/src/' + target + '.c' |
| 958 |
|
| 959 |
bld.SAMBA_BINARY(target, |
| 960 |
source=src, |
| 961 |
deps='''ctdb-tests-backtrace |
| 962 |
LIBASYNC_REQ |
| 963 |
samba-util |
| 964 |
sys_rw |
| 965 |
tevent-util |
| 966 |
talloc |
| 967 |
tevent |
| 968 |
tdb |
| 969 |
popt |
| 970 |
''', |
| 971 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 972 |
|
| 973 |
bld.SAMBA_BINARY('reqid_test', |
| 974 |
source='tests/src/reqid_test.c', |
| 975 |
deps='samba-util talloc', |
| 976 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 977 |
|
| 978 |
bld.SAMBA_BINARY('rb_test', |
| 979 |
source='tests/src/rb_test.c', |
| 980 |
deps='samba-util talloc', |
| 981 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 982 |
|
| 983 |
bld.SAMBA_BINARY('ctdb_packet_parse', |
| 984 |
source='tests/src/ctdb_packet_parse.c', |
| 985 |
deps='talloc tevent tdb ctdb-protocol', |
| 986 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 987 |
|
| 988 |
bld.SAMBA_BINARY('system_socket_test', |
| 989 |
source='tests/src/system_socket_test.c', |
| 990 |
deps='''ctdb-tests-backtrace |
| 991 |
talloc |
| 992 |
ctdb-protocol-util |
| 993 |
pcap |
| 994 |
''', |
| 995 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 996 |
|
| 997 |
bld.SAMBA_BINARY('porting_tests', |
| 998 |
source='tests/src/porting_tests.c', |
| 999 |
deps='samba-util ctdb-system popt', |
| 1000 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1001 |
|
| 1002 |
bld.SAMBA_BINARY('sock_daemon_test', |
| 1003 |
source='tests/src/sock_daemon_test.c', |
| 1004 |
deps='''ctdb-system talloc tevent tevent-util |
| 1005 |
LIBASYNC_REQ samba-util sys_rw''', |
| 1006 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1007 |
|
| 1008 |
bld.SAMBA_BINARY('ctdb_io_test', |
| 1009 |
source='tests/src/ctdb_io_test.c', |
| 1010 |
deps='''talloc tevent tdb samba-util sys_rw''', |
| 1011 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1012 |
|
| 1013 |
bld.SAMBA_BINARY('ctdb-db-test', |
| 1014 |
source='tests/src/db_test_tool.c', |
| 1015 |
cflags='-DCTDB_DB_TEST_TOOL', |
| 1016 |
deps='''ctdb-client ctdb-protocol |
| 1017 |
ctdb-util samba-util talloc tevent replace''', |
| 1018 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1019 |
|
| 1020 |
for target in ['tmon_ping_test', 'tmon_test']: |
| 1021 |
src = 'tests/src/' + target + '.c' |
| 1022 |
|
| 1023 |
bld.SAMBA_BINARY(target, |
| 1024 |
source=src, |
| 1025 |
deps='''ctdb-util |
| 1026 |
ctdb-tests-backtrace |
| 1027 |
LIBASYNC_REQ |
| 1028 |
samba-util |
| 1029 |
sys_rw |
| 1030 |
tevent-util |
| 1031 |
talloc |
| 1032 |
tevent |
| 1033 |
tdb |
| 1034 |
popt |
| 1035 |
''', |
| 1036 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1037 |
|
| 1038 |
bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-basic', |
| 1039 |
source=bld.SUBDIR('tests/src', |
| 1040 |
'protocol_common_basic.c'), |
| 1041 |
deps='samba-util replace talloc') |
| 1042 |
|
| 1043 |
bld.SAMBA_SUBSYSTEM('ctdb-protocol-tests-common', |
| 1044 |
source=bld.SUBDIR('tests/src', |
| 1045 |
'''protocol_common.c |
| 1046 |
protocol_common_ctdb.c |
| 1047 |
'''), |
| 1048 |
deps='ctdb-protocol-tests-basic replace talloc tdb') |
| 1049 |
|
| 1050 |
bld.SAMBA_BINARY('protocol_basic_test', |
| 1051 |
source=bld.SUBDIR('tests/src', 'protocol_basic_test.c'), |
| 1052 |
deps='ctdb-protocol-tests-basic talloc', |
| 1053 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1054 |
|
| 1055 |
ctdb_protocol_tests = [ |
| 1056 |
'protocol_types_test', |
| 1057 |
'protocol_ctdb_test', |
| 1058 |
'protocol_util_test', |
| 1059 |
'protocol_types_compat_test', |
| 1060 |
'protocol_ctdb_compat_test', |
| 1061 |
] |
| 1062 |
|
| 1063 |
for target in ctdb_protocol_tests: |
| 1064 |
src = 'tests/src/' + target + '.c' |
| 1065 |
|
| 1066 |
bld.SAMBA_BINARY(target, |
| 1067 |
source=src, |
| 1068 |
deps='''ctdb-protocol-tests-common |
| 1069 |
samba-util talloc tdb''', |
| 1070 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1071 |
|
| 1072 |
bld.SAMBA_BINARY('event_protocol_test', |
| 1073 |
source='event/event_protocol_test.c', |
| 1074 |
deps='''ctdb-protocol-tests-basic |
| 1075 |
ctdb-protocol-basic talloc''', |
| 1076 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1077 |
|
| 1078 |
bld.SAMBA_SUBSYSTEM('ctdb-tests-common', |
| 1079 |
source=bld.SUBDIR('tests/src', |
| 1080 |
'''cluster_wait.c |
| 1081 |
test_options.c |
| 1082 |
'''), |
| 1083 |
deps='''ctdb-client |
| 1084 |
samba-util |
| 1085 |
replace |
| 1086 |
popt |
| 1087 |
talloc |
| 1088 |
tevent |
| 1089 |
tdb''') |
| 1090 |
|
| 1091 |
bld.SAMBA_SUBSYSTEM('ctdb-tests-backtrace', |
| 1092 |
source=bld.SUBDIR('tests/src', |
| 1093 |
'test_backtrace.c'), |
| 1094 |
deps='''samba-util |
| 1095 |
replace''') |
| 1096 |
|
| 1097 |
# Test binaries |
| 1098 |
ctdb_tests = [ |
| 1099 |
'g_lock_loop', |
| 1100 |
'message_ring', |
| 1101 |
'fetch_ring', |
| 1102 |
'fetch_loop', |
| 1103 |
'fetch_loop_key', |
| 1104 |
'fetch_readonly', |
| 1105 |
'fetch_readonly_loop', |
| 1106 |
'transaction_loop', |
| 1107 |
'update_record', |
| 1108 |
'update_record_persistent', |
| 1109 |
'lock_tdb', |
| 1110 |
'dummy_client', |
| 1111 |
'tunnel_test', |
| 1112 |
'tunnel_cmd', |
| 1113 |
] |
| 1114 |
|
| 1115 |
for target in ctdb_tests: |
| 1116 |
src = 'tests/src/' + target + '.c' |
| 1117 |
|
| 1118 |
bld.SAMBA_BINARY(target, |
| 1119 |
source=src, |
| 1120 |
includes='include', |
| 1121 |
deps='''ctdb-client ctdb-protocol ctdb-util |
| 1122 |
samba-util ctdb-tests-common''', |
| 1123 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1124 |
|
| 1125 |
bld.SAMBA_BINARY('ctdb_takeover_tests', |
| 1126 |
source='''tests/src/ctdb_takeover_tests.c |
| 1127 |
tests/src/ipalloc_read_known_ips.c''', |
| 1128 |
deps='''replace popt tdb tevent talloc ctdb-system |
| 1129 |
samba-util tdb-wrap talloc_report |
| 1130 |
ctdb-ipalloc ctdb-protocol ctdb-util''', |
| 1131 |
includes='include', |
| 1132 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1133 |
|
| 1134 |
bld.SAMBA_BINARY('fake_ctdbd', |
| 1135 |
source='''tests/src/fake_ctdbd.c |
| 1136 |
tests/src/ipalloc_read_known_ips.c''', |
| 1137 |
deps='''ctdb-conf-util |
| 1138 |
ctdb-protocol |
| 1139 |
ctdb-protocol-util |
| 1140 |
ctdb-system |
| 1141 |
ctdb-util |
| 1142 |
popt |
| 1143 |
samba-util |
| 1144 |
tevent-util |
| 1145 |
LIBASYNC_REQ''', |
| 1146 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1147 |
|
| 1148 |
bld.SAMBA_BINARY('cluster_mutex_test', |
| 1149 |
source='tests/src/cluster_mutex_test.c', |
| 1150 |
deps='''ctdb-tests-backtrace |
| 1151 |
samba-util |
| 1152 |
talloc |
| 1153 |
tevent |
| 1154 |
''', |
| 1155 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1156 |
|
| 1157 |
if bld.env.HAVE_INFINIBAND: |
| 1158 |
bld.SAMBA_BINARY('ibwrapper_test', |
| 1159 |
source='ib/ibwrapper_test.c', |
| 1160 |
includes='include', |
| 1161 |
deps='replace talloc ctdb-common sys_rw' + |
| 1162 |
ib_deps, |
| 1163 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1164 |
|
| 1165 |
if bld.env.HAVE_ROBUST_MUTEXES and sys.platform.startswith('linux') and bld.env.DEVELOPER: |
| 1166 |
bld.SAMBA_BINARY('test_mutex_raw', |
| 1167 |
source='tests/src/test_mutex_raw.c', |
| 1168 |
deps='pthread', |
| 1169 |
install_path='${CTDB_TEST_LIBEXECDIR}') |
| 1170 |
|
| 1171 |
test_subdirs = [ |
| 1172 |
'CLUSTER', |
| 1173 |
'INTEGRATION', |
| 1174 |
'UNIT', |
| 1175 |
'etc-ctdb' |
| 1176 |
] |
| 1177 |
|
| 1178 |
if bld.env.standalone_ctdb: |
| 1179 |
testdir = 'tests' |
| 1180 |
else: |
| 1181 |
testdir = 'ctdb/tests' |
| 1182 |
|
| 1183 |
for t in test_subdirs: |
| 1184 |
files = SUBDIR_MODE('%s/%s' % (testdir, t), trim_path=testdir) |
| 1185 |
for fmode in files: |
| 1186 |
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0], |
| 1187 |
destname=fmode[0], chmod=fmode[1]) |
| 1188 |
|
| 1189 |
# Install tests/scripts directory, excluding files that need munging |
| 1190 |
test_scripts = [ |
| 1191 |
'cluster.bash', |
| 1192 |
'common.sh', |
| 1193 |
'integration.bash', |
| 1194 |
'integration_local_daemons.bash', |
| 1195 |
'integration_real_cluster.bash', |
| 1196 |
'unit.sh' |
| 1197 |
] |
| 1198 |
|
| 1199 |
for t in test_scripts: |
| 1200 |
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, |
| 1201 |
os.path.join('tests/scripts', t), |
| 1202 |
destname=os.path.join('scripts', t)) |
| 1203 |
|
| 1204 |
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, |
| 1205 |
'tests/scripts/test_wrap', |
| 1206 |
destname='scripts/test_wrap', |
| 1207 |
chmod=MODE_755) |
| 1208 |
|
| 1209 |
bld.SAMBA_GENERATOR('ctdb-test-script-install-paths', |
| 1210 |
source='tests/scripts/script_install_paths.sh', |
| 1211 |
target='script_install_paths.sh', |
| 1212 |
rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline)) |
| 1213 |
bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", |
| 1214 |
'script_install_paths.sh', |
| 1215 |
destname='script_install_paths.sh', chmod=MODE_644) |
| 1216 |
|
| 1217 |
sed_expr1 = 's@^\\(%s\\)=.*@\\1=%s@' % ( |
| 1218 |
'CTDB_TEST_DIR', bld.env.CTDB_TEST_DATADIR) |
| 1219 |
sed_expr2 = 's@^\\(CTDB_TESTS_ARE_INSTALLED\\)=false@\\\\1=true@' |
| 1220 |
bld.SAMBA_GENERATOR('ctdb-test-runner', |
| 1221 |
source='tests/run_tests.sh', |
| 1222 |
target='ctdb_run_tests.sh', |
| 1223 |
rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % ( |
| 1224 |
sed_expr1, sed_expr2)) |
| 1225 |
bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh', |
| 1226 |
destname='ctdb_run_tests', chmod=MODE_755) |
| 1227 |
bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'), |
| 1228 |
'ctdb_run_tests') |
| 1229 |
|
| 1230 |
bld.SAMBA_GENERATOR('ctdb-local-daemons', |
| 1231 |
source='tests/local_daemons.sh', |
| 1232 |
target='ctdb_local_daemons.sh', |
| 1233 |
rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % ( |
| 1234 |
sed_expr1, sed_expr2)) |
| 1235 |
bld.INSTALL_FILES('${BINDIR}', 'ctdb_local_daemons.sh', |
| 1236 |
destname='ctdb_local_daemons', chmod=MODE_755) |
| 1237 |
|
| 1238 |
|
| 1239 |
def testonly(ctx): |
| 1240 |
cmd = 'tests/run_tests.sh' |
| 1241 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1242 |
if ret != 0: |
| 1243 |
print('tests exited with exit status %d' % ret) |
| 1244 |
sys.exit(ret) |
| 1245 |
|
| 1246 |
|
| 1247 |
def test(ctx): |
| 1248 |
Options.commands.append('build') |
| 1249 |
Options.commands.append('testonly') |
| 1250 |
|
| 1251 |
|
| 1252 |
def autotest(ctx): |
| 1253 |
env = samba_utils.LOAD_ENVIRONMENT() |
| 1254 |
cmd = 'tests/run_tests.sh -eL -S %s' % env.SOCKET_WRAPPER_SO_PATH |
| 1255 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1256 |
if ret != 0: |
| 1257 |
print('autotest exited with exit status %d' % ret) |
| 1258 |
sys.exit(ret) |
| 1259 |
|
| 1260 |
|
| 1261 |
def show_version(ctx): |
| 1262 |
print(get_version_string()) |
| 1263 |
|
| 1264 |
|
| 1265 |
def manpages(ctx): |
| 1266 |
BASE_URL = 'http://docbook.sourceforge.net/release/xsl/current' |
| 1267 |
MAN_XSL = '%s/manpages/docbook.xsl' % BASE_URL |
| 1268 |
HTML_XSL = '%s/html/docbook.xsl' % BASE_URL |
| 1269 |
CMD_TEMPLATE = 'xsltproc --xinclude -o %s --nonet %s %s' |
| 1270 |
manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph |
| 1271 |
for t in manpages: |
| 1272 |
cmd = CMD_TEMPLATE % ('doc/%s' % t, MAN_XSL, 'doc/%s.xml' % t) |
| 1273 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1274 |
if ret != 0: |
| 1275 |
print('Command %s failed with exit status %d' % (cmd, ret)) |
| 1276 |
sys.exit(ret) |
| 1277 |
|
| 1278 |
cmd = CMD_TEMPLATE % ('doc/%s.html' % t, HTML_XSL, 'doc/%s.xml' % t) |
| 1279 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1280 |
if ret != 0: |
| 1281 |
print('Command %s failed with exit status %d' % (cmd, ret)) |
| 1282 |
sys.exit(ret) |
| 1283 |
|
| 1284 |
|
| 1285 |
def distonly(ctx): |
| 1286 |
samba_dist.DIST_FILES('VERSION:VERSION', extend=True) |
| 1287 |
|
| 1288 |
t = 'ctdb.spec' |
| 1289 |
sed_expr1 = 's/@VERSION@/%s/g' % get_version_string() |
| 1290 |
sed_expr2 = 's/@RELEASE@/%s/g' % '1' |
| 1291 |
cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % ( |
| 1292 |
sed_expr1, sed_expr2, t) |
| 1293 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1294 |
if ret != 0: |
| 1295 |
print('Command "%s" failed with exit status %d' % (cmd, ret)) |
| 1296 |
sys.exit(ret) |
| 1297 |
samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True) |
| 1298 |
|
| 1299 |
manpages = manpages_binary + manpages_misc + manpages_etcd + manpages_ceph |
| 1300 |
for t in manpages: |
| 1301 |
samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True) |
| 1302 |
samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t), |
| 1303 |
extend=True) |
| 1304 |
|
| 1305 |
samba_dist.dist() |
| 1306 |
|
| 1307 |
|
| 1308 |
def dist(): |
| 1309 |
Options.commands.append('manpages') |
| 1310 |
Options.commands.append('distonly') |
| 1311 |
|
| 1312 |
|
| 1313 |
def rpmonly(ctx): |
| 1314 |
opts = os.getenv('RPM_OPTIONS') or '' |
| 1315 |
cmd = 'rpmbuild -ta --clean --rmsource %s ctdb-%s.tar.gz' % \ |
| 1316 |
(opts, get_version_string()) |
| 1317 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1318 |
if ret != 0: |
| 1319 |
print('rpmbuild exited with exit status %d' % ret) |
| 1320 |
sys.exit(ret) |
| 1321 |
|
| 1322 |
|
| 1323 |
def rpm(ctx): |
| 1324 |
Options.commands.append('manpages') |
| 1325 |
Options.commands.append('distonly') |
| 1326 |
Options.commands.append('rpmonly') |
| 1327 |
|
| 1328 |
|
| 1329 |
def ctags(ctx): |
| 1330 |
"build 'tags' file using ctags" |
| 1331 |
source_root = os.path.dirname(Context.g_module.root_path) |
| 1332 |
cmd = 'ctags $(find %s -name "*.[ch]")' % source_root |
| 1333 |
print("Running: %s" % cmd) |
| 1334 |
ret = samba_utils.RUN_COMMAND(cmd) |
| 1335 |
if ret != 0: |
| 1336 |
print('ctags failed with exit status %d' % ret) |
| 1337 |
sys.exit(ret) |