svn commit: r49051 - head/share/mk

Warren Block wblock at FreeBSD.org
Mon Jul 4 14:56:43 UTC 2016


Author: wblock
Date: Mon Jul  4 14:56:42 2016
New Revision: 49051
URL: https://svnweb.freebsd.org/changeset/doc/49051

Log:
  Improve latest revision detection based on mat's work.  This clarifies
  the code, reduces dependencies, and removes a lot of quotes by using
  --stringparam.
  
  Differential Revision:	https://reviews.freebsd.org/D6902

Modified:
  head/share/mk/doc.commands.mk
  head/share/mk/doc.docbook.mk

Modified: head/share/mk/doc.commands.mk
==============================================================================
--- head/share/mk/doc.commands.mk	Sun Jul  3 21:48:20 2016	(r49050)
+++ head/share/mk/doc.commands.mk	Mon Jul  4 14:56:42 2016	(r49051)
@@ -32,12 +32,18 @@ SED?=		/usr/bin/sed
 SETENV?=	/usr/bin/env
 SH?=		/bin/sh
 SORT?=		/usr/bin/sort
+STAT?=		/usr/bin/stat
 TAIL?=		/usr/bin/tail
 TOUCH?=		/usr/bin/touch
 TRUE?=		/usr/bin/true
 XARGS?=		/usr/bin/xargs
 
 #
+# Version control
+#
+GIT?=		/usr/local/bin/git
+
+#
 # Compession and decompression
 #
 

Modified: head/share/mk/doc.docbook.mk
==============================================================================
--- head/share/mk/doc.docbook.mk	Sun Jul  3 21:48:20 2016	(r49050)
+++ head/share/mk/doc.docbook.mk	Mon Jul  4 14:56:42 2016	(r49051)
@@ -88,33 +88,38 @@ NO_SUBDIR=      YES
 # Determine latest revision
 #
 # This needs to contain all of:
-# --param latestrevision.timestamp "'timestamp'"
-# --param latestrevision.committer "'committer'"
-# --param latestrevision.number "'revision id'"
+# --stringparam latestrevision.timestamp "timestamp"
+# --stringparam latestrevision.committer "committer"
+# --stringparam latestrevision.number "revision id"
 
 # If using git, use git log.  The revision won't work with the generated links,
 # because it is a hash, and git log doesn't know about git svn find-rev.
-.if exists(${DOC_PREFIX}/.git)
-LATESTREVISION!=cd ${.CURDIR} && git log -1 \
-	--pretty=format:'--param latestrevision.timestamp "'\''%ci'\''" --param latestrevision.committer "'\''%cn'\''" --param latestrevision.number "'\''%h'\''"' \
-	${SRCS}
-.else
-# svn doesn't allow multiple files passed to it, so try to get the latest with grep
+.if exists(${DOC_PREFIX}/.git) && exists(${GIT})
+LATESTREVISION!=cd ${.CURDIR} && ${GIT} log -1 --pretty=format:'\
+	--stringparam latestrevision.timestamp "%ci" \
+	--stringparam latestrevision.committer "%cn" \
+	--stringparam latestrevision.number "%h"' ${SRCS}
+.else
+# version numbers are expected to be in Subversion, but we cannot
+# require Subversion to be installed just to build the documents,
+# so use grep to find the version strings
 LATESTREVISION!=${GREP} -Ehos '\$$[F]reeBSD: ([^\$$ ]+ ){5}\$$' ${SRCS} | \
 		${AWK} '{ print \
-		  " --param latestrevision.timestamp \"'\''"$$4" "$$5"'\''\"" \
-		  " --param latestrevision.committer \"'\''"$$6"'\''\"" \
-		  " --param latestrevision.number \"'\''"$$3"'\''\"" \
+		  "--stringparam latestrevision.timestamp \""$$4" "$$5"\" " \
+		  "--stringparam latestrevision.committer \""$$6"\" " \
+		  "--stringparam latestrevision.number \""$$3"\" " \
 		}' | ${SORT} | ${TAIL} -n1
 .endif
 
-# And sometime, strange things happen, so let's try to be a bit clever so that
-# we always have something to output, so use file on the file modified last,
-# and use its changed timestamp, user.  Leave the revision as blank.
+# if neither Subversion nor Git revision numbers are available, use
+# the revision date from the timestamp of the most recent file and
+# set the revision number to "filedate"
 .if empty(LATESTREVISION)
-LATESTREVISION!=stat -t '%F %T %Z' \
-	-f '--param latestrevision.timestamp "'\''%Sc'\''" --param latestrevision.committer "'\''%Su'\''" --param latestrevision.number "'\'''\''"' \
-	$(ls -t1 ${SRCS}|head -1)
+LATESTREVISION!=${STAT} 2>/dev/null -t '%F %T %Z' -f '\
+	--stringparam latestrevision.timestamp "%Sc" \
+	--stringparam latestrevision.committer "%Su" \
+	--stringparam latestrevision.number "filedate"' \
+	${SRCS} | ${SORT} -r | ${TAIL} -n1
 .endif
 
 XSLTPROCOPTS+=	${LATESTREVISION}


More information about the svn-doc-all mailing list