testprogs: use texpect instead of rkpty.
[Samba.git] / ctdb / wscript
blobd1f112e4c629dc6bc374f2f8a46175f2fc5aac69
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 have_pmda = False
84 if Options.options.ctdb_pmda:
85 pmda_support = True
87 if not conf.CHECK_HEADERS('pcp/pmapi.h pcp/impl.h pcp/pmda.h',
88 together=True):
89 pmda_support = False
90 if not conf.CHECK_FUNCS_IN('pmProgname', 'pcp'):
91 pmda_support = False
92 if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
93 pmda_support = False
94 if pmda_support:
95 have_pmda = True
96 else:
97 Logs.error("PMDA support not available")
98 if have_pmda:
99 Logs.info('Building with PMDA support')
100 conf.define('HAVE_PMDA', 1)
101 conf.env.CTDB_PMDADIR = os.path.join(conf.env.LOCALSTATEDIR,
102 'lib/pcp/pmdas/ctdb')
104 have_infiniband = False
105 if Options.options.ctdb_infiniband:
106 ib_support = True
108 if not conf.CHECK_HEADERS('infiniband/verbs.h rdma/rdma_cma.h'):
109 ib_support = False
110 if not conf.CHECK_FUNCS_IN('ibv_create_qp', 'ibverbs'):
111 ib_support = False
112 if not conf.CHECK_FUNCS_IN('rdma_connect', 'rdmacm'):
113 ib_support = False
114 if ib_support:
115 have_infiniband = True
116 else:
117 Logs.error("Infiniband support not available")
118 if have_infiniband:
119 Logs.info('Building with Infiniband support')
120 conf.define('HAVE_INFINIBAND', 1)
121 conf.define('USE_INFINIBAND', 1)
123 conf.env.CTDB_BINDIR = os.path.join(conf.env.EXEC_PREFIX, 'bin')
124 conf.env.CTDB_ETCDIR = os.path.join(conf.env.SYSCONFDIR, 'ctdb')
125 conf.env.CTDB_VARDIR = os.path.join(conf.env.LOCALSTATEDIR, 'lib/ctdb')
126 conf.env.CTDB_RUNDIR = os.path.join(conf.env.LOCALSTATEDIR, 'run/ctdb')
128 machine = os.uname()[4]
129 if machine in ['x86_64', 'ppc64', 'powerpc64']:
130 conf.env.LIBDIR = conf.env.LIBDIR + '64'
132 if Options.options.ctdb_logdir:
133 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
134 else:
135 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
137 if Options.options.ctdb_sockpath:
138 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
139 else:
140 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
141 'ctdbd.socket')
143 conf.ADD_CFLAGS('''-DBINDIR=\"%s\"
144 -DLOGDIR=\"%s\"
145 -DSOCKPATH=\"%s\"
146 -DCTDB_ETCDIR=\"%s\"
147 -DCTDB_VARDIR=\"%s\"
148 -DCTDB_RUNDIR=\"%s\"''' % (
149 conf.env.CTDB_BINDIR,
150 conf.env.CTDB_LOGDIR,
151 conf.env.CTDB_SOCKPATH,
152 conf.env.CTDB_ETCDIR,
153 conf.env.CTDB_VARDIR,
154 conf.env.CTDB_RUNDIR))
156 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
157 'share/ctdb-tests')
158 conf.env.CTDB_TEST_LIBDIR = os.path.join(conf.env.LIBDIR, 'ctdb-tests')
160 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
161 conf.SAMBA_CONFIG_H()
164 def build(bld):
165 bld.RECURSE('lib/replace')
166 if bld.CHECK_FOR_THIRD_PARTY():
167 bld.RECURSE('third_party/popt')
169 bld.RECURSE('lib/talloc')
170 bld.RECURSE('lib/tevent')
171 bld.RECURSE('lib/tdb')
172 bld.RECURSE('lib/socket_wrapper')
174 bld.SAMBA_GENERATOR('ctdb-version-header',
175 target='include/ctdb_version.h',
176 rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION),
177 always=True)
179 bld.SAMBA_SUBSYSTEM('ctdb-util',
180 source=bld.SUBDIR('lib/util',
181 'util.c util_file.c util_time.c'),
182 includes='include include/internal',
183 deps='replace talloc tevent tdb')
185 bld.SAMBA_SUBSYSTEM('ctdb-util-misc',
186 source=bld.SUBDIR('lib/util',
187 '''db_wrap.c debug.c fault.c
188 idtree.c signal.c strlist.c
189 substitute.c'''),
190 includes='include include/internal lib/util',
191 deps='replace talloc tevent tdb')
193 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
194 source=bld.SUBDIR('tcp',
195 'tcp_connect.c tcp_init.c tcp_io.c'),
196 includes='include include/internal',
197 deps='replace tdb talloc tevent')
199 ib_deps = ''
200 if bld.env.HAVE_INFINIBAND:
201 bld.SAMBA_SUBSYSTEM('ctdb-ib',
202 source=bld.SUBDIR('ib',
203 '''ibwrapper.c ibw_ctdb.c
204 ibw_ctdb_init.c'''),
205 includes='include include/internal',
206 deps='replace')
207 ib_deps = ' ctdb-ib rdmacm ibverbs'
209 bld.SAMBA_SUBSYSTEM('ctdb-common',
210 source=bld.SUBDIR('common',
211 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
212 ctdb_message.c cmdline.c rb_tree.c
213 system_common.c ctdb_fork.c'''),
214 includes='include include/internal common . lib/util',
215 deps='replace popt talloc tevent tdb popt')
217 bld.SAMBA_SUBSYSTEM('ctdb-common-util',
218 source=bld.SUBDIR('common',
219 'system_util.c ctdb_logging.c'),
220 includes='include include/internal',
221 deps='replace tevent tdb')
223 if sys.platform == 'linux2':
224 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_linux.c')
225 elif sys.platform == 'aix':
226 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_aix.c')
227 elif sys.platform == 'freebsd':
228 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_freebsd.c')
229 elif sys.platform == 'kfreebsd':
230 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_kfreebsd.c')
231 elif sys.platform == 'gnu':
232 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_gnu.c')
233 else:
234 Logs.error("Platform %s not supported" % sys.platform)
236 bld.SAMBA_SUBSYSTEM('ctdb-system',
237 source=CTDB_SYSTEM_SRC,
238 includes='include include/internal',
239 deps='replace talloc tevent tdb')
241 bld.SAMBA_SUBSYSTEM('ctdb-client',
242 source=bld.SUBDIR('client', 'ctdb_client.c'),
243 includes='include include/internal lib/util',
244 public_headers='include/ctdb_client.h',
245 deps='replace popt talloc tevent tdb')
247 bld.SAMBA_SUBSYSTEM('ctdb-server',
248 source='server/ctdbd.c ' +
249 bld.SUBDIR('server',
250 '''ctdb_daemon.c ctdb_recoverd.c
251 ctdb_recover.c ctdb_freeze.c
252 ctdb_tunables.c ctdb_monitor.c
253 ctdb_server.c ctdb_control.c
254 ctdb_call.c ctdb_ltdb_server.c
255 ctdb_traverse.c eventscript.c
256 ctdb_takeover.c ctdb_serverids.c
257 ctdb_persistent.c ctdb_keepalive.c
258 ctdb_logging.c ctdb_uptime.c
259 ctdb_vacuum.c ctdb_banning.c
260 ctdb_statistics.c
261 ctdb_update_record.c
262 ctdb_lock.c'''),
263 includes='include include/internal lib/util',
264 public_headers='''include/ctdb.h
265 include/ctdb_private.h
266 include/ctdb_protocol.h
267 include/ctdb_typesafe_cb.h''',
268 deps='replace popt talloc tevent tdb')
270 bld.SAMBA_BINARY('bin/ctdbd',
271 source='',
272 deps='''ctdb-server ctdb-client ctdb-common
273 ctdb-common-util ctdb-system ctdb-tcp
274 ctdb-util ctdb-util-misc''' +
275 ib_deps,
276 install_path='${SBINDIR}',
277 manpages='doc/ctdbd.1')
279 bld.SAMBA_BINARY('bin/ctdb',
280 source='tools/ctdb.c tools/ctdb_vacuum.c',
281 deps='''ctdb-client ctdb-common ctdb-common-util
282 ctdb-system ctdb-util ctdb-util-misc''',
283 install_path='${BINDIR}',
284 manpages='doc/ctdb.1')
286 bld.SAMBA_BINARY('bin/ltdbtool',
287 source='tools/ltdbtool.c',
288 includes='include',
289 deps='tdb',
290 install_path='${BINDIR}',
291 manpages='doc/ltdbtool.1')
293 bld.SAMBA_BINARY('bin/ctdb_lock_helper',
294 source='server/ctdb_lock_helper.c',
295 deps='ctdb-util ctdb-util-misc ctdb-common-util talloc tdb',
296 install_path='${BINDIR}')
298 bld.SAMBA_BINARY('bin/ctdb_event_helper',
299 source='server/ctdb_event_helper.c',
300 includes='include include/internal',
301 deps='ctdb-util ctdb-util-misc ctdb-common-util replace tdb',
302 install_path='${BINDIR}')
304 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
305 source='utils/smnotify/smnotify.x',
306 target='utils/smnotify/smnotify.h',
307 rule='rpcgen -h ${SRC} > ${TGT}')
309 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
311 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
312 source='utils/smnotify/smnotify.x',
313 target='utils/smnotify/gen_xdr.c',
314 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
316 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
317 source='utils/smnotify/smnotify.x',
318 target='utils/smnotify/gen_smnotify.c',
319 rule='rpcgen -l ${SRC} > ${TGT}')
321 bld.SAMBA_BINARY('bin/smnotify',
322 source=bld.SUBDIR('utils/smnotify',
323 'smnotify.c gen_smnotify.c gen_xdr.c'),
324 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
325 includes='utils utils/smnotify',
326 install_path='${BINDIR}')
328 bld.SAMBA_BINARY('bin/ping_pong',
329 source='utils/ping_pong/ping_pong.c',
330 deps='',
331 install_path='${BINDIR}',
332 manpages='doc/ping_pong.1')
334 if bld.env.HAVE_PMDA:
335 bld.SAMBA_BINARY('bin/pmdactdb',
336 source='utils/pmda/pmda_ctdb.c',
337 includes='include include/internal',
338 deps='''ctdb-client ctdb-common ctdb-system
339 ctdb-util-misc ctdb-util pcp_pmda pcp''',
340 install_path='${CTDB_PMDADIR}')
341 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
342 destname='Install')
343 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
344 destname='Remove')
345 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
346 destname='pmns')
347 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
348 destname='domain.h')
349 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
350 destname='help')
351 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
352 destname='README')
354 bld.MANPAGES('''doc/onnode.1 doc/ctdbd_wrapper.1 doc/ctdbd.conf.5
355 doc/ctdb.7 doc/ctdb-tunables.7''', True)
357 bld.INSTALL_FILES('${BINDIR}', 'tools/onnode',
358 destname='onnode', chmod=0755)
359 bld.INSTALL_FILES('${BINDIR}', 'tools/ctdb_diagnostics',
360 destname='ctdb_diagnostics', chmod=0755)
361 bld.INSTALL_FILES('${SBINDIR}', 'config/ctdbd_wrapper',
362 destname='ctdbd_wrapper', chmod=0755)
364 def SUBDIR_MODE_callback(arg, dirname, fnames):
365 for f in fnames:
366 fl = os.path.join(dirname, f)
367 if os.path.isdir(fl) or os.path.islink(fl):
368 continue
369 mode = os.lstat(fl).st_mode & 0777
370 if arg['trim_path']:
371 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
372 arg['file_list'].append([fl, mode])
374 def SUBDIR_MODE(path, trim_path=None):
375 pd = {'trim_path': trim_path, 'file_list': []}
376 os.path.walk(path, SUBDIR_MODE_callback, pd)
377 return pd['file_list']
379 etc_subdirs = [
380 'events.d',
381 'nfs-rpc-checks.d'
384 for t in etc_subdirs:
385 files = SUBDIR_MODE('config/%s' % t, trim_path='config')
386 for fmode in files:
387 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
388 destname=fmode[0], chmod=fmode[1])
390 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
391 destname='functions')
393 etc_scripts = [
394 'ctdb-crash-cleanup.sh',
395 'debug-hung-script.sh',
396 'debug_locks.sh',
397 'gcore_trace.sh',
398 'notify.sh',
399 'statd-callout'
402 for t in etc_scripts:
403 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/' + t,
404 destname=t, chmod=0755)
406 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
407 destname='ctdb')
409 bld.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
410 destname='README')
412 bld.install_dir(bld.env.CTDB_LOGDIR)
413 bld.install_dir(bld.env.CTDB_RUNDIR)
414 bld.install_dir(bld.env.CTDB_VARDIR)
416 sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
417 bld.SAMBA_GENERATOR('ctdb-pc',
418 source='ctdb.pc.in',
419 target='ctdb.pc',
420 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
421 bld.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
423 # Test binaries
424 ctdb_tests = [
425 'rb_test',
426 'ctdb_bench',
427 'ctdb_fetch',
428 'ctdb_fetch_one',
429 'ctdb_fetch_readonly_once',
430 'ctdb_fetch_readonly_loop',
431 'ctdb_trackingdb_test',
432 'ctdb_update_record',
433 'ctdb_update_record_persistent',
434 'ctdb_store',
435 'ctdb_traverse',
436 'ctdb_randrec',
437 'ctdb_persistent',
438 'ctdb_porting_tests',
439 'ctdb_transaction',
440 'ctdb_lock_tdb'
443 for t in ctdb_tests:
444 target = 'bin/' + t
445 src = 'tests/src/' + t + '.c'
447 bld.SAMBA_BINARY(target,
448 source=src,
449 deps='''ctdb-client ctdb-common ctdb-common-util
450 ctdb-system ctdb-util ctdb-util-misc''',
451 install_path='${CTDB_TEST_LIBDIR}')
453 bld.SAMBA_BINARY('bin/ctdb_takeover_tests',
454 source='tests/src/ctdb_takeover_tests.c',
455 deps='replace popt tdb tevent talloc ctdb-system' +
456 ib_deps,
457 includes='../include ../include/internal lib/util',
458 install_path='${CTDB_TEST_LIBDIR}')
460 bld.SAMBA_BINARY('bin/ctdb_functest',
461 source='tests/src/ctdb_functest.c',
462 deps='replace tdb tevent talloc popt ctdb-system',
463 includes='../include ../include/internal lib/util',
464 install_path='${CTDB_TEST_LIBDIR}')
466 bld.SAMBA_BINARY('bin/ctdb_stubtest',
467 source='tests/src/ctdb_test.c',
468 deps='replace tdb tevent talloc popt ctdb-system',
469 includes='../include ../include/internal lib/util',
470 install_path='${CTDB_TEST_LIBDIR}')
472 if bld.env.HAVE_INFINIBAND:
473 bld.SAMBA_BINARY('bin/ibwrapper_test',
474 source='ib/ibwrapper_test.c',
475 includes='include include/internal',
476 deps='''replace talloc ctdb-client ctdb-common
477 ctdb-system ctdb-util-misc ctdb-util''' +
478 ib_deps,
479 install_path='${CTDB_TEST_LIBDIR}')
481 test_subdirs = [
482 'complex',
483 'events.d',
484 'eventscripts',
485 'onnode',
486 'simple',
487 'takeover',
488 'tool'
491 for t in test_subdirs:
492 files = SUBDIR_MODE('tests/%s' % t, trim_path='tests')
493 for fmode in files:
494 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
495 destname=fmode[0], chmod=fmode[1])
497 # Install tests/scripts directory without test_wrap
498 test_scripts = [
499 'common.sh',
500 'integration.bash',
501 'unit.sh'
504 for t in test_scripts:
505 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
506 os.path.join('tests/scripts', t),
507 destname=os.path.join('scripts', t))
509 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
510 bld.env.CTDB_TEST_LIBDIR)
511 bld.SAMBA_GENERATOR('ctdb-test-wrap',
512 source='tests/scripts/test_wrap',
513 target='test_wrap',
514 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
515 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
516 destname='test_wrap', chmod=0755)
518 sed_expr1 = 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
519 bld.env.CTDB_TEST_DATADIR, bld.env.CTDB_TEST_LIBDIR)
520 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
521 bld.SAMBA_GENERATOR('ctdb-test-runner',
522 source='tests/run_tests.sh',
523 target='ctdb_run_tests.sh',
524 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
525 sed_expr1, sed_expr2))
526 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
527 destname='ctdb_run_tests', chmod=0755)
528 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
529 'ctdb_run_tests')
531 test_eventscript_links = [
532 'events.d',
533 'functions',
534 'nfs-rpc-checks.d'
537 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
538 'eventscripts/etc-ctdb')
539 for t in test_eventscript_links:
540 bld.symlink_as(os.path.join(test_link_dir, t),
541 os.path.join(bld.env.CTDB_ETCDIR, t))
544 def testonly(ctx):
545 cmd = 'tests/run_tests.sh -V tests/var'
546 ret = samba_utils.RUN_COMMAND(cmd)
547 if ret != 0:
548 print('tests exited with exit status %d' % ret)
549 sys.exit(ret)
552 def test(ctx):
553 import Scripting
554 Scripting.commands.append('build')
555 Scripting.commands.append('testonly')
558 def autotest(ctx):
559 cmd = 'LD_PRELOAD=bin/shared/libsocket-wrapper.so tests/run_tests.sh -e -S -C'
560 ret = samba_utils.RUN_COMMAND(cmd)
561 if ret != 0:
562 print('autotest exited with exit status %d' % ret)
563 sys.exit(ret)
566 def show_version(ctx):
567 print VERSION
570 def dist():
571 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
573 t = 'include/ctdb_version.h'
574 cmd = 'packaging/mkversion.sh %s %s' % (t, VERSION)
575 ret = samba_utils.RUN_COMMAND(cmd)
576 if ret != 0:
577 print('Command "%s" failed with exit status %d' % (cmd, ret))
578 sys.exit(ret)
579 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
581 t = 'ctdb.spec'
582 sed_expr1 = 's/@VERSION@/%s/g' % VERSION
583 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
584 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
585 sed_expr1, sed_expr2, t)
586 ret = samba_utils.RUN_COMMAND(cmd)
587 if ret != 0:
588 print('Command "%s" failed with exit status %d' % (cmd, ret))
589 sys.exit(ret)
590 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
592 manpages = [
593 'ctdb.1',
594 'ctdb.7',
595 'ctdbd.1',
596 'ctdbd.conf.5',
597 'ctdbd_wrapper.1',
598 'ctdb-tunables.7',
599 'ltdbtool.1'
602 cmd = 'make -C doc'
603 ret = samba_utils.RUN_COMMAND(cmd)
604 if ret != 0:
605 print('Command "%s" failed with exit status %d' % (cmd, ret))
606 sys.exit(ret)
607 for t in manpages:
608 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
609 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
610 extend=True)
612 samba_dist.dist()
615 def rpmonly(ctx):
616 cmd = 'rpmbuild -ta --clean --rmsource ctdb-%s.tar.gz' % VERSION
617 ret = samba_utils.RUN_COMMAND(cmd)
618 if ret != 0:
619 print('rpmbuild exited with exit status %d' % ret)
620 sys.exit(ret)
623 def rpm(ctx):
624 import Scripting
625 Scripting.commands.append('dist')
626 Scripting.commands.append('rpmonly')
629 def ctags(ctx):
630 "build 'tags' file using ctags"
631 import Utils
632 source_root = os.path.dirname(Utils.g_module.root_path)
633 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
634 print("Running: %s" % cmd)
635 ret = samba_utils.RUN_COMMAND(cmd)
636 if ret != 0:
637 print('ctags failed with exit status %d' % ret)
638 sys.exit(ret)