[Git][NTPsec/ntpsec][master] 3 commits: FFI: Fix the libntpc install path.

James Browning gitlab at mg.gitlab.com
Fri Nov 20 23:04:37 UTC 2020



James Browning pushed to branch master at NTPsec / ntpsec


Commits:
2c81d1cb by James Browning at 2020-11-17T10:17:00-08:00
FFI: Fix the libntpc install path.

- - - - -
6e5cac90 by James Browning at 2020-11-18T18:14:24-08:00
Docs: libntpc related changes


- - - - -
a4c2c792 by James Browning at 2020-11-18T18:18:18-08:00
bin test: from install directory recording skips


- - - - -


6 changed files:

- INSTALL.adoc
- README-PYTHON
- docs/build.adoc
- libntp/wscript
- wafhelpers/bin_test.py
- wscript


Changes:

=====================================
INSTALL.adoc
=====================================
@@ -150,6 +150,11 @@ Under Unix, the simplest way to compile this package is:
      configure and compile the package for a different kind of
      computer), run `./waf distclean`.
 
+=== ldconfig ===
+
+It may be necessary after installing on some systems (incl. Linux) to
+rebuild the ld.so cache or equivalent if using the FFI library (default).
+
 === Solaris ===
 
 When building the NTPsec suite using gcc under Solaris, you may see


=====================================
README-PYTHON
=====================================
@@ -49,3 +49,37 @@ This works for all users, including root.
 Note that the pth file must be on the default Python search path.
 
 
+OTOH if you run into something like:
+    Traceback (most recent call last):
+      File "/usr/bin/ntpdig", line 419, in <module>
+        timeout=timeout)
+      File "/usr/bin/ntpdig", line 109, in queryhost
+        keyid, keytype, passwd)
+      File "/usr/lib/python3/dist-packages/ntp/packet.py", line 1747, in compute_mac
+        if not ntp.ntpc.checkname(keytype):
+    AttributeError: module 'ntp.ntpc' has no attribute 'checkname'
+
+Then you probably want to either uninstall the previous Python extension, or
+install one after 1.1.9 (798b93) by adding the '--enable-pylib ext' option
+without quotes.
+
+OTOH if you are running into something like:
+    Traceback (most recent call last):
+    File "/usr/bin/ntpdig", line 19, in <module>
+        import ntp.packet
+    File "/usr/lib/python3/dist-packages/ntp/packet.py", line 219, in <module>
+        import ntp.ntpc
+    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 52, in <module>
+        _ntpc = _importado()
+    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 38, in _importado
+        return _dlo(ntpc_paths)
+    File "/usr/lib/python3/dist-packages/ntp/ntpc.py", line 49, in _dlo
+        raise OSError("Can't find %s library" % LIB)
+    OSError: Can't find ntpc library
+
+That means is that ntpc.py looked for libnptc.so in the usual places and could
+not find it either because it was installed in a subdirectory or in a
+directory that was not checked by Python. In either case, the recommendation is
+to update to a post 1.2.0 (2c81d1) install. Alternatively one could move the
+file and symlinks into a directory in the search path. This is left as an
+exercise for the reader.


=====================================
docs/build.adoc
=====================================
@@ -66,7 +66,8 @@ source tree. In the distribution base directory use the
 This command inspects the hardware and software environment and
 configures the build process accordingly. Use the +./waf build+ command to
 compile and link the distribution and the +./waf install+ command to install
-the executables by default in +/usr/local/bin+.
+the executables by default in +/usr/local/bin+. It may be necessary to run
++ldconfig+ on Linux systems if using the FFI library (default).
 
 [[conf]]
 == Configuration


=====================================
libntp/wscript
=====================================
@@ -53,7 +53,6 @@ def build(ctx):
         # Loadable FFI stub
         ctx(
             features="c cshlib",
-            install_path='${LIBDIR}/ntp',
             includes=[ctx.bldnode.parent.abspath(), "../include"],
             source=["ntp_c.c", "pymodule-mac.c"] + libntp_source_sharable,
             target="../pylib/ntpc",  # Put the output in the pylib directory


=====================================
wafhelpers/bin_test.py
=====================================
@@ -9,68 +9,77 @@ import waflib.Utils
 sys.path.insert(0, "%s/main/tests/pylib" % waflib.Context.out_dir)
 import ntp.util
 
-verStr = ntp.util.stdversion()
+version = ntp.util.stdversion()
+Popen = waflib.Utils.subprocess.Popen
 
+cmd_smap = {
+    ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % version,
+}
 cmd_map = {
     ("main/ntpclients/ntpleapfetch", "--version"): "ntpleapfetch %s\n"
-                                                   % verStr,
-    ("main/ntpd/ntpd", "--version"): "ntpd %s\n" % verStr,
-    ("main/ntpfrob/ntpfrob", "-V"): "ntpfrob %s\n" % verStr,
-    ("main/ntptime/ntptime", "-V"): "ntptime %s\n" % verStr
+                                                   % version,
+    ("main/ntpfrob/ntpfrob", "-V"): "ntpfrob %s\n" % version,
+    ("main/ntptime/ntptime", "-V"): "ntptime %s\n" % version
 }
 cmd_map_python = {
-    ("main/ntpclients/ntpdig", "--version"): "ntpdig %s\n" % verStr,
-    ("main/ntpclients/ntpkeygen", "--version"): "ntpkeygen %s\n" % verStr,
-    ("main/ntpclients/ntpq", "--version"): "ntpq %s\n" % verStr,
-    ("main/ntpclients/ntpsnmpd", "--version"): "ntpsnmpd %s\n" % verStr,
-    ("main/ntpclients/ntpsweep", "--version"): "ntpsweep %s\n" % verStr,
-    ("main/ntpclients/ntptrace", "--version"): "ntptrace %s\n" % verStr,
-    ("main/ntpclients/ntpwait", "--version"): "ntpwait %s\n" % verStr
+    ("main/ntpclients/ntpdig", "--version"): "ntpdig %s\n" % version,
+    ("main/ntpclients/ntpkeygen", "--version"): "ntpkeygen %s\n" % version,
+    ("main/ntpclients/ntpq", "--version"): "ntpq %s\n" % version,
+    ("main/ntpclients/ntpsnmpd", "--version"): "ntpsnmpd %s\n" % version,
+    ("main/ntpclients/ntpsweep", "--version"): "ntpsweep %s\n" % version,
+    ("main/ntpclients/ntptrace", "--version"): "ntptrace %s\n" % version,
+    ("main/ntpclients/ntpwait", "--version"): "ntpwait %s\n" % version
 }
 # Need argparse
 cmd_map_python_argparse = {
-    ("main/ntpclients/ntplogtemp", "--version"): "ntplogtemp %s\n" % verStr,
-    ("main/ntpclients/ntpviz", "--version"): "ntpviz %s\n" % verStr,
+    ("main/ntpclients/ntplogtemp", "--version"): "ntplogtemp %s\n" % version,
+    ("main/ntpclients/ntpviz", "--version"): "ntpviz %s\n" % version,
 }
 # Need python curses
 cmd_map_python_curses = {
-    ("main/ntpclients/ntpmon", "--version"): "ntpmon %s\n" % verStr,
+    ("main/ntpclients/ntpmon", "--version"): "ntpmon %s\n" % version,
 }
 
 test_logs = []
 
 
 def addLog(color, text):
+    """Add to the log."""
     test_logs.append((color, text))
 
 
-def bin_test_summary(ctx):
+def bin_test_summary(_):
+    """Print out the log."""
     for i in test_logs:
         waflib.Logs.pprint(i[0], i[1])
 
 
-def run(cmd, reg, pythonic):
+def run(cmd, reg, pythonic, apath=None, environ=None):
     """Run an individual non-python test."""
     check = False
+    odir = apath if apath else waflib.Context.out_dir
 
+    environ = {} if environ is None else environ
+    if apath:
+        cmd = [os.sep.join(['.'] + cmd[0].split(os.sep)[-1:])] + list(cmd[1:])
     prefix = "running: " + " ".join(cmd)
-
-    if not os.path.exists("%s/%s" % (waflib.Context.out_dir, cmd[0])):
-        addLog("YELLOW", prefix + " SKIPPING (does not exist)")
-        return False
-
-    if pythonic:
-        cmd = [sys.executable] + list(cmd)
-    p = waflib.Utils.subprocess.Popen(cmd, env={'PYTHONPATH': '%s/main/tests/pylib' %
-                                                 waflib.Context.out_dir},
-                         universal_newlines=True,
-                         stdin=waflib.Utils.subprocess.PIPE,
-                         stdout=waflib.Utils.subprocess.PIPE,
-                         stderr=waflib.Utils.subprocess.PIPE, cwd=waflib.Context.out_dir)
+    if not os.path.exists("%s/%s" % (odir, cmd[0])):
+        addLog("YELLOW", '"%s" SKIPPING (does not exist)' % "%s/%s" % (odir, cmd[0]))
+        return None
+    if not apath:
+        if pythonic:
+            cmd = [sys.executable] + list(cmd)
+            prefix = "running: " + " ".join(cmd)
+
+    p = Popen(cmd, universal_newlines=True,
+              env=environ, cwd=odir,
+              stdin=waflib.Utils.subprocess.PIPE,
+              stdout=waflib.Utils.subprocess.PIPE,
+              stderr=waflib.Utils.subprocess.PIPE)
 
     stdout, stderr = p.communicate()
 
-    if (stdout == reg) or (stderr == reg):
+    if reg in (stdout, stderr):
         check = True
 
     if check:
@@ -85,9 +94,22 @@ def run(cmd, reg, pythonic):
     return False
 
 
-def cmd_bin_test(ctx, config):
+def cmd_bin_test(ctx):
     """Run a suite of binary tests."""
     fails = 0
+    skips = 0
+    env = {}
+
+    destdir = os.path.abspath(os.environ.get('DESTDIR', '/'))
+    path = spath = None
+
+    if ctx.cmd == 'install':
+        pypath = destdir + ctx.env.PYTHONARCHDIR  # + os.sep + 'ntp'
+        env = {'PYTHONPATH': pypath} if destdir != '/' else {}
+        path = destdir + os.sep if destdir != '/' else '/'
+        spath = path + ctx.env.SBINDIR[1:] + os.sep
+        path = path + ctx.env.BINDIR[1:] + os.sep
+        addLog('BLUE', 'Following relative to: %s' % spath)
 
     if ctx.env['PYTHON_ARGPARSE']:
         cmd_map_python.update(cmd_map_python_argparse)
@@ -95,17 +117,34 @@ def cmd_bin_test(ctx, config):
     if ctx.env['PYTHON_CURSES']:
         cmd_map_python.update(cmd_map_python_curses)
 
+    for cmd in sorted(cmd_smap):
+        status = run(cmd, cmd_smap[cmd], False, spath, env)
+        fails = fails + 1 if status is False else fails
+        skips = skips + 1 if status is None else skips
+
+    if ctx.cmd == 'install':
+        addLog('BLUE', 'Following relative to: %s' % path)
+
     for cmd in sorted(cmd_map):
-        if not run(cmd, cmd_map[cmd], False):
-            fails += 1
+        status = run(cmd, cmd_map[cmd], False, path, env)
+        fails = fails + 1 if status is False else fails
+        skips = skips + 1 if status is None else skips
 
     for cmd in sorted(cmd_map_python):
-        if not run(cmd, cmd_map_python[cmd], True):
-            fails += 1
+        status = run(cmd, cmd_map_python[cmd], True, path, env)
+        fails = fails + 1 if status is False else fails
+        skips = skips + 1 if status is None else skips
 
-    if 1 == fails:
+    if skips > 0 or fails > 0:
         bin_test_summary(ctx)
+    if skips == 1:
+        waflib.Logs.warn("1 binary test skipped!")
+    elif skips > 1:
+        waflib.Logs.warn("%d binary tests skipped!" % skips)
+
+    if fails >= 7:
+        pass
+    if fails == 1:
         ctx.fatal("1 binary test failed!")
-    elif 1 < fails:
-        bin_test_summary(ctx)
+    elif fails > 1:
         ctx.fatal("%d binary tests failed!" % fails)


=====================================
wscript
=====================================
@@ -903,7 +903,7 @@ class check(BuildContext):
 def bin_test(ctx):
     """Run binary check, use after tests."""
     from wafhelpers.bin_test import cmd_bin_test
-    cmd_bin_test(ctx, config)
+    cmd_bin_test(ctx)
 
 
 def bin_test_summary(ctx):



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/33f883e23ed7672c11e3d1f0a7aacde7e6633a4a...a4c2c7921f144674402c2a3dbfc13a87b1ea3d1f

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/33f883e23ed7672c11e3d1f0a7aacde7e6633a4a...a4c2c7921f144674402c2a3dbfc13a87b1ea3d1f
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20201120/2936d8da/attachment-0001.htm>


More information about the vc mailing list