From: Harlan Stenn Date: Wed, 16 Jul 2014 08:33:06 +0000 (-0700) Subject: [Bug 2547] Automate update of "Last Update" datestamps in .html files X-Git-Tag: NTP_4_2_7P449~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ed41a8bb5fd9ed0fec7fa1cfaab1d1118017dd3;p=thirdparty%2Fntp.git [Bug 2547] Automate update of "Last Update" datestamps in .html files bk: 53c638c26ywtXRwhM4bj3Dz5CjxF4w --- diff --git a/ChangeLog b/ChangeLog index 207411cde..c924879ce 100644 --- 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 diff --git a/Makefile.am b/Makefile.am index ff12d7a1b..977d81e3d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 000000000..9d9a2f262 --- /dev/null +++ b/scripts/build/checkHtmlFileDates @@ -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 index 000000000..467e7070a --- /dev/null +++ b/scripts/build/updateBEDate @@ -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 + +# 3-oct-11 18:20 +# 01-Aug-2011 17:56 +# 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 (/(.*).*(.*)/) { + # 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: $!"; +}