]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2547] Automate update of "Last Update" datestamps in .html files
authorHarlan Stenn <stenn@ntp.org>
Wed, 16 Jul 2014 08:33:06 +0000 (01:33 -0700)
committerHarlan Stenn <stenn@ntp.org>
Wed, 16 Jul 2014 08:33:06 +0000 (01:33 -0700)
bk: 53c638c26ywtXRwhM4bj3Dz5CjxF4w

ChangeLog
Makefile.am
scripts/build/checkHtmlFileDates [new file with mode: 0755]
scripts/build/updateBEDate [new file with mode: 0755]

index 207411cde25dbcf33d9eb9eeeef1f1fe76fa44c3..c924879cef2d96607ffd226f9328c097a47cbb3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 2547] Automate update of "Last Update" datestamps in .html files.
 * [Bug 2623] Missing {} in refclock_oncore.c.
 * Quiet warnings from ntp_calendar.h: avoid using argument names.
 (4.2.7p448) 2014/07/15 Released by Harlan Stenn <stenn@ntp.org>
index ff12d7a1b6e081e8469bb244c2c47a5294d8536a..977d81e3d377c75aa4d754d3591345e27fcd07b6 100644 (file)
@@ -63,11 +63,34 @@ DISTCLEANFILES = .gcc-warning
 BUILT_SOURCES =                                \
        .gcc-warning                    \
        libtool                         \
+       html/.datecheck                 \
        sntp/built-sources-only         \
        $(srcdir)/COPYRIGHT             \
        $(srcdir)/.checkChangeLog       \
        $(NULL)
 
+.gcc-warning:
+       @echo "Compiling with GCC now generates lots of new warnings."
+       @echo " "
+       @echo "Don't be concerned. They're just warnings."
+       @echo " "
+       @echo "Don't send bug reports about the warnings, either."
+       @echo " "
+       @echo "Feel free to send patches that fix these warnings, though."
+       @echo " "
+       @sleep 1
+       @touch $@
+
+html/.datecheck: FRC.html
+       cd $(srcdir)/html && \
+       ../scripts/build/checkHtmlFileDates
+
+libtool: $(LIBTOOL_DEPS)
+       ./config.status --recheck
+
+sntp/built-sources-only: FRC.sntp
+       @cd sntp && $(MAKE) $(AM_MAKEFLAGS) built-sources-only
+
 $(srcdir)/COPYRIGHT: $(srcdir)/html/copyright.html
        { echo "This file is automatically generated from html/copyright.html" ; \
          lynx -dump $(srcdir)/html/copyright.html ;} > COPYRIGHT.new \
@@ -85,9 +108,6 @@ $(srcdir)/.checkChangeLog: $(srcdir)/ChangeLog $(srcdir)/scripts/build/checkChan
        cd $(srcdir) && \
        ./scripts/build/checkChangeLog
 
-sntp/built-sources-only: FRC.sntp
-       @cd sntp && $(MAKE) $(AM_MAKEFLAGS) built-sources-only
-
 dist-hook:
        @find $(distdir) -type d -name SCCS -print | xargs rm -rf
 
@@ -98,27 +118,12 @@ install-data-local:
 uninstall-local:
                rm -rf $(DESTDIR)$(htmldir)/html
 
-.gcc-warning:
-       @echo "Compiling with GCC now generates lots of new warnings."
-       @echo " "
-       @echo "Don't be concerned. They're just warnings."
-       @echo " "
-       @echo "Don't send bug reports about the warnings, either."
-       @echo " "
-       @echo "Feel free to send patches that fix these warnings, though."
-       @echo " "
-       @sleep 1
-       @touch $@
-
 CommitLog: FRC.CommitLog
        cd $(srcdir)                                    \
        && $(PATH_TEST) -e CommitLog                    \
                -a SCCS/s.ChangeSet -ot CommitLog       \
        || scripts/build/genCommitLog
 
-libtool: $(LIBTOOL_DEPS)
-       ./config.status --recheck
-
 # HMS: The following seems to be a work-in-progress...
 
 CVO=`$(srcdir)/sntp/libevent/build-aux/config.guess`
@@ -144,7 +149,7 @@ BHOST=`(hostname || uname -n)`
                echo " "; \
        fi
 
-FRC.CommitLog FRC.distwarn FRC.checkcvo FRC.checkhost FRC.sntp:
+FRC.CommitLog FRC.checkcvo FRC.checkhost FRC.distwarn FRC.html FRC.sntp:
        @: do-nothing action prevents any default
 
 # HMS: what was I trying to do with this?
diff --git a/scripts/build/checkHtmlFileDates b/scripts/build/checkHtmlFileDates
new file mode 100755 (executable)
index 0000000..9d9a2f2
--- /dev/null
@@ -0,0 +1,16 @@
+#! /bin/sh
+
+bk version > /dev/null 2>&1 || exit 0
+
+for i in `find * -type f -name '*.html' -print | grep -v SCCS/`
+do
+    # echo $i
+    set `bk diffs $i | wc -l`
+    lines=$1
+    case "$lines" in
+     0) ;;
+     *) echo "Processing <$i>"
+        ../scripts/build/updateBEDate $i
+       ;;
+    esac
+done
diff --git a/scripts/build/updateBEDate b/scripts/build/updateBEDate
new file mode 100755 (executable)
index 0000000..467e707
--- /dev/null
@@ -0,0 +1,53 @@
+#! /usr/bin/env perl
+use warnings;
+use strict;
+
+# for each filename on the command line
+# get the modtime
+# make a backup of the file
+# - error if there is already a backup?
+# flush the  live version(?)
+# start a line-by-line copy of the backup to the new file,
+# doing the BeginDate/EndDate substitution
+
+# <!-- #BeginDate format:En1m -->3-oct-11  18:20<!-- #EndDate -->
+# <!-- #BeginDate format:En2m -->01-Aug-2011  17:56<!-- #EndDate -->
+# without the 'm' no minutes are included.
+
+my $i;
+my $mod_time;
+my $stamp;
+my @m_abbr = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+
+foreach ( @ARGV ) {
+    $i = $_;
+    $mod_time = (stat ($i))[9];
+    $stamp = localtime($mod_time);
+    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+                                                localtime($mod_time);
+    $year += 1900;
+
+    # print "<$i> at <$stamp>\n";
+
+    open(my $IFILE, "<", $i) or die "Cannot open < $i: $!";
+    open(my $OFILE, ">", $i.".new") or die "Cannot open > $i.new: $!";
+    while(<$IFILE>) {
+       if (/(.*<!--\s*#BeginDate\s*format:)(\S*)(\s*-->).*(<!--\s*#EndDate\s*-->.*)/) {
+           # print "Got: $_";
+           # print "as: <$1><$2><$3>...<$4>\n";
+           print { $OFILE } $1,$2,$3;
+           printf { $OFILE } "%s-%s-%s  %02d:%02d", $mday,$m_abbr[$mon],$year,$hour,$min;
+           print { $OFILE } $4,"\n";
+       }
+       else {
+           print { $OFILE } $_;
+       }
+    }
+    close($IFILE);
+    close($OFILE);
+    #
+    utime(time, $mod_time, "$i.new") || die "touch $i.new failed: $!";
+    #
+    rename $i,"$i.old" || die "rename $i,$i.old failed: $!";
+    rename "$i.new",$i || die "rename $i.new,$i failed: $!";
+}