[Git][NTPsec/ntpsec][20L-Dec24-unholy] 6 commits: ntp.ntpc: Fix libntpc version checking.

James Browning gitlab at mg.gitlab.com
Mon Dec 28 00:44:14 UTC 2020



James Browning pushed to branch 20L-Dec24-unholy at NTPsec / ntpsec


Commits:
ea68a716 by James Browning at 2020-12-27T15:36:08-08:00
ntp.ntpc: Fix libntpc version checking.

- - - - -
1d47a640 by James Browning at 2020-12-27T16:39:50-08:00
ntpq: Do not crash on sysinfo. Use bitvector as it should be.

- - - - -
844ca3eb by James Browning at 2020-12-27T16:40:51-08:00
wscript, options: Add build decription text option.

- - - - -
c859687a by James Browning at 2020-12-27T16:40:51-08:00
build, libtnp: Hardcode 2020 Jan 01 as build epoch ...

This should be changed after 2029 Jan 23 to that date.
If I calculate right that should be the start of GPS week 2560.

- - - - -
dabc3935 by James Browning at 2020-12-27T16:40:51-08:00
test: pass output through polystr when writing build/main/test.log

- - - - -
f27feaf2 by James Browning at 2020-12-27T16:40:51-08:00
ntpviz: Do not explode but behave badly on --local-offset-multiplot

- - - - -


8 changed files:

- libntp/ntp_calendar.c
- ntpclients/ntpq.py
- ntpclients/ntpviz.py
- pylib/ntpc.py
- pylib/util.py
- wafhelpers/options.py
- wafhelpers/test.py
- wscript


Changes:

=====================================
libntp/ntp_calendar.c
=====================================
@@ -38,7 +38,7 @@ ntpcal_get_build_date(
 	struct calendar * jd
 	)
 {
-        time_t epoch = (time_t)BUILD_EPOCH;
+        time_t epoch = (time_t)1577836800; // 2020 Jan 01 -> 1863820800 - 2029 Jan 23
         struct tm epoch_tm;
 
 	ZERO(*jd);


=====================================
ntpclients/ntpq.py
=====================================
@@ -70,7 +70,7 @@ class Ntpq(cmd.Cmd):
         #  so I am leaving them, and possibly duplicating them.
         self.rawmode = False            # Flag which indicates raw mode output.
         self.directmode = False         # Flag for direct MRU output.
-        self.showhostnames = 1          # If & 1 false, display numeric IPs
+        self.showhostnames = 1          # If & 1, display names
         self.showunits = False          # If False, show old style float
         self.auth_delay = 20            # delay time (default 20msec)
         self.wideremote = False         # show wide remote names?
@@ -441,7 +441,7 @@ usage: timeout [ msec ]
                 value = queried[name][0]
                 rawvalue = queried[name][1]
                 if fmt in (NTP_ADD, NTP_ADP):
-                    if self.showhostnames[0]:
+                    if self.showhostnames & 1:  # if & 1, display names 
                         if self.debug:
                             self.say("DNS lookup begins...")
                         value = ntp.util.canonicalize_dns(


=====================================
ntpclients/ntpviz.py
=====================================
@@ -1295,7 +1295,7 @@ def local_offset_multiplot(statlist):
     plot = NTPViz.Common + '''\
 set terminal %(terminal)s size %(size)s
 set title "Multiplot Local Clock Offsets"
-set ytics format "%1.2f μs" nomirror textcolor rgb "#0060ad"
+set ytics format "%%1.2f μs" nomirror textcolor rgb "#0060ad"
 set key bottom right box
 plot \\
 ''' % out
@@ -1311,7 +1311,7 @@ plot \\
     for stats in statlist:
         # speed up by only sending gnuplot the data it will actually use
         # fields: time, offset
-        pt = NTPViz.plot_slice(stats.loopstats, 2)
+        pt = stats.plot_slice(stats.loopstats, 2)
         plot_data += pt[0]
 
     ret = {'html': '', 'stats': []}


=====================================
pylib/ntpc.py
=====================================
@@ -44,9 +44,9 @@ def _dlo(paths):
         try:
             lib = ctypes.CDLL(ntpc_path, use_errno=True)
             wrap_version = "@NTPSEC_VERSION_EXTENDED@"
-            clib_version = ctypes.c_char_p.in_dll(lib, 'version').value
+            clib_version = ntp.poly.polystr(ctypes.c_char_p.in_dll(lib, 'version').value)
             if clib_version != wrap_version:
-                sys.stderr.write("ntp.ntpc wrong version %s !== %s" % (clib_version, wrap_version))
+                sys.stderr.write("ntp.ntpc wrong version '%s' != '%s'\n" % (clib_version, wrap_version))
             return lib
         except OSError:
             pass


=====================================
pylib/util.py
=====================================
@@ -1233,7 +1233,7 @@ class MRUSummary:
         self.debug = debug
         self.logfp = logfp
         self.now = None
-        self.showhostnames = showhostnames  # If not [0], display numeric IPs
+        self.showhostnames = showhostnames  # if & 1, display names 
         self.wideremote = wideremote
 
     header = " lstint avgint rstr r m v  count    score   drop rport remote address"
@@ -1269,7 +1269,7 @@ class MRUSummary:
             rscode = '.'
         (ip, port) = portsplit(entry.addr)
         try:
-            if not self.showhostnames & 1:
+            if not self.showhostnames & 1  # if not & 1 display numeric IPs
                 dns = ip
             else:
                 dns = canonicalize_dns(ip)


=====================================
wafhelpers/options.py
=====================================
@@ -67,8 +67,8 @@ ext, ffi, or none. defaults to ffi.""", nargs=1)
     grp.add_option('--cflags', type='string', action="callback",
                    callback=callback_flags,
                    help="Users should use CFLAGS in their environment.")
-    grp.add_option('--build-epoch', type='int', default=None,
-                   help="Force epoch, or use SOURCE_DATE_EPOCH in environment")
+    grp.add_option('--build-desc', type='string', default="",
+                   help="Arbitrary text string to append to extended version.")
     grp.add_option('--ldflags', type='string', action="callback",
                    callback=callback_flags,
                    help="Users should use LDFLAGS in their environment.")


=====================================
wafhelpers/test.py
=====================================
@@ -1,6 +1,7 @@
 from __future__ import print_function
 
 from waflib.Logs import pprint
+from pylib.poly import polystr
 
 
 def test_write_log(ctx):
@@ -16,9 +17,9 @@ def test_write_log(ctx):
             fp.write("BINARY      : %s\n" % binary)
             fp.write("RETURN VALUE: %s\n" % retval)
             fp.write("\n*** stdout ***\n")
-            fp.write(str(lines))
+            fp.write(polystr(lines))
             fp.write("\n*** stderr ***\n")
-            fp.write(str(error))
+            fp.write(polystr(error))
             fp.write("\n\n\n")
 
     pprint("BLUE", "Wrote test log to: ", file_out)


=====================================
wscript
=====================================
@@ -173,40 +173,23 @@ def configure(ctx):
     if os.path.exists(".git"):
         ctx.find_program("git", var="BIN_GIT", mandatory=False)
 
-    source_date_epoch = os.getenv('SOURCE_DATE_EPOCH', None)
-    if ctx.options.build_epoch is not None:
-        build_epoch = ctx.options.build_epoch
-        ctx.define("BUILD_EPOCH", build_epoch, comment="Using --build-epoch")
-    elif source_date_epoch:
-        if not source_date_epoch.isdigit():
-            ctx.fatal("ERROR: malformed SOURCE_DATE_EPOCH")
-        build_epoch = int(source_date_epoch)
-        ctx.define("BUILD_EPOCH", build_epoch,
-                   comment="Using SOURCE_DATE_EPOCH")
-    elif ctx.env.BIN_GIT:
-        cmd = ctx.env.BIN_GIT + shlex.split("log -1 --pretty=%ct")
-        build_epoch = int(ctx.cmd_and_log(cmd).strip())
-        ctx.define("BUILD_EPOCH", build_epoch, comment="last git commit")
-    else:
-        build_epoch = int(time.time())
-        ctx.define("BUILD_EPOCH", build_epoch, comment="Using default")
-
-    build_epoch_formatted = datetime.utcfromtimestamp(build_epoch).strftime(
-        "%Y-%m-%dT%H:%M:%SZ")
+    build_desc = ctx.options.build_desc.strip()
+    if build_desc:
+        build_desc = ' ' + build_desc
     if ctx.env.BIN_GIT:
         cmd = ctx.env.BIN_GIT + shlex.split("describe --dirty")
         git_short_hash = ctx.cmd_and_log(cmd).strip()
         git_short_hash = '-'.join(git_short_hash.split('-')[1:])
 
         ctx.env.NTPSEC_VERSION = "%s+" % ntpsec_release
-        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s %s" %
+        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s+%s%s" %
                                            (ntpsec_release,
                                             git_short_hash,
-                                            build_epoch_formatted))
+                                            build_desc))
     else:
         ctx.env.NTPSEC_VERSION = "%s" % ntpsec_release
-        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s %s" % (ntpsec_release,
-                                                      build_epoch_formatted))
+        ctx.env.NTPSEC_VERSION_EXTENDED = ("%s%s" % (ntpsec_release,
+                                                      build_desc))
     ctx.define("NTPSEC_VERSION", ctx.env.NTPSEC_VERSION)
     ctx.define("NTPSEC_VERSION_EXTENDED", ctx.env.NTPSEC_VERSION_EXTENDED)
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/9e18925e1e4f71b7cef4cf74dc3b060ffd65a8cb...f27feaf281a67137837e716b4e096f22e9c37e22

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/9e18925e1e4f71b7cef4cf74dc3b060ffd65a8cb...f27feaf281a67137837e716b4e096f22e9c37e22
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/20201228/545d242f/attachment-0001.htm>


More information about the vc mailing list