ctdb-build: Add generation of Samba-style version.h
[Samba.git] / ctdb / wscript
blob969c034c518008e592551c513fe797e7e280541b
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 buildtools:buildtools''')
38 def set_options(opt):
39 opt.PRIVATE_EXTENSION_DEFAULT('ctdb')
40 opt.RECURSE('lib/replace')
41 opt.RECURSE('lib/talloc')
42 opt.RECURSE('lib/tevent')
43 opt.RECURSE('lib/tdb')
45 opt.add_option('--enable-infiniband',
46 help=("Turn on infiniband support (default=no)"),
47 action="store_true", dest='ctdb_infiniband', default=False)
48 opt.add_option('--enable-pmda',
49 help=("Turn on PCP pmda support (default=no)"),
50 action="store_true", dest='ctdb_pmda', default=False)
52 opt.add_option('--with-logdir',
53 help=("Path to log directory"),
54 action="store", dest='ctdb_logdir', default=None)
55 opt.add_option('--with-socketpath',
56 help=("path to CTDB daemon socket"),
57 action="store_true", dest='ctdb_sockpath', default=False)
60 def configure(conf):
62 # CTDB relies on nested event loops
63 conf.env.TEVENT_DEPRECATED = 1
65 # No need to build python bindings for talloc/tevent/tdb
66 if conf.IN_LAUNCH_DIR():
67 Options.options.disable_python = True
69 conf.RECURSE('lib/replace')
70 if conf.CHECK_FOR_THIRD_PARTY():
71 conf.RECURSE('third_party/popt')
72 else:
73 if not conf.CHECK_POPT():
74 raise Utils.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
75 else:
76 conf.define('USING_SYSTEM_POPT', 1)
78 conf.RECURSE('lib/talloc')
79 conf.RECURSE('lib/tevent')
80 conf.RECURSE('lib/tdb')
81 conf.RECURSE('lib/socket_wrapper')
83 conf.CHECK_HEADERS('sched.h')
84 conf.CHECK_HEADERS('procinfo.h')
85 if sys.platform.startswith('aix') and not conf.CHECK_FUNCS('thread_setsched'):
86 Logs.error('Need thread_setsched() on AIX')
87 sys.exit(1)
88 elif not conf.CHECK_FUNCS('sched_setscheduler'):
89 Logs.error('Need sched_setscheduler()')
90 sys.exit(1)
91 conf.CHECK_FUNCS('mlockall')
93 if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
94 conf.DEFINE('ETIME', 'ETIMEDOUT')
96 if sys.platform.startswith('linux'):
97 conf.SET_TARGET_TYPE('pcap', 'EMPTY')
98 else:
99 if not conf.CHECK_HEADERS('pcap.h'):
100 Logs.error('Need libpcap')
101 sys.exit(1)
102 if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
103 Logs.error('Need libpcap')
104 sys.exit(1)
106 if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
107 checklibc=True, headers='execinfo.h'):
108 Logs.error('backtrace support not available')
110 have_pmda = False
111 if Options.options.ctdb_pmda:
112 pmda_support = True
114 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
115 together=True):
116 pmda_support = False
117 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
118 pmda_support = False
119 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
120 pmda_support = False
121 if pmda_support:
122 have_pmda = True
123 else:
124 Logs.error("PMDA support not available")
125 if have_pmda:
126 Logs.info('Building with PMDA support')
127 conf.define('HAVE_PMDA', 1)
128 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
129 'lib/pcp/pmdas/ctdb')
131 have_infiniband = False
132 if Options.options.ctdb_infiniband:
133 ib_support = True
135 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
136 ib_support = False
137 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
138 ib_support = False
139 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
140 ib_support = False
141 if ib_support:
142 have_infiniband = True
143 else:
144 Logs.error("Infiniband support not available")
145 if have_infiniband:
146 Logs.info('Building with Infiniband support')
147 conf.define('HAVE_INFINIBAND', 1)
148 conf.define('USE_INFINIBAND', 1)
150 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
151 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
152 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
153 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
155 if Options.options.ctdb_logdir:
156 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
157 else:
158 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
160 if Options.options.ctdb_sockpath:
161 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
162 else:
163 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
164 'ctdbd.socket')
166 conf.ADD_CFLAGS('''-DBINDIR=\"%s\"
167 -DLOGDIR=\"%s\"
168 -DSOCKPATH=\"%s\"
169 -DCTDB_ETCDIR=\"%s\"
170 -DCTDB_VARDIR=\"%s\"
171 -DCTDB_RUNDIR=\"%s\"''' % (
172 conf.env.CTDB_BINDIR,
173 conf.env.CTDB_LOGDIR,
174 conf.env.CTDB_SOCKPATH,
175 conf.env.CTDB_ETCDIR,
176 conf.env.CTDB_VARDIR,
177 conf.env.CTDB_RUNDIR))
179 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
180 'share/ctdb-tests')
181 conf.env.CTDB_TEST_LIBDIR = os.path.join(conf.env.LIBDIR, 'ctdb-tests')
183 # Allow separate compilation of utilities to find includes
184 if srcdir == '.':
185 # Building from tarball
186 conf.ADD_EXTRA_INCLUDES('#include')
187 conf.ADD_EXTRA_INCLUDES('#include/internal')
188 else:
189 # Building standalone CTDB from within Samba tree
190 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
191 conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal')
192 conf.ADD_EXTRA_INCLUDES('#ctdb')
194 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
195 conf.SAMBA_CONFIG_H()
198 def build(bld):
199 t = bld.SAMBA_GENERATOR('ctdb-version-header',
200 target='include/ctdb_version.h',
201 rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION),
202 dep_vars=['VERSION'])
203 t.env.VERSION = VERSION
205 version_h = samba_utils.os_path_relpath(os.path.join(Options.launch_dir,
206 "version.h"),
207 bld.curdir)
208 t.bld.SAMBA_GENERATOR('ctdb-samba-version-header',
209 target=version_h,
210 rule='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}',
211 dep_vars=['VERSION'])
212 t.env.VERSION = VERSION
214 bld.RECURSE('lib/replace')
215 if bld.CHECK_FOR_THIRD_PARTY():
216 bld.RECURSE('third_party/popt')
218 bld.RECURSE('lib/tdb_wrap')
219 bld.RECURSE('lib/util')
221 bld.RECURSE('lib/talloc')
222 bld.RECURSE('lib/tevent')
223 bld.RECURSE('lib/tdb')
224 bld.RECURSE('lib/socket_wrapper')
226 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
227 source=bld.SUBDIR('tcp',
228 'tcp_connect.c tcp_init.c tcp_io.c'),
229 includes='include include/internal',
230 deps='replace tdb talloc tevent')
232 ib_deps = ''
233 if bld.env.HAVE_INFINIBAND:
234 bld.SAMBA_SUBSYSTEM('ctdb-ib',
235 source=bld.SUBDIR('ib',
236 '''ibwrapper.c ibw_ctdb.c
237 ibw_ctdb_init.c'''),
238 includes='include include/internal',
239 deps='replace')
240 ib_deps = ' ctdb-ib rdmacm ibverbs'
242 bld.SAMBA_SUBSYSTEM('ctdb-common',
243 source=bld.SUBDIR('common',
244 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
245 ctdb_message.c cmdline.c rb_tree.c
246 system_common.c ctdb_fork.c'''),
247 includes='include include/internal common .',
248 deps='replace popt talloc tevent tdb popt')
250 bld.SAMBA_SUBSYSTEM('ctdb-common-util',
251 source=bld.SUBDIR('common',
252 'system_util.c ctdb_logging.c'),
253 includes='include include/internal',
254 deps='replace tevent tdb')
256 if sys.platform.startswith('linux'):
257 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_linux.c')
258 elif sys.platform.startswith('aix'):
259 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_aix.c')
260 elif sys.platform.startswith('freebsd'):
261 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_freebsd.c')
262 elif sys.platform == 'kfreebsd':
263 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_kfreebsd.c')
264 elif sys.platform == 'gnu':
265 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_gnu.c')
266 else:
267 Logs.error("Platform %s not supported" % sys.platform)
269 bld.SAMBA_SUBSYSTEM('ctdb-system',
270 source=CTDB_SYSTEM_SRC,
271 includes='include include/internal',
272 deps='replace talloc tevent tdb pcap')
274 bld.SAMBA_SUBSYSTEM('ctdb-client',
275 source=bld.SUBDIR('client', 'ctdb_client.c'),
276 includes='include include/internal',
277 public_headers='include/ctdb_client.h',
278 deps='''replace popt talloc tevent tdb
279 ctdb-util tdb-wrap''')
281 bld.SAMBA_SUBSYSTEM('ctdb-server',
282 source='server/ctdbd.c ' +
283 bld.SUBDIR('server',
284 '''ctdb_daemon.c ctdb_recoverd.c
285 ctdb_recover.c ctdb_freeze.c
286 ctdb_tunables.c ctdb_monitor.c
287 ctdb_server.c ctdb_control.c
288 ctdb_call.c ctdb_ltdb_server.c
289 ctdb_traverse.c eventscript.c
290 ctdb_takeover.c ctdb_serverids.c
291 ctdb_persistent.c ctdb_keepalive.c
292 ctdb_logging.c ctdb_uptime.c
293 ctdb_vacuum.c ctdb_banning.c
294 ctdb_statistics.c
295 ctdb_update_record.c
296 ctdb_lock.c'''),
297 includes='include include/internal',
298 public_headers='''include/ctdb.h
299 include/ctdb_private.h
300 include/ctdb_protocol.h
301 include/ctdb_typesafe_cb.h''',
302 deps='replace popt talloc tevent tdb')
304 bld.SAMBA_BINARY('ctdbd',
305 source='',
306 deps='''ctdb-server ctdb-client ctdb-common
307 ctdb-common-util ctdb-system ctdb-tcp''' +
308 ib_deps,
309 install_path='${SBINDIR}',
310 manpages='doc/ctdbd.1')
312 bld.SAMBA_BINARY('ctdb',
313 source='tools/ctdb.c tools/ctdb_vacuum.c',
314 deps='''ctdb-client ctdb-common ctdb-common-util
315 ctdb-system''',
316 includes='include include/internal',
317 install_path='${BINDIR}',
318 manpages='doc/ctdb.1')
320 bld.SAMBA_BINARY('ltdbtool',
321 source='tools/ltdbtool.c',
322 includes='include',
323 deps='tdb',
324 install_path='${BINDIR}',
325 manpages='doc/ltdbtool.1')
327 bld.SAMBA_BINARY('ctdb_lock_helper',
328 source='server/ctdb_lock_helper.c',
329 deps='ctdb-util ctdb-common-util talloc tdb',
330 includes='include include/internal',
331 install_path='${BINDIR}')
333 bld.SAMBA_BINARY('ctdb_event_helper',
334 source='server/ctdb_event_helper.c',
335 includes='include include/internal',
336 deps='ctdb-util ctdb-common-util replace tdb',
337 install_path='${BINDIR}')
339 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
340 source='utils/smnotify/smnotify.x',
341 target='utils/smnotify/smnotify.h',
342 rule='rpcgen -h ${SRC} > ${TGT}')
344 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
346 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
347 source='utils/smnotify/smnotify.x',
348 target='utils/smnotify/gen_xdr.c',
349 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
351 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
352 source='utils/smnotify/smnotify.x',
353 target='utils/smnotify/gen_smnotify.c',
354 rule='rpcgen -l ${SRC} > ${TGT}')
356 bld.SAMBA_BINARY('smnotify',
357 source=bld.SUBDIR('utils/smnotify',
358 'smnotify.c gen_smnotify.c gen_xdr.c'),
359 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
360 includes='utils utils/smnotify',
361 install_path='${BINDIR}')
363 bld.SAMBA_BINARY('ping_pong',
364 source='utils/ping_pong/ping_pong.c',
365 deps='',
366 install_path='${BINDIR}',
367 manpages='doc/ping_pong.1')
369 if bld.env.HAVE_PMDA:
370 bld.SAMBA_BINARY('pmdactdb',
371 source='utils/pmda/pmda_ctdb.c',
372 includes='include include/internal',
373 deps='''ctdb-client ctdb-common ctdb-system
374 pcp_pmda pcp''',
375 install_path='${CTDB_PMDADIR}')
376 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
377 destname='Install')
378 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
379 destname='Remove')
380 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
381 destname='pmns')
382 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
383 destname='domain.h')
384 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
385 destname='help')
386 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
387 destname='README')
389 bld.MANPAGES('''doc/onnode.1 doc/ctdbd_wrapper.1 doc/ctdbd.conf.5
390 doc/ctdb.7 doc/ctdb-statistics.7 doc/ctdb-tunables.7''',
391 True)
393 bld.INSTALL_FILES('${BINDIR}', 'tools/onnode',
394 destname='onnode', chmod=0755)
395 bld.INSTALL_FILES('${BINDIR}', 'tools/ctdb_diagnostics',
396 destname='ctdb_diagnostics', chmod=0755)
397 bld.INSTALL_FILES('${SBINDIR}', 'config/ctdbd_wrapper',
398 destname='ctdbd_wrapper', chmod=0755)
400 def SUBDIR_MODE_callback(arg, dirname, fnames):
401 for f in fnames:
402 fl = os.path.join(dirname, f)
403 if os.path.isdir(fl) or os.path.islink(fl):
404 continue
405 mode = os.lstat(fl).st_mode & 0777
406 if arg['trim_path']:
407 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
408 arg['file_list'].append([fl, mode])
410 def SUBDIR_MODE(path, trim_path=None):
411 pd = {'trim_path': trim_path, 'file_list': []}
412 os.path.walk(path, SUBDIR_MODE_callback, pd)
413 return pd['file_list']
415 etc_subdirs = [
416 'events.d',
417 'nfs-rpc-checks.d'
420 for t in etc_subdirs:
421 files = SUBDIR_MODE('config/%s' % t, trim_path='config')
422 for fmode in files:
423 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
424 destname=fmode[0], chmod=fmode[1])
426 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
427 destname='functions')
429 etc_scripts = [
430 'ctdb-crash-cleanup.sh',
431 'debug-hung-script.sh',
432 'debug_locks.sh',
433 'gcore_trace.sh',
434 'notify.sh',
435 'statd-callout'
438 for t in etc_scripts:
439 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/' + t,
440 destname=t, chmod=0755)
442 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
443 destname='ctdb')
445 bld.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
446 destname='README')
448 bld.install_dir(bld.env.CTDB_LOGDIR)
449 bld.install_dir(bld.env.CTDB_RUNDIR)
450 bld.install_dir(bld.env.CTDB_VARDIR)
452 sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
453 t = bld.SAMBA_GENERATOR('ctdb-pc',
454 source='ctdb.pc.in',
455 target='ctdb.pc',
456 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr,
457 dep_vars=['VERSION'])
458 t.env.VERSION = VERSION
459 bld.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
461 # Test binaries
462 ctdb_tests = [
463 'rb_test',
464 'ctdb_bench',
465 'ctdb_fetch',
466 'ctdb_fetch_one',
467 'ctdb_fetch_readonly_once',
468 'ctdb_fetch_readonly_loop',
469 'ctdb_trackingdb_test',
470 'ctdb_update_record',
471 'ctdb_update_record_persistent',
472 'ctdb_store',
473 'ctdb_traverse',
474 'ctdb_randrec',
475 'ctdb_persistent',
476 'ctdb_porting_tests',
477 'ctdb_transaction',
478 'ctdb_lock_tdb'
481 for target in ctdb_tests:
482 src = 'tests/src/' + target + '.c'
484 bld.SAMBA_BINARY(target,
485 source=src,
486 includes='include include/internal',
487 deps='''ctdb-client ctdb-common ctdb-common-util
488 ctdb-system''',
489 install_path='${CTDB_TEST_LIBDIR}')
491 bld.SAMBA_BINARY('ctdb_takeover_tests',
492 source='tests/src/ctdb_takeover_tests.c',
493 deps='''replace popt tdb tevent talloc ctdb-system
494 ctdb-util tdb-wrap''' +
495 ib_deps,
496 includes='include include/internal',
497 install_path='${CTDB_TEST_LIBDIR}')
499 bld.SAMBA_BINARY('ctdb_functest',
500 source='tests/src/ctdb_functest.c',
501 deps='''replace tdb tevent talloc popt ctdb-system
502 ctdb-util tdb-wrap''',
503 includes='include include/internal',
504 install_path='${CTDB_TEST_LIBDIR}')
506 bld.SAMBA_BINARY('ctdb_stubtest',
507 source='tests/src/ctdb_test.c',
508 deps='''replace tdb tevent talloc popt ctdb-system
509 ctdb-util tdb-wrap''',
510 includes='include include/internal',
511 install_path='${CTDB_TEST_LIBDIR}')
513 if bld.env.HAVE_INFINIBAND:
514 bld.SAMBA_BINARY('ibwrapper_test',
515 source='ib/ibwrapper_test.c',
516 includes='include include/internal',
517 deps='''replace talloc ctdb-client ctdb-common
518 ctdb-system''' +
519 ib_deps,
520 install_path='${CTDB_TEST_LIBDIR}')
522 test_subdirs = [
523 'complex',
524 'events.d',
525 'eventscripts',
526 'onnode',
527 'simple',
528 'takeover',
529 'tool'
532 for t in test_subdirs:
533 files = SUBDIR_MODE('tests/%s' % t, trim_path='tests')
534 for fmode in files:
535 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
536 destname=fmode[0], chmod=fmode[1])
538 # Install tests/scripts directory without test_wrap
539 test_scripts = [
540 'common.sh',
541 'integration.bash',
542 'unit.sh'
545 for t in test_scripts:
546 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
547 os.path.join('tests/scripts', t),
548 destname=os.path.join('scripts', t))
550 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
551 bld.env.CTDB_TEST_LIBDIR)
552 bld.SAMBA_GENERATOR('ctdb-test-wrap',
553 source='tests/scripts/test_wrap',
554 target='test_wrap',
555 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
556 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
557 destname='test_wrap', chmod=0755)
559 sed_expr1 = 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
560 bld.env.CTDB_TEST_DATADIR, bld.env.CTDB_TEST_LIBDIR)
561 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
562 bld.SAMBA_GENERATOR('ctdb-test-runner',
563 source='tests/run_tests.sh',
564 target='ctdb_run_tests.sh',
565 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
566 sed_expr1, sed_expr2))
567 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
568 destname='ctdb_run_tests', chmod=0755)
569 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
570 'ctdb_run_tests')
572 test_eventscript_links = [
573 'events.d',
574 'functions',
575 'nfs-rpc-checks.d'
578 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
579 'eventscripts/etc-ctdb')
580 for t in test_eventscript_links:
581 bld.symlink_as(os.path.join(test_link_dir, t),
582 os.path.join(bld.env.CTDB_ETCDIR, t))
585 def testonly(ctx):
586 cmd = 'tests/run_tests.sh -V tests/var'
587 ret = samba_utils.RUN_COMMAND(cmd)
588 if ret != 0:
589 print('tests exited with exit status %d' % ret)
590 sys.exit(ret)
593 def test(ctx):
594 import Scripting
595 Scripting.commands.append('build')
596 Scripting.commands.append('testonly')
599 def autotest(ctx):
600 cmd = 'LD_PRELOAD=bin/shared/libsocket-wrapper.so tests/run_tests.sh -e -S -C'
601 ret = samba_utils.RUN_COMMAND(cmd)
602 if ret != 0:
603 print('autotest exited with exit status %d' % ret)
604 sys.exit(ret)
607 def show_version(ctx):
608 print VERSION
611 def dist():
612 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
614 t = 'include/ctdb_version.h'
615 cmd = 'packaging/mkversion.sh %s %s' % (t, VERSION)
616 ret = samba_utils.RUN_COMMAND(cmd)
617 if ret != 0:
618 print('Command "%s" failed with exit status %d' % (cmd, ret))
619 sys.exit(ret)
620 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
622 t = 'ctdb.spec'
623 sed_expr1 = 's/@VERSION@/%s/g' % VERSION
624 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
625 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
626 sed_expr1, sed_expr2, t)
627 ret = samba_utils.RUN_COMMAND(cmd)
628 if ret != 0:
629 print('Command "%s" failed with exit status %d' % (cmd, ret))
630 sys.exit(ret)
631 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
633 manpages = [
634 'ctdb.1',
635 'ctdb.7',
636 'ctdbd.1',
637 'ctdbd.conf.5',
638 'ctdbd_wrapper.1',
639 'ctdb-statistics.7',
640 'ctdb-tunables.7',
641 'ltdbtool.1'
644 cmd = 'make -C doc'
645 ret = samba_utils.RUN_COMMAND(cmd)
646 if ret != 0:
647 print('Command "%s" failed with exit status %d' % (cmd, ret))
648 sys.exit(ret)
649 for t in manpages:
650 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
651 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
652 extend=True)
654 samba_dist.dist()
657 def rpmonly(ctx):
658 cmd = 'rpmbuild -ta --clean --rmsource ctdb-%s.tar.gz' % VERSION
659 ret = samba_utils.RUN_COMMAND(cmd)
660 if ret != 0:
661 print('rpmbuild exited with exit status %d' % ret)
662 sys.exit(ret)
665 def rpm(ctx):
666 import Scripting
667 Scripting.commands.append('dist')
668 Scripting.commands.append('rpmonly')
671 def ctags(ctx):
672 "build 'tags' file using ctags"
673 import Utils
674 source_root = os.path.dirname(Utils.g_module.root_path)
675 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
676 print("Running: %s" % cmd)
677 ret = samba_utils.RUN_COMMAND(cmd)
678 if ret != 0:
679 print('ctags failed with exit status %d' % ret)
680 sys.exit(ret)