Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Mar 2010 21:13:03 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        obrien@FreeBSD.org
Cc:        freebsd-current@FreeBSD.org
Subject:   Re: [PATCH] newvers.sh
Message-ID:  <20100313.211303.585238797224891349.imp@bsdimp.com>
In-Reply-To: <20100312171206.GA31761@dragon.NUXI.org>
References:  <20100312171206.GA31761@dragon.NUXI.org>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <20100312171206.GA31761@dragon.NUXI.org>
            "David O'Brien" <obrien@freebsd.org> writes:
: * 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

<patch omitted>

David,

I have a better simplification, I think, that works for me for each of
the tests that I've done (both traditional and buildkernel builds).

The Makefile already knows where the kernel src is located.  Let's use
that knowledge to make things a little simpler.  This also uses the
Makefile variable SYSDIR.  It should also work with non-standard sys
directories.

There's one divergence between svn and git tagging: svn does src/sys,
while git does src.  This is how the previous code was before, and I
don't think I've changed that.

Can you confirm this works for you and also comment on the change
itself?  It is a bigger change, but results in a simpler (I think)
newvers.sh.

Comments?

Warner

Index: conf/kern.post.mk
===================================================================
--- conf/kern.post.mk	(revision 204938)
+++ conf/kern.post.mk	(working copy)
@@ -244,7 +244,7 @@
 	${NORMAL_LINT}
 
 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
-	MAKE=${MAKE} sh $S/conf/newvers.sh ${KERN_IDENT}
+	MAKE=${MAKE} SYSDIR=$S sh $S/conf/newvers.sh ${KERN_IDENT}
 
 vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
 	${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c
Index: conf/newvers.sh
===================================================================
--- conf/newvers.sh	(revision 204938)
+++ conf/newvers.sh	(working copy)
@@ -44,7 +44,7 @@
 		${PARAMFILE})
 else
 	RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \
-		$(dirname $0)/../sys/param.h)
+		${SYSDIR}/sys/param.h)
 fi
 
 
@@ -84,54 +84,46 @@
 fi
 
 touch version
-v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
+v=`cat version` u=${USER:-root} h=${HOSTNAME:-`hostname`} t=`date`
 i=`${MAKE:-make} -V KERN_IDENT`
 
-case "$d" in
-*/sys/*)
-	SRCDIR=${d##*obj}
-	if [ -n "$MACHINE" ]; then
-		SRCDIR=${SRCDIR##/$MACHINE}
+for dir in /bin /usr/bin /usr/local/bin; do
+	if [ -d "${SYSDIR}/.svn" -a -x "${dir}/svnversion" ] ; then
+		svnversion=${dir}/svnversion
+		break
 	fi
-	SRCDIR=${SRCDIR%%/sys/*}
+	if [ -d "${SYSDIR}/../.git" -a -x "${dir}/git" ] ; then
+		git_cmd="${dir}/git --git-dir=${SYSDIR}/../.git"
+		break
+	fi
+done
 
-	for dir in /bin /usr/bin /usr/local/bin; do
-		if [ -d "${SRCDIR}/sys/.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"
-			break
-		fi
-	done
+if [ -n "$svnversion" ] ; then
+    echo "$svnversion"
+	svn=" r`cd ${SYSDIR} && $svnversion`"
+fi
 
-	if [ -n "$svnversion" ] ; then
-		svn=" r`cd ${SRCDIR}/sys && $svnversion`"
-	fi
-	if [ -n "$git_cmd" ] ; then
-		git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
-		svn=`$git_cmd svn find-rev $git 2>/dev/null`
-		if [ -n "$svn" ] ; then
+if [ -n "$git_cmd" ] ; then
+	git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
+	svn=`$git_cmd svn find-rev $git 2>/dev/null`
+	if [ -n "$svn" ] ; then
+		svn=" r${svn}"
+		git="=${git}"
+	else
+		svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \
+		     sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`
+		if [ -n $svn ] ; then
 			svn=" r${svn}"
-			git="=${git}"
+			git="+${git}"
 		else
-			svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \
-			     sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`
-			if [ -n $svn ] ; then
-				svn=" r${svn}"
-				git="+${git}"
-			else
-				git=" ${git}"
-			fi
+			git=" ${git}"
 		fi
-		if $git_cmd --work-tree=${SRCDIR} diff-index \
-		    --name-only HEAD | read dummy; then
-			git="${git}-dirty"
-		fi
 	fi
-	;;
-esac
+	if $git_cmd --work-tree=${SYSDIR}/.. diff-index \
+	    --name-only HEAD | read dummy; then
+		git="${git}-dirty"
+	fi
+fi
 
 cat << EOF > vers.c
 $COPYRIGHT



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100313.211303.585238797224891349.imp>