Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Sep 2010 04:13:08 -0400
From:      jhell <jhell@DataIX.net>
To:        Anonymous <swell.k@gmail.com>
Cc:        freebsd-bugs@freebsd.org
Subject:   Re: misc/149510: [build] [patch] CFT: sys/conf/newvers.sh: Cleanup and additions.
Message-ID:  <4C9F0094.704@DataIX.net>
In-Reply-To: <201009260800.o8Q80OmE026551@freefall.freebsd.org>
References:  <201009260800.o8Q80OmE026551@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040009020206000705040109
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On 09/26/2010 04:00, Anonymous wrote:
> The following reply was made to PR misc/149510; it has been noted by GNATS.
> 
> From: Anonymous <swell.k@gmail.com>
> To: jhell@DataIX.net
> Cc: bug-followup@FreeBSD.org
> Subject: Re: misc/149510: [build] [patch] CFT: sys/conf/newvers.sh: Cleanup and additions.
> Date: Sun, 26 Sep 2010 11:44:29 +0400
> 
>  Typo in git(1) search path: LOCALBASE vs. LOCALBASE/bin.
>  
>  -	for dir in /usr/bin ${LOCALBASE:-/usr/local}; do
>  +	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
>  
>  And thanks for including conf/146828.

You welcome and thank you again for noticing this. Funny how that always
happens to the stuff you ask to be tested ;)

Anyway the edited patches are up at the previously stated URLs and
attached here for pleasure. Beware same situation as before.... these
get concatenated when they hit GNATS so expect to have to separate these
if downloaded from the PR database.


Regards,

-- 

 jhell,v

--------------040009020206000705040109
Content-Type: text/plain;
 name="newvers.sh-head-r213132.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="newvers.sh-head-r213132.patch"

Index: sys/conf/newvers.sh
===================================================================
--- sys/conf/newvers.sh	(revision 213142)
+++ sys/conf/newvers.sh	(working copy)
@@ -38,7 +38,10 @@
 fi
 RELEASE="${REVISION}-${BRANCH}"
 VERSION="${TYPE} ${RELEASE}"
-SYSDIR=$(dirname $0)/..
+
+# These are here so we don't have to work in reverse later on.
+SRCDIR=$(dirname $0)/../..
+SYSDIR=${SRCDIR}/sys
 
 if [ "X${PARAMFILE}" != "X" ]; then
 	RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \
@@ -78,57 +81,77 @@
 "
 
 LC_ALL=C; export LC_ALL
-if [ ! -r version ]
-then
-	echo 0 > version
+if [ ! -r version ]; then
+	echo 0 >version
 fi
 
-touch version
 v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
 i=`${MAKE:-make} -V KERN_IDENT`
 
-for dir in /bin /usr/bin /usr/local/bin; do
-	if [ -d "${SYSDIR}/.svn" -a -x "${dir}/svnversion" ] ; then
-		svnversion=${dir}/svnversion
-		break
+if [ -d "${SRCDIR}/.svn" -o -d "${SYSDIR}/.svn" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/svn" ]; then
+			svnversion=${dir}/svnversion
+			break
+		fi
+	done
+	if [ -n "$svnversion" ] ; then
+		svnrev=" r`cd ${SYSDIR} && $svnversion`"
 	fi
-	if [ -d "${SYSDIR}/../.git" -a -x "${dir}/git" ] ; then
-		git_cmd="${dir}/git --git-dir=${SYSDIR}/../.git"
-		break
+fi
+
+if [ -d "${SRCDIR}/.hg" -o -d "${SYSDIR}/.hg" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/hg" ]; then
+			hg=${dir}/hg
+			break
+		fi
+	done
+	if [ -n "$hg" ]; then
+		hgrev=" `cd ${SYSDIR} && $hg tip --template '{rev}:{node|short}'`"
 	fi
-done
+fi
+
+if [ -d "${SRCDIR}/.git" -o -d "${SYSDIR}/.git" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/git" ]; then
+			if [ -d "${SRCDIR}/.git" ]; then
+				git="${dir}/git --git-dir=${SRCDIR}/.git"
+				git="${git} --work-tree=${SRCDIR}"
+			else
+				git="${dir}/git --git-dir=${SYSDIR}/.git"
+				git="${git} --work-tree=${SYSDIR}"
+			fi
+			break
+		fi
+	done
 
-if [ -n "$svnversion" ] ; then
-    echo "$svnversion"
-	svn=" r`cd ${SYSDIR} && $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
-		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}"
+	if [ -n "$git" ] ; then
+		gitrev="`$git rev-parse --verify --short HEAD 2>/dev/null`"
+		gitsvnrev="`$git svn find-rev $gitrev 2>/dev/null`"
+		if [ -n "${gitsvnrev}" ] ; then
+			svnrev=" r${gitsvnrev}"
+			gitrev=" ${gitrev}"
 		else
-			git=" ${git}"
+			gitsvnid="`$git log |sed -n '/git-svn-id:/ {
+			s/.*@\([[:digit:]]\{1,\}\).*/\1/p; q; }'`"
+			if [ -n "${gitsvnid}" ]; then
+				svnrev=" r${gitsvnid}"
+				gitrev="+${gitrev}"
+			else
+				gitrev=" ${gitrev}"
+			fi
+		fi
+		if [ -n "`$git diff-index --name-only HEAD`" ]; then
+			gitrev="${gitrev}-dirty"
 		fi
-	fi
-	if $git_cmd --work-tree=${SYSDIR}/.. diff-index \
-	    --name-only HEAD | read dummy; then
-		git="${git}-dirty"
 	fi
 fi
 
 cat << EOF > vers.c
 $COPYRIGHT
-#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}"
-#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n    ${u}@${h}:${d}\\n"
+#define SCCSSTR "@(#)${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}"
+#define VERSTR "${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}\\n 	${u}@${h}:${d}\\n"
 #define RELSTR "${RELEASE}"
 
 char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
@@ -139,4 +162,4 @@
 char kern_ident[] = "${i}";
 EOF
 
-echo `expr ${v} + 1` > version
+echo $((${v}+1)) >version

--------------040009020206000705040109
Content-Type: text/plain;
 name="newvers.sh-stable8-r213132.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="newvers.sh-stable8-r213132.patch"

Index: sys/conf/newvers.sh
===================================================================
--- sys/conf/newvers.sh	(revision 213132)
+++ sys/conf/newvers.sh	(working copy)
@@ -39,15 +39,18 @@
 RELEASE="${REVISION}-${BRANCH}"
 VERSION="${TYPE} ${RELEASE}"
 
+# These are here so we don't have to work in reverse later on.
+SRCDIR=$(dirname $0)/../..
+SYSDIR=${SRCDIR}/sys
+
 if [ "X${PARAMFILE}" != "X" ]; then
 	RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \
 		${PARAMFILE})
 else
 	RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \
-		$(dirname $0)/../sys/param.h)
+		${SYSDIR}/sys/param.h)
 fi
 
-
 b=share/examples/etc/bsd-style-copyright
 year=`date '+%Y'`
 # look for copyright template
@@ -78,65 +81,77 @@
 "
 
 LC_ALL=C; export LC_ALL
-if [ ! -r version ]
-then
-	echo 0 > version
+if [ ! -r version ]; then
+	echo 0 >version
 fi
 
-touch version
 v=`cat version` u=${USER:-root} d=`pwd` 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}
+if [ -d "${SRCDIR}/.svn" -o -d "${SYSDIR}/.svn" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/svn" ]; then
+			svnversion=${dir}/svnversion
+			break
+		fi
+	done
+	if [ -n "$svnversion" ] ; then
+		svnrev=" r`cd ${SYSDIR} && $svnversion`"
 	fi
-	SRCDIR=${SRCDIR%%/sys/*}
+fi
 
-	for dir in /bin /usr/bin /usr/local/bin; do
-		if [ -d "${SRCDIR}/sys/.svn" -a -x "${dir}/svnversion" ] ; then
-			svnversion=${dir}/svnversion
+if [ -d "${SRCDIR}/.hg" -o -d "${SYSDIR}/.hg" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/hg" ]; then
+			hg=${dir}/hg
 			break
 		fi
-		if [ -d "${SRCDIR}/.git" -a -x "${dir}/git" ] ; then
-			git_cmd="${dir}/git --git-dir=${SRCDIR}/.git"
+	done
+	if [ -n "$hg" ]; then
+		hgrev=" `cd ${SYSDIR} && $hg tip --template '{rev}:{node|short}'`"
+	fi
+fi
+
+if [ -d "${SRCDIR}/.git" -o -d "${SYSDIR}/.git" ]; then
+	for dir in /usr/bin ${LOCALBASE:-/usr/local}/bin; do
+		if [ -x "${dir}/git" ]; then
+			if [ -d "${SRCDIR}/.git" ]; then
+				git="${dir}/git --git-dir=${SRCDIR}/.git"
+				git="${git} --work-tree=${SRCDIR}"
+			else
+				git="${dir}/git --git-dir=${SYSDIR}/.git"
+				git="${git} --work-tree=${SYSDIR}"
+			fi
 			break
 		fi
 	done
 
-	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
-			svn=" r${svn}"
-			git="=${git}"
+	if [ -n "$git" ] ; then
+		gitrev="`$git rev-parse --verify --short HEAD 2>/dev/null`"
+		gitsvnrev="`$git svn find-rev $gitrev 2>/dev/null`"
+		if [ -n "${gitsvnrev}" ] ; then
+			svnrev=" r${gitsvnrev}"
+			gitrev=" ${gitrev}"
 		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}"
+			gitsvnid="`$git log |sed -n '/git-svn-id:/ {
+			s/.*@\([[:digit:]]\{1,\}\).*/\1/p; q; }'`"
+			if [ -n "${gitsvnid}" ]; then
+				svnrev=" r${gitsvnid}"
+				gitrev="+${gitrev}"
 			else
-				git=" ${git}"
+				gitrev=" ${gitrev}"
 			fi
 		fi
-		if $git_cmd --work-tree=${SRCDIR} diff-index \
-		    --name-only HEAD | read dummy; then
-			git="${git}-dirty"
+		if [ -n "`$git diff-index --name-only HEAD`" ]; then
+			gitrev="${gitrev}-dirty"
 		fi
 	fi
-	;;
-esac
+fi
 
 cat << EOF > vers.c
 $COPYRIGHT
-#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}"
-#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n    ${u}@${h}:${d}\\n"
+#define SCCSSTR "@(#)${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}"
+#define VERSTR "${VERSION} #${v}${svnrev}${gitrev}${hgrev} ${t}\\n 	${u}@${h}:${d}\\n"
 #define RELSTR "${RELEASE}"
 
 char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
@@ -147,4 +162,4 @@
 char kern_ident[] = "${i}";
 EOF
 
-echo `expr ${v} + 1` > version
+echo $((${v}+1)) >version

--------------040009020206000705040109--



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