s3:smbd: allocate out_context_blobs with talloc
[Samba.git] / ctdb / wscript
blobf346f97e575b88553c30a4a9c99a817644f7a559
1 #!/usr/bin/env python
3 APPNAME = 'ctdb'
5 blddir = 'bin'
7 import sys, os
9 # find the buildtools directory
10 srcdir = '.'
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'):
20 vdir = '.'
21 elif os.path.isfile('../VERSION'):
22 vdir = '..'
23 else:
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 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 buildtools:buildtools''')
40 def set_options(opt):
41 opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
43 opt.RECURSE('lib/replace')
45 opt.RECURSE('lib/util')
47 opt.RECURSE('lib/talloc')
48 opt.RECURSE('lib/tevent')
49 opt.RECURSE('lib/tdb')
51 opt.add_option('--enable-infiniband',
52 help=("Turn on infiniband support (default=no)"),
53 action="store_true", dest='ctdb_infiniband', default=False)
54 opt.add_option('--enable-pmda',
55 help=("Turn on PCP pmda support (default=no)"),
56 action="store_true", dest='ctdb_pmda', default=False)
58 opt.add_option('--with-logdir',
59 help=("Path to log directory"),
60 action="store", dest='ctdb_logdir', default=None)
61 opt.add_option('--with-socketpath',
62 help=("path to CTDB daemon socket"),
63 action="store_true", dest='ctdb_sockpath', default=False)
66 def configure(conf):
68 # CTDB relies on nested event loops
69 conf.env.TEVENT_DEPRECATED = 1
71 # No need to build python bindings for talloc/tevent/tdb
72 if conf.IN_LAUNCH_DIR():
73 conf.env.standalone_ctdb = True
74 Options.options.disable_python = True
76 conf.RECURSE('lib/replace')
78 if conf.env.standalone_ctdb:
79 conf.SAMBA_CHECK_PERL(mandatory=True)
81 conf.SAMBA_CHECK_PYTHON(mandatory=True, version=(2,5,0))
82 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
84 if conf.CHECK_FOR_THIRD_PARTY():
85 conf.RECURSE('third_party/popt')
86 else:
87 if not conf.CHECK_POPT():
88 raise Utils.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
89 else:
90 conf.define('USING_SYSTEM_POPT', 1)
92 conf.RECURSE('lib/util')
94 conf.RECURSE('lib/talloc')
95 conf.RECURSE('lib/tevent')
96 conf.RECURSE('lib/tdb')
97 conf.RECURSE('lib/socket_wrapper')
99 conf.CHECK_HEADERS('sched.h')
100 conf.CHECK_HEADERS('procinfo.h')
101 if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'):
102 Logs.error('Need thread_setsched() on AIX')
103 sys.exit(1)
104 elif not conf.CHECK_FUNCS('sched_setscheduler'):
105 Logs.error('Need sched_setscheduler()')
106 sys.exit(1)
107 conf.CHECK_FUNCS('mlockall')
109 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
110 conf.DEFINE('ETIME', 'ETIMEDOUT')
112 if sys.platform.startswith('linux'):
113 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
114 else:
115 if not conf.CHECK_HEADERS('pcap.h'):
116 Logs.error('Need libpcap')
117 sys.exit(1)
118 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
119 Logs.error('Need libpcap')
120 sys.exit(1)
122 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
123 checklibc=True, headers='execinfo.h'):
124 Logs.error('backtrace support not available')
126 have_pmda = False
127 if Options.options.ctdb_pmda:
128 pmda_support = True
130 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
131 together=True):
132 pmda_support = False
133 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
134 pmda_support = False
135 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
136 pmda_support = False
137 if pmda_support:
138 have_pmda = True
139 else:
140 Logs.error("PMDA support not available")
141 if have_pmda:
142 Logs.info('Building with PMDA support')
143 conf.define('HAVE_PMDA', 1)
144 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
145 'lib/pcp/pmdas/ctdb')
147 have_infiniband = False
148 if Options.options.ctdb_infiniband:
149 ib_support = True
151 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
152 ib_support = False
153 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
154 ib_support = False
155 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
156 ib_support = False
157 if ib_support:
158 have_infiniband = True
159 else:
160 Logs.error("Infiniband support not available")
161 if have_infiniband:
162 Logs.info('Building with Infiniband support')
163 conf.define('HAVE_INFINIBAND', 1)
164 conf.define('USE_INFINIBAND', 1)
166 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
167 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
168 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
169 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
171 if Options.options.ctdb_logdir:
172 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
173 else:
174 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
176 if Options.options.ctdb_sockpath:
177 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
178 else:
179 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
180 'ctdbd.socket')
182 conf.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%s\"
183 -DLOGDIR=\"%s\"
184 -DSOCKPATH=\"%s\"
185 -DCTDB_ETCDIR=\"%s\"
186 -DCTDB_VARDIR=\"%s\"
187 -DCTDB_RUNDIR=\"%s\"''' % (
188 conf.env.CTDB_BINDIR,
189 conf.env.CTDB_LOGDIR,
190 conf.env.CTDB_SOCKPATH,
191 conf.env.CTDB_ETCDIR,
192 conf.env.CTDB_VARDIR,
193 conf.env.CTDB_RUNDIR))
195 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
196 'share/ctdb-tests')
197 conf.env.CTDB_TEST_LIBDIR = os.path.join(conf.env.LIBDIR, 'ctdb-tests')
199 # Allow unified compilation and separate compilation of utilities
200 # to find includes
201 if not conf.env.standalone_ctdb:
202 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
203 else:
204 if srcdir == '.':
205 # Building from tarball
206 conf.ADD_EXTRA_INCLUDES('#include')
207 conf.ADD_EXTRA_INCLUDES('#include/internal')
208 else:
209 # Building standalone CTDB from within Samba tree
210 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
211 conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal')
212 conf.ADD_EXTRA_INCLUDES('#ctdb')
213 conf.ADD_EXTRA_INCLUDES('#lib #lib/replace')
215 conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
217 del(conf.env.defines['PYTHONDIR'])
218 del(conf.env.defines['PYTHONARCHDIR'])
220 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
221 conf.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags=True)
222 conf.SAMBA_CONFIG_H()
225 def build(bld):
226 if bld.env.standalone_ctdb:
227 # enable building of public headers in the build tree
228 bld.env.build_public_headers = 'include/public'
230 if bld.env.standalone_ctdb:
231 ctdb_mkversion = '../packaging/mkversion.sh'
232 else:
233 ctdb_mkversion = '../ctdb/packaging/mkversion.sh'
234 t = bld.SAMBA_GENERATOR('ctdb-version-header',
235 target='include/ctdb_version.h',
236 rule='%s ${TGT} %s' % (ctdb_mkversion, VERSION),
237 dep_vars=['VERSION'])
238 t.env.VERSION = VERSION
240 if bld.env.standalone_ctdb:
241 version_h = samba_utils.os_path_relpath(os.path.join(Options.launch_dir,
242 "version.h"),
243 bld.curdir)
244 t.bld.SAMBA_GENERATOR('ctdb-samba-version-header',
245 target=version_h,
246 rule='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}',
247 dep_vars=['VERSION'])
248 t.env.VERSION = VERSION
250 bld.RECURSE('lib/replace')
251 if bld.CHECK_FOR_THIRD_PARTY():
252 bld.RECURSE('third_party/popt')
254 bld.RECURSE('lib/tdb_wrap')
255 bld.RECURSE('lib/util')
257 bld.RECURSE('lib/talloc')
258 bld.RECURSE('lib/tevent')
259 bld.RECURSE('lib/tdb')
260 bld.RECURSE('lib/socket_wrapper')
262 if bld.env.standalone_ctdb:
263 # In a combined build is implemented, CTDB will wanted to
264 # build against samba-util rather than samba-util-core.
265 # Similarly, other Samba subsystems expect samba-util. So,
266 # for a standalone build, just define a fake samba-util
267 # subsystem that pulls in samba-util-core.
268 bld.SAMBA_SUBSYSTEM('samba-util',
269 source='',
270 deps='samba-util-core')
272 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
273 source=bld.SUBDIR('tcp',
274 'tcp_connect.c tcp_init.c tcp_io.c'),
275 includes='include include/internal',
276 deps='replace tdb talloc tevent')
278 ib_deps = ''
279 if bld.env.HAVE_INFINIBAND:
280 bld.SAMBA_SUBSYSTEM('ctdb-ib',
281 source=bld.SUBDIR('ib',
282 '''ibwrapper.c ibw_ctdb.c
283 ibw_ctdb_init.c'''),
284 includes='include include/internal',
285 deps='replace')
286 ib_deps = ' ctdb-ib rdmacm ibverbs'
288 bld.SAMBA_SUBSYSTEM('ctdb-common',
289 source=bld.SUBDIR('common',
290 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
291 ctdb_message.c cmdline.c rb_tree.c
292 system_common.c ctdb_fork.c'''),
293 includes='include include/internal common .',
294 deps='replace popt talloc tevent tdb popt')
296 bld.SAMBA_SUBSYSTEM('ctdb-common-util',
297 source=bld.SUBDIR('common',
298 'system_util.c ctdb_logging.c'),
299 includes='include include/internal',
300 deps='replace tevent tdb')
302 if sys.platform.startswith('linux'):
303 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_linux.c')
304 elif sys.platform.startswith('aix'):
305 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_aix.c')
306 elif sys.platform.startswith('freebsd'):
307 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_freebsd.c')
308 elif sys.platform == 'kfreebsd':
309 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_kfreebsd.c')
310 elif sys.platform == 'gnu':
311 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_gnu.c')
312 else:
313 Logs.error("Platform %s not supported" % sys.platform)
315 bld.SAMBA_SUBSYSTEM('ctdb-system',
316 source=CTDB_SYSTEM_SRC,
317 includes='include include/internal',
318 deps='replace talloc tevent tdb pcap')
320 bld.SAMBA_SUBSYSTEM('ctdb-client',
321 source=bld.SUBDIR('client', 'ctdb_client.c'),
322 includes='include include/internal',
323 public_headers='include/ctdb_client.h',
324 deps='''replace popt talloc tevent tdb
325 samba-util tdb-wrap''')
327 bld.SAMBA_SUBSYSTEM('ctdb-server',
328 source='server/ctdbd.c ' +
329 bld.SUBDIR('server',
330 '''ctdb_daemon.c ctdb_recoverd.c
331 ctdb_recover.c ctdb_freeze.c
332 ctdb_tunables.c ctdb_monitor.c
333 ctdb_server.c ctdb_control.c
334 ctdb_call.c ctdb_ltdb_server.c
335 ctdb_traverse.c eventscript.c
336 ctdb_takeover.c ctdb_serverids.c
337 ctdb_persistent.c ctdb_keepalive.c
338 ctdb_logging.c
339 ctdb_logging_syslog.c
340 ctdb_logging_file.c
341 ctdb_uptime.c
342 ctdb_vacuum.c ctdb_banning.c
343 ctdb_statistics.c
344 ctdb_update_record.c
345 ctdb_lock.c'''),
346 includes='include include/internal',
347 public_headers='''include/ctdb_version.h
348 include/ctdb.h
349 include/ctdb_private.h
350 include/ctdb_protocol.h
351 include/ctdb_typesafe_cb.h''',
352 deps='replace popt talloc tevent tdb')
354 bld.SAMBA_BINARY('ctdbd',
355 source='',
356 deps='''ctdb-server ctdb-client ctdb-common
357 ctdb-common-util ctdb-system ctdb-tcp''' +
358 ib_deps,
359 install_path='${SBINDIR}',
360 manpages='doc/ctdbd.1')
362 bld.SAMBA_BINARY('ctdb',
363 source='tools/ctdb.c tools/ctdb_vacuum.c',
364 deps='''ctdb-client ctdb-common ctdb-common-util
365 ctdb-system''',
366 includes='include include/internal',
367 install_path='${BINDIR}',
368 manpages='doc/ctdb.1')
370 bld.SAMBA_BINARY('ltdbtool',
371 source='tools/ltdbtool.c',
372 includes='include',
373 deps='tdb',
374 install_path='${BINDIR}',
375 manpages='doc/ltdbtool.1')
377 bld.SAMBA_BINARY('ctdb_lock_helper',
378 source='server/ctdb_lock_helper.c',
379 deps='samba-util ctdb-common-util talloc tdb',
380 includes='include include/internal',
381 install_path='${BINDIR}')
383 bld.SAMBA_BINARY('ctdb_event_helper',
384 source='server/ctdb_event_helper.c',
385 includes='include include/internal',
386 deps='samba-util ctdb-common-util replace tdb',
387 install_path='${BINDIR}')
389 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
390 source='utils/smnotify/smnotify.x',
391 target='utils/smnotify/smnotify.h',
392 rule='rpcgen -h ${SRC} > ${TGT}')
394 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
396 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
397 source='utils/smnotify/smnotify.x',
398 target='utils/smnotify/gen_xdr.c',
399 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
401 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
402 source='utils/smnotify/smnotify.x',
403 target='utils/smnotify/gen_smnotify.c',
404 rule='rpcgen -l ${SRC} > ${TGT}')
406 bld.SAMBA_BINARY('smnotify',
407 source=bld.SUBDIR('utils/smnotify',
408 'smnotify.c gen_smnotify.c gen_xdr.c'),
409 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
410 includes='utils utils/smnotify',
411 install_path='${BINDIR}')
413 bld.SAMBA_BINARY('ping_pong',
414 source='utils/ping_pong/ping_pong.c',
415 deps='',
416 install_path='${BINDIR}',
417 manpages='doc/ping_pong.1')
419 if bld.env.HAVE_PMDA:
420 bld.SAMBA_BINARY('pmdactdb',
421 source='utils/pmda/pmda_ctdb.c',
422 includes='include include/internal',
423 deps='''ctdb-client ctdb-common ctdb-system
424 pcp_pmda pcp''',
425 install_path='${CTDB_PMDADIR}')
426 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
427 destname='Install')
428 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
429 destname='Remove')
430 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
431 destname='pmns')
432 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
433 destname='domain.h')
434 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
435 destname='help')
436 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
437 destname='README')
439 bld.MANPAGES('''doc/onnode.1 doc/ctdbd_wrapper.1 doc/ctdbd.conf.5
440 doc/ctdb.7 doc/ctdb-statistics.7 doc/ctdb-tunables.7''',
441 True)
443 bld.INSTALL_FILES('${BINDIR}', 'tools/onnode',
444 destname='onnode', chmod=0755)
445 bld.INSTALL_FILES('${BINDIR}', 'tools/ctdb_diagnostics',
446 destname='ctdb_diagnostics', chmod=0755)
447 bld.INSTALL_FILES('${SBINDIR}', 'config/ctdbd_wrapper',
448 destname='ctdbd_wrapper', chmod=0755)
450 def SUBDIR_MODE_callback(arg, dirname, fnames):
451 for f in fnames:
452 fl = os.path.join(dirname, f)
453 if os.path.isdir(fl) or os.path.islink(fl):
454 continue
455 mode = os.lstat(fl).st_mode & 0777
456 if arg['trim_path']:
457 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
458 arg['file_list'].append([fl, mode])
460 def SUBDIR_MODE(path, trim_path=None):
461 pd = {'trim_path': trim_path, 'file_list': []}
462 os.path.walk(path, SUBDIR_MODE_callback, pd)
463 return pd['file_list']
465 etc_subdirs = [
466 'events.d',
467 'nfs-rpc-checks.d'
470 for t in etc_subdirs:
471 files = SUBDIR_MODE('config/%s' % t, trim_path='config')
472 for fmode in files:
473 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
474 destname=fmode[0], chmod=fmode[1])
476 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
477 destname='functions')
479 etc_scripts = [
480 'ctdb-crash-cleanup.sh',
481 'debug-hung-script.sh',
482 'debug_locks.sh',
483 'gcore_trace.sh',
484 'notify.sh',
485 'statd-callout'
488 for t in etc_scripts:
489 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/' + t,
490 destname=t, chmod=0755)
492 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
493 destname='ctdb')
495 bld.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
496 destname='README')
498 bld.install_dir(bld.env.CTDB_LOGDIR)
499 bld.install_dir(bld.env.CTDB_RUNDIR)
500 bld.install_dir(bld.env.CTDB_VARDIR)
502 sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
503 t = bld.SAMBA_GENERATOR('ctdb-pc',
504 source='ctdb.pc.in',
505 target='ctdb.pc',
506 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr,
507 dep_vars=['VERSION'])
508 t.env.VERSION = VERSION
509 bld.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
511 # Test binaries
512 ctdb_tests = [
513 'rb_test',
514 'ctdb_bench',
515 'ctdb_fetch',
516 'ctdb_fetch_one',
517 'ctdb_fetch_readonly_once',
518 'ctdb_fetch_readonly_loop',
519 'ctdb_trackingdb_test',
520 'ctdb_update_record',
521 'ctdb_update_record_persistent',
522 'ctdb_store',
523 'ctdb_traverse',
524 'ctdb_randrec',
525 'ctdb_persistent',
526 'ctdb_porting_tests',
527 'ctdb_transaction',
528 'ctdb_lock_tdb'
531 for target in ctdb_tests:
532 src = 'tests/src/' + target + '.c'
534 bld.SAMBA_BINARY(target,
535 source=src,
536 includes='include include/internal',
537 deps='''ctdb-client ctdb-common ctdb-common-util
538 ctdb-system''',
539 install_path='${CTDB_TEST_LIBDIR}')
541 bld.SAMBA_BINARY('ctdb_takeover_tests',
542 source='tests/src/ctdb_takeover_tests.c',
543 deps='''replace popt tdb tevent talloc ctdb-system
544 samba-util tdb-wrap''' +
545 ib_deps,
546 includes='include include/internal',
547 install_path='${CTDB_TEST_LIBDIR}')
549 bld.SAMBA_BINARY('ctdb_functest',
550 source='tests/src/ctdb_functest.c',
551 deps='''replace tdb tevent talloc popt ctdb-system
552 samba-util tdb-wrap''',
553 includes='include include/internal',
554 install_path='${CTDB_TEST_LIBDIR}')
556 bld.SAMBA_BINARY('ctdb_stubtest',
557 source='tests/src/ctdb_test.c',
558 deps='''replace tdb tevent talloc popt ctdb-system
559 samba-util tdb-wrap''',
560 includes='include include/internal',
561 install_path='${CTDB_TEST_LIBDIR}')
563 if bld.env.HAVE_INFINIBAND:
564 bld.SAMBA_BINARY('ibwrapper_test',
565 source='ib/ibwrapper_test.c',
566 includes='include include/internal',
567 deps='''replace talloc ctdb-client ctdb-common
568 ctdb-system''' +
569 ib_deps,
570 install_path='${CTDB_TEST_LIBDIR}')
572 test_subdirs = [
573 'complex',
574 'events.d',
575 'eventscripts',
576 'onnode',
577 'simple',
578 'takeover',
579 'tool'
582 for t in test_subdirs:
583 files = SUBDIR_MODE('tests/%s' % t, trim_path='tests')
584 for fmode in files:
585 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
586 destname=fmode[0], chmod=fmode[1])
588 # Install tests/scripts directory without test_wrap
589 test_scripts = [
590 'common.sh',
591 'integration.bash',
592 'unit.sh'
595 for t in test_scripts:
596 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
597 os.path.join('tests/scripts', t),
598 destname=os.path.join('scripts', t))
600 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
601 bld.env.CTDB_TEST_LIBDIR)
602 bld.SAMBA_GENERATOR('ctdb-test-wrap',
603 source='tests/scripts/test_wrap',
604 target='test_wrap',
605 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
606 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
607 destname='test_wrap', chmod=0755)
609 sed_expr1 = 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
610 bld.env.CTDB_TEST_DATADIR, bld.env.CTDB_TEST_LIBDIR)
611 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
612 bld.SAMBA_GENERATOR('ctdb-test-runner',
613 source='tests/run_tests.sh',
614 target='ctdb_run_tests.sh',
615 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
616 sed_expr1, sed_expr2))
617 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
618 destname='ctdb_run_tests', chmod=0755)
619 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
620 'ctdb_run_tests')
622 test_eventscript_links = [
623 'events.d',
624 'functions',
625 'nfs-rpc-checks.d'
628 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
629 'eventscripts/etc-ctdb')
630 for t in test_eventscript_links:
631 bld.symlink_as(os.path.join(test_link_dir, t),
632 os.path.join(bld.env.CTDB_ETCDIR, t))
635 def testonly(ctx):
636 cmd = 'tests/run_tests.sh -V tests/var'
637 ret = samba_utils.RUN_COMMAND(cmd)
638 if ret != 0:
639 print('tests exited with exit status %d' % ret)
640 sys.exit(ret)
643 def test(ctx):
644 import Scripting
645 Scripting.commands.append('build')
646 Scripting.commands.append('testonly')
649 def autotest(ctx):
650 cmd = 'LD_PRELOAD=bin/shared/libsocket-wrapper.so tests/run_tests.sh -e -S -C'
651 ret = samba_utils.RUN_COMMAND(cmd)
652 if ret != 0:
653 print('autotest exited with exit status %d' % ret)
654 sys.exit(ret)
657 def show_version(ctx):
658 print VERSION
661 def dist():
662 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
664 t = 'include/ctdb_version.h'
665 cmd = 'packaging/mkversion.sh %s %s' % (t, VERSION)
666 ret = samba_utils.RUN_COMMAND(cmd)
667 if ret != 0:
668 print('Command "%s" failed with exit status %d' % (cmd, ret))
669 sys.exit(ret)
670 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
672 t = 'ctdb.spec'
673 sed_expr1 = 's/@VERSION@/%s/g' % VERSION
674 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
675 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
676 sed_expr1, sed_expr2, t)
677 ret = samba_utils.RUN_COMMAND(cmd)
678 if ret != 0:
679 print('Command "%s" failed with exit status %d' % (cmd, ret))
680 sys.exit(ret)
681 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
683 manpages = [
684 'ctdb.1',
685 'ctdb.7',
686 'ctdbd.1',
687 'ctdbd.conf.5',
688 'ctdbd_wrapper.1',
689 'ctdb-statistics.7',
690 'ctdb-tunables.7',
691 'ltdbtool.1'
694 cmd = 'make -C doc'
695 ret = samba_utils.RUN_COMMAND(cmd)
696 if ret != 0:
697 print('Command "%s" failed with exit status %d' % (cmd, ret))
698 sys.exit(ret)
699 for t in manpages:
700 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
701 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
702 extend=True)
704 samba_dist.dist()
707 def rpmonly(ctx):
708 cmd = 'rpmbuild -ta --clean --rmsource ctdb-%s.tar.gz' % VERSION
709 ret = samba_utils.RUN_COMMAND(cmd)
710 if ret != 0:
711 print('rpmbuild exited with exit status %d' % ret)
712 sys.exit(ret)
715 def rpm(ctx):
716 import Scripting
717 Scripting.commands.append('dist')
718 Scripting.commands.append('rpmonly')
721 def ctags(ctx):
722 "build 'tags' file using ctags"
723 import Utils
724 source_root = os.path.dirname(Utils.g_module.root_path)
725 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
726 print("Running: %s" % cmd)
727 ret = samba_utils.RUN_COMMAND(cmd)
728 if ret != 0:
729 print('ctags failed with exit status %d' % ret)
730 sys.exit(ret)