Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ntp Perl script to aid importers of ntp-4.x (replac...



details:   https://anonhg.NetBSD.org/src/rev/bc2faf77f8ff
branches:  trunk
changeset: 477170:bc2faf77f8ff
user:      jonathan <jonathan%NetBSD.org@localhost>
date:      Wed Oct 13 22:18:53 1999 +0000

description:
Perl script to aid importers of ntp-4.x (replaces xntp)

diffstat:

 usr.sbin/ntp/ntp2netbsd |  2704 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 2704 insertions(+), 0 deletions(-)

diffs (truncated from 2708 to 300 lines):

diff -r 3a53e431c8a8 -r bc2faf77f8ff usr.sbin/ntp/ntp2netbsd
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/ntp/ntp2netbsd   Wed Oct 13 22:18:53 1999 +0000
@@ -0,0 +1,2704 @@
+#!/usr/pkg/bin/perl
+#
+#      $NetBSD: ntp2netbsd,v 1.1 1999/10/13 22:18:53 jonathan Exp $
+#
+#  Perl script to convert a standard distribution directory for ntpv4.0 into
+#      a NetBSD source tree.
+#
+#  This is done as a script so that as each distribution is released,
+#      only changes from the previous one need to be dealt with as
+#      modifications to this script and related files.  This should
+#      reduce the cost of updating from a new release of ntp by an
+#      order of magnitude (or more?)
+#
+#  This script requires two environment variables set:
+#      SRCDIR - gcc source directory from FSF
+#      TARGETDIR - name of the high level directory to make
+#
+#  Written by Christos Zoulas April 17, 1997 for xntp 3-5.90
+#  Updated by Jonathan Stone Oct 10, 1999    for ntp 4-0.93a
+#
+
+$version = "4-0.93a";
+
+# definitions ...
+
+@subdirs = ("lib/libntp", "domestic/lib/libntp", 
+           "usr.sbin/ntp/include", "usr.sbin/ntp/html",    
+           "usr.sbin/ntp/ntpdate", "usr.sbin/ntp/ntptime", 
+           "usr.sbin/ntp/ntpq",    "usr.sbin/ntp/ntptrace", 
+            "usr.sbin/ntp/ntpd",   "usr.sbin/ntp/ntpdc");
+
+@includef = (
+            "adjtime.h",     "mbg_gps166.h",  "ntp_filegen.h", "ntp_request.h", "ntpd.h",
+            "ascii.h",       "md5.h",         "ntp_fp.h",      "ntp_select.h",  "parse.h",
+            "binio.h",       "mx4200.h",      "ntp_if.h",      "ntp_stdlib.h",  "parse_conf.h",
+            "global.h",      "ntif.h",        "ntp_io.h",      "ntp_string.h",  "recvbuff.h",
+            "gps.h",         "ntp.h",         "ntp_machine.h", "ntp_syscall.h", "trimble.h",
+            "ieee754io.h",   "ntp_calendar.h","ntp_malloc.h",  "ntp_syslog.h",
+            "iosignal.h",    "ntp_control.h", "ntp_proto.h",   "ntp_types.h",
+            "l_stdlib.h",    "ntp_datum.h",   "ntp_refclock.h","ntp_unixtime.h");
+
+
+#      l_stdlib.h", "ntp.h", "ntp_calendar.h", "ntp_control.h",
+#           "ntp_filegen.h", "ntp_fp.h", "ntp_if.h", "ntp_io.h", 
+#           "ntp_machine.h", "ntp_malloc.h", "ntp_proto.h", "ntp_refclock.h",
+#           "ntp_request.h", "ntp_select.h", "ntp_stdlib.h", "ntp_string.h",
+#           "ntp_syslog.h", "ntp_types.h", "ntp_unixtime.h", "ntpd.h",
+#           "parse.h", "parse_conf.h");
+
+@libntpf = (   "a_md5encrypt.c", "adjtime.c", "atoint.c", "atolfp.c",
+       "atouint.c", "authencrypt.c", "authkeys.c", "authparity.c",
+       "authreadkeys.c", "authusekey.c", "buftvtots.c", "caljulian.c",
+       "calleapwhen.c", "caltontp.c", "calyearstart.c", "clocktime.c",
+       "clocktypes.c", "decodenetnum.c", "dofptoa.c", "dolfptoa.c",
+       "emalloc.c", "findconfig.c", "fptoa.c", "fptoms.c", "getopt.c",
+       "hextoint.c", "hextolfp.c", "humandate.c", "inttoa.c", "lib_strbuf.c",
+       "machines.c", "md5c.c", "memmove.c", "mexit.c", "mfptoa.c", 
+       "mfptoms.c", "modetoa.c", "mstolfp.c", "msutotsf.c", "msyslog.c",
+       "netof.c", "numtoa.c", "numtohost.c", "octtoint.c", "prettydate.c",
+       "ranny.c", "refnumtoa.c", "statestr.c", "syssignal.c", "systime.c",
+       "tsftomsu.c", "tstotv.c", "tvtoa.c", "tvtots.c", "uglydate.c",
+       "uinttoa.c", "utvtoa.c", "ymd2yd.c", "mfp_mul.c", "binio.c",
+       "ieee754io.c", "gpstolfp.c", "recvbuff.c", "iosignal.c",
+       "lib_strbuf.h");
+
+@ntpdf = (     "map_vme.c", "ntp_config.c", "ntp_control.c", "ntp_io.c",
+       "ntp_loopfilter.c", "ntp_monitor.c", "ntp_peer.c", "ntp_proto.c",
+       "ntp_refclock.c", "ntp_request.c", "ntp_restrict.c", "ntp_timer.c",
+       "ntp_util.c", "ntp_intres.c", "ntp_filegen.c", "ntpd.c",
+       "refclock_conf.c", "refclock_chu.c", "refclock_local.c",
+       "refclock_pst.c", "refclock_wwvb.c", "refclock_mx4200.c",
+       "refclock_parse.c", "refclock_as2201.c", "refclock_bancomm.c",
+       "refclock_tpro.c", "refclock_leitch.c", "refclock_irig.c",
+       "refclock_msfees.c", "refclock_trak.c", "refclock_datum.c",
+       "refclock_acts.c", "refclock_heath.c", "refclock_nmea.c",
+       "refclock_atom.c", "refclock_ptbacts.c", "refclock_jupiter.c",
+       "refclock_usno.c", "refclock_true.c", "refclock_hpgps.c",
+       "refclock_shm.c", "refclock_gpsvme.c", "refclock_arbiter.c",
+       "refclock_arc.c", "refclock_palisade.c", 
+       "refclock_oncore.c", "refclock_chronolog.c", "refclock_dumbclock.c",
+       "refclock_ulink.c",
+       "jupiter.h", "refclock_palisade.h" );
+
+
+
+
+@ntpd_pf = ( "parse.c", "parse_conf.c", "clk_meinberg.c", 
+            "clk_schmid.c", "clk_rawdcf.c", "clk_trimtsip.c", 
+            "clk_dcf7000.c", "clk_trimtaip.c", "clk_rcc8000.c", 
+            "clk_hopf6021.c", "clk_computime.c", "clk_wharton.c", 
+            "clk_varitext.c", "data_mbg.c", "info_trimble.c", 
+            "trim_info.c");
+
+@ntpdcf = ("ntpdc.c", "ntpdc.h", "ntpdc_ops.c");
+
+@ntpdatef = ("ntpdate.c", "ntpdate.h");
+
+@ntptimef = ("ntptime.c");
+
+@ntpqf = ("ntpq.c", "ntpq.h", "ntpq_ops.c");
+
+@ntptracef = ("ntptrace.c", "ntptrace.h");
+
+@htmlf = (
+       "accopt.htm",   "assoc.htm",    "authopt.htm",  
+       "biblio.htm",           "build.htm",    "clockopt.htm", 
+       "config.htm",           "confopt.htm",  "copyright.htm",        
+       "debug.htm",            "driver1.htm",  "driver10.htm", 
+       "driver11.htm",         "driver12.htm", "driver18.htm", 
+       "driver19.htm",         "driver2.htm",  "driver20.htm", 
+       "driver22.htm",         "driver23.htm", "driver24.htm", 
+       "driver26.htm",         "driver27.htm", "driver28.htm", 
+       "driver29.htm",         "driver3.htm",  "driver30.htm", 
+       "driver32.htm",         "driver33.htm", "driver34.htm", 
+       "driver4.htm",          "driver5.htm",  "driver6.htm",  
+       "driver7.htm",          "driver8.htm",  "driver9.htm",  
+       "exec.htm",             "extern.htm",   "gadget.htm",   
+       "hints.htm",            "howto.htm",    "htmlprimer.htm",       
+       "index.htm",            "kern.htm",     "kernpps.htm",  
+       "ldisc.htm",            "measure.htm",  "miscopt.htm",  
+       "monopt.htm",           "mx4200data.htm",       "notes.htm",    
+       "ntpd.htm",             "ntpdate.htm",  "ntpdc.htm",    
+       "ntpq.htm",             "ntptime.htm",  "ntptrace.htm", 
+       "parsedata.htm",        "parsenew.htm", "patches.htm",  
+       "porting.htm",          "pps.htm",      "prefer.htm",   
+       "quick.htm",            "rdebug.htm",   "refclock.htm", 
+       "release.htm",          "tickadj.htm",  "vxworks.htm",
+       "y2k.htm");
+
+#
+# Utility Subroutines
+#
+
+sub makedir {
+    system("mkdir -p @_");
+}
+
+# &copyfiles (fromdir, todir, list of files);
+sub copyfiles {
+    local ($fdir, $tdir, @list) = @_;
+    local ($f);
+
+    foreach $f (@list) {
+       print "  $fdir/$f --> $tdir/$f\n";
+       system ("cp $fdir/$f $tdir/$f");
+    }
+}
+
+sub uniq {
+    local (@inlist) = @_;
+    local (@outlist);
+
+    @outlist = ($inlist[0]);
+    for ( $i=1; $i < @inlist; $i++ ) {
+       if ($inlist[$i] ne $inlist[$i-1]) {
+           push (@outlist, $inlist[$i]);
+       }
+    }
+
+    @outlist;
+}
+
+sub dumpsrcs {
+    local (@names) = @_;
+    local ($count);
+
+    print ODATA "SRCS=\t";
+    $count = 0;
+    while ($f = pop(@names)) {
+        print ODATA "$f ";
+       if ($count == 5 && @names > 0) {
+           print ODATA "\\\n";
+           $count = 0;
+       } else {
+           $count += 1;
+       }
+    }
+    if ($count != 0) {
+       print ODATA "\n";
+    }
+}
+
+#
+# Main progarm.
+# 
+
+$srcdir = $ENV{'SRCDIR'};
+$targetdir = $ENV{'TARGETDIR'};
+$incdirs = "-I. -I$srcdir/config -I$srcdir";
+
+if (!$srcdir | !targetdir) {
+    die "You must define the environment variables SRCDIR and TARGETDIR.\n"
+} 
+print "Making the NetBSD directory tree.\n";
+foreach $f (@subdirs) { 
+    print "   -->$f\n";
+    makedir ("$targetdir/$f");
+}
+
+
+print "Populating the lib/libntp directory.\n";
+&copyfiles ("$srcdir", "$targetdir/lib/libntp", "COPYRIGHT");
+&copyfiles ("$srcdir/libntp", "$targetdir/lib/libntp", @libntpf);
+system("cp $srcdir/libntp/authdes.c.export $targetdir/lib/libntp/authdes.c");
+
+print "Populating the domestic/lib/libntp directory.\n";
+&copyfiles ("$srcdir", "$targetdir/domestic/lib/libntp", "COPYRIGHT");
+system("cp $srcdir/libntp/authdes.c $targetdir/domestic/lib/libntp/authdes.c");
+
+print "Populating the usr.sbin/ntp directory.\n";
+&copyfiles ("$srcdir", "$targetdir/usr.sbin/ntp", "COPYRIGHT");
+
+print "Populating the usr.sbin/ntp/include directory.\n";
+&copyfiles ("$srcdir/include", "$targetdir/usr.sbin/ntp/include", @includef);
+
+print "Populating the usr.sbin/ntp/ntpd directory.\n";
+&copyfiles ("$srcdir/ntpd", "$targetdir/usr.sbin/ntp/ntpd", @ntpdf);
+&copyfiles ("$srcdir/libparse", "$targetdir/usr.sbin/ntp/ntpd", @ntpd_pf);
+
+print "Populating the usr.sbin/ntp/ntpdc directory.\n";
+&copyfiles ("$srcdir/ntpdc", "$targetdir/usr.sbin/ntp/ntpdc", @ntpdcf);
+
+print "Populating the usr.sbin/ntp/ntpdate directory.\n";
+&copyfiles ("$srcdir/ntpdate", "$targetdir/usr.sbin/ntp/ntpdate", @ntpdatef);
+
+print "Populating the usr.sbin/ntp/ntptime directory.\n";
+&copyfiles ("$srcdir/util", "$targetdir/usr.sbin/ntp/ntptime", @ntptimef);
+
+print "Populating the usr.sbin/ntp/ntpq directory.\n";
+&copyfiles ("$srcdir/ntpq", "$targetdir/usr.sbin/ntp/ntpq", @ntpqf);
+
+print "Populating the usr.sbin/ntp/ntptrace directory.\n";
+&copyfiles ("$srcdir/ntptrace", "$targetdir/usr.sbin/ntp/ntptrace", @ntptracef);
+
+print "Populating the usr.sbin/ntp/html directory.\n";
+&copyfiles ("$srcdir/html", "$targetdir/usr.sbin/ntp/html", @htmlf);
+
+#
+# Build makefiles
+#
+
+$first = "True";
+while ($line = <DATA>) {
+    chop ($line);
+    if (substr($line,0,2) eq "%%") {
+       @cmd = split (/ /,$line);
+       if ($cmd[1] eq "file") {
+           print "Building $targetdir/$cmd[2]\n";
+           if ($first eq "") {
+               close (ODATA);
+           } else {
+               $first = "";
+           }
+           open (ODATA, ">$targetdir/$cmd[2]") ||
+               die "Could not create $targetdir/$cmd[2]";
+       } elsif ($cmd[1] eq "srcs") {
+           print "  Defining SRCS for $cmd[2]\n";
+           if ($first) {
+               die "Data file must start with a %% file!";
+           }
+           if ($cmd[2] eq "ntpd") {
+               &dumpsrcs (@ntpdf, @ntpd_pf);
+           } elsif ($cmd[2] eq "ntpdc") {
+               &dumpsrcs (@ntpdcf);
+           } elsif ($cmd[2] eq "ntpq") {
+               &dumpsrcs (@ntpqf);
+           } elsif ($cmd[2] eq "ntpdate") {
+               &dumpsrcs (@ntpdatef);
+           } elsif ($cmd[2] eq "ntptime") {
+               &dumpsrcs (@ntptimef);
+           } elsif ($cmd[2] eq "ntptrace") {
+               &dumpsrcs (@ntptracef);
+           } elsif ($cmd[2] eq "html") {
+               &dumpsrcs (@htmlf);
+           } elsif ($cmd[2] eq "libntp") {
+               &dumpsrcs (@libntpf);
+           } else {
+               die "Unknown SRCS command";
+           }
+       } elsif ($cmd[1] eq "NetBSD") {
+           if ($first) {
+               die "Data section must start with a %% file!";
+           }
+           print ODATA "$cmd[2]        \$"."NetBSD".": \$\n";
+       }
+    } else {
+       if ($first) {
+           die "Data file must start with a %% file!";
+       }
+       print ODATA "$line\n";
+    }
+}    
+close (ODATA);
+
+#
+# Sed transformations of files



Home | Main Index | Thread Index | Old Index