[PATCH] newvers.sh

From: David O'Brien <obrien_at_freebsd.org>
Date: Fri, 12 Mar 2010 09:12:06 -0800
* Simplify SRCDIR calculation by directly finding the kernel sources
  based directly on one of them.

Reviewed by: dhw

  This change does not increase the kernel build time.  It also continues
  to restrict the revision to just the kernel sources, and not the whole
  tree.

Timing tests by: dhw


Index: newvers.sh
===================================================================
--- newvers.sh	(revision 204939)
+++ newvers.sh	(working copy)
_at__at_ -89,25 +89,21 _at__at_ i=`${MAKE:-make} -V KERN_IDENT`
 
 case "$d" in
 */sys/*)
-	SRCDIR=${d##*obj}
-	if [ -n "$MACHINE" ]; then
-		SRCDIR=${SRCDIR##/$MACHINE}
-	fi
-	SRCDIR=${SRCDIR%%/sys/*}
+	SRCDIR=$(dirname $0)/..
 
 	for dir in /bin /usr/bin /usr/local/bin; do
-		if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then
+		if [ -d "${SRCDIR}/.svn" -a -x "${dir}/svnversion" ] ; then
 			svnversion=${dir}/svnversion
 			break
 		fi
-		if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then
-			git_cmd="${dir}/git --git-dir=${SRCDIR}/.git"
+		if [ -d "${SRCDIR}/../.git" -a -x "${dir}/git" ] ; then
+			git_cmd="${dir}/git --git-dir=${SRCDIR}/../.git"
 			break
 		fi
 	done
 
 	if [ -n "$svnversion" ] ; then
-		svn=" r`cd ${SRCDIR}/sys && $svnversion`"
+		svn=" r`cd ${SRCDIR} && $svnversion`"
 	fi
 	if [ -n "$git_cmd" ] ; then
 		git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
_at__at_ -125,7 +121,7 _at__at_ case "$d" in
 				git=" ${git}"
 			fi
 		fi
-		if $git_cmd --work-tree=${SRCDIR} diff-index \
+		if $git_cmd --work-tree=${SRCDIR}/.. diff-index \
 		    --name-only HEAD | read dummy; then
 			git="${git}-dirty"
 		fi

-- 
-- David  (obrien_at_FreeBSD.org)
Received on Fri Mar 12 2010 - 16:12:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:01 UTC