From owner-freebsd-current@FreeBSD.ORG Sun Mar 14 04:18:39 2010 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1DE8106564A; Sun, 14 Mar 2010 04:18:39 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 616D08FC15; Sun, 14 Mar 2010 04:18:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o2E4CsEA089699; Sat, 13 Mar 2010 21:12:54 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Sat, 13 Mar 2010 21:13:03 -0700 (MST) Message-Id: <20100313.211303.585238797224891349.imp@bsdimp.com> To: obrien@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <20100312171206.GA31761@dragon.NUXI.org> References: <20100312171206.GA31761@dragon.NUXI.org> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-current@FreeBSD.org Subject: Re: [PATCH] newvers.sh X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2010 04:18:39 -0000 In message: <20100312171206.GA31761@dragon.NUXI.org> "David O'Brien" 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 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