ctdb-build: Tests don't include lib/util/*.c, link ctdb-util instead
[Samba.git] / ctdb / wscript
blob7c791ff6c7bf1247aded3767ae684ab5406470bd
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 if Options.options.ctdb_logdir:
129 conf.env.CTDB_LOGDIR = Options.options.ctdb_logdir
130 else:
131 conf.env.CTDB_LOGDIR = os.path.join(conf.env.LOCALSTATEDIR, 'log')
133 if Options.options.ctdb_sockpath:
134 conf.env.CTDB_SOCKPATH = Options.options.ctdb_sockpath
135 else:
136 conf.env.CTDB_SOCKPATH = os.path.join(conf.env.CTDB_RUNDIR,
137 'ctdbd.socket')
139 conf.ADD_CFLAGS('''-DBINDIR=\"%s\"
140 -DLOGDIR=\"%s\"
141 -DSOCKPATH=\"%s\"
142 -DCTDB_ETCDIR=\"%s\"
143 -DCTDB_VARDIR=\"%s\"
144 -DCTDB_RUNDIR=\"%s\"''' % (
145 conf.env.CTDB_BINDIR,
146 conf.env.CTDB_LOGDIR,
147 conf.env.CTDB_SOCKPATH,
148 conf.env.CTDB_ETCDIR,
149 conf.env.CTDB_VARDIR,
150 conf.env.CTDB_RUNDIR))
152 conf.env.CTDB_TEST_DATADIR = os.path.join(conf.env.EXEC_PREFIX,
153 'share/ctdb-tests')
154 conf.env.CTDB_TEST_LIBDIR = os.path.join(conf.env.LIBDIR, 'ctdb-tests')
156 # Allow separate compilation of utilities to find includes
157 if srcdir == '.':
158 # Building from tarball
159 conf.ADD_EXTRA_INCLUDES('#include')
160 conf.ADD_EXTRA_INCLUDES('#include/internal')
161 else:
162 # Building standalone CTDB from within Samba tree
163 conf.ADD_EXTRA_INCLUDES('#ctdb/include')
164 conf.ADD_EXTRA_INCLUDES('#ctdb/include/internal')
165 conf.ADD_EXTRA_INCLUDES('#ctdb')
167 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
168 conf.SAMBA_CONFIG_H()
171 def build(bld):
172 bld.RECURSE('lib/replace')
173 if bld.CHECK_FOR_THIRD_PARTY():
174 bld.RECURSE('third_party/popt')
176 bld.RECURSE('lib/tdb_wrap')
177 bld.RECURSE('lib/util')
179 bld.RECURSE('lib/talloc')
180 bld.RECURSE('lib/tevent')
181 bld.RECURSE('lib/tdb')
182 bld.RECURSE('lib/socket_wrapper')
184 t = bld.SAMBA_GENERATOR('ctdb-version-header',
185 target='include/ctdb_version.h',
186 rule='../packaging/mkversion.sh ${TGT} %s' % (VERSION),
187 dep_vars=['VERSION'])
188 t.env.VERSION = VERSION
190 bld.SAMBA_SUBSYSTEM('ctdb-tcp',
191 source=bld.SUBDIR('tcp',
192 'tcp_connect.c tcp_init.c tcp_io.c'),
193 includes='include include/internal',
194 deps='replace tdb talloc tevent')
196 ib_deps = ''
197 if bld.env.HAVE_INFINIBAND:
198 bld.SAMBA_SUBSYSTEM('ctdb-ib',
199 source=bld.SUBDIR('ib',
200 '''ibwrapper.c ibw_ctdb.c
201 ibw_ctdb_init.c'''),
202 includes='include include/internal',
203 deps='replace')
204 ib_deps = ' ctdb-ib rdmacm ibverbs'
206 bld.SAMBA_SUBSYSTEM('ctdb-common',
207 source=bld.SUBDIR('common',
208 '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
209 ctdb_message.c cmdline.c rb_tree.c
210 system_common.c ctdb_fork.c'''),
211 includes='include include/internal common .',
212 deps='replace popt talloc tevent tdb popt')
214 bld.SAMBA_SUBSYSTEM('ctdb-common-util',
215 source=bld.SUBDIR('common',
216 'system_util.c ctdb_logging.c'),
217 includes='include include/internal',
218 deps='replace tevent tdb')
220 if sys.platform == 'linux2':
221 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_linux.c')
222 elif sys.platform == 'aix':
223 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_aix.c')
224 elif sys.platform == 'freebsd':
225 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_freebsd.c')
226 elif sys.platform == 'kfreebsd':
227 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_kfreebsd.c')
228 elif sys.platform == 'gnu':
229 CTDB_SYSTEM_SRC = bld.SUBDIR('common', 'system_gnu.c')
230 else:
231 Logs.error("Platform %s not supported" % sys.platform)
233 bld.SAMBA_SUBSYSTEM('ctdb-system',
234 source=CTDB_SYSTEM_SRC,
235 includes='include include/internal',
236 deps='replace talloc tevent tdb')
238 bld.SAMBA_SUBSYSTEM('ctdb-client',
239 source=bld.SUBDIR('client', 'ctdb_client.c'),
240 includes='include include/internal',
241 public_headers='include/ctdb_client.h',
242 deps='''replace popt talloc tevent tdb
243 ctdb-util tdb-wrap''')
245 bld.SAMBA_SUBSYSTEM('ctdb-server',
246 source='server/ctdbd.c ' +
247 bld.SUBDIR('server',
248 '''ctdb_daemon.c ctdb_recoverd.c
249 ctdb_recover.c ctdb_freeze.c
250 ctdb_tunables.c ctdb_monitor.c
251 ctdb_server.c ctdb_control.c
252 ctdb_call.c ctdb_ltdb_server.c
253 ctdb_traverse.c eventscript.c
254 ctdb_takeover.c ctdb_serverids.c
255 ctdb_persistent.c ctdb_keepalive.c
256 ctdb_logging.c ctdb_uptime.c
257 ctdb_vacuum.c ctdb_banning.c
258 ctdb_statistics.c
259 ctdb_update_record.c
260 ctdb_lock.c'''),
261 includes='include include/internal',
262 public_headers='''include/ctdb.h
263 include/ctdb_private.h
264 include/ctdb_protocol.h
265 include/ctdb_typesafe_cb.h''',
266 deps='replace popt talloc tevent tdb')
268 bld.SAMBA_BINARY('ctdbd',
269 source='',
270 deps='''ctdb-server ctdb-client ctdb-common
271 ctdb-common-util ctdb-system ctdb-tcp''' +
272 ib_deps,
273 install_path='${SBINDIR}',
274 manpages='doc/ctdbd.1')
276 bld.SAMBA_BINARY('ctdb',
277 source='tools/ctdb.c tools/ctdb_vacuum.c',
278 deps='''ctdb-client ctdb-common ctdb-common-util
279 ctdb-system''',
280 includes='include include/internal',
281 install_path='${BINDIR}',
282 manpages='doc/ctdb.1')
284 bld.SAMBA_BINARY('ltdbtool',
285 source='tools/ltdbtool.c',
286 includes='include',
287 deps='tdb',
288 install_path='${BINDIR}',
289 manpages='doc/ltdbtool.1')
291 bld.SAMBA_BINARY('ctdb_lock_helper',
292 source='server/ctdb_lock_helper.c',
293 deps='ctdb-util ctdb-common-util talloc tdb',
294 includes='include include/internal',
295 install_path='${BINDIR}')
297 bld.SAMBA_BINARY('ctdb_event_helper',
298 source='server/ctdb_event_helper.c',
299 includes='include include/internal',
300 deps='ctdb-util ctdb-common-util replace tdb',
301 install_path='${BINDIR}')
303 bld.SAMBA_GENERATOR('ctdb-smnotify-h',
304 source='utils/smnotify/smnotify.x',
305 target='utils/smnotify/smnotify.h',
306 rule='rpcgen -h ${SRC} > ${TGT}')
308 xdr_buf_hack = 'sed -e "s@^\([ \t]*register int32_t \*buf\);@\\1 = buf;@"'
310 bld.SAMBA_GENERATOR('ctdb-smnotify-x',
311 source='utils/smnotify/smnotify.x',
312 target='utils/smnotify/gen_xdr.c',
313 rule='rpcgen -c ${SRC} | ' + xdr_buf_hack + ' > ${TGT}')
315 bld.SAMBA_GENERATOR('ctdb-smnotify-c',
316 source='utils/smnotify/smnotify.x',
317 target='utils/smnotify/gen_smnotify.c',
318 rule='rpcgen -l ${SRC} > ${TGT}')
320 bld.SAMBA_BINARY('smnotify',
321 source=bld.SUBDIR('utils/smnotify',
322 'smnotify.c gen_smnotify.c gen_xdr.c'),
323 deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
324 includes='utils utils/smnotify',
325 install_path='${BINDIR}')
327 bld.SAMBA_BINARY('ping_pong',
328 source='utils/ping_pong/ping_pong.c',
329 deps='',
330 install_path='${BINDIR}',
331 manpages='doc/ping_pong.1')
333 if bld.env.HAVE_PMDA:
334 bld.SAMBA_BINARY('pmdactdb',
335 source='utils/pmda/pmda_ctdb.c',
336 includes='include include/internal',
337 deps='''ctdb-client ctdb-common ctdb-system
338 pcp_pmda pcp''',
339 install_path='${CTDB_PMDADIR}')
340 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
341 destname='Install')
342 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Remove',
343 destname='Remove')
344 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/pmns',
345 destname='pmns')
346 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/domain.h',
347 destname='domain.h')
348 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/help',
349 destname='help')
350 bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/README',
351 destname='README')
353 bld.MANPAGES('''doc/onnode.1 doc/ctdbd_wrapper.1 doc/ctdbd.conf.5
354 doc/ctdb.7 doc/ctdb-tunables.7''', True)
356 bld.INSTALL_FILES('${BINDIR}', 'tools/onnode',
357 destname='onnode', chmod=0755)
358 bld.INSTALL_FILES('${BINDIR}', 'tools/ctdb_diagnostics',
359 destname='ctdb_diagnostics', chmod=0755)
360 bld.INSTALL_FILES('${SBINDIR}', 'config/ctdbd_wrapper',
361 destname='ctdbd_wrapper', chmod=0755)
363 def SUBDIR_MODE_callback(arg, dirname, fnames):
364 for f in fnames:
365 fl = os.path.join(dirname, f)
366 if os.path.isdir(fl) or os.path.islink(fl):
367 continue
368 mode = os.lstat(fl).st_mode & 0777
369 if arg['trim_path']:
370 fl = samba_utils.os_path_relpath(fl, arg['trim_path'])
371 arg['file_list'].append([fl, mode])
373 def SUBDIR_MODE(path, trim_path=None):
374 pd = {'trim_path': trim_path, 'file_list': []}
375 os.path.walk(path, SUBDIR_MODE_callback, pd)
376 return pd['file_list']
378 etc_subdirs = [
379 'events.d',
380 'nfs-rpc-checks.d'
383 for t in etc_subdirs:
384 files = SUBDIR_MODE('config/%s' % t, trim_path='config')
385 for fmode in files:
386 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/%s' % fmode[0],
387 destname=fmode[0], chmod=fmode[1])
389 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/functions',
390 destname='functions')
392 etc_scripts = [
393 'ctdb-crash-cleanup.sh',
394 'debug-hung-script.sh',
395 'debug_locks.sh',
396 'gcore_trace.sh',
397 'notify.sh',
398 'statd-callout'
401 for t in etc_scripts:
402 bld.INSTALL_FILES(bld.env.CTDB_ETCDIR, 'config/' + t,
403 destname=t, chmod=0755)
405 bld.INSTALL_FILES('${SYSCONFDIR}/sudoers.d', 'config/ctdb.sudoers',
406 destname='ctdb')
408 bld.INSTALL_FILES('${CTDB_ETCDIR}/notify.d', 'config/notify.d.README',
409 destname='README')
411 bld.install_dir(bld.env.CTDB_LOGDIR)
412 bld.install_dir(bld.env.CTDB_RUNDIR)
413 bld.install_dir(bld.env.CTDB_VARDIR)
415 sed_expr = 's/@PACKAGE_VERSION@/%s/g' % VERSION
416 t = bld.SAMBA_GENERATOR('ctdb-pc',
417 source='ctdb.pc.in',
418 target='ctdb.pc',
419 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr,
420 dep_vars=['VERSION'])
421 t.env.VERSION = VERSION
422 bld.INSTALL_FILES('${LIBDIR}/pkgconfig', 'ctdb.pc')
424 # Test binaries
425 ctdb_tests = [
426 'rb_test',
427 'ctdb_bench',
428 'ctdb_fetch',
429 'ctdb_fetch_one',
430 'ctdb_fetch_readonly_once',
431 'ctdb_fetch_readonly_loop',
432 'ctdb_trackingdb_test',
433 'ctdb_update_record',
434 'ctdb_update_record_persistent',
435 'ctdb_store',
436 'ctdb_traverse',
437 'ctdb_randrec',
438 'ctdb_persistent',
439 'ctdb_porting_tests',
440 'ctdb_transaction',
441 'ctdb_lock_tdb'
444 for target in ctdb_tests:
445 src = 'tests/src/' + target + '.c'
447 bld.SAMBA_BINARY(target,
448 source=src,
449 includes='include include/internal',
450 deps='''ctdb-client ctdb-common ctdb-common-util
451 ctdb-system''',
452 install_path='${CTDB_TEST_LIBDIR}')
454 bld.SAMBA_BINARY('ctdb_takeover_tests',
455 source='tests/src/ctdb_takeover_tests.c',
456 deps='''replace popt tdb tevent talloc ctdb-system
457 ctdb-util tdb-wrap''' +
458 ib_deps,
459 includes='include include/internal lib/util',
460 install_path='${CTDB_TEST_LIBDIR}')
462 bld.SAMBA_BINARY('ctdb_functest',
463 source='tests/src/ctdb_functest.c',
464 deps='''replace tdb tevent talloc popt ctdb-system
465 ctdb-util tdb-wrap''',
466 includes='include include/internal lib/util',
467 install_path='${CTDB_TEST_LIBDIR}')
469 bld.SAMBA_BINARY('ctdb_stubtest',
470 source='tests/src/ctdb_test.c',
471 deps='''replace tdb tevent talloc popt ctdb-system
472 ctdb-util tdb-wrap''',
473 includes='include include/internal lib/util',
474 install_path='${CTDB_TEST_LIBDIR}')
476 if bld.env.HAVE_INFINIBAND:
477 bld.SAMBA_BINARY('ibwrapper_test',
478 source='ib/ibwrapper_test.c',
479 includes='include include/internal',
480 deps='''replace talloc ctdb-client ctdb-common
481 ctdb-system''' +
482 ib_deps,
483 install_path='${CTDB_TEST_LIBDIR}')
485 test_subdirs = [
486 'complex',
487 'events.d',
488 'eventscripts',
489 'onnode',
490 'simple',
491 'takeover',
492 'tool'
495 for t in test_subdirs:
496 files = SUBDIR_MODE('tests/%s' % t, trim_path='tests')
497 for fmode in files:
498 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR, 'tests/%s' % fmode[0],
499 destname=fmode[0], chmod=fmode[1])
501 # Install tests/scripts directory without test_wrap
502 test_scripts = [
503 'common.sh',
504 'integration.bash',
505 'unit.sh'
508 for t in test_scripts:
509 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR,
510 os.path.join('tests/scripts', t),
511 destname=os.path.join('scripts', t))
513 sed_expr = 's@^TEST_SCRIPTS_DIR=.*@&\\nexport TEST_BIN_DIR=\"%s\"@' % (
514 bld.env.CTDB_TEST_LIBDIR)
515 bld.SAMBA_GENERATOR('ctdb-test-wrap',
516 source='tests/scripts/test_wrap',
517 target='test_wrap',
518 rule='sed -e "%s" ${SRC} > ${TGT}' % sed_expr)
519 bld.INSTALL_FILES(bld.env.CTDB_TEST_DATADIR+"/scripts", 'test_wrap',
520 destname='test_wrap', chmod=0755)
522 sed_expr1 = 's@^test_dir=.*@test_dir=%s\\nexport TEST_BIN_DIR=\"%s\"@' % (
523 bld.env.CTDB_TEST_DATADIR, bld.env.CTDB_TEST_LIBDIR)
524 sed_expr2 = 's@^\(export CTDB_TESTS_ARE_INSTALLED\)=false@\\1=true@'
525 bld.SAMBA_GENERATOR('ctdb-test-runner',
526 source='tests/run_tests.sh',
527 target='ctdb_run_tests.sh',
528 rule='sed -e "%s" -e "%s" ${SRC} > ${TGT}' % (
529 sed_expr1, sed_expr2))
530 bld.INSTALL_FILES('${BINDIR}', 'ctdb_run_tests.sh',
531 destname='ctdb_run_tests', chmod=0755)
532 bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
533 'ctdb_run_tests')
535 test_eventscript_links = [
536 'events.d',
537 'functions',
538 'nfs-rpc-checks.d'
541 test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
542 'eventscripts/etc-ctdb')
543 for t in test_eventscript_links:
544 bld.symlink_as(os.path.join(test_link_dir, t),
545 os.path.join(bld.env.CTDB_ETCDIR, t))
548 def testonly(ctx):
549 cmd = 'tests/run_tests.sh -V tests/var'
550 ret = samba_utils.RUN_COMMAND(cmd)
551 if ret != 0:
552 print('tests exited with exit status %d' % ret)
553 sys.exit(ret)
556 def test(ctx):
557 import Scripting
558 Scripting.commands.append('build')
559 Scripting.commands.append('testonly')
562 def autotest(ctx):
563 cmd = 'LD_PRELOAD=bin/shared/libsocket-wrapper.so tests/run_tests.sh -e -S -C'
564 ret = samba_utils.RUN_COMMAND(cmd)
565 if ret != 0:
566 print('autotest exited with exit status %d' % ret)
567 sys.exit(ret)
570 def show_version(ctx):
571 print VERSION
574 def dist():
575 samba_dist.DIST_FILES('VERSION:VERSION', extend=True)
577 t = 'include/ctdb_version.h'
578 cmd = 'packaging/mkversion.sh %s %s' % (t, VERSION)
579 ret = samba_utils.RUN_COMMAND(cmd)
580 if ret != 0:
581 print('Command "%s" failed with exit status %d' % (cmd, ret))
582 sys.exit(ret)
583 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
585 t = 'ctdb.spec'
586 sed_expr1 = 's/@VERSION@/%s/g' % VERSION
587 sed_expr2 = 's/@RELEASE@/%s/g' % '1'
588 cmd = 'sed -e "%s" -e "%s" packaging/RPM/ctdb.spec.in > %s' % (
589 sed_expr1, sed_expr2, t)
590 ret = samba_utils.RUN_COMMAND(cmd)
591 if ret != 0:
592 print('Command "%s" failed with exit status %d' % (cmd, ret))
593 sys.exit(ret)
594 samba_dist.DIST_FILES('ctdb/%s:%s' % (t, t), extend=True)
596 manpages = [
597 'ctdb.1',
598 'ctdb.7',
599 'ctdbd.1',
600 'ctdbd.conf.5',
601 'ctdbd_wrapper.1',
602 'ctdb-tunables.7',
603 'ltdbtool.1'
606 cmd = 'make -C doc'
607 ret = samba_utils.RUN_COMMAND(cmd)
608 if ret != 0:
609 print('Command "%s" failed with exit status %d' % (cmd, ret))
610 sys.exit(ret)
611 for t in manpages:
612 samba_dist.DIST_FILES('ctdb/doc/%s:doc/%s' % (t, t), extend=True)
613 samba_dist.DIST_FILES('ctdb/doc/%s.html:doc/%s.html' % (t, t),
614 extend=True)
616 samba_dist.dist()
619 def rpmonly(ctx):
620 cmd = 'rpmbuild -ta --clean --rmsource ctdb-%s.tar.gz' % VERSION
621 ret = samba_utils.RUN_COMMAND(cmd)
622 if ret != 0:
623 print('rpmbuild exited with exit status %d' % ret)
624 sys.exit(ret)
627 def rpm(ctx):
628 import Scripting
629 Scripting.commands.append('dist')
630 Scripting.commands.append('rpmonly')
633 def ctags(ctx):
634 "build 'tags' file using ctags"
635 import Utils
636 source_root = os.path.dirname(Utils.g_module.root_path)
637 cmd = 'ctags $(find %s -name "*.[ch]")' % source_root
638 print("Running: %s" % cmd)
639 ret = samba_utils.RUN_COMMAND(cmd)
640 if ret != 0:
641 print('ctags failed with exit status %d' % ret)
642 sys.exit(ret)