9 # find the buildtools directory
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'):
21 elif os
.path
.isfile('../VERSION'):
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 third_party/waf:third_party/waf''')
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)
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')
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.')
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')
104 elif not conf
.CHECK_FUNCS('sched_setscheduler'):
105 Logs
.error('Need sched_setscheduler()')
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')
115 if not conf
.CHECK_HEADERS('pcap.h'):
116 Logs
.error('Need libpcap')
118 if not conf
.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers
='pcap.h'):
119 Logs
.error('Need libpcap')
122 if not conf
.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
123 checklibc
=True, headers
='execinfo.h'):
124 Logs
.error('backtrace support not available')
127 if Options
.options
.ctdb_pmda
:
130 if not conf
.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
133 if not conf
.CHECK_FUNCS_IN('pmProgname', 'pcp'):
135 if not conf
.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
140 Logs
.error("PMDA support not available")
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
:
151 if not conf
.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
153 if not conf
.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
155 if not conf
.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
158 have_infiniband
= True
160 Logs
.error("Infiniband support not available")
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
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
179 conf
.env
.CTDB_SOCKPATH
= os
.path
.join(conf
.env
.CTDB_RUNDIR
,
182 conf
.ADD_CFLAGS('''-DCTDB_HELPER_BINDIR=\"%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
,
197 conf
.env
.CTDB_TEST_LIBDIR
= os
.path
.join(conf
.env
.LIBDIR
, 'ctdb-tests')
199 # Allow unified compilation and separate compilation of utilities
201 if not conf
.env
.standalone_ctdb
:
202 conf
.ADD_EXTRA_INCLUDES('#ctdb/include')
205 # Building from tarball
206 conf
.ADD_EXTRA_INCLUDES('#include')
207 conf
.ADD_EXTRA_INCLUDES('#include/internal')
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
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
216 conf
.DEFINE('SAMBA_UTIL_CORE_ONLY', 1, add_to_cflags
=True)
217 conf
.SAMBA_CONFIG_H()
221 if bld
.env
.standalone_ctdb
:
222 # enable building of public headers in the build tree
223 bld
.env
.build_public_headers
= 'include/public'
225 version_h
= samba_utils
.os_path_relpath(os
.path
.join(Options
.launch_dir
,
229 if bld
.env
.standalone_ctdb
:
230 ctdb_mkversion
= '../packaging/mkversion.sh'
231 t
= bld
.SAMBA_GENERATOR('ctdb-version-header',
232 target
='include/ctdb_version.h',
233 rule
='%s ${TGT} %s' % (ctdb_mkversion
, VERSION
),
234 dep_vars
=['VERSION'])
235 t
.env
.VERSION
= VERSION
237 t
= bld
.SAMBA_GENERATOR('ctdb-samba-version-header',
239 rule
='printf "#include \\"ctdb_version.h\\" \\n#define SAMBA_VERSION_STRING CTDB_VERSION_STRING\\n" > ${TGT}',
240 dep_vars
=['VERSION'])
241 t
.env
.VERSION
= VERSION
243 t
= bld
.SAMBA_GENERATOR('ctdb-samba-version-header',
244 target
='include/ctdb_version.h',
245 rule
='printf "#include \\"%s\\" \\n#define CTDB_VERSION_STRING SAMBA_VERSION_STRING\\n" > ${TGT}' % version_h
,
246 dep_vars
=['VERSION'])
247 t
.env
.VERSION
= VERSION
249 bld
.RECURSE('lib/replace')
250 if bld
.CHECK_FOR_THIRD_PARTY():
251 bld
.RECURSE('third_party/popt')
253 bld
.RECURSE('lib/tdb_wrap')
254 bld
.RECURSE('lib/util')
256 bld
.RECURSE('lib/talloc')
257 bld
.RECURSE('lib/tevent')
258 bld
.RECURSE('lib/tdb')
259 bld
.RECURSE('lib/socket_wrapper')
261 if bld
.env
.standalone_ctdb
:
262 # In a combined build is implemented, CTDB will wanted to
263 # build against samba-util rather than samba-util-core.
264 # Similarly, other Samba subsystems expect samba-util. So,
265 # for a standalone build, just define a fake samba-util
266 # subsystem that pulls in samba-util-core.
267 bld
.SAMBA_SUBSYSTEM('samba-util',
269 deps
='samba-util-core')
271 bld
.SAMBA_SUBSYSTEM('ctdb-tcp',
272 source
=bld
.SUBDIR('tcp',
273 'tcp_connect.c tcp_init.c tcp_io.c'),
274 includes
='include include/internal',
275 deps
='replace tdb talloc tevent')
278 if bld
.env
.HAVE_INFINIBAND
:
279 bld
.SAMBA_SUBSYSTEM('ctdb-ib',
280 source
=bld
.SUBDIR('ib',
281 '''ibwrapper.c ibw_ctdb.c
283 includes
='include include/internal',
285 ib_deps
= ' ctdb-ib rdmacm ibverbs'
287 bld
.SAMBA_SUBSYSTEM('ctdb-common',
288 source
=bld
.SUBDIR('common',
289 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
290 ctdb_message.c cmdline.c rb_tree.c
291 system_common.c ctdb_fork.c'''),
292 includes
='include include/internal common .',
293 deps
='replace popt talloc tevent tdb popt')
295 bld
.SAMBA_SUBSYSTEM('ctdb-common-util',
296 source
=bld
.SUBDIR('common',
297 'system_util.c ctdb_logging.c'),
298 includes
='include include/internal',
299 deps
='replace tevent tdb')
301 if sys
.platform
.startswith('linux'):
302 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_linux.c')
303 elif sys
.platform
.startswith('aix'):
304 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_aix.c')
305 elif sys
.platform
.startswith('freebsd'):
306 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_freebsd.c')
307 elif sys
.platform
== 'kfreebsd':
308 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_kfreebsd.c')
309 elif sys
.platform
== 'gnu':
310 CTDB_SYSTEM_SRC
= bld
.SUBDIR('common', 'system_gnu.c')
312 Logs
.error("Platform %s not supported" % sys
.platform
)
314 bld
.SAMBA_SUBSYSTEM('ctdb-system',
315 source
=CTDB_SYSTEM_SRC
,
316 includes
='include include/internal',
317 deps
='replace talloc tevent tdb pcap')
319 bld
.SAMBA_SUBSYSTEM('ctdb-client',
320 source
=bld
.SUBDIR('client', 'ctdb_client.c'),
321 includes
='include include/internal',
322 public_headers
='include/ctdb_client.h',
323 deps
='''replace popt talloc tevent tdb
324 samba-util tdb-wrap''')
326 bld
.SAMBA_SUBSYSTEM('ctdb-server',
327 source
='server/ctdbd.c ' +
329 '''ctdb_daemon.c ctdb_recoverd.c
330 ctdb_recover.c ctdb_freeze.c
331 ctdb_tunables.c ctdb_monitor.c
332 ctdb_server.c ctdb_control.c
333 ctdb_call.c ctdb_ltdb_server.c
334 ctdb_traverse.c eventscript.c
335 ctdb_takeover.c ctdb_serverids.c
336 ctdb_persistent.c ctdb_keepalive.c
338 ctdb_logging_syslog.c
341 ctdb_vacuum.c ctdb_banning.c
345 includes
='include include/internal',
346 public_headers
='''include/ctdb_version.h
348 include/ctdb_private.h
349 include/ctdb_protocol.h
350 include/ctdb_typesafe_cb.h''',
351 deps
='replace popt talloc tevent tdb')
353 bld
.SAMBA_BINARY('ctdbd',
355 deps
='''ctdb-server ctdb-client ctdb-common
356 ctdb-common-util ctdb-system ctdb-tcp''' +
358 install_path
='${SBINDIR}',
359 manpages
='doc/ctdbd.1')
361 bld
.SAMBA_BINARY('ctdb',
362 source
='tools/ctdb.c tools/ctdb_vacuum.c',
363 deps
='''ctdb-client ctdb-common ctdb-common-util
365 includes
='include include/internal',
366 install_path
='${BINDIR}',
367 manpages
='doc/ctdb.1')
369 bld
.SAMBA_BINARY('ltdbtool',
370 source
='tools/ltdbtool.c',
373 install_path
='${BINDIR}',
374 manpages
='doc/ltdbtool.1')
376 bld
.SAMBA_BINARY('ctdb_lock_helper',
377 source
='server/ctdb_lock_helper.c',
378 deps
='samba-util ctdb-common-util talloc tdb',
379 includes
='include include/internal',
380 install_path
='${BINDIR}')
382 bld
.SAMBA_BINARY('ctdb_event_helper',
383 source
='server/ctdb_event_helper.c',
384 includes
='include include/internal',
385 deps
='samba-util ctdb-common-util replace tdb',
386 install_path
='${BINDIR}')
388 bld
.SAMBA_GENERATOR('ctdb-smnotify-h',
389 source
='utils/smnotify/smnotify.x',
390 target
='utils/smnotify/smnotify.h',
391 rule
='rpcgen -h ${SRC} > ${TGT}')
393 xdr_buf_hack
= 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
395 bld
.SAMBA_GENERATOR('ctdb-smnotify-x',
396 source
='utils/smnotify/smnotify.x',
397 target
='utils/smnotify/gen_xdr.c',
398 rule
='rpcgen -c ${SRC} | ' + xdr_buf_hack
+ ' > ${TGT}')
400 bld
.SAMBA_GENERATOR('ctdb-smnotify-c',
401 source
='utils/smnotify/smnotify.x',
402 target
='utils/smnotify/gen_smnotify.c',
403 rule
='rpcgen -l ${SRC} > ${TGT}')
405 bld
.SAMBA_BINARY('smnotify',
406 source
=bld
.SUBDIR('utils/smnotify',
407 'smnotify.c gen_smnotify.c gen_xdr.c'),
408 deps
='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
409 includes
='utils utils/smnotify',
410 install_path
='${BINDIR}')
412 bld
.SAMBA_BINARY('ping_pong',
413 source
='utils/ping_pong/ping_pong.c',
415 install_path
='${BINDIR}',
416 manpages
='doc/ping_pong.1')
418 if bld
.env
.HAVE_PMDA
:
419 bld
.SAMBA_BINARY('pmdactdb',
420 source
='utils/pmda/pmda_ctdb.c',
421 includes
='include include/internal',
422 deps
='''ctdb-client ctdb-common ctdb-system
423 ctdb-common-util pcp_pmda pcp''',
424 install_path
='${CTDB_PMDADIR}')
425 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
427 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
429 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
431 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
433 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
435 bld
.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
438 if 'XSLTPROC_MANPAGES' in bld
.env
and bld
.env
['XSLTPROC_MANPAGES']:
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''',
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
):
452 fl
= os
.path
.join(dirname
, f
)
453 if os
.path
.isdir(fl
) or os
.path
.islink(fl
):
455 mode
= os
.lstat(fl
).st_mode
& 0777
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']
470 if bld
.env
.standalone_ctdb
:
473 configdir
= 'ctdb/config'
475 for t
in etc_subdirs
:
476 files
= SUBDIR_MODE('%s/%s' % (configdir
, t
), trim_path
=configdir
)
478 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % fmode
[0],
479 destname
=fmode
[0], chmod
=fmode
[1])
481 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/functions',
482 destname
='functions')
485 'ctdb-crash-cleanup.sh',
486 'debug-hung-script.sh',
493 for t
in etc_scripts
:
494 bld
.INSTALL_FILES(bld
.env
.CTDB_ETCDIR
, 'config/%s' % t
,
495 destname
=t
, chmod
=0755)
497 bld
.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
500 bld
.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
503 bld
.install_dir(bld
.env
.CTDB_LOGDIR
)
504 bld
.install_dir(bld
.env
.CTDB_RUNDIR
)
505 bld
.install_dir(bld
.env
.CTDB_VARDIR
)
507 sed_expr
= 's/@PACKAGE_VERSION@/%s/g' % VERSION
508 t
= bld
.SAMBA_GENERATOR('ctdb-pc',
511 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
,
512 dep_vars
=['VERSION'])
513 t
.env
.VERSION
= VERSION
514 bld
.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
522 'ctdb_fetch_readonly_once',
523 'ctdb_fetch_readonly_loop',
524 'ctdb_trackingdb_test',
525 'ctdb_update_record',
526 'ctdb_update_record_persistent',
531 'ctdb_porting_tests',
536 for target
in ctdb_tests
:
537 src
= 'tests/src/' + target
+ '.c'
539 bld
.SAMBA_BINARY(target
,
541 includes
='include include/internal',
542 deps
='''ctdb-client ctdb-common ctdb-common-util
544 install_path
='${CTDB_TEST_LIBDIR}')
546 bld
.SAMBA_BINARY('ctdb_takeover_tests',
547 source
='tests/src/ctdb_takeover_tests.c',
548 deps
='''replace popt tdb tevent talloc ctdb-system
549 samba-util tdb-wrap''' +
551 includes
='include include/internal',
552 install_path
='${CTDB_TEST_LIBDIR}')
554 bld
.SAMBA_BINARY('ctdb_functest',
555 source
='tests/src/ctdb_functest.c',
556 deps
='''replace tdb tevent talloc popt ctdb-system
557 samba-util tdb-wrap''',
558 includes
='include include/internal',
559 install_path
='${CTDB_TEST_LIBDIR}')
561 bld
.SAMBA_BINARY('ctdb_stubtest',
562 source
='tests/src/ctdb_test.c',
563 deps
='''replace tdb tevent talloc popt ctdb-system
564 samba-util tdb-wrap''',
565 includes
='include include/internal',
566 install_path
='${CTDB_TEST_LIBDIR}')
568 if bld
.env
.HAVE_INFINIBAND
:
569 bld
.SAMBA_BINARY('ibwrapper_test',
570 source
='ib/ibwrapper_test.c',
571 includes
='include include/internal',
572 deps
='''replace talloc ctdb-client ctdb-common
575 install_path
='${CTDB_TEST_LIBDIR}')
587 for t
in test_subdirs
:
588 files
= SUBDIR_MODE('tests/%s' % t
, trim_path
='tests')
590 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
, 'tests/%s' % fmode
[0],
591 destname
=fmode
[0], chmod
=fmode
[1])
593 # Install tests/scripts directory without test_wrap
600 for t
in test_scripts
:
601 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
,
602 os
.path
.join('tests/scripts', t
),
603 destname
=os
.path
.join('scripts', t
))
605 sed_expr
= 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
606 bld
.env
.CTDB_TEST_LIBDIR
)
607 bld
.SAMBA_GENERATOR('ctdb-test-wrap',
608 source
='tests/scripts/test_wrap',
610 rule
='sed -e "%s" ${SRC} > ${TGT}' % sed_expr
)
611 bld
.INSTALL_FILES(bld
.env
.CTDB_TEST_DATADIR
+"/scripts", 'test_wrap',
612 destname
='test_wrap', chmod
=0755)
614 sed_expr1
= 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
615 bld
.env
.CTDB_TEST_DATADIR
, bld
.env
.CTDB_TEST_LIBDIR
)
616 sed_expr2
= 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
617 bld
.SAMBA_GENERATOR('ctdb-test-runner',
618 source
='tests/run_tests.sh',
619 target
='ctdb_run_tests.sh',
620 rule
='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
621 sed_expr1
, sed_expr2
))
622 bld
.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
623 destname
='ctdb_run_tests', chmod
=0755)
624 bld
.symlink_as(os
.path
.join(bld
.env
.BINDIR
, 'ctdb_run_cluster_tests'),
627 test_eventscript_links
= [
634 test_link_dir
= os
.path
.join(bld
.env
.CTDB_TEST_DATADIR
,
635 'eventscripts/etc-ctdb')
636 for t
in test_eventscript_links
:
637 bld
.symlink_as(os
.path
.join(test_link_dir
, t
),
638 os
.path
.join(bld
.env
.CTDB_ETCDIR
, t
))
642 cmd
= 'tests/run_tests.sh -V tests/var'
643 ret
= samba_utils
.RUN_COMMAND(cmd
)
645 print('tests exited with exit status %d' % ret
)
651 Scripting
.commands
.append('build')
652 Scripting
.commands
.append('testonly')
656 ld
= 'LD_PRELOAD=%s/bin/shared/libsocket-wrapper.so' % os
.getcwd()
657 cmd
= '%s tests/run_tests.sh -e -S -C' % ld
658 ret
= samba_utils
.RUN_COMMAND(cmd
)
660 print('autotest exited with exit status %d' % ret
)
664 def show_version(ctx
):
669 samba_dist
.DIST_FILES('VERSION:VERSION', extend
=True)
671 t
= 'include/ctdb_version.h'
672 cmd
= 'packaging/mkversion.sh %s %s' % (t
, VERSION
)
673 ret
= samba_utils
.RUN_COMMAND(cmd
)
675 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
677 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
680 sed_expr1
= 's/@VERSION@/%s/g' % VERSION
681 sed_expr2
= 's/@RELEASE@/%s/g' % '1'
682 cmd
= 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
683 sed_expr1
, sed_expr2
, t
)
684 ret
= samba_utils
.RUN_COMMAND(cmd
)
686 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
688 samba_dist
.DIST_FILES('ctdb/%s:%s' % (t
, t
), extend
=True)
702 ret
= samba_utils
.RUN_COMMAND(cmd
)
704 print('Command "%s" failed with exit status %d' % (cmd
, ret
))
707 samba_dist
.DIST_FILES('ctdb/doc/%s:doc/%s' % (t
, t
), extend
=True)
708 samba_dist
.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t
, t
),
715 cmd
= 'rpmbuild -ta --clean --rmsource ctdb-%s.tar.gz' % VERSION
716 ret
= samba_utils
.RUN_COMMAND(cmd
)
718 print('rpmbuild exited with exit status %d' % ret
)
724 Scripting
.commands
.append('dist')
725 Scripting
.commands
.append('rpmonly')
729 "build 'tags' file using ctags"
731 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
732 cmd
= 'ctags $(find %s -name "*.[ch]")' % source_root
733 print("Running: %s" % cmd
)
734 ret
= samba_utils
.RUN_COMMAND(cmd
)
736 print('ctags failed with exit status %d' % ret
)