ctdb-common: Add config file parsing code
[vlendec/samba-autobuild/.git] / ctdb / wscript
index a35b138eba4c42dbd81e0bdb0bbf53db4100b9d0..7c417aab93eadbcc8e180e85f2e0ece29a4bc786 100644 (file)
@@ -30,7 +30,7 @@ default_prefix = Options.default_prefix = '/usr/local'
 
 samba_dist.DIST_DIRS('''ctdb:. lib/replace:lib/replace lib/talloc:lib/talloc
                         lib/tevent:lib/tevent lib/tdb:lib/tdb
-                        lib/socket_wrapper:lib/socket_wrapper
+                        third_party/socket_wrapper:third_party/socket_wrapper
                         third_party/popt:third_party/popt
                         lib/util:lib/util lib/tdb_wrap:lib/tdb_wrap
                         lib/ccan:lib/ccan libcli/util:libcli/util
@@ -48,6 +48,8 @@ manpages_misc = [
     'ctdb_diagnostics.1',
     'ctdbd_wrapper.1',
     'onnode.1',
+    'ctdb-script.options.5',
+    'ctdb.sysconfig.5',
     'ctdbd.conf.5',
     'ctdb.7',
     'ctdb-statistics.7',
@@ -112,20 +114,29 @@ def configure(conf):
 
     if conf.CHECK_FOR_THIRD_PARTY():
         conf.RECURSE('third_party/popt')
+        if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
+            conf.RECURSE('third_party/socket_wrapper')
+            conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
     else:
         if not conf.CHECK_POPT():
             raise Utils.WafError('popt development packages have not been found\nIf third_party is installed, check that it is in the proper place.')
         else:
             conf.define('USING_SYSTEM_POPT', 1)
+        conf.env.SOCKET_WRAPPER_SO_PATH = ''
+
+
+        if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
+            if not conf.CHECK_SOCKET_WRAPPER():
+                raise Utils.WafError('socket_wrapper package has not been found.\nIf third_party is installed, check that it is in the proper place.')
+            else:
+                conf.define('USING_SYSTEM_SOCKET_WRAPPER', 1)
+                conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
 
     conf.RECURSE('lib/util')
 
     conf.RECURSE('lib/talloc')
     conf.RECURSE('lib/tevent')
     conf.RECURSE('lib/tdb')
-    if conf.env.standalone_ctdb or conf.CONFIG_GET('ENABLE_SELFTEST'):
-        conf.RECURSE('lib/socket_wrapper')
-        conf.env.SOCKET_WRAPPER_SO_PATH = conf.CONFIG_GET('LIBSOCKET_WRAPPER_SO_PATH')
 
     conf.CHECK_HEADERS('sched.h')
     conf.CHECK_HEADERS('procinfo.h')
@@ -166,6 +177,7 @@ def configure(conf):
         if not conf.CHECK_FUNCS_IN('pmdaDaemon', 'pcp_pmda'):
             pmda_support = False
         if pmda_support:
+            conf.CHECK_TYPE_IN('__pmID_int', 'pcp/pmapi.h pcp/impl.h')
             have_pmda = True
         else:
             Logs.error("PMDA support not available")
@@ -315,6 +327,8 @@ def build(bld):
     bld.RECURSE('lib/replace')
     if bld.CHECK_FOR_THIRD_PARTY():
         bld.RECURSE('third_party/popt')
+        if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
+            bld.RECURSE('third_party/socket_wrapper')
 
     bld.RECURSE('lib/tdb_wrap')
     bld.RECURSE('lib/util')
@@ -323,8 +337,6 @@ def build(bld):
     bld.RECURSE('lib/talloc')
     bld.RECURSE('lib/tevent')
     bld.RECURSE('lib/tdb')
-    if bld.env.standalone_ctdb or bld.CONFIG_GET('SOCKET_WRAPPER'):
-        bld.RECURSE('lib/socket_wrapper')
 
     if bld.env.standalone_ctdb:
         # If a combined build is implemented, CTDB will want to
@@ -377,7 +389,8 @@ def build(bld):
                                           '''ctdb_io.c ctdb_util.c ctdb_ltdb.c
                                              sock_io.c'''),
                         includes='include',
-                        deps='replace popt talloc tevent tdb popt ctdb-system')
+                        deps='''replace popt talloc tevent tdb popt ctdb-system
+                                ctdb-protocol-util''')
 
     bld.SAMBA_SUBSYSTEM('ctdb-util',
                         source=bld.SUBDIR('common',
@@ -385,9 +398,12 @@ def build(bld):
                                              pkt_read.c pkt_write.c comm.c
                                              logging.c rb_tree.c tunable.c
                                              pidfile.c run_proc.c
-                                             hash_count.c run_event.c'''),
+                                             hash_count.c run_event.c
+                                             sock_client.c version.c
+                                             cmdline.c path.c conf.c
+                                          '''),
                         deps='''samba-util sys_rw tevent-util
-                                replace talloc tevent tdb''')
+                                replace talloc tevent tdb popt''')
 
     bld.SAMBA_SUBSYSTEM('ctdb-protocol',
                         source=bld.SUBDIR('protocol',
@@ -397,27 +413,26 @@ def build(bld):
                                              protocol_message.c
                                              protocol_control.c
                                              protocol_keepalive.c
+                                             protocol_tunnel.c
                                              protocol_client.c
                                              protocol_debug.c
-                                             protocol_util.c
-                                             protocol_event.c'''),
+                                             protocol_event.c
+                                             protocol_sock.c'''),
                         includes='include',
                         deps='replace talloc tdb')
 
-    bld.SAMBA_SUBSYSTEM('ctdb-client',
-                        source=bld.SUBDIR('client', 'ctdb_client.c'),
-                        includes='include',
-                        deps='''replace popt talloc tevent tdb
-                                samba-util tdb-wrap ctdb-util''')
+    bld.SAMBA_SUBSYSTEM('ctdb-protocol-util',
+                        source='protocol/protocol_util.c',
+                        deps='replace talloc tdb')
 
-    bld.SAMBA_SUBSYSTEM('ctdb-client2',
+    bld.SAMBA_SUBSYSTEM('ctdb-client',
                         source=bld.SUBDIR('client',
                                           '''client_connect.c client_call.c
                                              client_message.c client_control.c
                                              client_message_sync.c
                                              client_control_sync.c
                                              client_db.c client_util.c
-                                             client_event.c
+                                             client_event.c client_tunnel.c
                                           '''),
                         includes='include',
                         deps='replace talloc tevent tdb tdb-wrap')
@@ -426,7 +441,7 @@ def build(bld):
                         source=bld.SUBDIR('common',
                                           '''sock_daemon.c'''),
                         deps='''samba-util ctdb-util tevent-util
-                                replace talloc tevent''')
+                                LIBASYNC_REQ replace talloc tevent''')
 
     bld.SAMBA_SUBSYSTEM('ctdb-ipalloc',
                         source=bld.SUBDIR('server',
@@ -437,7 +452,13 @@ def build(bld):
                                              ipalloc.c
                                           '''),
                         includes='include',
-                        deps='ctdb-protocol replace talloc tevent')
+                        deps='ctdb-protocol-util replace talloc tevent')
+
+    bld.SAMBA_BINARY('ctdb-path',
+                     source='common/path_tool.c',
+                     cflags='-DCTDB_PATH_TOOL',
+                     deps='''ctdb-util samba-util talloc replace popt''',
+                     install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ctdbd',
                      source='server/ctdbd.c ' +
@@ -456,32 +477,33 @@ def build(bld):
                                              ctdb_vacuum.c ctdb_banning.c
                                              ctdb_statistics.c
                                              ctdb_update_record.c
-                                             ctdb_lock.c ctdb_fork.c'''),
+                                             ctdb_lock.c ctdb_fork.c
+                                             ctdb_tunnel.c ctdb_client.c'''),
                      includes='include',
-                     deps='''ctdb-ipalloc ctdb-client ctdb-common ctdb-system
+                     deps='''ctdb-common ctdb-system ctdb-protocol
                              ctdb-tcp ctdb-util replace sys_rw popt
-                             talloc tevent tdb talloc_report''' +
+                             talloc tevent tdb-wrap tdb talloc_report''' +
                           ib_deps,
                      install_path='${SBINDIR}',
                      manpages='ctdbd.1')
 
     bld.SAMBA_BINARY('ctdb',
                      source='tools/ctdb.c',
-                     deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
-                             samba-util sys_rw popt''',
+                     deps='''ctdb-client ctdb-protocol ctdb-protocol-util
+                             ctdb-util ctdb-system samba-util sys_rw popt''',
                      install_path='${BINDIR}',
                      manpages='ctdb.1')
 
     bld.SAMBA_BINARY('ctdb_killtcp',
                      source='tools/ctdb_killtcp.c',
-                     deps='''ctdb-protocol ctdb-util ctdb-system
+                     deps='''ctdb-protocol-util ctdb-util ctdb-system
                              samba-util replace''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ctdb_event',
                      source='tools/ctdb_event.c',
-                     deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system
-                             samba-util replace''',
+                     deps='''ctdb-client ctdb-protocol ctdb-protocol-util
+                             ctdb-util ctdb-system samba-util replace''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ltdbtool',
@@ -493,8 +515,8 @@ def build(bld):
 
     bld.SAMBA_BINARY('ctdb_eventd',
                      source='server/ctdb_eventd.c',
-                     deps='''ctdb-server-util ctdb-protocol ctdb-util
-                             samba-util LIBASYNC_REQ replace popt''',
+                     deps='''ctdb-server-util ctdb-protocol ctdb-protocol-util
+                             ctdb-util samba-util replace popt''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ctdb_lock_helper',
@@ -506,13 +528,13 @@ def build(bld):
 
     bld.SAMBA_BINARY('ctdb_recovery_helper',
                      source='server/ctdb_recovery_helper.c',
-                     deps='''ctdb-client2 ctdb-protocol ctdb-util
+                     deps='''ctdb-client ctdb-protocol ctdb-util
                              samba-util sys_rw replace tdb''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
     bld.SAMBA_BINARY('ctdb_takeover_helper',
                      source='server/ctdb_takeover_helper.c',
-                     deps='''ctdb-client2 ctdb-protocol ctdb-util
+                     deps='''ctdb-client ctdb-protocol ctdb-util
                              samba-util sys_rw replace ctdb-ipalloc popt''',
                      install_path='${CTDB_HELPER_BINDIR}')
 
@@ -542,7 +564,7 @@ def build(bld):
     bld.SAMBA_BINARY('smnotify',
                      source=bld.SUBDIR('utils/smnotify',
                                        'smnotify.c gen_smnotify.c gen_xdr.c'),
-                     deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt',
+                     deps='ctdb-smnotify-h ctdb-smnotify-c ctdb-smnotify-x popt tirpc',
                      includes='utils utils/smnotify',
                      install_path='${CTDB_HELPER_BINDIR}')
 
@@ -556,7 +578,7 @@ def build(bld):
         bld.SAMBA_BINARY('pmdactdb',
                          source='utils/pmda/pmda_ctdb.c',
                          includes='include',
-                         deps='''ctdb-client2 ctdb-protocol ctdb-util
+                         deps='''ctdb-client ctdb-protocol ctdb-util
                                  samba-util pcp_pmda pcp''',
                          install_path='${CTDB_PMDADIR}')
         bld.INSTALL_FILES('${CTDB_PMDADIR}', 'utils/pmda/Install',
@@ -696,7 +718,6 @@ def build(bld):
         'ctdb-crash-cleanup.sh',
         'debug-hung-script.sh',
         'debug_locks.sh',
-        'gcore_trace.sh',
         'nfs-linux-kernel-callout',
         'notify.sh',
         'statd-callout'
@@ -735,6 +756,8 @@ def build(bld):
         'sock_io_test',
         'hash_count_test',
         'run_event_test',
+        'cmdline_test',
+        'conf_test',
     ]
 
     for target in ctdb_unit_tests:
@@ -742,7 +765,7 @@ def build(bld):
 
         bld.SAMBA_BINARY(target,
                          source=src,
-                         deps='''talloc tevent tdb tevent-util
+                         deps='''talloc tevent tdb tevent-util popt
                                  LIBASYNC_REQ samba-util sys_rw''',
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
@@ -812,7 +835,10 @@ def build(bld):
         'transaction_loop',
         'update_record',
         'update_record_persistent',
-        'lock_tdb'
+        'lock_tdb',
+        'dummy_client',
+        'tunnel_test',
+        'tunnel_cmd',
     ]
 
     for target in ctdb_tests:
@@ -821,7 +847,7 @@ def build(bld):
         bld.SAMBA_BINARY(target,
                          source=src,
                          includes='include',
-                         deps='''ctdb-client2 ctdb-protocol ctdb-util
+                         deps='''ctdb-client ctdb-protocol ctdb-util
                                  samba-util ctdb-tests-common''',
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
@@ -837,15 +863,16 @@ def build(bld):
     bld.SAMBA_BINARY('fake_ctdbd',
                      source='''tests/src/fake_ctdbd.c
                                tests/src/ipalloc_read_known_ips.c''',
-                     deps='''ctdb-util ctdb-protocol ctdb-system
-                             samba-util tevent-util LIBASYNC_REQ popt''',
+                     deps='''ctdb-util ctdb-protocol ctdb-protocol-util
+                             ctdb-system samba-util tevent-util
+                             LIBASYNC_REQ popt''',
                      install_path='${CTDB_TEST_LIBEXECDIR}')
 
     if bld.env.HAVE_INFINIBAND:
         bld.SAMBA_BINARY('ibwrapper_test',
                          source='ib/ibwrapper_test.c',
                          includes='include',
-                         deps='replace talloc ctdb-client ctdb-common sys_rw' +
+                         deps='replace talloc ctdb-common sys_rw' +
                               ib_deps,
                          install_path='${CTDB_TEST_LIBEXECDIR}')
 
@@ -859,7 +886,6 @@ def build(bld):
         'complex',
         'cunit',
         'eventd',
-        'events.d',
         'eventscripts',
         'onnode',
         'shellcheck',
@@ -923,31 +949,6 @@ def build(bld):
     bld.symlink_as(os.path.join(bld.env.BINDIR, 'ctdb_run_cluster_tests'),
                    'ctdb_run_tests')
 
-    test_eventscript_links = [
-        'events.d',
-        'functions',
-        'nfs-checks.d',
-        'nfs-linux-kernel-callout',
-        'statd-callout'
-    ]
-
-    test_link_dir = os.path.join(bld.env.CTDB_TEST_DATADIR,
-                                 'eventscripts/etc-ctdb')
-    for t in test_eventscript_links:
-        bld.symlink_as(os.path.join(test_link_dir, t),
-                       os.path.join(bld.env.CTDB_ETCDIR, t))
-
-    # Tests that use onnode need to overwrite link to in-tree
-    # functions file when installed
-    bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'onnode/functions'),
-                   os.path.join(bld.env.CTDB_ETCDIR, 'functions'))
-    bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple/functions'),
-                   os.path.join(bld.env.CTDB_ETCDIR, 'functions'))
-
-    # Need a link to nodes file because $CTDB_BASE is overridden
-    bld.symlink_as(os.path.join(bld.env.CTDB_TEST_DATADIR, 'simple/nodes'),
-                   os.path.join(bld.env.CTDB_ETCDIR, 'nodes'))
-
 
 def testonly(ctx):
     cmd = 'tests/run_tests.sh -V tests/var'
@@ -965,8 +966,7 @@ def test(ctx):
 
 def autotest(ctx):
     env = samba_utils.LOAD_ENVIRONMENT()
-    ld = 'LD_PRELOAD=%s' % env.SOCKET_WRAPPER_SO_PATH
-    cmd = '%s tests/run_tests.sh -e -S -C' % ld
+    cmd = 'tests/run_tests.sh -e -S %s -C' % env.SOCKET_WRAPPER_SO_PATH
     ret = samba_utils.RUN_COMMAND(cmd)
     if ret != 0:
         print('autotest exited with exit status %d' % ret)