[Git][NTPsec/ntpsec][master] Run ldconfig during install

James Browning gitlab at mg.gitlab.com
Fri Dec 4 15:22:04 UTC 2020



James Browning pushed to branch master at NTPsec / ntpsec


Commits:
4b32f859 by Richard Laager at 2020-12-04T15:13:25+00:00
Run ldconfig during install

If the system has ldconfig (Linux does) and the FFI library is being
installed, run ldconfig to "bless" the library.  Otherwise, it will not
be found by the dynamic linker at runtime.

Also, update the documentation.

- - - - -


3 changed files:

- README-PYTHON
- libntp/wscript
- wscript


Changes:

=====================================
README-PYTHON
=====================================
@@ -78,8 +78,13 @@ OTOH if you are running into something like:
     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.
+not find it.  If it is being installed to the wrong location on your platform,
+you can correct the install location using: waf configure --libdir=  If you
+are intentionally installing to a non-default location, you can modify the
+dynamic linker's search path globally (e.g. /etc/ld.so.conf or
+/etc/ld.so.conf.d/) or in your environment (e.g. LD_LIBRARY_PATH).
+
+On some platforms, it is necessary to run ldconfig after installing libraries.
+This is normally done by the waf install step, but it may have failed.  When
+using a temporary --destdir (e.g. as part of package builds), ldconfig must be
+run manually after the library is installed to its final location.


=====================================
libntp/wscript
=====================================
@@ -1,5 +1,9 @@
 import os
 
+import waflib
+from waflib import Errors, Options
+from waflib.Logs import pprint
+
 def build(ctx):
 
     libntp_source = [
@@ -59,6 +63,7 @@ def build(ctx):
             use="M RT CRYPTO",
             vnum=ctx.env['ntpcver'],
         )
+        ctx.add_post_fun(post)
     elif ctx.env['ntpc'] == 'ext':
         # Loadable Python extension
         ctx(
@@ -69,3 +74,33 @@ def build(ctx):
             target="../pylib/ntpc",  # Put the output in the pylib directory
             use="M RT CRYPTO",
         )
+
+def post(ctx):
+    if not (ctx.cmd == 'install' and ctx.env.BIN_LDCONFIG):
+        return
+
+    destdir = Options.options.destdir
+    if destdir:
+        # When --destdir is set, we are by definition not installing to the
+        # real location, so running ldconfig is pointless.  It will need to
+        # be run manually by the user (or the package install process, if
+        # this is a package build).
+        pprint("YELLOW", "WARNING:")
+        pprint("YELLOW", "WARNING: Run ldconfig manually.")
+        pprint("YELLOW", "WARNING:")
+        return
+
+    # Try to run ldconfig.  It is not a fatal error here if it fails, as the
+    # install could be run by a non-root user.
+    ldconfig = ' '.join(ctx.env.BIN_LDCONFIG)
+    try:
+        out = ctx.cmd_and_log(
+            ctx.env.BIN_LDCONFIG, output=waflib.Context.STDOUT,
+            quiet=waflib.Context.BOTH)
+        pprint("GREEN", "running: %s  OK" % ldconfig)
+    except Errors.WafError as e:
+        pprint("RED", "running: %s  FAILED" % ldconfig)
+        if e.stdout:
+            pprint("RED", e.stdout)
+        if e.stderr:
+            pprint("RED", e.stderr)


=====================================
wscript
=====================================
@@ -129,6 +129,14 @@ def configure(ctx):
     ctx.load('compiler_c')
     ctx.start_msg('Checking compiler version')
     ctx.end_msg("%s" % ".".join(ctx.env.CC_VERSION))
+
+    # Some distros do not have /sbin in the PATH for non-root users.  We honor
+    # the real PATH first, but append the sbin directories.
+    ctx.find_program(
+        "ldconfig", var="BIN_LDCONFIG", mandatory=False,
+        path_list=(os.environ.get('PATH','').split(os.pathsep) +
+            ["/sbin", "/usr/sbin", "/usr/local/sbin"]))
+
     # Ensure m4 is present, or bison will fail with SIGPIPE
     ctx.find_program('m4')
     ctx.load('bison')



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/4b32f8595ebc849add4caaf5a70884c05d791a50

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/4b32f8595ebc849add4caaf5a70884c05d791a50
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/20201204/82863ec4/attachment-0001.htm>


More information about the vc mailing list